/* tile.c */
void monocled_add(Monitor* mon, Column* col, Client* c);
void monocled_del(Monitor* mon, Column* col, Client* c);
+void monocled_set(Monitor* mon, Column* col, Client* c);
void stacked_add(Monitor* mon, Column* col, Client* c);
void stacked_del(Monitor* mon, Column* col, Client* c);
+void stacked_set(Monitor* mon, Column* col, Client* c);
/* error.c */
extern int (*error_default)(Display* disp, XErrorEvent* ev);
static char* terminal[] = { "xterm", NULL };
static char* locker[] = { "slock", NULL };
+/* TODO: Add shortcuts to add/del columns and resize them */
+/* TODO: Add shortcuts to transfer windows between monitors */
+/* TODO: Add shortcuts to toggle between tiled and floating */
static Key keys[] = {
{ MODKEY|ShiftMask, XK_q, quit, { 0 } },
{ MODKEY, XK_p, runcmd, { .cmd = pickexec } },
wins = realloc(wins, ++nwins * sizeof(Window));
wins[nwins-1] = c->frame;
}
+ /* add in the monocled windows first */
+ for (Column* col = mon->cspace->columns; col; col = col->next)
+ {
+ if (col->focused)
+ {
+ wins = realloc(wins, ++nwins * sizeof(Window));
+ wins[nwins-1] = col->focused->frame;
+ }
+ }
/* now lower all of the tiled windows */
for (Column* col = mon->cspace->columns; col; col = col->next)
{
for (Client* c = col->clients; c; c = c->next)
{
- wins = realloc(wins, ++nwins * sizeof(Window));
- wins[nwins-1] = c->frame;
+ if (col->focused != c)
+ {
+ wins = realloc(wins, ++nwins * sizeof(Window));
+ wins[nwins-1] = c->frame;
+ }
}
}
if (nwins)
XRestackWindows(X.disp, wins, nwins);
XSync(X.disp, False);
}
+ xfree(wins);
}
/* adds a new client to the most appropriate monitor */
#include "anvil.h"
+/* 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 */
+
static inline int PRESSED(int mods, int btn)
{
return ((mods & (1 << (btn + 7))) == (1 << (btn + 7)));
{
if (ev->button == Button1)
{
- puts("switch to expanded");
+ stacked_set(loc->monitor, loc->column, loc->client);
}
else if (ev->button == Button2)
{
for (tail = loc->column->clients; tail && tail->next; tail = tail->next);
client->next = NULL;
tail->next = client;
+ monocled_set(loc->monitor, loc->column, loc->column->clients);
}
}
mons_layer(loc->monitor);
static void stacked_click(XButtonEvent* ev, Location* loc)
{
+ /* TODO: handle button 1 drag to resize, reposition, and move windows */
if (ev->button == Button2)
{
client_close(loc->client);
}
+ else if (ev->button == Button3)
+ {
+ monocled_set(loc->monitor, loc->column, loc->client);
+ }
}
void mouse_click(XButtonEvent* ev, Location* loc)
void monocled_del(Monitor* mon, Column* col, Client* c)
{
- (void)mon;
col->clients = delclient(col->clients, c);
+ col->focused = col->clients;
+ c = col->clients;
+ if (c)
+ {
+ coldims(mon, col, &(c->x), &(c->y), &(c->w), &(c->h));
+ client_adjust(c);
+ }
+}
+
+void monocled_set(Monitor* mon, Column* col, Client* c)
+{
+ col->clients = delclient(col->clients, c);
+ c->next = col->clients;
+ col->clients = c;
+ col->focused = c;
+ coldims(mon, col, &(c->x), &(c->y), &(c->w), &(c->h));
+ client_adjust(c);
+ mons_layer(mon);
}
void stacked_add(Monitor* mon, Column* col, Client* c)
max->h -= max->h/2;
c->next = max->next;
max->next = c;
- client_adjust(max);
client_adjust(c);
+ client_adjust(max);
}
else
{
}
}
+void stacked_set(Monitor* mon, Column* col, Client* c)
+{
+ (void)mon, (void)col, (void)c;
+ puts("switching to stacked mode");
+ /* TODO: implement switch back to stacked mode */
+}
+
+
+