]> git.mdlowis.com Git - proto/anvil.git/commitdiff
added shading logic and fixed resizing
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 19 Mar 2020 02:11:47 +0000 (22:11 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 19 Mar 2020 02:11:47 +0000 (22:11 -0400)
anvil.c
anvil.h
client.c
mouse.c

diff --git a/anvil.c b/anvil.c
index bd74e7ae8bc3e2945f879b99964713f3927b63dd..95feb8e74d482b0b07515417392f446e5591611a 100644 (file)
--- a/anvil.c
+++ b/anvil.c
@@ -87,7 +87,7 @@ static void xunmapnotify(XEvent* e)
 {
     XUnmapEvent* ev = &(e->xunmap);
     Client* c = client_get(ev->window, NULL);
-    if (c && c->win == ev->window)
+    if (c && c->win == ev->window && !(c->flags & F_SHADED))
     {
         XUnmapWindow(X.disp, c->frame);
     }
diff --git a/anvil.h b/anvil.h
index 4349b14b18c06e3f1f8488e004b4cc7476d0cc60..2818d8b5eaa9e86c1d5559d71bb12ca7ded10ad6 100644 (file)
--- a/anvil.h
+++ b/anvil.h
@@ -82,6 +82,7 @@ typedef struct {
 enum {
     F_WM_DELETE = (1 << 0),
     F_DIALOG    = (1 << 1),
+    F_SHADED    = (1 << 2),
 };
 
 typedef struct Client {
@@ -169,6 +170,7 @@ void client_close(Client* c);
 void client_focus(Client* c);
 void client_show(Client* c, int show);
 void client_readprops(Client* c);
+void client_shade(Client* c);
 
 /* mouse.c */
 void mouse_click(XButtonEvent* ev, Location* loc);
index 0d78e9f2312498a4d1e34a60833d9181dd055ef2..5d1d93ba2265a07bbbe24355574e903c8de32115 100644 (file)
--- a/client.c
+++ b/client.c
@@ -108,11 +108,18 @@ void client_resize(Client* c, int xdiff, int ydiff)
     c->h += ydiff;
     if (c->w < 50) c->w = 50;
     if (c->h < 50) c->h = 50;
-    XResizeWindow(X.disp, c->frame, c->w, c->h);
-    XResizeWindow(X.disp, c->win,
-        c->w - 2*BORDER_WIDTH - 2,
-        c->h - 2*BORDER_WIDTH - TITLE_HEIGHT - 2
-    );
+    if (c->flags & F_SHADED)
+    {
+        XResizeWindow(X.disp, c->frame, c->w, TITLE_HEIGHT+BORDER_WIDTH);
+    }
+    else
+    {
+        XResizeWindow(X.disp, c->frame, c->w, c->h);
+        XResizeWindow(X.disp, c->win,
+            c->w - 2*BORDER_WIDTH - 2,
+            c->h - 2*BORDER_WIDTH - TITLE_HEIGHT - 2
+        );
+    }
     mons_place(c);
 }
 
@@ -181,3 +188,18 @@ void client_readprops(Client* c)
     }
     xfree(protos);
 }
+
+void client_shade(Client* c)
+{
+    if (c->flags & F_SHADED)
+    {
+        c->flags &= ~F_SHADED;
+        XMapWindow(X.disp, c->win);
+    }
+    else
+    {
+        c->flags |= F_SHADED;
+        XUnmapWindow(X.disp, c->win);
+    }
+    client_adjust(c);
+}
diff --git a/mouse.c b/mouse.c
index af0ae571478ca2050cde9d0a94ed67922ae5960c..7c35742b770445cc110863c264537b92b5c04c9a 100644 (file)
--- a/mouse.c
+++ b/mouse.c
@@ -7,10 +7,19 @@ static inline int PRESSED(int mods, int btn)
 
 static void float_click(XButtonEvent* ev, Location* loc)
 {
-    if (ev->button == Button2)
+    if ((ev->button == Button1) && (ev->y > (TITLE_HEIGHT + BORDER_WIDTH)))
+    {
+        X.mode = M_RESIZE;
+        warp_mouse(loc->client);
+    }
+    else if (ev->button == Button2)
     {
         client_close(loc->client);
     }
+    else if (ev->button == Button3)
+    {
+        client_shade(loc->client);
+    }
     else if (ev->button == Button4)
     {
         mons_lower(loc->monitor, loc->client);
@@ -18,11 +27,6 @@ static void float_click(XButtonEvent* ev, Location* loc)
     else if (ev->button == Button5)
     {
         mons_raise(loc->monitor, loc->client);
-        if (ev->y > (TITLE_HEIGHT + BORDER_WIDTH))
-        {
-            X.mode = M_RESIZE;
-            warp_mouse(loc->client);
-        }
     }
 }