#include "anvil.h"
+#include <sys/wait.h>
XConf X = {0};
/* only allow floating clients to resize on their own */
if ((loc.client->win == ev->window) && !loc.column)
{
- loc.client->w = wc.width;
- loc.client->h = wc.height;
+ loc.client->w = wc.width + FRAME_WIDTH_SUM;
+ loc.client->h = wc.height + FRAME_HEIGHT_SUM;
client_adjust(loc.client);
if (X.mode == M_RESIZE && Focused == loc.client)
{
X.font_ext = XExtentsOfFontSet(X.font);
}
+void sigchld(int sig)
+{
+ (void)sig;
+ while (waitpid(-1, 0, WNOHANG) > 0);
+}
+
int main(void)
{
+ /* make sure we cleanup zombie processes */
+ signal(SIGCHLD, sigchld);
+
/* Initialize X server*/
check( (X.disp = XOpenDisplay(0)) != NULL,
"could not open display");
#else
#define MODKEY Mod4Mask
#endif
+#define FRAME_HEIGHT_SUM (2*BORDER_WIDTH + TITLE_HEIGHT)
+#define FRAME_WIDTH_SUM (2*BORDER_WIDTH)
/* anvil.c */
extern XConf X;
c->win = win;
c->x = attr->x;
c->y = attr->y;
- c->w = attr->width + 2*BORDER_WIDTH - 2;
- c->h = attr->height + 2*BORDER_WIDTH + TITLE_HEIGHT - 2;
+ c->w = attr->width + FRAME_WIDTH_SUM;
+ c->h = attr->height + FRAME_HEIGHT_SUM;
client_readprops(c);
/* Reparent the window if applicable */
if (c->frame)
{
XSetWindowBackground(X.disp, c->frame, ((c->wm_flags & XUrgencyHint) ? X.clr_urgent : X.clr_bg));
- XSetWindowBorderWidth(X.disp, c->frame, 1);
- XSetWindowBorder(X.disp, c->frame, X.clr_bdr);
- XSetWindowBorderWidth(X.disp, c->win, 1);
- XSetWindowBorder(X.disp, c->win, X.clr_bdr);
+ XSetWindowBorderWidth(X.disp, c->frame, 0);
+ XSetWindowBorderWidth(X.disp, c->win, 0);
XDefineCursor(X.disp, c->frame, X.csr_point);
XClearWindow(X.disp, c->frame);
+
+ /* set border color */
+ XSetForeground(X.disp, DefaultGC(X.disp, X.screen), BlackPixel(X.disp, X.screen));
+ XSetFillStyle(X.disp, DefaultGC(X.disp, X.screen), FillSolid);
+
+ /* draw outer border */
+ XDrawLine(X.disp, c->frame, DefaultGC(X.disp, X.screen), 0, 0, c->w, 0);
+ XDrawLine(X.disp, c->frame, DefaultGC(X.disp, X.screen), 0, c->h-1, c->w, c->h-1);
+ XDrawLine(X.disp, c->frame, DefaultGC(X.disp, X.screen), 0, 0, 0, c->h);
+ XDrawLine(X.disp, c->frame, DefaultGC(X.disp, X.screen), c->w-1, 0, c->w-1, c->h);
+
+ /* draw inner border */
+ int bw = BORDER_WIDTH;
+ int mh = MIN_HEIGHT;
+ XDrawLine(X.disp, c->frame, DefaultGC(X.disp, X.screen),
+ bw-1, mh-1, c->w-bw, mh-1);
+ XDrawLine(X.disp, c->frame, DefaultGC(X.disp, X.screen),
+ bw-1, c->h-bw, c->w-bw, c->h-bw);
+ XDrawLine(X.disp, c->frame, DefaultGC(X.disp, X.screen),
+ bw-1, mh-1, bw-1, c->h-bw);
+ XDrawLine(X.disp, c->frame, DefaultGC(X.disp, X.screen),
+ c->w-bw, mh-1, c->w-bw, c->h-bw);
+
+ /* draw title text */
if (c->name) {
int ascent = abs(X.font_ext->max_logical_extent.y);
Xutf8DrawString(X.disp, c->frame, X.font,
XMoveResizeWindow(X.disp, c->frame, c->x, c->y, c->w, (shaded ? minheight : c->h));
if ( !(c->flags & F_SHADED) )
{
- int child_w = c->w - 2*BORDER_WIDTH - 2;
- int child_h = c->h - 2*BORDER_WIDTH - TITLE_HEIGHT - 2;
+ int child_w = c->w - FRAME_WIDTH_SUM;
+ int child_h = c->h - FRAME_HEIGHT_SUM;
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);
}
}
-static char* pickexec[] = { "pickexec", NULL };
-static char* terminal[] = { "xterm", NULL };
-static char* locker[] = { "slock", 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 Key keys[] = {
{ MODKEY, XK_p, runcmd, { .cmd = pickexec } },
{ 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 } },
m->cspace = m->wspaces;
}
xfree(mons);
+
+ Monitor* m = Monitors;
+ while (m)
+ {
+ printf("x: %d y: %d w: %d h: %d\n", m->x, m->y, m->w, m->h);
+ Workspace* w = m->wspaces;
+ while (w)
+ {
+ printf(" wspace %p\n", (void*)w);
+ Column* c = w->columns;
+ while (c)
+ {
+ printf(" col %p %d\n", (void*)c, c->width);
+ c = c->next;
+ }
+ w = w->next;
+ }
+ m = m->next;
+ }
+
}
void mons_layer(Monitor* mon)
void mons_colsplit(void)
{
Monitor* mon = pickmon();
- Column* col = pickcol(mon->cspace->columns, PtrX);
+ Column* col = pickcol(mon->cspace->columns, PtrX - mon->x);
int next_empty = (col->next && !col->next->clients);
if (col->clients && !next_empty && col->width >= 2*min_col_width(mon))
{
void mons_coljoin(void)
{
Monitor* mon = pickmon();
- Column* dest = pickcol(mon->cspace->columns, PtrX);
+ Column* dest = pickcol(mon->cspace->columns, PtrX - mon->x);
Column* dead = dest->next;
if (!dead)
{
void mons_tilemove(Location* loc, int hdiff)
{
Monitor* mon = pickmon();
- Column* col = pickcol(mon->cspace->columns, PtrX);
+ Column* col = pickcol(mon->cspace->columns, PtrX - mon->x);
if (loc->monitor != mon || loc->column != col)
{
remove_client(loc, loc->client);
{
Column* col;
int left = 0, right = 0;
+ printf("cols %p\n", cols);
LIST_FOR_EACH(col, cols)
{
+ printf("curr = %p\n", col);
left = right, right += col->width;
+ printf("%d <= %d < %d\n", left, relx, right);
if (left <= relx && relx < right)
{
break; /* we found the column holding the mouse */
}
}
+ printf("%p\n", (void*)col);
+// if (!col) col = cols;
return col;
}
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->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);
CHECK(loc->column->focused == &next);
CHECK(next.x == 0);
CHECK(next.y == 0);
- CHECK(next.w == 48);
- CHECK(next.h == 98);
+ CHECK(next.w == 50);
+ CHECK(next.h == 100);
}
UNITTEST(monocled_del_should_del_client_and_leave_column_empty)
static void coldims(Monitor *mon, Column *col, int *x, int *y, int *w, int *h)
{
Column* c;
- *x = mon->x, *y = mon->y, *w = col->width-2, *h = mon->h-2;
+ *x = mon->x, *y = mon->y, *w = col->width, *h = mon->h;
LIST_FOR_EACH_UNTIL(c, mon->cspace->columns, (c == col))
{
*x += c->width;