]> git.mdlowis.com Git - proto/anvil.git/commitdiff
checkpoint commit
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 12 Jun 2020 11:48:25 +0000 (07:48 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 12 Jun 2020 11:48:25 +0000 (07:48 -0400)
.DS_Store [new file with mode: 0644]
anvil.c
anvil.h
client.c
mons.c
mouse.c
runner.dSYM/Contents/Info.plist [new file with mode: 0644]
runner.dSYM/Contents/Resources/DWARF/runner [new file with mode: 0644]
test/tile.c
tile.c

diff --git a/.DS_Store b/.DS_Store
new file mode 100644 (file)
index 0000000..f1e7a8f
Binary files /dev/null and b/.DS_Store differ
diff --git a/anvil.c b/anvil.c
index f689f6675de3d4ff04aadbbcba4c263c9b2b4a95..2b18961968d44e2aae46779c7f8bae70d3695029 100644 (file)
--- a/anvil.c
+++ b/anvil.c
@@ -75,10 +75,19 @@ static void xbtnmotion(XEvent* e)
     X.last_x = ev->x_root, X.last_y  = ev->y_root;
 }
 
+static void xconfignotify(XEvent* e)
+{
+    XConfigureEvent* ev = &(e->xconfigure);
+    if (ev->window == X.root)
+    {
+        puts("root window resized");
+    }
+}
+
 static void xconfigrequest(XEvent* e)
 {
     XConfigureRequestEvent* ev = &(e->xconfigurerequest);
-    //printf("CONF(w: 0x%lx x: %d y: %d w: %d h: %d)\n", ev->window, ev->x, ev->y, ev->width, ev->height);
+    printf("CONF(w: 0x%lx x: %d y: %d w: %d h: %d)\n", ev->window, ev->x, ev->y, ev->width, ev->height);
     XWindowChanges wc;
     wc.x = ev->x;
     wc.y = ev->y;
@@ -259,6 +268,7 @@ int main(void)
     X.eventfns[ButtonRelease] = xbtnrelease;
     X.eventfns[MotionNotify] = xbtnmotion;
     X.eventfns[KeyPress] = xkeypress;
+    X.eventfns[ConfigureNotify] = xconfignotify;
     X.eventfns[ConfigureRequest] = xconfigrequest;
     X.eventfns[MapRequest] = xmaprequest;
     X.eventfns[UnmapNotify] = xunmapnotify;
diff --git a/anvil.h b/anvil.h
index fb2685d1c8856e4012353eed899500e61ecd4384..8e80cbb738f1d67566017660af2a4575b86ec67a 100644 (file)
--- a/anvil.h
+++ b/anvil.h
 #define min(a,b) (a < b ? a : b)
 #define max(a,b) (a > b ? a : b)
 
-/* TODO: warp mouse pointer to title bars on new windows */
 /* TODO: Add shortcuts to transfer windows between monitors */
-/* 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 */
 /* TODO: add floating addclient function */
 
 enum {
@@ -185,7 +182,6 @@ void mouse_get(int* ptrx, int* ptry);
 void monocled_add(Location* loc);
 void monocled_del(Location* loc);
 void monocled_raise(Location* loc);
-void monocled_set(Location* loc);
 void stacked_add(Location* loc);
 void stacked_del(Location* loc);
 void stacked_set(Location* loc);
@@ -204,4 +200,4 @@ void xfree(void* p);
 Atom atom(char* str);
 void sendmsg(Window win, Atom proto, Atom type);
 
-#endif
\ No newline at end of file
+#endif
index 09aba4893be0f0444e9ed741e2e471b88cd80f1f..d1de79d75e28d9ef27d6e7132fdb69d9e944c473 100644 (file)
--- a/client.c
+++ b/client.c
@@ -81,6 +81,7 @@ void client_adjust(Client* c)
     int minheight = (shaded || !floating ? MIN_HEIGHT : 3*MIN_HEIGHT);
     if (c->w < minheight) c->w = minheight;
     if (c->h < minheight) c->h = minheight;
+printf("XMoveResize(0x%lx, %d, %d, %d, %d)\n", c->frame, c->x, c->y, c->w, c->h);
     XMoveResizeWindow(X.disp, c->frame, c->x, c->y, c->w, (shaded ? minheight : c->h));
     if ( !(c->flags & F_SHADED) )
     {
@@ -88,6 +89,7 @@ void client_adjust(Client* c)
         int child_h = c->h - 2*BORDER_WIDTH - TITLE_HEIGHT - 2;
         if (child_w < 1) c->w = 1;
         if (child_h < 1) c->h = 1;
+printf("XResize(0x%lx, %d, %d)\n", c->win, c->w, c->h);
         XResizeWindow(X.disp, c->win, child_w, child_h);
     }
     mons_place(c);
diff --git a/mons.c b/mons.c
index 9220487b16ff4b2d5a63d083368d3a37eb29816c..45f7ec6942b8b21a676a0a5bdf5d97d48f79a8ea 100644 (file)
--- a/mons.c
+++ b/mons.c
@@ -442,10 +442,11 @@ static void add_client(Monitor* mon, Client* c, int ptrx)
     else
     {
         /* find first empty column, and fill that first */
-        Column* col = list_last(mon->cspace->columns);
+        Column* col = NULL;
+        LIST_FOR_EACH_UNTIL(col, mon->cspace->columns, col->clients == NULL);
         if (!col)
         {
-            /* otherwise pick the column to the right or current column */
+            /* otherwise pick the column to the right or the current column */
             col = pickcol(mon->cspace->columns, ptrx - mon->x);
             if (col->next)
             {
diff --git a/mouse.c b/mouse.c
index b4768bed120069cba0f5405b0e5bdcbf2426b868..fbd89730a9f8fe68155fcb29a97a8bd52679eeb9 100644 (file)
--- a/mouse.c
+++ b/mouse.c
@@ -67,7 +67,7 @@ static void rotate_client(Location* loc)
         tail = list_last(loc->column->clients);
         client->next = NULL;
         tail->next = client;
-        monocled_set(loc);
+        monocled_raise(loc);
     }
 }
 
@@ -79,7 +79,7 @@ static void reposition_tile(Location* loc)
 
 static void monocle_client(Location* loc)
 {
-    monocled_set(loc);
+    monocled_raise(loc);
 }
 
 MouseAct Floating[] = {
diff --git a/runner.dSYM/Contents/Info.plist b/runner.dSYM/Contents/Info.plist
new file mode 100644 (file)
index 0000000..869fe36
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+       <dict>
+               <key>CFBundleDevelopmentRegion</key>
+               <string>English</string>
+               <key>CFBundleIdentifier</key>
+               <string>com.apple.xcode.dsym.runner</string>
+               <key>CFBundleInfoDictionaryVersion</key>
+               <string>6.0</string>
+               <key>CFBundlePackageType</key>
+               <string>dSYM</string>
+               <key>CFBundleSignature</key>
+               <string>????</string>
+               <key>CFBundleShortVersionString</key>
+               <string>1.0</string>
+               <key>CFBundleVersion</key>
+               <string>1</string>
+       </dict>
+</plist>
diff --git a/runner.dSYM/Contents/Resources/DWARF/runner b/runner.dSYM/Contents/Resources/DWARF/runner
new file mode 100644 (file)
index 0000000..caec86a
Binary files /dev/null and b/runner.dSYM/Contents/Resources/DWARF/runner differ
index f3ea4f229d70e01d05b2cbecc5113a15dd173251..316744af797a8c11f634d50d2ac87141912c2a41 100644 (file)
@@ -25,29 +25,72 @@ void mouse_totitle(Client* c)
     (void)c;
 }
 
-/**** Stub Functions ****/
+/**** Test Setup Functions ****/
 
-Monitor TestMon = {
-    .x = 0, .y = 0,
-    .w = 100, .h = 100,
-    .midx = 50, .midy = 50
-};
-
-Location TestLoc = {
-    .monitor = &TestMon,
-    .workspace = &(Workspace){
-        .columns = &(Column){
-            .width = 50,
-            .next = &(Column){
-                .width = 50
-            }
-        }
-    },
-
-};
+Location* setup(void)
+{
+    Location* loc = calloc(1, sizeof(Location));
+    Monitor* mon = calloc(1, sizeof(Monitor));
+    mon->w = 100, mon->h = 100;
+    mon->midx = 50, mon->midy = 50;
+    Column* col1 = calloc(1, sizeof(Column));
+    col1->width = 50;
+    Column* col2 = calloc(1, sizeof(Column));
+    col2->width = 50;
+    col1->next = col2;
+    Workspace* wspace = calloc(1, sizeof(Workspace));
+    wspace->columns = col1;
+    mon->wspaces = wspace;
+    mon->cspace = wspace;
+    loc->monitor = mon;
+    loc->workspace = wspace;
+    loc->column = col1;
+    loc->client = calloc(1, sizeof(Client));
+    return loc;
+}
 
-/**** Stub Functions ****/
-UNITTEST(Foo)
+/**** Unit Tests - Monocled Mode ****/
+UNITTEST(monocled_add_should_add_client)
 {
-    CHECK(1==9);
-}
\ No newline at end of file
+    Client next = {0};
+    Location* loc = setup();
+    loc->column->clients = &next;
+    monocled_add(loc);
+    CHECK(loc->client->x == 0);
+    CHECK(loc->client->y == 0);
+    CHECK(loc->client->w == 48); /* TODO: account for window border in client size */
+    CHECK(loc->client->h == 98);
+    CHECK(loc->client->next == &next);
+    CHECK(loc->column->clients == loc->client);
+    CHECK(loc->column->focused == loc->client);
+}
+
+UNITTEST(monocled_del_should_del_client_and_focus_next)
+{
+    Client next = {0};
+    Location* loc = setup();
+    loc->column->clients = &next;
+    monocled_add(loc);
+    monocled_del(loc);
+    CHECK(loc->column->clients == &next);
+    CHECK(loc->column->focused == &next);
+    CHECK(next.x == 0);
+    CHECK(next.y == 0);
+    CHECK(next.w == 48);
+    CHECK(next.h == 98);
+}
+
+UNITTEST(monocled_del_should_del_client_and_leave_column_empty)
+{
+    Location* loc = setup();
+    monocled_add(loc);
+    monocled_del(loc);
+    CHECK(loc->column->clients == NULL);
+    CHECK(loc->column->focused == NULL);
+}
+
+
+/**** Unit Tests - Stacked Mode ****/
+
+/**** Unit Tests - Floating Mode ****/
+
diff --git a/tile.c b/tile.c
index 1307e5b9bd18d4f37b098ea8f6731ddbc0f5457d..47eec1b41bb48cc41512c540609cd1f1669e75f9 100644 (file)
--- a/tile.c
+++ b/tile.c
@@ -14,6 +14,7 @@ void monocled_add(Location* loc)
 {
     Client* c = loc->client;
     coldims(loc->monitor, loc->column, &(c->x), &(c->y), &(c->w), &(c->h));
+    client_setshade(c, 0);
     client_adjust(c);
     c->next = loc->column->clients;
     loc->column->clients = c;
@@ -28,9 +29,9 @@ void monocled_del(Location* loc)
     c = loc->column->clients;
     if (c)
     {
-        coldims(loc->monitor, loc->column,
-            &(loc->client->x), &(loc->client->y), &(loc->client->w), &(loc->client->h));
-        client_adjust(loc->client);
+        coldims(loc->monitor, loc->column, &(c->x), &(c->y), &(c->w), &(c->h));
+        client_setshade(c, 0);
+        client_adjust(c);
     }
 }
 
@@ -42,7 +43,9 @@ void monocled_raise(Location* loc)
     loc->column->focused = loc->client;
     coldims(loc->monitor, loc->column,
         &(loc->client->x), &(loc->client->y), &(loc->client->w), &(loc->client->h));
+    client_setshade(loc->client, 0);
     client_adjust(loc->client);
+    mons_layer(loc->monitor);
 }
 
 void monocled_set(Location* loc)
@@ -91,6 +94,7 @@ void stacked_add(Location* loc)
         {
             c->h = max->h/2;
             c->y = max->y + c->h;
+            c->w = max->w;
             max->h -= max->h/2;
             c->next = max->next;
             max->next = c;
@@ -175,7 +179,6 @@ void stacked_addheight(Location* loc, int amount)
         c->y = max(miny, min(maxy, c->y + amount));
         prev->h = c->y - prev->y;
         c->h = (c->next ? c->next->y : loc->monitor->y + loc->monitor->h) - c->y;
-        printf("ADD_HEIGHT(w: %lx x: %d y: %d w: %d h: %d)\n", c->frame, c->x, c->y, c->w, c->h);
         client_setshade(prev, (prev->h <= MIN_HEIGHT));
         client_setshade(c, (c->h <= MIN_HEIGHT));
         client_adjust(prev);