X.last_x = ev->x_root, X.last_y = ev->y_root;
}
+static void xconfignotify(XEvent* e)
+{
+ XConfigureEvent* ev = &(e->xconfigure);
+ if (ev->window == X.root)
+ {
+ puts("root window resized");
+ }
+}
+
static void xconfigrequest(XEvent* e)
{
XConfigureRequestEvent* ev = &(e->xconfigurerequest);
- //printf("CONF(w: 0x%lx x: %d y: %d w: %d h: %d)\n", ev->window, ev->x, ev->y, ev->width, ev->height);
+ printf("CONF(w: 0x%lx x: %d y: %d w: %d h: %d)\n", ev->window, ev->x, ev->y, ev->width, ev->height);
XWindowChanges wc;
wc.x = ev->x;
wc.y = ev->y;
X.eventfns[ButtonRelease] = xbtnrelease;
X.eventfns[MotionNotify] = xbtnmotion;
X.eventfns[KeyPress] = xkeypress;
+ X.eventfns[ConfigureNotify] = xconfignotify;
X.eventfns[ConfigureRequest] = xconfigrequest;
X.eventfns[MapRequest] = xmaprequest;
X.eventfns[UnmapNotify] = xunmapnotify;
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
-/* TODO: warp mouse pointer to title bars on new windows */
/* TODO: Add shortcuts to transfer windows between monitors */
-/* 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 */
/* TODO: add floating addclient function */
enum {
void monocled_add(Location* loc);
void monocled_del(Location* loc);
void monocled_raise(Location* loc);
-void monocled_set(Location* loc);
void stacked_add(Location* loc);
void stacked_del(Location* loc);
void stacked_set(Location* loc);
Atom atom(char* str);
void sendmsg(Window win, Atom proto, Atom type);
-#endif
\ No newline at end of file
+#endif
int minheight = (shaded || !floating ? MIN_HEIGHT : 3*MIN_HEIGHT);
if (c->w < minheight) c->w = minheight;
if (c->h < minheight) c->h = minheight;
+printf("XMoveResize(0x%lx, %d, %d, %d, %d)\n", c->frame, c->x, c->y, c->w, c->h);
XMoveResizeWindow(X.disp, c->frame, c->x, c->y, c->w, (shaded ? minheight : c->h));
if ( !(c->flags & F_SHADED) )
{
int child_h = c->h - 2*BORDER_WIDTH - TITLE_HEIGHT - 2;
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);
XResizeWindow(X.disp, c->win, child_w, child_h);
}
mons_place(c);
else
{
/* find first empty column, and fill that first */
- Column* col = list_last(mon->cspace->columns);
+ Column* col = NULL;
+ LIST_FOR_EACH_UNTIL(col, mon->cspace->columns, col->clients == NULL);
if (!col)
{
- /* otherwise pick the column to the right or current column */
+ /* otherwise pick the column to the right or the current column */
col = pickcol(mon->cspace->columns, ptrx - mon->x);
if (col->next)
{
tail = list_last(loc->column->clients);
client->next = NULL;
tail->next = client;
- monocled_set(loc);
+ monocled_raise(loc);
}
}
static void monocle_client(Location* loc)
{
- monocled_set(loc);
+ monocled_raise(loc);
}
MouseAct Floating[] = {
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.apple.xcode.dsym.runner</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>dSYM</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ </dict>
+</plist>
(void)c;
}
-/**** Stub Functions ****/
+/**** Test Setup Functions ****/
-Monitor TestMon = {
- .x = 0, .y = 0,
- .w = 100, .h = 100,
- .midx = 50, .midy = 50
-};
-
-Location TestLoc = {
- .monitor = &TestMon,
- .workspace = &(Workspace){
- .columns = &(Column){
- .width = 50,
- .next = &(Column){
- .width = 50
- }
- }
- },
-
-};
+Location* setup(void)
+{
+ Location* loc = calloc(1, sizeof(Location));
+ Monitor* mon = calloc(1, sizeof(Monitor));
+ mon->w = 100, mon->h = 100;
+ mon->midx = 50, mon->midy = 50;
+ Column* col1 = calloc(1, sizeof(Column));
+ col1->width = 50;
+ Column* col2 = calloc(1, sizeof(Column));
+ col2->width = 50;
+ col1->next = col2;
+ Workspace* wspace = calloc(1, sizeof(Workspace));
+ wspace->columns = col1;
+ mon->wspaces = wspace;
+ mon->cspace = wspace;
+ loc->monitor = mon;
+ loc->workspace = wspace;
+ loc->column = col1;
+ loc->client = calloc(1, sizeof(Client));
+ return loc;
+}
-/**** Stub Functions ****/
-UNITTEST(Foo)
+/**** Unit Tests - Monocled Mode ****/
+UNITTEST(monocled_add_should_add_client)
{
- CHECK(1==9);
-}
\ No newline at end of file
+ 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 == 48); /* TODO: account for window border in client size */
+ CHECK(loc->client->h == 98);
+ 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 == 48);
+ CHECK(next.h == 98);
+}
+
+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 ****/
+
+/**** Unit Tests - Floating Mode ****/
+
{
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;
c = loc->column->clients;
if (c)
{
- coldims(loc->monitor, loc->column,
- &(loc->client->x), &(loc->client->y), &(loc->client->w), &(loc->client->h));
- client_adjust(loc->client);
+ coldims(loc->monitor, loc->column, &(c->x), &(c->y), &(c->w), &(c->h));
+ client_setshade(c, 0);
+ client_adjust(c);
}
}
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)
{
c->h = max->h/2;
c->y = max->y + c->h;
+ c->w = max->w;
max->h -= max->h/2;
c->next = max->next;
max->next = c;
c->y = max(miny, min(maxy, c->y + amount));
prev->h = c->y - prev->y;
c->h = (c->next ? c->next->y : loc->monitor->y + loc->monitor->h) - c->y;
- printf("ADD_HEIGHT(w: %lx x: %d y: %d w: %d h: %d)\n", c->frame, c->x, c->y, c->w, c->h);
client_setshade(prev, (prev->h <= MIN_HEIGHT));
client_setshade(c, (c->h <= MIN_HEIGHT));
client_adjust(prev);