]> git.mdlowis.com Git - proto/anvil.git/commitdiff
use relative positioning to keep windows in the right spot as workspaces move around...
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 6 Aug 2024 03:16:34 +0000 (23:16 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 6 Aug 2024 03:16:34 +0000 (23:16 -0400)
anvil.h
client.c
monitors.c

diff --git a/anvil.h b/anvil.h
index d097e2c65111fa3b2aaae380fa5e007a70f7e003..3f08f62f82b75329870aa922c720dd69bea9a65b 100644 (file)
--- a/anvil.h
+++ b/anvil.h
@@ -80,7 +80,7 @@ typedef struct Client {
     struct Client* next;
     char* name;
     Window frame, win;
-    int state, flags, wspace, x, y, w, h;
+    int state, flags, wspace, x, y, w, h, rel_x, rel_y;
     long hint_flags, wm_flags;
     XWMHints hints;
     XSizeHints size_hints;
@@ -92,7 +92,7 @@ typedef struct Client {
 //    int width;
 //    Client* clients;
 //} Column;
-//
+
 typedef struct Workspace {
     int monitor;
 //    Client* floating;
index 89e313893bc4af9bb267409120c32f3acfcd25e7..7451c01af22bb71d5b6d199ab6735ba2d9d652fc 100644 (file)
--- a/client.c
+++ b/client.c
@@ -127,6 +127,8 @@ Client* Client_Create(Window win)
                 XFree(hints);
             }
         }
+        Client_Place(c);
+
     }
     return c;
 }
@@ -136,18 +138,11 @@ Client* Client_Create(Window win)
 
 void Client_Show(Client* c)
 {
-    /*
-        If window not overlapping workspace
-            center on configured workspace
-        end
-    */
+    /* position it with relative coords */
     Monitor* mon = &Monitors[Workspaces[c->wspace].monitor];
-    if (MonitorOverlap(mon, c) == 0)
-    {
-        c->x = mon->midx - c->w/2;
-        c->y = mon->midy - c->h/2;
-        Client_MoveResize(c);
-    }
+    c->x = mon->x + c->rel_x;
+    c->y = mon->y + c->rel_y;
+    Client_MoveResize(c);
 
     ReadProps(c);
     SetWMState(c, NormalState);
@@ -272,6 +267,8 @@ void Client_Place(Client* c)
 
     /* update the workspace this client is mapped to */
     c->wspace = Monitors[monitor].wspace;
+    c->rel_x  = c->x - Monitors[monitor].x;
+    c->rel_y  = c->y - Monitors[monitor].y;
 }
 
 static void ReadProps(Client* c)
index 60d0f5e93c63a5fc4e2e7274ff1f2c350dd011d3..478b1366cd7a4a8ff3b2ea9d08e55bad9d5bc5b7 100644 (file)
@@ -81,6 +81,6 @@ void Monitors_SetWorkspace(int ws_id)
 
 void Monitors_SendToWorkspace(Client* c, int id)
 {
-    (void)c;
-    (void)id;
+    c->wspace = id;
+    Client_UpdateAll(); // TODO: this is overkill...
 }