From: Michael D. Lowis Date: Wed, 31 Jul 2024 02:16:19 +0000 (-0400) Subject: added debug log, removed monocle mode, eliminated unused key shortcuts X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=4692cdf6ace369461c386a5900e2aa7156103c2d;p=proto%2Fanvil.git added debug log, removed monocle mode, eliminated unused key shortcuts --- diff --git a/anvil-session b/anvil-session new file mode 100755 index 0000000..275ada1 --- /dev/null +++ b/anvil-session @@ -0,0 +1,5 @@ +#!/bin/bash + +source ~/.anvilrc +edit +exec anvil diff --git a/anvil.c b/anvil.c index d039546..546ce31 100644 --- a/anvil.c +++ b/anvil.c @@ -18,7 +18,7 @@ static void xbtnpress(XEvent* e) XGrabPointer(X.disp, ev->window, False, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, X.csr_move, CurrentTime); - //printf("BTN_DN(w: 0x%lx s: %d x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->state, ev->x, ev->y, ev->x_root, ev->y_root); + printf("BTN_DN(w: 0x%lx s: %d x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->state, ev->x, ev->y, ev->x_root, ev->y_root); X.start_x = ev->x_root, X.start_y = ev->y_root; X.last_x = ev->x_root, X.last_y = ev->y_root; Location loc = {0}; @@ -52,7 +52,7 @@ static void xbtnpress(XEvent* e) static void xbtnrelease(XEvent* e) { XButtonEvent* ev = &(e->xbutton); - //printf("BTN_UP(w: 0x%lx x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->x, ev->y, ev->x_root, ev->y_root); + printf("BTN_UP(w: 0x%lx x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->x, ev->y, ev->x_root, ev->y_root); Location loc = {0}; if (mons_find(ev->window, &loc) && (loc.client->frame == ev->window)) { @@ -66,7 +66,7 @@ static void xbtnmotion(XEvent* e) { /* make sure we get just the latest event */ XMotionEvent *ev = &e->xmotion; - //printf("BTN_MV(w: 0x%lx x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->x, ev->y, ev->x_root, ev->y_root); + printf("BTN_MV(w: 0x%lx x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->x, ev->y, ev->x_root, ev->y_root); while (XCheckTypedWindowEvent(X.disp, ev->window, ev->type, e)); Location loc = {0}; if (mons_find(ev->window, &loc) && (loc.client->frame == ev->window)) @@ -121,7 +121,7 @@ static void xconfigrequest(XEvent* e) static void xmaprequest(XEvent* e) { XMapRequestEvent* ev = &(e->xmaprequest); - //printf("MAP(w: 0x%lx)\n", ev->window); + printf("MAP(w: 0x%lx)\n", ev->window); XWindowAttributes attr; Location loc = {0}; if (!mons_find(ev->window, &loc)) @@ -133,10 +133,22 @@ static void xmaprequest(XEvent* e) } } +static void xmapnotify(XEvent* e) +{ + XMapEvent* ev = &(e->xmap); + printf("MAP(e: 0x%lx w: 0x%lx)\n", ev->event, ev->window); + Location loc = {0}; + if (mons_find(ev->window, &loc))// && loc.client->win == ev->window) + { + client_draw(loc.client); + } +} + + static void xunmapnotify(XEvent* e) { XUnmapEvent* ev = &(e->xunmap); - //printf("UNMAP(e: 0x%lx w: 0x%lx %d)\n", ev->event, ev->window, ev->from_configure); + printf("UNMAP(e: 0x%lx w: 0x%lx %d)\n", ev->event, ev->window, ev->from_configure); Location loc = {0}; if (mons_find(ev->window, &loc))// && loc.client->win == ev->window) { @@ -154,7 +166,7 @@ static void xunmapnotify(XEvent* e) static void xdestroynotify(XEvent* e) { XDestroyWindowEvent* ev = &(e->xdestroywindow); - //printf("DESTROY(w: 0x%lx)\n", ev->window); + printf("DESTROY(w: 0x%lx)\n", ev->window); Location loc = {0}; if (mons_find(ev->window, &loc)) { @@ -165,7 +177,7 @@ static void xdestroynotify(XEvent* e) static void xclientmsg(XEvent* e) { XClientMessageEvent* ev = &(e->xclient); - //printf("CLIENT_MSG(w: 0x%lx a: '%s')\n", ev->window, XGetAtomName(X.disp, ev->message_type)); + printf("CLIENT_MSG(w: 0x%lx a: '%s')\n", ev->window, XGetAtomName(X.disp, ev->message_type)); if (ev->message_type == atom("_NET_ACTIVE_WINDOW")) { mons_activate(ev->window); @@ -175,7 +187,7 @@ static void xclientmsg(XEvent* e) static void xpropnotify(XEvent* e) { XPropertyEvent* ev = &(e->xproperty); - //printf("PROP_NOTIFY(w: 0x%lx)\n", ev->window); + printf("PROP_NOTIFY(w: 0x%lx)\n", ev->window); Location loc = {0}; if (mons_find(ev->window, &loc)) { @@ -188,7 +200,7 @@ static void xenternotify(XEvent* e) { XCrossingEvent* ev = &(e->xcrossing); Location loc = {0}; - //printf("ENTER(w: 0x%lx s: %d m: %d d: %d)\n", ev->window, ev->state, ev->mode, ev->detail); + printf("ENTER(w: 0x%lx s: %d m: %d d: %d)\n", ev->window, ev->state, ev->mode, ev->detail); if (mons_find(ev->window, &loc)) { client_focus(loc.client); @@ -200,7 +212,7 @@ static void xexpose(XEvent* e) XExposeEvent* ev = &(e->xexpose); if (ev->count == 0) { - //printf("EXPOSE(w: 0x%lx)\n", ev->window); + printf("EXPOSE(w: 0x%lx)\n", ev->window); Location loc = {0}; if (mons_find(ev->window, &loc)) { @@ -212,7 +224,7 @@ static void xexpose(XEvent* e) static void xkeypress(XEvent* e) { XKeyEvent* ev = &(e->xkey); - //printf("KEY_DN(w: 0x%lx)\n", ev->window); + printf("KEY_DN(w: 0x%lx)\n", ev->window); keys_run(ev); } @@ -255,6 +267,14 @@ int main(void) /* make sure we cleanup zombie processes */ signal(SIGCHLD, sigchld); + /* remap stdout and stderr to file */ + fclose(stdout); + fclose(stderr); + FILE* log = fopen("/home/mdlowis/anvil.log", "wb"); + setvbuf(log, NULL, _IONBF, 0); + stdout = log; + stderr = log; + /* Initialize X server*/ check( (X.disp = XOpenDisplay(0)) != NULL, "could not open display"); @@ -284,6 +304,7 @@ int main(void) X.eventfns[ConfigureNotify] = xconfignotify; X.eventfns[ConfigureRequest] = xconfigrequest; X.eventfns[MapRequest] = xmaprequest; + X.eventfns[MapNotify] = xmapnotify; X.eventfns[UnmapNotify] = xunmapnotify; X.eventfns[DestroyNotify] = xdestroynotify; X.eventfns[ClientMessage] = xclientmsg; diff --git a/anvil.h b/anvil.h index 2e38de5..0444fa9 100644 --- a/anvil.h +++ b/anvil.h @@ -111,18 +111,14 @@ typedef struct { Arg arg; } Key; -#define BORDER_WIDTH 5 -#define TITLE_HEIGHT (X.font_ext->max_logical_extent.height) -#define MIN_HEIGHT (TITLE_HEIGHT+BORDER_WIDTH) -#define MIN_COL_FACT 0.20 -#define FONT_NAME "-*-lucida-bold-r-normal-sans-14-*-*-*-p-*-iso10646-1" -#ifdef __APPLE__ -#define MODKEY Mod1Mask -#else -#define MODKEY Mod4Mask -#endif +#define BORDER_WIDTH 5 +#define TITLE_HEIGHT (X.font_ext->max_logical_extent.height) +#define MIN_HEIGHT (TITLE_HEIGHT+BORDER_WIDTH) +#define MIN_COL_FACT 0.20 +#define FONT_NAME "-*-lucida-bold-r-normal-sans-14-*-*-*-p-*-iso10646-1" +#define MODKEY Mod4Mask #define FRAME_HEIGHT_SUM (2*BORDER_WIDTH + TITLE_HEIGHT) -#define FRAME_WIDTH_SUM (2*BORDER_WIDTH) +#define FRAME_WIDTH_SUM (2*BORDER_WIDTH) /* anvil.c */ extern XConf X; @@ -184,9 +180,6 @@ void mouse_totitle(Client* c); void mouse_get(int* ptrx, int* ptry); /* tile.c */ -void monocled_add(Location* loc); -void monocled_del(Location* loc); -void monocled_raise(Location* loc); void stacked_add(Location* loc); void stacked_del(Location* loc); void stacked_set(Location* loc); diff --git a/client.c b/client.c index 3960f8e..78f6c18 100644 --- a/client.c +++ b/client.c @@ -97,6 +97,9 @@ void client_draw(Client* c) c->name, strlen(c->name)); } } + + /* tell the window to redraw itself */ +// XClearArea(X.disp, c->win, 0, 0, 0, 0, True); } void client_adjust(Client* c) @@ -118,6 +121,7 @@ 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); +// client_draw(c); } void client_move(Client* c, int xdiff, int ydiff) diff --git a/error.c b/error.c index 2a9b55e..bf26623 100644 --- a/error.c +++ b/error.c @@ -11,6 +11,8 @@ int error_init(Display* disp, XErrorEvent* ev) int error_panic(Display* disp, XErrorEvent* ev) { + printf("error panic!\n"); + int ignore_error = ( (ev->error_code == BadWindow) || (ev->request_code == X_SetInputFocus && ev->error_code == BadMatch) diff --git a/keys.c b/keys.c index 5c21ebb..3a91299 100644 --- a/keys.c +++ b/keys.c @@ -3,12 +3,8 @@ static char* wmcmd[] = { "anvil", NULL }; static char* pickexec[] = { "pickexec", NULL }; -static char* terminal[] = { "st", NULL }; -static char* locker[] = { "slock", NULL }; -static char* new_note[] = { "j", "note", NULL }; -static char* new_task[] = { "j", "task", NULL }; -static char* new_journal[] = { "j", "journal", NULL }; -static char* fetchsel[] = { "fetch", NULL, NULL }; +static char* terminal[] = { "xterm", NULL }; +static char* locker[] = { "i3lock", NULL }; static void restart(Arg* arg) { @@ -91,12 +87,6 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_c, killwin, { 0 } }, { MODKEY|ShiftMask, XK_f, togfloat, { 0 } }, - /* Jarvis-specific shortcuts */ - { MODKEY, XK_n, runcmd, { .cmd = new_note } }, - { MODKEY, XK_t, runcmd, { .cmd = new_task } }, - { MODKEY, XK_j, runcmd, { .cmd = new_journal } }, - { MODKEY, XK_f, runcmd, { .cmd = fetchsel } }, - { MODKEY, XK_1, set_workspace, { .i = 0 } }, { MODKEY, XK_2, set_workspace, { .i = 1 } }, { MODKEY, XK_3, set_workspace, { .i = 2 } }, diff --git a/mons.c b/mons.c index 78fa4b9..033859f 100644 --- a/mons.c +++ b/mons.c @@ -80,15 +80,6 @@ void mons_layer(Monitor* mon) wins = realloc(wins, ++nwins * sizeof(Window)); wins[nwins-1] = c->frame; } - /* add in the monocled windows first */ - LIST_FOR_EACH(col, mon->cspace->columns) - { - if (col->focused) - { - wins = realloc(wins, ++nwins * sizeof(Window)); - wins[nwins-1] = col->focused->frame; - } - } /* now lower all of the tiled windows */ LIST_FOR_EACH(col, mon->cspace->columns) { @@ -296,15 +287,7 @@ void mons_coljoin(void) for (Client* c = dead->clients; c;) { Client* next = c->next; - if (dest->focused) - { - - monocled_add(&(Location){mon, NULL, dest, c}); - } - else - { - stacked_add(&(Location){mon, NULL, dest, c}); - } + stacked_add(&(Location){mon, NULL, dest, c}); c = next; } dest->next = dead->next; @@ -355,14 +338,7 @@ void mons_tilemove(Location* loc, int hdiff) client_setshade(loc->client, 0); loc->monitor = mon; loc->column = col; - if (col->focused) - { - monocled_add(loc); - } - else - { - stacked_add(loc); - } + stacked_add(loc); } else { @@ -377,12 +353,7 @@ void mons_activate(Window win) if (mons_find(win, &loc)) { change_wspace(loc.monitor, loc.workspace); - if (loc.column && loc.column->focused) - { - monocled_raise(&loc); - mons_layer(loc.monitor); - } - else if (!loc.column) + if (!loc.column) { mons_raise(loc.monitor, loc.client); } @@ -479,14 +450,7 @@ static void add_client(Monitor* mon, Client* c, int ptrx) } } /* add in monocled or stacked mode */ - if (col->focused) - { - monocled_add(&(Location){mon, NULL, col, c}); - } - else - { - stacked_add(&(Location){mon, NULL, col, c}); - } + stacked_add(&(Location){mon, NULL, col, c}); } mons_layer(mon); } @@ -497,10 +461,6 @@ static void remove_client(Location* loc, Client* c) { loc->workspace->floating = list_del(loc->workspace->floating, c); } - else if (loc->column->focused) - { - monocled_del(loc); - } else { stacked_del(loc); diff --git a/mouse.c b/mouse.c index fbd8973..22d2cfd 100644 --- a/mouse.c +++ b/mouse.c @@ -58,30 +58,12 @@ static void stack_clients(Location* loc) stacked_set(loc); } -static void rotate_client(Location* loc) -{ - Client *tail, *client = loc->column->clients; - if (client->next) - { - loc->column->clients = client->next; - tail = list_last(loc->column->clients); - client->next = NULL; - tail->next = client; - monocled_raise(loc); - } -} - static void reposition_tile(Location* loc) { (void)loc; X.mode = (X.edge == E_TOP ? M_TILE_RESIZE : M_COL_RESIZE); } -static void monocle_client(Location* loc) -{ - monocled_raise(loc); -} - MouseAct Floating[] = { { 0, Button1, ButtonPress, resize_frame }, { MODKEY|ShiftMask, Button2, ButtonPress, toggle_float }, @@ -91,19 +73,12 @@ MouseAct Floating[] = { { 0, Button5, ButtonPress, raise_client } }; -MouseAct Monocled[] = { - { 0, Button1, ButtonPress, stack_clients }, - { MODKEY|ShiftMask, Button2, ButtonPress, toggle_float }, - { MODKEY, Button2, ButtonPress, close_client }, - { 0, Button3, ButtonPress, rotate_client }, -}; - MouseAct Stacked[] = { { 0, Button1, ButtonPress, reposition_tile }, { MODKEY|ShiftMask, Button2, ButtonPress, toggle_float }, { MODKEY, Button2, ButtonPress, close_client }, { 0, Button2, ButtonPress, stack_clients }, - { 0, Button3, ButtonPress, monocle_client }, + { 0, Button3, ButtonPress, stack_clients }, }; static void process(XButtonEvent* ev, Location* loc, MouseAct* actions, int nactions) @@ -131,10 +106,6 @@ void mouse_down(XButtonEvent* ev, Location* loc) { process(ev, loc, Floating, sizeof(Floating)/sizeof(Floating[0])); } - else if (loc->column->focused) - { - process(ev, loc, Monocled, sizeof(Monocled)/sizeof(Monocled[0])); - } else { process(ev, loc, Stacked, sizeof(Stacked)/sizeof(Stacked[0])); diff --git a/test/tile.c b/test/tile.c index 732bbd8..6597ac0 100644 --- a/test/tile.c +++ b/test/tile.c @@ -50,45 +50,6 @@ Location* setup(void) } /**** Unit Tests - Monocled Mode ****/ -UNITTEST(monocled_add_should_add_client) -{ - 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 == 50); /* TODO: account for window border in client size */ - CHECK(loc->client->h == 100); - 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 == 50); - CHECK(next.h == 100); -} - -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 ****/ diff --git a/tile.c b/tile.c index 6da1d8e..2dffe2a 100644 --- a/tile.c +++ b/tile.c @@ -10,57 +10,6 @@ static void coldims(Monitor *mon, Column *col, int *x, int *y, int *w, int *h) } } -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; - loc->column->focused = c; -} - -void monocled_del(Location* loc) -{ - Client* c = loc->client; - loc->column->clients = list_del(loc->column->clients, c); - loc->column->focused = loc->column->clients; - c = loc->column->clients; - if (c) - { - coldims(loc->monitor, loc->column, &(c->x), &(c->y), &(c->w), &(c->h)); - client_setshade(c, 0); - client_adjust(c); - } -} - -void monocled_raise(Location* loc) -{ - loc->column->clients = list_del(loc->column->clients, loc->client); - loc->client->next = loc->column->clients; - loc->column->clients = loc->client; - 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) -{ - loc->column->clients = list_del(loc->column->clients, loc->client); - loc->client->next = loc->column->clients; - loc->column->clients = loc->client; - 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 stacked_add(Location* loc) { Client* c = loc->client;