From d06ea7dcb8d51bf7cff3800dcfcd7ae852e3cb7f Mon Sep 17 00:00:00 2001 From: Squibid Date: Tue, 11 Feb 2025 15:45:12 -0600 Subject: add colored borders --- client.h | 20 ++++++++++++++++++-- config.def.h | 2 ++ dwl.c | 6 ++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/client.h b/client.h index f1e2ab5..74ddd2a 100644 --- a/client.h +++ b/client.h @@ -314,8 +314,24 @@ static inline void client_set_border_color(Client *c, const float color[static 4]) { int i; - for (i = 0; i < 4; i++) - wlr_scene_rect_set_color(c->border[i], color); + + if (!c) + return; + + if (c == focustop(selmon)) { + if (selmon->lt[selmon->sellt] == (Layout*)&layouts[1] || c->isfloating) + color = floatcolor; + else if (selmon->lt[selmon->sellt] == (Layout*)&layouts[2]) + color = monoclecolor; + else if (c->isurgent && client_is_mapped(c)) + color = urgentcolor; + else if (!exclusive_focus && !seat->drag) + color = focuscolor; + } else + color = color; + + for (i = 0; i < 4; i++) + wlr_scene_rect_set_color(c->border[i], color); } static inline void diff --git a/config.def.h b/config.def.h index f56367f..93beec4 100644 --- a/config.def.h +++ b/config.def.h @@ -13,6 +13,8 @@ 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(0xff0099ff); +static const float monoclecolor[] = COLOR(0xff9900ff); /* 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 8c600f8..7edb3fd 100644 --- a/dwl.c +++ b/dwl.c @@ -1642,10 +1642,7 @@ focusclient(Client *c, int lift) selmon = c->mon; c->isurgent = 0; - /* Don't change border color if there is an exclusive focus or we are - * handling a drag operation */ - if (!exclusive_focus && !seat->drag) - client_set_border_color(c, focuscolor); + client_set_border_color(c, focuscolor); } /* Deactivate old client if focus is changing */ @@ -2128,6 +2125,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d if (sloppyfocus) selmon = xytomon(cursor->x, cursor->y); } + client_set_border_color(focustop(selmon), focuscolor); /* Update drag icon's position */ wlr_scene_node_set_position(&drag_icon->node, (int)round(cursor->x), (int)round(cursor->y)); -- cgit v1.2.1