From 80ae662f24a078b7fa52b139668ee613034c3de9 Mon Sep 17 00:00:00 2001 From: Sravan Balaji Date: Fri, 27 Sep 2024 20:03:44 -0400 Subject: [PATCH] Add float unfocused border color patch --- README.org | 14 +++++ config.def.h | 3 + config.h | 3 + dwl.c | 16 ++++- patches.def.h | 2 + ...loat-unfocused-border-color-20240607.patch | 60 +++++++++++++++++++ 6 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 patches/float-unfocused-border-color-20240607.patch diff --git a/README.org b/README.org index 8c7b2dc..523708d 100644 --- a/README.org +++ b/README.org @@ -10,6 +10,7 @@ - [[#always-center][Always Center]] - [[#attach-top][Attach Top]] - [[#auto-start][Auto Start]] + - [[#float-unfocused-border-color][Float Unfocused Border Color]] - [[#foreign-toplevel-management][Foreign Toplevel Management]] - [[#ipc][IPC]] - [[#natural-scroll-trackpad][Natural Scroll Trackpad]] @@ -88,6 +89,16 @@ Note: Commands from array are executed using execvp(). So if you need to execute #define AUTOSTART_PATCH 1 #+END_SRC +** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/float-unfocused-border-color][Float Unfocused Border Color]] + +A revive of the floatBorderColor patch. + +This patch allows you to set a color for floating windows when they are unfocused. + +#+BEGIN_SRC c :tangle patches.def.h +#define FLOAT_UNFOCUSED_BORDER_COLOR_PATCH 1 +#+END_SRC + ** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/foreign-toplevel-management][Foreign Toplevel Management]] Implement ~foreign-toplevel-management~, it add handlers for activate, close, fullscreen and destroy request events, it's missing minimize and maximize request handlers. @@ -199,6 +210,9 @@ static const float rootcolor[] = COLOR(0x282a36ff); static const float bordercolor[] = COLOR(0x4d4d4dff); static const float focuscolor[] = COLOR(0xbd93f9ff); static const float urgentcolor[] = COLOR(0xff5555ff); +#if FLOAT_UNFOCUSED_BORDER_COLOR_PATCH +static const float floatcolor[] = COLOR(0xff79c6ff); +#endif // FLOAT_UNFOCUSED_BORDER_COLOR_PATCH /* 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 */ #+END_SRC diff --git a/config.def.h b/config.def.h index 4faab85..f7c8b01 100644 --- a/config.def.h +++ b/config.def.h @@ -17,6 +17,9 @@ static const float rootcolor[] = COLOR(0x222222ff); static const float bordercolor[] = COLOR(0x444444ff); static const float focuscolor[] = COLOR(0x005577ff); static const float urgentcolor[] = COLOR(0xff0000ff); +#if FLOAT_UNFOCUSED_BORDER_COLOR_PATCH +static const float floatcolor[] = COLOR(0xff0000ff); +#endif // FLOAT_UNFOCUSED_BORDER_COLOR_PATCH /* 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 */ diff --git a/config.h b/config.h index 6349459..efbf7ee 100644 --- a/config.h +++ b/config.h @@ -20,6 +20,9 @@ static const float rootcolor[] = COLOR(0x282a36ff); static const float bordercolor[] = COLOR(0x4d4d4dff); static const float focuscolor[] = COLOR(0xbd93f9ff); static const float urgentcolor[] = COLOR(0xff5555ff); +#if FLOAT_UNFOCUSED_BORDER_COLOR_PATCH +static const float floatcolor[] = COLOR(0xff79c6ff); +#endif // FLOAT_UNFOCUSED_BORDER_COLOR_PATCH /* 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 */ diff --git a/dwl.c b/dwl.c index 475beff..9f3934f 100644 --- a/dwl.c +++ b/dwl.c @@ -806,6 +806,9 @@ buttonpress(struct wl_listener *listener, void *data) /* Drop the window off on its new monitor */ selmon = xytomon(cursor->x, cursor->y); setmon(grabc, selmon, 0); +#if FLOAT_UNFOCUSED_BORDER_COLOR_PATCH + grabc = NULL; +#endif // FLOAT_UNFOCUSED_BORDER_COLOR_PATCH return; } else { cursor_mode = CurNormal; @@ -1907,9 +1910,13 @@ focusclient(Client *c, int lift) /* Don't deactivate old client if the new one wants focus, as this causes issues with winecfg * and probably other clients */ } else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) { +#if !FLOAT_UNFOCUSED_BORDER_COLOR_PATCH client_set_border_color(old_c, bordercolor); - client_activate_surface(old, 0); +#else // FLOAT_UNFOCUSED_BORDER_COLOR_PATCH + client_set_border_color(old_c, old_c->isfloating ? floatcolor : bordercolor); + client_activate_surface(old, 0); +#endif // FLOAT_UNFOCUSED_BORDER_COLOR_PATCH #if FOREIGN_TOPLEVEL_MANAGEMENT_PATCH if (old_c->foreign_toplevel) wlr_foreign_toplevel_handle_v1_set_activated(old_c->foreign_toplevel, 0); @@ -3004,6 +3011,13 @@ setfloating(Client *c, int floating) wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen || (p && p->isfullscreen) ? LyrFS : c->isfloating ? LyrFloat : LyrTile]); +#if FLOAT_UNFOCUSED_BORDER_COLOR_PATCH + if (!grabc && floating) + for (int i = 0; i < 4; i++) { + wlr_scene_rect_set_color(c->border[i], floatcolor); + wlr_scene_node_lower_to_bottom(&c->border[i]->node); + } +#endif // FLOAT_UNFOCUSED_BORDER_COLOR_PATCH arrange(c->mon); printstatus(); } diff --git a/patches.def.h b/patches.def.h index 5753fe7..28ce32f 100644 --- a/patches.def.h +++ b/patches.def.h @@ -4,6 +4,8 @@ #define AUTOSTART_PATCH 1 +#define FLOAT_UNFOCUSED_BORDER_COLOR_PATCH 1 + #define FOREIGN_TOPLEVEL_MANAGEMENT_PATCH 1 #define IPC_PATCH 1 diff --git a/patches/float-unfocused-border-color-20240607.patch b/patches/float-unfocused-border-color-20240607.patch new file mode 100644 index 0000000..fe60f3d --- /dev/null +++ b/patches/float-unfocused-border-color-20240607.patch @@ -0,0 +1,60 @@ +From 591c031a4d8e62acfef4ef41816c1fbbb8b1473a Mon Sep 17 00:00:00 2001 +From: yuki +Date: Fri, 7 Jun 2024 11:44:37 +0800 +Subject: [PATCH] Added float-unfocused-border-color patch. + +--- + config.def.h | 1 + + dwl.c | 11 ++++++++--- + 2 files changed, 9 insertions(+), 3 deletions(-) + +diff --git a/config.def.h b/config.def.h +index a784eb4..8131af5 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -11,6 +11,7 @@ static const float rootcolor[] = COLOR(0x222222ff); + static const float bordercolor[] = COLOR(0x444444ff); + static const float focuscolor[] = COLOR(0x005577ff); + static const float urgentcolor[] = COLOR(0xff0000ff); ++static const float floatcolor[] = COLOR(0xff0000ff); + /* 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 */ + +diff --git a/dwl.c b/dwl.c +index 6f041a0..777c0e1 100644 +--- a/dwl.c ++++ b/dwl.c +@@ -632,6 +632,7 @@ buttonpress(struct wl_listener *listener, void *data) + /* Drop the window off on its new monitor */ + selmon = xytomon(cursor->x, cursor->y); + setmon(grabc, selmon, 0); ++ grabc = NULL; + return; + } else { + cursor_mode = CurNormal; +@@ -1348,9 +1349,8 @@ focusclient(Client *c, int lift) + /* Don't deactivate old client if the new one wants focus, as this causes issues with winecfg + * 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_activate_surface(old, 0); ++ client_set_border_color(old_c, old_c->isfloating ? floatcolor : bordercolor); ++ client_activate_surface(old, 0); + } + } + printstatus(); +@@ -2218,6 +2218,11 @@ setfloating(Client *c, int floating) + wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen || + (p && p->isfullscreen) ? LyrFS + : c->isfloating ? LyrFloat : LyrTile]); ++ if (!grabc && floating) ++ for (int i = 0; i < 4; i++) { ++ wlr_scene_rect_set_color(c->border[i], floatcolor); ++ wlr_scene_node_lower_to_bottom(&c->border[i]->node); ++ } + arrange(c->mon); + printstatus(); + } +-- +2.45.2 \ No newline at end of file