diff options
| author | Alexander Leonhardt <equinox.salexander@gmail.com> | |
|---|---|---|
| 2026-09-05 11:04:49 +0200 | ||
| committer | Alexander Leonhardt <equinox.salexander@gmail.com> | |
| 2026-09-05 11:04:49 +0200 | ||
| commit | e11979432c73395f00c52def04f3f2b35ca4ad3c (patch) | |
| tree | 2b349cdb3b6bf00c1f2ab247910d5f80a57f6140 | |
| parent | 2554be4300170799a64c68b02a420b4fcdb90431 (diff) | |
| download | dwl-e11979432c73395f00c52def04f3f2b35ca4ad3c.tar.gz dwl-e11979432c73395f00c52def04f3f2b35ca4ad3c.tar.bz2 dwl-e11979432c73395f00c52def04f3f2b35ca4ad3c.zip | |
Added dim unfocused patch
| -rw-r--r-- | client.h | 6 | ||||
| -rw-r--r-- | config.def.h | 11 | ||||
| -rw-r--r-- | dwl.c | 27 |
3 files changed, 33 insertions, 11 deletions
@@ -319,6 +319,12 @@ client_set_border_color(Client *c, const float color[static 4]) } static inline void +client_set_dimmer_state(Client *c, const int dim) +{ + wlr_scene_node_set_enabled(&c->dimmer->node, DIMOPT && !c->neverdim && dim); +} + +static inline void client_set_fullscreen(Client *c, int fullscreen) { #ifdef XWAYLAND diff --git a/config.def.h b/config.def.h index aa108b2..d1967ca 100644 --- a/config.def.h +++ b/config.def.h @@ -10,6 +10,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ static const float rootcolor[] = COLOR(0x222222ff); static const float bordercolor[] = COLOR(0x444444ff); static const float focuscolor[] = COLOR(0x005577ff); +static const float unfocuseddim[] = COLOR(0x00000088); static const float urgentcolor[] = COLOR(0x00000055); /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */ @@ -21,9 +22,9 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca static int log_level = WLR_ERROR; static const Rule rules[] = { - /* app_id title tags mask isfloating monitor */ - { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */ - { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */ + /* app_id title tags mask isfloating neverdim monitor */ + { "Gimp_EXAMPLE", NULL, 0, 1, 0, -1 }, /* Start on currently visible tags floating, not tiled */ + { "firefox_EXAMPLE", NULL, 1 << 8, 0, 0, -1 }, /* Start on ONLY tag "9" */ /* default/example rule: can be changed but cannot be eliminated; at least one rule must exist */ }; @@ -43,8 +44,8 @@ static const MonitorRule monrules[] = { /* name mfact nmaster scale layout rotate/reflect x y * example of a HiDPI laptop monitor: { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, */ - { "eDP-1", 0.55f, 1, 1.7, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, - { "DP-3", 0.55f, 1, 1.7, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, + { "eDP-1", 0.55f, 1, 1.7f, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, + { "DP-3", 0.55f, 1, 1.7f, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, /* default monitor rule: can be changed but cannot be eliminated; at least one monitor rule must exist */ }; @@ -109,6 +109,7 @@ typedef struct { Monitor *mon; struct wlr_scene_tree *scene; struct wlr_scene_rect *border[4]; /* top, bottom, left, right */ + struct wlr_scene_rect *dimmer; struct wlr_scene_tree *scene_surface; struct wl_list link; struct wl_list flink; @@ -138,7 +139,7 @@ typedef struct { #endif unsigned int bw; uint32_t tags; - int isfloating, isurgent, isfullscreen; + int isfloating, isurgent, isfullscreen, neverdim; uint32_t resize; /* configure serial of a pending resize */ } Client; @@ -228,6 +229,7 @@ typedef struct { const char *title; uint32_t tags; int isfloating; + int neverdim; int monitor; } Rule; @@ -406,6 +408,7 @@ static struct wlr_output_layout *output_layout; static struct wlr_box sgeom; static struct wl_list mons; static Monitor *selmon; +static int DIMOPT = 1; /* global event handlers */ static struct wl_listener cursor_axis = {.notify = axisnotify}; @@ -491,6 +494,7 @@ applyrules(Client *c) if ((!r->title || strstr(title, r->title)) && (!r->id || strstr(appid, r->id))) { c->isfloating = r->isfloating; + c->neverdim = r-> neverdim; newtags |= r->tags; i = 0; wl_list_for_each(m, &mons, link) { @@ -1433,8 +1437,10 @@ focusclient(Client *c, int lift) /* Don't change border color if there is an exclusive focus or we are * handling a drag operation */ - if (!exclusive_focus && !seat->drag) + if (!exclusive_focus && !seat->drag) { client_set_border_color(c, focuscolor); + client_set_dimmer_state(c, 0); + } } /* Deactivate old client if focus is changing */ @@ -1452,7 +1458,7 @@ focusclient(Client *c, int lift) * and probably other clients */ } else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) { client_set_border_color(old_c, bordercolor); - + client_set_dimmer_state(old_c, 1); client_activate_surface(old, 0); } } @@ -1739,8 +1745,7 @@ void mapnotify(struct wl_listener *listener, void *data) { /* Called when the surface is mapped, or ready to display on-screen. */ - Client *p = NULL; - Client *w, *c = wl_container_of(listener, c, map); + Client *p, *w, *d, *c = wl_container_of(listener, c, map); Monitor *m; int i; @@ -1774,6 +1779,10 @@ mapnotify(struct wl_listener *listener, void *data) c->border[i]->node.data = c; } + c->dimmer = wlr_scene_rect_create(c->scene, 0, 0, unfocuseddim); + c->dimmer->node.data = c; + client_set_dimmer_state(c, 1); + /* Initialize client geometry with room for border */ client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); c->geom.width += 2 * c->bw; @@ -1792,6 +1801,10 @@ mapnotify(struct wl_listener *listener, void *data) setmon(c, p->mon, p->tags); } else { applyrules(c); + d = focustop(selmon); + if (d) { + client_set_dimmer_state(d, 0); + } } printstatus(); @@ -2218,7 +2231,7 @@ resize(Client *c, struct wlr_box geo, int interact) c->geom = geo; applybounds(c, bbox); - /* Update scene-graph, including borders */ + /* Update scene-graph, including borders and dimmer*/ wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y); wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw); wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw); @@ -2228,6 +2241,8 @@ resize(Client *c, struct wlr_box geo, int interact) wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw); wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw); wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw); + wlr_scene_rect_set_size(c->dimmer, c->geom.width - 2*c->bw, c-> geom.height - 2*c->bw); + wlr_scene_node_set_position(&c->dimmer->node, c->bw, c->bw); /* this is a no-op if size hasn't changed */ c->resize = client_set_size(c, c->geom.width - 2 * c->bw, |