diff --git a/Makefile b/Makefile index 7a0d57a7..a2498367 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ CC ?= gcc PREFIX ?= /usr BINDIR ?= $(PREFIX)/bin MANDIR ?= $(PREFIX)/share/man/man1 +APPDIR ?= $(PREFIX)/share/applications PACKAGES = x11 xcomposite xfixes xdamage xrender xext xrandr LIBS = -lm -lrt @@ -79,7 +80,8 @@ else export LD_ALTEXEC = /usr/bin/ld.gold OBJS += backtrace-symbols.o LIBS += -lbfd - CFLAGS += -ggdb -Weverything -Wno-disabled-macro-expansion -Wno-padded -Wno-gnu + CFLAGS += -ggdb + # CFLAGS += -Weverything -Wno-disabled-macro-expansion -Wno-padded -Wno-gnu endif LIBS += $(shell pkg-config --libs $(PACKAGES)) @@ -112,9 +114,10 @@ man/%.1.html: man/%.1.asciidoc docs: $(MANPAGES) $(MANPAGES_HTML) install: $(BINS) docs - @install -d "$(DESTDIR)$(BINDIR)" "$(DESTDIR)$(MANDIR)" + @install -d "$(DESTDIR)$(BINDIR)" "$(DESTDIR)$(MANDIR)" "$(DESTDIR)$(APPDIR)" @install -m755 $(BINS) "$(DESTDIR)$(BINDIR)"/ @install -m644 $(MANPAGES) "$(DESTDIR)$(MANDIR)"/ + @install -m644 compton.desktop "$(DESTDIR)$(APPDIR)"/ ifneq "$(DOCDIR)" "" @install -d "$(DESTDIR)$(DOCDIR)" @install -m644 README.md compton.sample.conf "$(DESTDIR)$(DOCDIR)"/ @@ -124,6 +127,7 @@ endif uninstall: @rm -f "$(DESTDIR)$(BINDIR)/compton" "$(DESTDIR)$(BINDIR)/compton-trans" @rm -f $(addprefix "$(DESTDIR)$(MANDIR)"/, compton.1 compton-trans.1) + @rm -f "$(DESTDIR)$(APPDIR)/compton.desktop" ifneq "$(DOCDIR)" "" @rm -f $(addprefix "$(DESTDIR)$(DOCDIR)"/, README.md compton.sample.conf cdbus-driver.sh) endif diff --git a/src/compton.c b/src/compton.c index 539f8d20..a2fbee26 100644 --- a/src/compton.c +++ b/src/compton.c @@ -4136,7 +4136,7 @@ usage(void) { "--glx-no-stencil\n" " Avoid using stencil buffer under GLX backend. Might cause issues\n" " when rendering transparent content, may have a positive or\n" - " negative effect on performance.\n" + " negative effect on performance. (My test shows a 10% slowdown.)\n" #undef WARNING #ifndef CONFIG_DBUS #define WARNING WARNING_DISABLED diff --git a/src/opengl.c b/src/opengl.c index 21b3c181..92b0292b 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -487,7 +487,31 @@ glx_set_clip(session_t *ps, XserverRegion reg) { if (ps->o.glx_no_stencil) return; - if (reg) { + static XRectangle rect_blank = { + .x = 0, .y = 0, .width = 0, .height = 0 + }; + + glDisable(GL_STENCIL_TEST); + glDisable(GL_SCISSOR_TEST); + + if (!reg) + return; + + int nrects = 0; + XRectangle *rects = XFixesFetchRegion(ps->dpy, reg, &nrects); + if (!nrects) { + if (rects) XFree(rects); + nrects = 1; + rects = &rect_blank; + } + + assert(nrects); + if (1 == nrects) { + glEnable(GL_SCISSOR_TEST); + glScissor(rects[0].x, ps->root_height - rects[0].y - rects[0].height, + rects[0].width, rects[0].height); + } + else { glEnable(GL_STENCIL_TEST); glClear(GL_STENCIL_BUFFER_BIT); @@ -495,8 +519,6 @@ glx_set_clip(session_t *ps, XserverRegion reg) { glDepthMask(GL_FALSE); glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); - int nrects = 0; - XRectangle *rects = XFixesFetchRegion(ps->dpy, reg, &nrects); glBegin(GL_QUADS); @@ -519,16 +541,13 @@ glx_set_clip(session_t *ps, XserverRegion reg) { glEnd(); - if (rects) - XFree(rects); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDepthMask(GL_TRUE); } - else { - glDisable(GL_STENCIL_TEST); - } + + if (rects && &rect_blank != rects) + XFree(rects); } /**