]> git.mdlowis.com Git - proto/anvil.git/commitdiff
added debug log, removed monocle mode, eliminated unused key shortcuts
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 31 Jul 2024 02:16:19 +0000 (22:16 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 31 Jul 2024 02:16:19 +0000 (22:16 -0400)
anvil-session [new file with mode: 0755]
anvil.c
anvil.h
client.c
error.c
keys.c
mons.c
mouse.c
test/tile.c
tile.c

diff --git a/anvil-session b/anvil-session
new file mode 100755 (executable)
index 0000000..275ada1
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+source ~/.anvilrc
+edit
+exec anvil
diff --git a/anvil.c b/anvil.c
index d0395469ec433d803bf16959e0d40f4f322bd518..546ce31f2ecec43ae76b675b663cdb1b3939adf3 100644 (file)
--- 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 2e38de50e78605ed442e93521d4cb717d5d90d1e..0444fa983ef1b04098a0ba7b82cab7b07dd19bd8 100644 (file)
--- 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);
index 3960f8e27293d5ee7b4650a8a2f3da4d55859774..78f6c180f26ad3bab134b6dcf032e3d1a117f42d 100644 (file)
--- 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 2a9b55e6e68f174a918738cfd6a731b881c09d9e..bf2662372274aa296cb6371e575c51fdd84ce00c 100644 (file)
--- 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 5c21ebb40f5d52051a5c5895e450edc63aef7a60..3a91299e3b0c61bfae4a32a00ceee9193691d05b 100644 (file)
--- 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 78fa4b902d075a5db58a4afd022f58f0b9118036..033859fbcad96170b1b191a1019ab8ef070386b5 100644 (file)
--- 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 fbd89730a9f8fe68155fcb29a97a8bd52679eeb9..22d2cfd70f5611f42dd4eeccf4b2a5294b02241d 100644 (file)
--- 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]));
index 732bbd8cf9eba89f50715fa1e423fc49fc626738..6597ac015ac9c350bcf20b542bf2c5e9373c74b9 100644 (file)
@@ -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 6da1d8e87ff3a146ae49368d3db4a98803abe779..2dffe2a17de3f7c089029915cd28b113d348b3fb 100644 (file)
--- 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;