--- /dev/null
+#!/bin/bash
+
+source ~/.anvilrc
+edit
+exec anvil
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};
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))
{
{
/* 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))
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))
}
}
+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)
{
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))
{
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);
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))
{
{
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);
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))
{
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);
}
/* 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");
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;
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;
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);
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)
XResizeWindow(X.disp, c->win, child_w, child_h);
}
mons_place(c);
+// client_draw(c);
}
void client_move(Client* c, int xdiff, int ydiff)
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)
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)
{
{ 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 } },
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)
{
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;
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
{
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);
}
}
}
/* 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);
}
{
loc->workspace->floating = list_del(loc->workspace->floating, c);
}
- else if (loc->column->focused)
- {
- monocled_del(loc);
- }
else
{
stacked_del(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 },
{ 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)
{
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]));
}
/**** 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 ****/
}
}
-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;