Add float unfocused border color patch

This commit is contained in:
Sravan Balaji
2024-09-27 20:03:44 -04:00
parent c385bd6f4c
commit 80ae662f24
6 changed files with 97 additions and 1 deletions

View File

@@ -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

View File

@@ -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 */

View File

@@ -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 */

16
dwl.c
View File

@@ -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();
}

View File

@@ -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

View File

@@ -0,0 +1,60 @@
From 591c031a4d8e62acfef4ef41816c1fbbb8b1473a Mon Sep 17 00:00:00 2001
From: yuki <yukiat@proton.me>
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