]> git.mdlowis.com Git - proto/anvil.git/commitdiff
add support for the urgency hint
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 2 Apr 2020 13:59:34 +0000 (09:59 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 2 Apr 2020 13:59:34 +0000 (09:59 -0400)
anvil.c
anvil.h
client.c

diff --git a/anvil.c b/anvil.c
index bee8e34db06de3af55ffaf487f1734292041adb8..f9d5f00f3eef7c804b5ff91457b836c1a61c4d6e 100644 (file)
--- a/anvil.c
+++ b/anvil.c
@@ -229,40 +229,22 @@ static void init_font(void)
     X.font_ext = XExtentsOfFontSet(X.font);
 }
 
-static void init_graphics(void)
-{
-    XGCValues gv;
-    /* Set up root (frame) GC's. */
-    gv.foreground = X.black ^ X.white;
-    gv.background = X.white;
-    gv.function = GXxor;
-    gv.line_width = 1;
-    gv.subwindow_mode = IncludeInferiors;
-    gv.line_width = 2;
-    X.graphics = XCreateGC(X.disp, X.root,
-        GCForeground | GCBackground | GCFunction |
-        GCLineWidth | GCSubwindowMode, &gv);
-}
-
 int main(void)
 {
-    XColor color, exact;
     /* Initialize X server*/
     check( (X.disp = XOpenDisplay(0)) != NULL,
         "could not open display");
     X.mode = M_INIT;
     X.root = DefaultRootWindow(X.disp);
     X.screen = DefaultScreen(X.disp);
-    X.black = BlackPixel(X.disp, X.screen);
-    X.white = WhitePixel(X.disp, X.screen);
-    XAllocNamedColor(X.disp, DefaultColormap(X.disp, X.screen), "DimGray", &color, &exact);
-    X.gray = color.pixel;
+    X.clr_bg = 0x00FFFFEA;
+    X.clr_bdr = 0x00000000;
+    X.clr_urgent = 0x00FF7700;
 
     /* initialize all the things */
     check_for_wm();
     init_cursors();
     init_font();
-    init_graphics();
     mons_init();
     client_initall();
     keys_init();
@@ -292,6 +274,7 @@ int main(void)
         {
             X.eventfns[ev.type](&ev);
         }
+        XSync(X.disp, False);
     }
 
     return 0;
diff --git a/anvil.h b/anvil.h
index e32152e40ec057290fafa8c018588f14f98559be..b7ea56a31730693c26ba324e5ef6126e4d0d2f9a 100644 (file)
--- a/anvil.h
+++ b/anvil.h
@@ -38,11 +38,10 @@ typedef struct {
     Display* disp;
     int screen, mode, edge, start_x, start_y, last_x, last_y;
     Window root;
-    unsigned long black, white, gray;
+    unsigned long clr_bg, clr_bdr, clr_urgent;
     Cursor csr_root, csr_point, csr_move;
     XFontSet font;
     XFontSetExtents *font_ext;
-    GC graphics;
     void (*eventfns[LASTEvent])(XEvent*);
 } XConf;
 
@@ -61,7 +60,7 @@ typedef struct Client {
     char* name;
     Window frame, win;
     int flags, x, y, w, h;
-    long hint_flags;
+    long hint_flags, wm_flags;
     XSizeHints hints;
 } Client;
 
index 43010e06fcd706795cb18fd9617486fb6c15a4d5..c06f283f7343c8854ffc596c469a7ad1e07b920f 100644 (file)
--- a/client.c
+++ b/client.c
@@ -33,7 +33,7 @@ Client* client_add(Window win, XWindowAttributes* attr)
     client_readprops(c);
 
     /* Reparent the window if applicable */
-    c->frame = XCreateSimpleWindow(X.disp, X.root, c->x, c->y, c->w, c->h, 1, X.black, X.black);
+    c->frame = XCreateSimpleWindow(X.disp, X.root, c->x, c->y, c->w, c->h, 1, X.clr_bdr, X.clr_bg);
     XSelectInput(X.disp, c->frame,
         ExposureMask | EnterWindowMask |
         ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
@@ -59,17 +59,18 @@ void client_draw(Client* c)
 {
     if (c->frame)
     {
-        XSetWindowBackground(X.disp, c->frame, (Focused == c) ? X.black : X.white);
+        XSetWindowBackground(X.disp, c->frame, ((c->wm_flags & XUrgencyHint) ? X.clr_urgent : X.clr_bg));
         XSetWindowBorderWidth(X.disp, c->frame, 1);
-        XSetWindowBorder(X.disp, c->frame, (Focused == c) ? X.white : X.black);
+        XSetWindowBorder(X.disp, c->frame, X.clr_bdr);
         XSetWindowBorderWidth(X.disp, c->win, 1);
-        XSetWindowBorder(X.disp, c->win, (Focused == c) ? X.white : X.black);
+        XSetWindowBorder(X.disp, c->win, X.clr_bdr);
         XClearWindow(X.disp, c->frame);
         XDefineCursor(X.disp, c->frame, X.csr_point);
         if (c->name) {
             int ascent = abs(X.font_ext->max_logical_extent.y);
             Xutf8DrawString(X.disp, c->frame, X.font,
-                X.graphics, BORDER_WIDTH,
+                DefaultGC(X.disp, X.screen),
+                BORDER_WIDTH,
                 2 + ascent,
                 c->name, strlen(c->name));
         }
@@ -186,6 +187,14 @@ void client_readprops(Client* c)
         }
     }
     xfree(protos);
+
+
+    XWMHints* hints = XGetWMHints(X.disp, c->win);
+    if (hints)
+    {
+        c->wm_flags = hints->flags;
+    }
+    xfree(hints);
 }
 
 void client_shade(Client* c)