]> git.corax.cc Git - dwm/commitdiff
Draw the client indicator in a different color on other screens client-status
authorMatthias Kruk <m@m10k.eu>
Sun, 9 May 2021 12:53:23 +0000 (21:53 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 9 May 2021 12:55:49 +0000 (21:55 +0900)
The client indicator has the same color on all screens, making it
harder to distinguish which one is the selected screen. This commit
changes the color of the client indicator on non-selected screens.

config.def.h
dwm.c

index 632c8834fd4c95bd000f9f61cc5ca98331efd2d0..416a4d70c7f61a92603822039c96b8a17d7ec4d1 100755 (executable)
@@ -13,7 +13,7 @@ static struct color_set theme[PalLast] = {
                 .background = "#bb2323",
                 .foreground = "#ffffff"
         }, { /* PalNotSelected */
-                .border     = "#486c9c",
+                .border     = "#708fc9",
                 .background = "#486c9c",
                 .foreground = "#ffffff"
         }, { /* PalOther */
diff --git a/dwm.c b/dwm.c
index abdd7a4c1df9d9f961e0bc777b6a0da918584185..d823e8e8fecaac5209e188629f619daf8ef8e9da 100755 (executable)
--- a/dwm.c
+++ b/dwm.c
@@ -274,6 +274,7 @@ static struct client_indicator* client_indicator_new(struct monitor *monitor, in
 static void client_indicator_free(struct client_indicator **indicator);
 static void client_indicator_update_geometry(struct client_indicator *ci);
 static void client_indicator_update(struct client_indicator *ci);
+static void client_indicator_update_all(void);
 static void client_indicator_set_visible(struct client_indicator *ci, int visible);
 static void client_indicator_resize(struct client_indicator *ci);
 
@@ -459,9 +460,23 @@ struct NumTags {
        char limitexceeded[LENGTH(tags) > 31 ? -1 : 1];
 };
 
+static void client_indicator_update_all(void)
+{
+       struct monitor *monitor;
+
+       for(monitor = mons; monitor; monitor = monitor->next) {
+               client_indicator_update(monitor->v_clind);
+               client_indicator_update(monitor->h_clind);
+       }
+
+       return;
+}
+
 static void client_indicator_update(struct client_indicator *ci)
 {
        struct client *focused;
+       unsigned long fg_color;
+       unsigned long bg_color;
 
        XCopyArea(dpy, root, ci->win, ci->gc,
                  ci->geom.x, ci->geom.y,
@@ -470,6 +485,14 @@ static void client_indicator_update(struct client_indicator *ci)
 
        focused = ci->monitor->workspace->focused;
 
+       if(ci->monitor == selmon) {
+               fg_color = dc.palette[PalIndicator].color[ColBG];
+               bg_color = dc.palette[PalIndicator].color[ColFG];
+       } else {
+               fg_color = dc.palette[PalNotSelected].color[ColBG];
+               bg_color = dc.palette[PalNotSelected].color[ColBorder];
+       }
+
        if(focused) {
                int x, y, w, h;
 
@@ -485,11 +508,11 @@ static void client_indicator_update(struct client_indicator *ci)
                        h = focused->geom.h + 2 * borderpx;
                }
 
-               XSetForeground(dpy, ci->gc, dc.palette[PalIndicator].color[ColBG]);
+               XSetForeground(dpy, ci->gc, fg_color);
                XFillRectangle(dpy, ci->win, ci->gc,
                               x, y, w, h);
 
-               XSetForeground(dpy, ci->gc, dc.palette[PalIndicator].color[ColFG]);
+               XSetForeground(dpy, ci->gc, bg_color);
                XDrawRectangle(dpy, ci->win, ci->gc,
                               x, y, w - 1, h - 1);
        }
@@ -595,12 +618,9 @@ static void client_indicator_set_visible(struct client_indicator *ci, int visibl
 
 static void client_indicator_resize(struct client_indicator *ci)
 {
-       ci->geom.x = ci->monitor->geom.x;
-       ci->geom.y = ci->monitor->geom.y + bar_height;
-       ci->geom.w = ci->monitor->geom.w;
-       ci->geom.h = clind_height;
-
+       client_indicator_update_geometry(ci);
        XMoveResizeWindow(dpy, ci->win, ci->geom.x, ci->geom.y, ci->geom.w, ci->geom.h);
+
        return;
 }
 
@@ -786,6 +806,8 @@ void workspace_update(struct workspace *workspace)
 
                if(workspace->viewer) {
                        monitor_arrange_clients(workspace->viewer);
+                       client_indicator_update(workspace->viewer->v_clind);
+                       client_indicator_update(workspace->viewer->h_clind);
                }
        } else {
                int i;
@@ -793,6 +815,8 @@ void workspace_update(struct workspace *workspace)
                for(i = 0; i < LENGTH(workspaces); i++) {
                        workspace_update(&workspaces[i]);
                }
+
+               client_indicator_update_all();
        }
 
        return;
@@ -1170,6 +1194,8 @@ static struct monitor *monitor_new(int num, int x, int y, int w, int h)
         struct monitor *m;
        int i;
 
+       fprintf(stderr, "%s(%d, %d, %d, %d, %d)\n", __func__, num, x, y, w, h);
+
        m = (struct monitor*)calloc(1, sizeof(*m));
 
        if(!m) {
@@ -1514,8 +1540,7 @@ void focus(struct client *c)
        }
 
        selmon->workspace->focused = c;
-       client_indicator_update(selmon->h_clind);
-       client_indicator_update(selmon->v_clind);
+       client_indicator_update_all();
        drawbars();
 
        return;
@@ -3213,7 +3238,7 @@ static int updategeom(void)
                for(i = 0; i < num_mons; i++) {
                        struct monitor *mon;
 
-                       mon = monitor_get(info->screen_number);
+                       mon = monitor_get(info[i].screen_number);
 
                        if(mon) {
                                monitor_update_geometry(mon, info[i].x_org, info[i].y_org,