From: Michael D. Lowis Date: Fri, 13 Mar 2020 19:34:03 +0000 (-0400) Subject: cleaned up logic to read window titles. Also laid groundwork for tiling windows in... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=67e299db1f25f2deac65c94a38ce6335a616fcd0;p=proto%2Fanvil.git cleaned up logic to read window titles. Also laid groundwork for tiling windows in columns --- diff --git a/anvil.c b/anvil.c index a038478..707f2c1 100644 --- a/anvil.c +++ b/anvil.c @@ -139,11 +139,20 @@ static void xdestroynotify(XEvent* e) static void xclientmsg(XEvent* e) { (void)e; + /* TODO: handle client messages per ICCCM */ } static void xpropnotify(XEvent* e) { (void)e; + /* TODO: update window titles */ + XPropertyEvent* ev = &(e->xproperty); + Client* c = client_get(ev->window); + if (c) + { + client_readprops(c); + client_draw(c); + } } static void xenternotify(XEvent* e) diff --git a/anvil.h b/anvil.h index 5158cfc..d90f47d 100644 --- a/anvil.h +++ b/anvil.h @@ -44,9 +44,20 @@ typedef struct Client { int x, y, w, h; } Client; +enum { + STACKED, + EXPAND, + MONOCOLE +} TileMode; + typedef struct Workspace { struct Workspace* next; + float mfact; Client* floating; + struct { + int mode; + Client* clients; + } cols[2]; } Workspace; typedef struct Monitor { @@ -107,10 +118,10 @@ void client_resize(Client* c, int xdiff, int ydiff); void client_close(Client* c); void client_focus(Client* c); void client_show(Client* c, int show); +void client_readprops(Client* c); /* error.c */ extern int (*error_default)(Display* disp, XErrorEvent* ev); -int error_ignore(Display* disp, XErrorEvent* ev); int error_init(Display* disp, XErrorEvent* ev); int error_panic(Display* disp, XErrorEvent* ev); diff --git a/client.c b/client.c index 26d1fab..15530e5 100644 --- a/client.c +++ b/client.c @@ -30,12 +30,10 @@ Client* client_add(Window win, XWindowAttributes* attr) c->h = attr->height; mons_addclient(c); + /* TODO: place window on current monitor centered by default */ + /* get window name */ - Atom actual_type; - int format; - unsigned long n, extra; - XGetWindowProperty( - X.disp, c->win, XA_WM_NAME, 0L, 100L, False, AnyPropertyType, &actual_type, &format, &n, &extra, (unsigned char **)&c->name); + client_readprops(c); /* get normal hints ? */ /* get registered protocols */ @@ -58,9 +56,8 @@ Client* client_add(Window win, XWindowAttributes* attr) ); XSetWindowAttributes wa; wa.event_mask = EnterWindowMask | PropertyChangeMask | FocusChangeMask; - wa.win_gravity = StaticGravity; wa.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask; - XChangeWindowAttributes(X.disp, c->win, CWEventMask | CWWinGravity | CWDontPropagate, &wa); + XChangeWindowAttributes(X.disp, c->win, CWEventMask | CWDontPropagate, &wa); XReparentWindow(X.disp, c->win, c->frame, BORDER_WIDTH, BORDER_WIDTH + TITLE_HEIGHT); /* Map the window and draw the frame */ @@ -170,4 +167,15 @@ void client_show(Client* c, int show) XUnmapWindow(X.disp, c->frame); XUnmapWindow(X.disp, c->win); } -} \ No newline at end of file +} + +void client_readprops(Client* c) +{ + Atom actual_type; + int format; + unsigned long n, extra; + xfree(c->name); + c->name = NULL; + XGetWindowProperty( + X.disp, c->win, XA_WM_NAME, 0L, 100L, False, AnyPropertyType, &actual_type, &format, &n, &extra, (unsigned char **)&c->name); +}