]> git.mdlowis.com Git - proto/anvil.git/commitdiff
fixed issue with stacking order and added more mouse actions
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 18 Mar 2020 17:13:58 +0000 (13:13 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 18 Mar 2020 17:13:58 +0000 (13:13 -0400)
anvil.h
mons.c
mouse.c

diff --git a/anvil.h b/anvil.h
index c5e0bc4fbb06d8e3a34baffdb6cd13426c4afa0f..b157eaa28188f3e5a300c19d90fece2a20d4ba9d 100644 (file)
--- a/anvil.h
+++ b/anvil.h
@@ -24,11 +24,42 @@ Management Notes:
     * Windows can tile in a column or float on workspaces
     * Columns can have different layouts: manual, stacked, monocle
 
-    TODO: window border is wrong width on right and bottom for some reason...
     TODO: warp mouse pointer to title bars on new windows
-    TODO: account for frame size in client x,y,w,h fields
     TODO: implement mouse handling for tiling methods
 
+Mouse Actions:
+    Floating:
+        Btn Click 1:
+        Btn Drag 1: Move Window
+        Btn Click 2: Close Window
+        Btn Click 3:
+        Btn Click 4: Lower Window
+        Btn Click 5: Raise Window
+
+    Monocled:
+        Btn Click 1:
+        Btn Drag 1:
+        Btn Click 2: Close Window
+        Btn Click 3: Lower Window
+        Btn Click 4:
+        Btn Click 5:
+
+    Stacked:
+        Btn Click 1:
+        Btn Drag 1:
+        Btn Click 2: Close Window
+        Btn Click 3:
+        Btn Click 4:
+        Btn Click 5:
+
+    Expanded:
+        Btn Click 1:
+        Btn Drag 1:
+        Btn Click 2: Close Window
+        Btn Click 3:
+        Btn Click 4:
+        Btn Click 5:
+
 */
 
 enum {
diff --git a/mons.c b/mons.c
index 040cec9456f04b8dd56d41322e2d59f800c58e15..41bae5818644bf9a6b6536a7dbb3807c174fbe93 100644 (file)
--- a/mons.c
+++ b/mons.c
@@ -42,21 +42,27 @@ void mons_init(void)
 
 void mons_layer(Monitor* mon)
 {
-    /* lower all of the floating windows first */
-    for (Client* client = mon->cspace->floating; client; client = client->next)
+    int nwins = 0;
+    Window* wins = NULL;
+    for (Client* c = mon->cspace->floating; c; c = c->next)
     {
-        XLowerWindow(X.disp, client->win);
-        XLowerWindow(X.disp, client->frame);
+        wins = realloc(wins, ++nwins);
+        wins[nwins-1] = c->frame;
     }
     /* now lower all of the tiled windows */
     for (Column* col = mon->cspace->columns; col; col = col->next)
     {
-        for (Client* client = col->clients; client; client = client->next)
+        for (Client* c = col->clients; c; c = c->next)
         {
-            XLowerWindow(X.disp, client->win);
-            XLowerWindow(X.disp, client->frame);
+            wins = realloc(wins, ++nwins);
+            wins[nwins-1] = c->frame;
         }
     }
+    if (nwins)
+    {
+        XRestackWindows(X.disp, wins, nwins);
+        XSync(X.disp, False);
+    }
 }
 
 /* adds a new client to the most appropriate monitor */
diff --git a/mouse.c b/mouse.c
index d44c814b8dbf13e1d3e43dfcfed201bc5a099170..f698378e0749c54e27b02265be79e629c7fee89a 100644 (file)
--- a/mouse.c
+++ b/mouse.c
@@ -7,7 +7,15 @@ static inline int PRESSED(int mods, int btn)
 
 static void float_click(XButtonEvent* ev, Location* loc)
 {
-    if (ev->button == Button1)
+    if (ev->button == Button2)
+    {
+        client_close(loc->client);
+    }
+    else if (ev->button == Button4)
+    {
+        mons_lower(loc->monitor, loc->client);
+    }
+    else if (ev->button == Button5)
     {
         mons_raise(loc->monitor, loc->client);
         if (ev->y > (TITLE_HEIGHT + BORDER_WIDTH))
@@ -16,17 +24,9 @@ static void float_click(XButtonEvent* ev, Location* loc)
             warp_mouse(loc->client);
         }
     }
-    else if (ev->button == Button2)
-    {
-        client_close(loc->client);
-    }
-    else if (ev->button == Button3)
-    {
-        mons_lower(loc->monitor, loc->client);
-    }
 }
 
-static void monocle_click(XButtonEvent* ev, Location* loc)
+static void monocled_click(XButtonEvent* ev, Location* loc)
 {
     if (ev->button == Button2)
     {
@@ -46,6 +46,22 @@ static void monocle_click(XButtonEvent* ev, Location* loc)
     mons_layer(loc->monitor);
 }
 
+static void stacked_click(XButtonEvent* ev, Location* loc)
+{
+    if (ev->button == Button2)
+    {
+        client_close(loc->client);
+    }
+}
+
+static void expanded_click(XButtonEvent* ev, Location* loc)
+{
+    if (ev->button == Button2)
+    {
+        client_close(loc->client);
+    }
+}
+
 void mouse_click(XButtonEvent* ev, Location* loc)
 {
     if (!loc->column)
@@ -54,15 +70,15 @@ void mouse_click(XButtonEvent* ev, Location* loc)
     }
     else if (loc->column->mode == TILE_MONOCLE)
     {
-        monocle_click(ev, loc);
+        monocled_click(ev, loc);
     }
     else if (loc->column->mode == TILE_STACKED)
     {
-        puts("tiled (S) mouse click");
+        stacked_click(ev, loc);
     }
     else if (loc->column->mode == TILE_EXPAND)
     {
-        puts("tiled (E) mouse click");
+        expanded_click(ev, loc);
     }
 }
 
@@ -82,15 +98,38 @@ static void float_drag(XMotionEvent* ev, Location* loc)
     }
 }
 
+static void monocled_drag(XMotionEvent* ev, Location* loc)
+{
+    (void)ev, (void)loc;
+}
+
+static void stacked_drag(XMotionEvent* ev, Location* loc)
+{
+    (void)ev, (void)loc;
+}
+
+static void expanded_drag(XMotionEvent* ev, Location* loc)
+{
+    (void)ev, (void)loc;
+}
+
 void mouse_drag(XMotionEvent* ev, Location* loc)
 {
     if (!loc->column)
     {
         float_drag(ev, loc);
     }
-    else
+    else if (loc->column->mode == TILE_MONOCLE)
+    {
+        monocled_drag(ev, loc);
+    }
+    else if (loc->column->mode == TILE_STACKED)
+    {
+        stacked_drag(ev, loc);
+    }
+    else if (loc->column->mode == TILE_EXPAND)
     {
-        puts("tiled mouse drag");
+        expanded_drag(ev, loc);
     }
 }