]> git.mdlowis.com Git - proto/anvil.git/commitdiff
minor tweaks and sketched out logic for stacked and expanded tiling modes
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 17 Mar 2020 15:34:01 +0000 (11:34 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 17 Mar 2020 15:34:01 +0000 (11:34 -0400)
anvil.h
client.c
mons.c

diff --git a/anvil.h b/anvil.h
index b465e1cf51f6d0f8db4fa9086d80e166507b3f0d..4082f2c1fced06fce541c30d358202a1595793e9 100644 (file)
--- a/anvil.h
+++ b/anvil.h
@@ -44,7 +44,8 @@ typedef struct {
 } XConf;
 
 enum {
-    F_WM_DELETE = (1 << 0)
+    F_WM_DELETE = (1 << 0),
+    F_DIALOG    = (1 << 1),
 };
 
 typedef struct Client {
@@ -130,6 +131,7 @@ void client_initall(void);
 Client* client_add(Window win, XWindowAttributes* attr);
 void client_draw(Client* c);
 Client* client_get(Window w, Location* loc);
+void client_adjust(Client* c);
 void client_move(Client* c, int xdiff, int ydiff);
 void client_resize(Client* c, int xdiff, int ydiff);
 void client_close(Client* c);
index 701981506c74dc293f9fbf32182f2e2aa2546af0..e302c3328c613370e264d1757d75516c332dfe6c 100644 (file)
--- a/client.c
+++ b/client.c
@@ -86,16 +86,10 @@ Client* client_get(Window w, Location* loc)
     return c;
 }
 
-void client_raise(Client* c)
+void client_adjust(Client* c)
 {
-    XRaiseWindow(X.disp, c->frame);
-    XRaiseWindow(X.disp, c->win);
-}
-
-void client_lower(Client* c)
-{
-    XLowerWindow(X.disp, c->win);
-    XLowerWindow(X.disp, c->frame);
+    client_move(c, 0, 0);
+    client_resize(c, 0, 0);
 }
 
 void client_move(Client* c, int xdiff, int ydiff)
@@ -105,7 +99,6 @@ void client_move(Client* c, int xdiff, int ydiff)
     XMoveWindow(X.disp, c->frame,
         c->x - BORDER_WIDTH,
         c->y - TITLE_HEIGHT - BORDER_WIDTH);
-    XSync(X.disp, False);
     mons_place(c);
 }
 
@@ -119,7 +112,6 @@ void client_resize(Client* c, int xdiff, int ydiff)
     XResizeWindow(X.disp, c->frame,
         c->w + 2*BORDER_WIDTH,
         c->h + 2*BORDER_WIDTH + TITLE_HEIGHT);
-    XSync(X.disp, False);
     mons_place(c);
 }
 
@@ -157,13 +149,26 @@ void client_show(Client* c, int show)
 
 void client_readprops(Client* c)
 {
-    Atom *protos = NULL, actual_type;
+    Atom *protos = NULL, actual_type, *wintype;
     int format, nprotos = 0;
     unsigned long n, extra;
+
+    /* get window title */
     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);
+        X.disp, c->win, XA_WM_NAME, 0, -1, False, AnyPropertyType, &actual_type, &format, &n, &extra, (unsigned char **)&c->name);
+
+    /* check if the window is a dialog */
+    XGetWindowProperty(
+        X.disp, c->win, atom("_NET_WM_WINDOW_TYPE"), 0L, -1, False, XA_ATOM, &actual_type, &format, &n, &extra, (unsigned char **)&wintype);
+    if (wintype && *wintype == atom("_NET_WM_WINDOW_TYPE_DIALOG"))
+    {
+        c->flags |= F_DIALOG;
+    }
+    xfree(wintype);
+
+    /* get the other hints and protocols */
     XGetWMNormalHints(X.disp, c->win, &(c->hints), &(c->hint_flags));
     XGetWMProtocols(X.disp, c->win, &protos, &nprotos);
     for (int i = 0; i < nprotos; i++)
diff --git a/mons.c b/mons.c
index b842801fef5a21cf2d70be565a9ba4eee8d33061..b04e6c9fbab9ab990656e47354dc19dedd302f3e 100644 (file)
--- a/mons.c
+++ b/mons.c
@@ -44,11 +44,14 @@ void mons_init(void)
 static void coldims(Monitor* mon, Column* col, int *x, int *y, int *w, int *h)
 {
     *x = mon->x, *y = mon->y, *w = col->width, *h = mon->h;
+//    printf("bef: %d %d %d %d\n", mon->x, mon->y, col->width, mon->h);
+//    printf("mon: %d %d %d %d\n", mon->x, mon->y, mon->w, mon->h);
     for (Column* c = mon->cspace->columns; c != col; *x += c->width, c = c->next);
     *x += BORDER_WIDTH;
     *y += BORDER_WIDTH + TITLE_HEIGHT;
-    *w -= 2*BORDER_WIDTH;
-    *h -= 2*BORDER_WIDTH + TITLE_HEIGHT;
+    *w -= (2*BORDER_WIDTH) + 2;
+    *h -= (2*BORDER_WIDTH + TITLE_HEIGHT) + 2;
+//    printf("%d %d %d %d\n", *x, *y, *w, *h);
 }
 
 void mons_layer(Monitor* mon)
@@ -73,14 +76,17 @@ void mons_layer(Monitor* mon)
 static void tile_monocle(Monitor* mon, Column* col, Client* c)
 {
     coldims(mon, col, &(c->x), &(c->y), &(c->w), &(c->h));
-    client_move(c, 0, 0);
-    client_resize(c, 0, 0);
+    client_adjust(c);
     c->next = col->clients;
     col->clients = c;
 }
 
 static void tile_expand(Monitor* mon, Column* col, Client* client)
 {
+    /*
+        * stack all existing clients top to bottom only showing title bars
+        * move+resize new client to fill remaining space or place its title bar at bottom of screen
+    */
     (void)mon, (void)col;
     client->next = col->clients;
     col->clients = client;
@@ -88,6 +94,11 @@ static void tile_expand(Monitor* mon, Column* col, Client* client)
 
 static void tile_stacked(Monitor* mon, Column* col, Client* client)
 {
+    /*
+        * find biggest client in stack
+        * split that client in half
+        * move+resize new client to fill the gap
+    */
     (void)mon, (void)col;
     client->next = col->clients;
     col->clients = client;
@@ -100,7 +111,7 @@ void mons_addclient(Client* c)
     int ptrx = 0, ptry = 0, winx = 0, winy = 0, mask = 0;
     XQueryPointer(X.disp, X.root, &root, &child, &ptrx, &ptry, &winx, &winy, (unsigned int*)&mask);
     Monitor* mon = pickmon(ptrx, ptry);
-    if (X.mode == M_INIT)
+    if (X.mode == M_INIT || c->flags & F_DIALOG)
     {
         c->next = mon->cspace->floating;
         mon->cspace->floating = c;
@@ -297,12 +308,10 @@ static Column* pickcol(Column* cols, int relx)
     /* otherwise, return the current column */
     if (!col)
     {
-//        puts("searching for active col");
         int left = 0, right = 0;
         for (col = cols; col; col = col->next)
         {
             left = right, right += col->width;
-//            printf("%d <= %d < %d\n", left, relx, right);
             if (left <= relx && relx < right)
             {
                 break; /* we found the column holding the mouse */