]> git.mdlowis.com Git - proto/anvil.git/commitdiff
implemented switch to monocled mode, swapping through monocled clients, and added...
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 19 Mar 2020 17:16:47 +0000 (13:16 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 19 Mar 2020 17:16:47 +0000 (13:16 -0400)
anvil.h
keys.c
mons.c
mouse.c
tile.c

diff --git a/anvil.h b/anvil.h
index 2818d8b5eaa9e86c1d5559d71bb12ca7ded10ad6..7d3abf956cbd5dce8895acbcf0f4bbd33afd5e45 100644 (file)
--- a/anvil.h
+++ b/anvil.h
@@ -179,8 +179,10 @@ void mouse_drag(XMotionEvent* ev, Location* loc);
 /* tile.c */
 void monocled_add(Monitor* mon, Column* col, Client* c);
 void monocled_del(Monitor* mon, Column* col, Client* c);
+void monocled_set(Monitor* mon, Column* col, Client* c);
 void stacked_add(Monitor* mon, Column* col, Client* c);
 void stacked_del(Monitor* mon, Column* col, Client* c);
+void stacked_set(Monitor* mon, Column* col, Client* c);
 
 /* error.c */
 extern int (*error_default)(Display* disp, XErrorEvent* ev);
diff --git a/keys.c b/keys.c
index 18018d17d03476185a0a28465939958d77291cdb..887208c01d2239e3d7dc3fd7f90c2626db369098 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -45,6 +45,9 @@ static char* pickexec[]  = { "pickexec", NULL };
 static char* terminal[]  = { "xterm", NULL };
 static char* locker[]  = { "slock", NULL };
 
+/* TODO: Add shortcuts to add/del columns and resize them */
+/* TODO: Add shortcuts to transfer windows between monitors */
+/* TODO: Add shortcuts to toggle between tiled and floating */
 static Key keys[] = {
     { MODKEY|ShiftMask, XK_q,      quit,    { 0 } },
     { MODKEY,           XK_p,      runcmd,  { .cmd = pickexec } },
diff --git a/mons.c b/mons.c
index 914767c821e7e405810992aec60ae47b8fc1cd53..08fdacd955cb00971f657b5d7566a2d06caf4b63 100644 (file)
--- a/mons.c
+++ b/mons.c
@@ -50,13 +50,25 @@ void mons_layer(Monitor* mon)
         wins = realloc(wins, ++nwins * sizeof(Window));
         wins[nwins-1] = c->frame;
     }
+    /* add in the monocled windows first */
+    for (Column* col = mon->cspace->columns; col; col = col->next)
+    {
+        if (col->focused)
+        {
+            wins = realloc(wins, ++nwins * sizeof(Window));
+            wins[nwins-1] = col->focused->frame;
+        }
+    }
     /* now lower all of the tiled windows */
     for (Column* col = mon->cspace->columns; col; col = col->next)
     {
         for (Client* c = col->clients; c; c = c->next)
         {
-            wins = realloc(wins, ++nwins * sizeof(Window));
-            wins[nwins-1] = c->frame;
+            if (col->focused != c)
+            {
+                wins = realloc(wins, ++nwins * sizeof(Window));
+                wins[nwins-1] = c->frame;
+            }
         }
     }
     if (nwins)
@@ -64,6 +76,7 @@ void mons_layer(Monitor* mon)
         XRestackWindows(X.disp, wins, nwins);
         XSync(X.disp, False);
     }
+    xfree(wins);
 }
 
 /* adds a new client to the most appropriate monitor */
diff --git a/mouse.c b/mouse.c
index 7c35742b770445cc110863c264537b92b5c04c9a..8773d1dd18cea5c7c29405f4a8f36cfdcbff9ffb 100644 (file)
--- a/mouse.c
+++ b/mouse.c
@@ -1,5 +1,8 @@
 #include "anvil.h"
 
+/* TODO: warp the mouse to titlebar on various locations */
+/* TODO: make sure mouse warps to the correct titlebar and floating windows don't get in the way */
+
 static inline int PRESSED(int mods, int btn)
 {
     return ((mods & (1 << (btn + 7))) == (1 << (btn + 7)));
@@ -34,7 +37,7 @@ static void monocled_click(XButtonEvent* ev, Location* loc)
 {
     if (ev->button == Button1)
     {
-        puts("switch to expanded");
+        stacked_set(loc->monitor, loc->column, loc->client);
     }
     else if (ev->button == Button2)
     {
@@ -49,6 +52,7 @@ static void monocled_click(XButtonEvent* ev, Location* loc)
             for (tail = loc->column->clients; tail && tail->next; tail = tail->next);
             client->next = NULL;
             tail->next = client;
+            monocled_set(loc->monitor, loc->column, loc->column->clients);
         }
     }
     mons_layer(loc->monitor);
@@ -56,10 +60,15 @@ static void monocled_click(XButtonEvent* ev, Location* loc)
 
 static void stacked_click(XButtonEvent* ev, Location* loc)
 {
+    /* TODO: handle button 1 drag to resize, reposition, and move windows */
     if (ev->button == Button2)
     {
         client_close(loc->client);
     }
+    else if (ev->button == Button3)
+    {
+        monocled_set(loc->monitor, loc->column, loc->client);
+    }
 }
 
 void mouse_click(XButtonEvent* ev, Location* loc)
diff --git a/tile.c b/tile.c
index e2b2ce6c449e9a62ea3b0337784b5b3e67737a0d..1432c0fd3bc71de9fe7f4a94255c9aab21af3cc3 100644 (file)
--- a/tile.c
+++ b/tile.c
@@ -16,8 +16,25 @@ void monocled_add(Monitor* mon, Column* col, Client* c)
 
 void monocled_del(Monitor* mon, Column* col, Client* c)
 {
-    (void)mon;
     col->clients = delclient(col->clients, c);
+    col->focused = col->clients;
+    c = col->clients;
+    if (c)
+    {
+        coldims(mon, col, &(c->x), &(c->y), &(c->w), &(c->h));
+        client_adjust(c);
+    }
+}
+
+void monocled_set(Monitor* mon, Column* col, Client* c)
+{
+    col->clients = delclient(col->clients, c);
+    c->next = col->clients;
+    col->clients = c;
+    col->focused = c;
+    coldims(mon, col, &(c->x), &(c->y), &(c->w), &(c->h));
+    client_adjust(c);
+    mons_layer(mon);
 }
 
 void stacked_add(Monitor* mon, Column* col, Client* c)
@@ -38,8 +55,8 @@ void stacked_add(Monitor* mon, Column* col, Client* c)
         max->h -= max->h/2;
         c->next = max->next;
         max->next = c;
-        client_adjust(max);
         client_adjust(c);
+        client_adjust(max);
     }
     else
     {
@@ -71,3 +88,12 @@ void stacked_del(Monitor* mon, Column* col, Client* c)
     }
 }
 
+void stacked_set(Monitor* mon, Column* col, Client* c)
+{
+    (void)mon, (void)col, (void)c;
+    puts("switching to stacked mode");
+    /* TODO: implement switch back to stacked mode */
+}
+
+
+