]> git.mdlowis.com Git - proto/anvil.git/commitdiff
cleaned up logic to read window titles. Also laid groundwork for tiling windows in...
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 13 Mar 2020 19:34:03 +0000 (15:34 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 13 Mar 2020 19:34:03 +0000 (15:34 -0400)
anvil.c
anvil.h
client.c

diff --git a/anvil.c b/anvil.c
index a0384781addd6dc1274688e8af2e00dfe894cba2..707f2c192fdb1ee05ea991939ee2cfd0a798f026 100644 (file)
--- 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 5158cfcac5775d83f304ff114353c1c5b4a036f2..d90f47d273fcb3fd5b50fad178ba4dc1eb74cc5e 100644 (file)
--- 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);
 
index 26d1faba5c6b018dd50804254d7c06406ae5fa8f..15530e59fdb353c9f424a4cd943332bae5340499 100644 (file)
--- 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);
+}