From: Michael D. Lowis Date: Fri, 12 Jun 2020 11:48:25 +0000 (-0400) Subject: checkpoint commit X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=9b941606bdec85b7e5ad92fdb18edbe08dc58006;p=proto%2Fanvil.git checkpoint commit --- diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..f1e7a8f Binary files /dev/null and b/.DS_Store differ diff --git a/anvil.c b/anvil.c index f689f66..2b18961 100644 --- 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 fb2685d..8e80cbb 100644 --- a/anvil.h +++ b/anvil.h @@ -19,10 +19,7 @@ #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 diff --git a/client.c b/client.c index 09aba48..d1de79d 100644 --- 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 9220487..45f7ec6 100644 --- 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 b4768be..fbd8973 100644 --- 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 index 0000000..869fe36 --- /dev/null +++ b/runner.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.runner + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/runner.dSYM/Contents/Resources/DWARF/runner b/runner.dSYM/Contents/Resources/DWARF/runner new file mode 100644 index 0000000..caec86a Binary files /dev/null and b/runner.dSYM/Contents/Resources/DWARF/runner differ diff --git a/test/tile.c b/test/tile.c index f3ea4f2..316744a 100644 --- a/test/tile.c +++ b/test/tile.c @@ -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 1307e5b..47eec1b 100644 --- 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);