addded dim-unfocused patch

This commit is contained in:
Aaro Koivukangas
2024-11-24 15:19:00 +02:00
parent 8e22cdc4b3
commit 68ac87cc3e
3 changed files with 57 additions and 11 deletions
+6
View File
@@ -344,6 +344,12 @@ client_set_border_color(Client *c, const float color[static 4])
wlr_scene_rect_set_color(c->border[i], color); wlr_scene_rect_set_color(c->border[i], color);
} }
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 static inline void
client_set_fullscreen(Client *c, int fullscreen) client_set_fullscreen(Client *c, int fullscreen)
{ {
+6 -4
View File
@@ -11,6 +11,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
static const float rootcolor[] = COLOR(0x222222ff); static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff); static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff); static const float focuscolor[] = COLOR(0x005577ff);
static const float unfocuseddim[] = COLOR(0x00000088);
static const float urgentcolor[] = COLOR(0xff0000ff); static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
@@ -23,11 +24,10 @@ static int log_level = WLR_ERROR;
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */ /* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = { static const Rule rules[] = {
/* app_id title tags mask isfloating isterm noswallow monitor */ /* app_id title tags mask isfloating isterm noswallow neverdim monitor */
/* examples: */ /* examples: */
{ "Gimp_EXAMPLE", NULL, 0, 1, 0, 0, -1 }, /* Start on currently visible tags floating, not tiled */ { "Gimp_EXAMPLE", NULL, 0, 1, 0, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
{ "firefox_EXAMPLE", NULL, 1 << 8, 0, 0, 0, -1 }, /* Start on ONLY tag "9" */ { "foot", NULL, 0, 0, 1, 1, 0, -1 }, /* make foot swallow clients that are not foot */
{ "foot", NULL, 0, 0, 1, 1, -1 }, /* make foot swallow clients that are not foot */
}; };
/* layout(s) */ /* layout(s) */
@@ -146,6 +146,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XKB_KEY_r, setlayout, {.v = &layouts[3]} }, { MODKEY, XKB_KEY_r, setlayout, {.v = &layouts[3]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} }, { MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY, XKB_KEY_apostrophe, toggledimming, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} }, { MODKEY, XKB_KEY_e, togglefullscreen, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} }, { MODKEY, XKB_KEY_0, view, {.ui = ~0} },
@@ -178,5 +179,6 @@ static const Key keys[] = {
static const Button buttons[] = { static const Button buttons[] = {
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} }, { MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
{ MODKEY, BTN_MIDDLE, togglefloating, {0} }, { MODKEY, BTN_MIDDLE, togglefloating, {0} },
{ MODKEY|ShiftMask, BTN_MIDDLE, toggledimmingclient, {0} },
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} }, { MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
}; };
+44 -6
View File
@@ -114,6 +114,7 @@ struct Client {
Monitor *mon; Monitor *mon;
struct wlr_scene_tree *scene; struct wlr_scene_tree *scene;
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */ struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
struct wlr_scene_rect *dimmer;
struct wlr_scene_tree *scene_surface; struct wlr_scene_tree *scene_surface;
struct wl_list link; struct wl_list link;
struct wl_list flink; struct wl_list flink;
@@ -142,7 +143,7 @@ struct Client {
#endif #endif
unsigned int bw; unsigned int bw;
uint32_t tags; uint32_t tags;
int isfloating, isurgent, isfullscreen, isterm, noswallow, issticky; int isfloating, isurgent, isfullscreen, isterm, noswallow, issticky, neverdim;
uint32_t resize; /* configure serial of a pending resize */ uint32_t resize; /* configure serial of a pending resize */
pid_t pid; pid_t pid;
Client *swallowing, *swallowedby; Client *swallowing, *swallowedby;
@@ -245,6 +246,7 @@ typedef struct {
int isfloating; int isfloating;
int isterm; int isterm;
int noswallow; int noswallow;
int neverdim;
int monitor; int monitor;
} Rule; } Rule;
@@ -356,6 +358,8 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg); static void tag(const Arg *arg);
static void tagmon(const Arg *arg); static void tagmon(const Arg *arg);
static void tile(Monitor *m); static void tile(Monitor *m);
static void toggledimming(const Arg *arg);
static void toggledimmingclient(const Arg *arg);
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
static void togglesticky(const Arg *arg); static void togglesticky(const Arg *arg);
static void togglefullscreen(const Arg *arg); static void togglefullscreen(const Arg *arg);
@@ -435,6 +439,7 @@ static struct wlr_output_layout *output_layout;
static struct wlr_box sgeom; static struct wlr_box sgeom;
static struct wl_list mons; static struct wl_list mons;
static Monitor *selmon; static Monitor *selmon;
static int DIMOPT = 1;
#ifdef XWAYLAND #ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data); static void activatex11(struct wl_listener *listener, void *data);
@@ -505,6 +510,7 @@ applyrules(Client *c)
c->isfloating = r->isfloating; c->isfloating = r->isfloating;
c->isterm = r->isterm; c->isterm = r->isterm;
c->noswallow = r->noswallow; c->noswallow = r->noswallow;
c->neverdim = r-> neverdim;
newtags |= r->tags; newtags |= r->tags;
i = 0; i = 0;
wl_list_for_each(m, &mons, link) { wl_list_for_each(m, &mons, link) {
@@ -1481,8 +1487,10 @@ focusclient(Client *c, int lift)
/* Don't change border color if there is an exclusive focus or we are /* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */ * handling a drag operation */
if (!exclusive_focus && !seat->drag) if (!exclusive_focus && !seat->drag) {
client_set_border_color(c, focuscolor); client_set_border_color(c, focuscolor);
client_set_dimmer_state(c, 0);
}
} }
/* Deactivate old client if focus is changing */ /* Deactivate old client if focus is changing */
@@ -1500,7 +1508,7 @@ focusclient(Client *c, int lift)
* and probably other clients */ * and probably other clients */
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) { } else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
client_set_border_color(old_c, bordercolor); client_set_border_color(old_c, bordercolor);
client_set_dimmer_state(old_c, 1);
client_activate_surface(old, 0); client_activate_surface(old, 0);
} }
} }
@@ -1854,8 +1862,7 @@ void
mapnotify(struct wl_listener *listener, void *data) mapnotify(struct wl_listener *listener, void *data)
{ {
/* Called when the surface is mapped, or ready to display on-screen. */ /* Called when the surface is mapped, or ready to display on-screen. */
Client *p = NULL; Client *p, *w, *d, *c = wl_container_of(listener, c, map);
Client *w, *c = wl_container_of(listener, c, map);
Monitor *m; Monitor *m;
int i; int i;
@@ -1887,6 +1894,10 @@ mapnotify(struct wl_listener *listener, void *data)
c->border[i]->node.data = c; 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 */ /* Initialize client geometry with room for border */
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT);
c->geom.width += 2 * c->bw; c->geom.width += 2 * c->bw;
@@ -1905,6 +1916,10 @@ mapnotify(struct wl_listener *listener, void *data)
setmon(c, p->mon, p->tags); setmon(c, p->mon, p->tags);
} else { } else {
applyrules(c); applyrules(c);
d = focustop(selmon);
if (d) {
client_set_dimmer_state(d, 0);
}
} }
printstatus(); printstatus();
@@ -2395,7 +2410,7 @@ resize(Client *c, struct wlr_box geo, int interact, int draw_borders)
c->bw = draw_borders ? borderpx : 0; c->bw = draw_borders ? borderpx : 0;
applybounds(c, bbox); 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->node, c->geom.x, c->geom.y);
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw); 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); wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
@@ -2405,6 +2420,8 @@ resize(Client *c, struct wlr_box geo, int interact, int draw_borders)
wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw); 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[2]->node, 0, c->bw);
wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, 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 */ /* this is a no-op if size hasn't changed */
c->resize = client_set_size(c, c->geom.width - 2 * c->bw, c->resize = client_set_size(c, c->geom.width - 2 * c->bw,
@@ -2947,6 +2964,27 @@ tile(Monitor *m)
} }
} }
void toggledimming(const Arg *arg)
{
Client *c;
DIMOPT ^= 1;
wl_list_for_each(c, &clients, link)
{
client_set_dimmer_state(c, 1);
}
c = focustop(selmon);
if (c)
client_set_dimmer_state(c, 0);
}
void
toggledimmingclient(const Arg *arg)
{
Client *sel = focustop(selmon);
if (sel)
sel -> neverdim ^= 1;
}
void void
togglefloating(const Arg *arg) togglefloating(const Arg *arg)
{ {