From d722b2d3466b4f87bb462328f4e71c855af1b51e Mon Sep 17 00:00:00 2001 From: jorchube Date: Sun, 25 Feb 2018 19:24:47 +0100 Subject: [PATCH 1/6] Add focused window shadow color Signed-off-by: jorchube --- src/common.h | 3 +++ src/compton.c | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/common.h b/src/common.h index 2b75ff7a..66d94f90 100644 --- a/src/common.h +++ b/src/common.h @@ -239,6 +239,7 @@ #define WFLAG_POS_CHANGE 0x0002 // Window opacity / dim state changed #define WFLAG_OPCT_CHANGE 0x0004 +#define WFLAG_FOCUS_CHANGE 0x0008 // === Types === @@ -644,6 +645,7 @@ typedef struct _options_t { bool wintype_shadow[NUM_WINTYPES]; /// Red, green and blue tone of the shadow. double shadow_red, shadow_green, shadow_blue; + double shadow_focused_red, shadow_focused_green, shadow_focused_blue; int shadow_radius; int shadow_offset_x, shadow_offset_y; double shadow_opacity; @@ -921,6 +923,7 @@ typedef struct _session_t { Picture black_picture; /// 1x1 Picture of the shadow color. Picture cshadow_picture; + Picture cshadow_picture_focused; /// 1x1 white Picture. Picture white_picture; /// Gaussian map of shadow. diff --git a/src/compton.c b/src/compton.c index 92935a3d..5b24d0f7 100644 --- a/src/compton.c +++ b/src/compton.c @@ -452,6 +452,8 @@ win_build_shadow(session_t *ps, win *w, double opacity) { const int width = w->widthb; const int height = w->heightb; + Picture *shadow_to_apply; + XImage *shadow_image = NULL; Pixmap shadow_pixmap = None, shadow_pixmap_argb = None; Picture shadow_picture = None, shadow_picture_argb = None; @@ -482,7 +484,14 @@ win_build_shadow(session_t *ps, win *w, double opacity) { XPutImage(ps->dpy, shadow_pixmap, gc, shadow_image, 0, 0, 0, 0, shadow_image->width, shadow_image->height); - XRenderComposite(ps->dpy, PictOpSrc, ps->cshadow_picture, shadow_picture, + + if (win_is_focused_real(ps, w)) { + shadow_to_apply = &ps->cshadow_picture_focused; + } else { + shadow_to_apply = &ps->cshadow_picture; + } + + XRenderComposite(ps->dpy, PictOpSrc, *shadow_to_apply, shadow_picture, shadow_picture_argb, 0, 0, 0, 0, 0, 0, shadow_image->width, shadow_image->height); @@ -1110,7 +1119,7 @@ paint_preprocess(session_t *ps, win *list) { // Data expiration { // Remove built shadow if needed - if (w->flags & WFLAG_SIZE_CHANGE) + if (w->flags & (WFLAG_SIZE_CHANGE | WFLAG_FOCUS_CHANGE)) free_paint(ps, &w->shadow_paint); // Destroy reg_ignore on all windows if they should expire @@ -1309,6 +1318,7 @@ static inline void win_paint_shadow(session_t *ps, win *w, XserverRegion reg_paint, const reg_data_t *pcache_reg) { // Bind shadow pixmap to GLX texture if needed + paint_bind_tex(ps, &w->shadow_paint, 0, 0, 32, false); if (!paint_isvalid(ps, &w->shadow_paint)) { @@ -1748,6 +1758,7 @@ rebuild_shadow_exclude_reg(session_t *ps) { ps->shadow_exclude_reg = rect_to_reg(ps, &rect); } + static void paint_all(session_t *ps, XserverRegion region, XserverRegion region_real, win *t) { if (!region_real) @@ -3469,6 +3480,7 @@ win_update_focused(session_t *ps, win *w) { // options depend on the output value of win_is_focused_real() instead of // w->focused w->flags |= WFLAG_OPCT_CHANGE; + w->flags |= WFLAG_FOCUS_CHANGE; } /** @@ -5040,7 +5052,7 @@ parse_matrix(session_t *ps, const char *src, const char **endptr) { int wid = 0, hei = 0; const char *pc = NULL; XFixed *matrix = NULL; - + // Get matrix width and height { double val = 0.0; @@ -5538,6 +5550,14 @@ parse_config(session_t *ps, struct options_tmp *pcfgtmp) { config_lookup_float(&cfg, "shadow-green", &ps->o.shadow_green); // --shadow-blue config_lookup_float(&cfg, "shadow-blue", &ps->o.shadow_blue); + + // --shadow-focused-red + config_lookup_float(&cfg, "shadow-focused-red", &ps->o.shadow_focused_red); + // --shadow-focused-green + config_lookup_float(&cfg, "shadow-focused-green", &ps->o.shadow_focused_green); + // --shadow-focused-blue + config_lookup_float(&cfg, "shadow-focused-blue", &ps->o.shadow_focused_blue); + // --shadow-exclude-reg if (config_lookup_string(&cfg, "shadow-exclude-reg", &sval) && !parse_geometry(ps, sval, &ps->o.shadow_exclude_reg_geom)) @@ -5694,7 +5714,10 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) { { "no-dnd-shadow", no_argument, NULL, 'G' }, { "shadow-red", required_argument, NULL, 257 }, { "shadow-green", required_argument, NULL, 258 }, - { "shadow-blue", required_argument, NULL, 259 }, + { "shadow-blue", required_argument, NULL, 259 }, + { "shadow-focused-red", required_argument, NULL, 800 }, + { "shadow-focused-green", required_argument, NULL, 801 }, + { "shadow-focused-blue", required_argument, NULL, 802 }, { "inactive-opacity-override", no_argument, NULL, 260 }, { "inactive-dim", required_argument, NULL, 261 }, { "mark-wmwin-focused", no_argument, NULL, 262 }, @@ -5893,14 +5916,23 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) { // --shadow-red ps->o.shadow_red = atof(optarg); break; + case 800: + ps->o.shadow_focused_red = atof(optarg); + break; case 258: // --shadow-green ps->o.shadow_green = atof(optarg); break; + case 801: + ps->o.shadow_focused_green = atof(optarg); + break; case 259: // --shadow-blue ps->o.shadow_blue = atof(optarg); break; + case 802: + ps->o.shadow_focused_blue = atof(optarg); + break; P_CASEBOOL(260, inactive_opacity_override); case 261: // --inactive-dim @@ -6046,6 +6078,9 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) { ps->o.shadow_red = normalize_d(ps->o.shadow_red); ps->o.shadow_green = normalize_d(ps->o.shadow_green); ps->o.shadow_blue = normalize_d(ps->o.shadow_blue); + ps->o.shadow_focused_red = normalize_d(ps->o.shadow_focused_red); + ps->o.shadow_focused_green = normalize_d(ps->o.shadow_focused_green); + ps->o.shadow_focused_blue = normalize_d(ps->o.shadow_focused_blue); ps->o.inactive_dim = normalize_d(ps->o.inactive_dim); ps->o.frame_opacity = normalize_d(ps->o.frame_opacity); ps->o.shadow_opacity = normalize_d(ps->o.shadow_opacity); @@ -7001,6 +7036,9 @@ session_init(session_t *ps_old, int argc, char **argv) { .shadow_red = 0.0, .shadow_green = 0.0, .shadow_blue = 0.0, + .shadow_focused_red = 0.0, + .shadow_focused_green = 0.0, + .shadow_focused_blue = 0.0, .shadow_radius = 12, .shadow_offset_x = -15, .shadow_offset_y = -15, @@ -7399,6 +7437,9 @@ session_init(session_t *ps_old, int argc, char **argv) { ps->o.shadow_red, ps->o.shadow_green, ps->o.shadow_blue); } + ps->cshadow_picture_focused = solid_picture(ps, true, 1, + ps->o.shadow_focused_red, ps->o.shadow_focused_green, ps->o.shadow_focused_blue); + fds_insert(ps, ConnectionNumber(ps->dpy), POLLIN); ps->tmout_unredir = timeout_insert(ps, ps->o.unredir_if_possible_delay, tmout_unredir_callback, NULL); From 736d60d404549e9334fbe0230a057f60888584aa Mon Sep 17 00:00:00 2001 From: jorchube Date: Sun, 25 Feb 2018 19:36:10 +0100 Subject: [PATCH 2/6] Added info in the readme file --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 05c30a45..9f570b4a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +This is a fork from the original Compton by chjj. This fork exists (for now) solely to provide compton with support for a different shadow color for the focused window. For this, three new options have been included: +- shawod-focused-red +- shawod-focused-green +- shawod-focused-blue +These options are used exactly as the original shadow-red/green/blue options, but only afffect the focused window shadow. + # Compton [![Join the chat at https://gitter.im/chjj/compton](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/chjj/compton?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) From 78b1ce317ccac05d3779e7ca3ae066c6bf568a7e Mon Sep 17 00:00:00 2001 From: jorchube Date: Mon, 12 Mar 2018 21:43:22 +0100 Subject: [PATCH 3/6] Typo in the README --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9f570b4a..0993786c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,12 @@ This is a fork from the original Compton by chjj. This fork exists (for now) solely to provide compton with support for a different shadow color for the focused window. For this, three new options have been included: -- shawod-focused-red -- shawod-focused-green -- shawod-focused-blue +- shadow-focused-red +- shadow-focused-green +- shadow-focused-blue These options are used exactly as the original shadow-red/green/blue options, but only afffect the focused window shadow. + +Here is the original compton README: + # Compton [![Join the chat at https://gitter.im/chjj/compton](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/chjj/compton?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) From ac655c833d4b6331df6b101d80559a7b5c756689 Mon Sep 17 00:00:00 2001 From: Seth Gower Date: Wed, 14 Mar 2018 15:19:29 -0400 Subject: [PATCH 4/6] Fixes uninstall profile When uninstalling and reinstalling normal compton, I got an error stating that these two icons were still present. Simply removes those two icons when running the uninstall target. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 25e78b1b..ba7e3633 100644 --- a/Makefile +++ b/Makefile @@ -172,6 +172,8 @@ 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" + @rm -f "/usr/share/icon/hicolor/48x48/apps/compton.png" + @rm -f "/usr/share/icons/hicolor/scaleable/apps/compton.png" ifneq "$(DOCDIR)" "" @rm -f $(addprefix "$(DESTDIR)$(DOCDIR)"/, README.md compton.sample.conf cdbus-driver.sh) endif From 2565833f6198d02c1d0fccd8ce06076dec812ebc Mon Sep 17 00:00:00 2001 From: Jordi Date: Mon, 20 Aug 2018 22:51:03 +0200 Subject: [PATCH 5/6] Prepare for pull request --- README.md | 9 --------- compton.sample.conf | 3 +++ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0993786c..05c30a45 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,3 @@ -This is a fork from the original Compton by chjj. This fork exists (for now) solely to provide compton with support for a different shadow color for the focused window. For this, three new options have been included: -- shadow-focused-red -- shadow-focused-green -- shadow-focused-blue -These options are used exactly as the original shadow-red/green/blue options, but only afffect the focused window shadow. - - -Here is the original compton README: - # Compton [![Join the chat at https://gitter.im/chjj/compton](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/chjj/compton?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) diff --git a/compton.sample.conf b/compton.sample.conf index a964dc47..e4a34825 100644 --- a/compton.sample.conf +++ b/compton.sample.conf @@ -10,6 +10,9 @@ shadow-offset-y = -7; # shadow-red = 0.0; # shadow-green = 0.0; # shadow-blue = 0.0; +# shadow-focused-red = 0.0; +# shadow-focused-green = 0.0; +# shadow-focused-blue = 0.0; shadow-exclude = [ "name = 'Notification'", "class_g = 'Conky'", From cd7d997c45962d6e3957fe87083a18fd68dc3450 Mon Sep 17 00:00:00 2001 From: Jordi Date: Mon, 20 Aug 2018 22:55:26 +0200 Subject: [PATCH 6/6] Fix indentation --- src/compton.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compton.c b/src/compton.c index 5b24d0f7..789a84fb 100644 --- a/src/compton.c +++ b/src/compton.c @@ -5714,9 +5714,9 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) { { "no-dnd-shadow", no_argument, NULL, 'G' }, { "shadow-red", required_argument, NULL, 257 }, { "shadow-green", required_argument, NULL, 258 }, - { "shadow-blue", required_argument, NULL, 259 }, - { "shadow-focused-red", required_argument, NULL, 800 }, - { "shadow-focused-green", required_argument, NULL, 801 }, + { "shadow-blue", required_argument, NULL, 259 }, + { "shadow-focused-red", required_argument, NULL, 800 }, + { "shadow-focused-green", required_argument, NULL, 801 }, { "shadow-focused-blue", required_argument, NULL, 802 }, { "inactive-opacity-override", no_argument, NULL, 260 }, { "inactive-dim", required_argument, NULL, 261 },