From: Michael D. Lowis Date: Thu, 2 Apr 2020 13:59:34 +0000 (-0400) Subject: add support for the urgency hint X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=074984d1d4721857b372865c12ea735ca1fe54d1;p=proto%2Fanvil.git add support for the urgency hint --- diff --git a/anvil.c b/anvil.c index bee8e34..f9d5f00 100644 --- 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 e32152e..b7ea56a 100644 --- 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; diff --git a/client.c b/client.c index 43010e0..c06f283 100644 --- 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)