* Windows can tile in a column or float on workspaces
* Columns can have different layouts: manual, stacked, monocle
- TODO: window border is wrong width on right and bottom for some reason...
TODO: warp mouse pointer to title bars on new windows
- TODO: account for frame size in client x,y,w,h fields
TODO: implement mouse handling for tiling methods
+Mouse Actions:
+ Floating:
+ Btn Click 1:
+ Btn Drag 1: Move Window
+ Btn Click 2: Close Window
+ Btn Click 3:
+ Btn Click 4: Lower Window
+ Btn Click 5: Raise Window
+
+ Monocled:
+ Btn Click 1:
+ Btn Drag 1:
+ Btn Click 2: Close Window
+ Btn Click 3: Lower Window
+ Btn Click 4:
+ Btn Click 5:
+
+ Stacked:
+ Btn Click 1:
+ Btn Drag 1:
+ Btn Click 2: Close Window
+ Btn Click 3:
+ Btn Click 4:
+ Btn Click 5:
+
+ Expanded:
+ Btn Click 1:
+ Btn Drag 1:
+ Btn Click 2: Close Window
+ Btn Click 3:
+ Btn Click 4:
+ Btn Click 5:
+
*/
enum {
void mons_layer(Monitor* mon)
{
- /* lower all of the floating windows first */
- for (Client* client = mon->cspace->floating; client; client = client->next)
+ int nwins = 0;
+ Window* wins = NULL;
+ for (Client* c = mon->cspace->floating; c; c = c->next)
{
- XLowerWindow(X.disp, client->win);
- XLowerWindow(X.disp, client->frame);
+ wins = realloc(wins, ++nwins);
+ wins[nwins-1] = c->frame;
}
/* now lower all of the tiled windows */
for (Column* col = mon->cspace->columns; col; col = col->next)
{
- for (Client* client = col->clients; client; client = client->next)
+ for (Client* c = col->clients; c; c = c->next)
{
- XLowerWindow(X.disp, client->win);
- XLowerWindow(X.disp, client->frame);
+ wins = realloc(wins, ++nwins);
+ wins[nwins-1] = c->frame;
}
}
+ if (nwins)
+ {
+ XRestackWindows(X.disp, wins, nwins);
+ XSync(X.disp, False);
+ }
}
/* adds a new client to the most appropriate monitor */
static void float_click(XButtonEvent* ev, Location* loc)
{
- if (ev->button == Button1)
+ if (ev->button == Button2)
+ {
+ client_close(loc->client);
+ }
+ else if (ev->button == Button4)
+ {
+ mons_lower(loc->monitor, loc->client);
+ }
+ else if (ev->button == Button5)
{
mons_raise(loc->monitor, loc->client);
if (ev->y > (TITLE_HEIGHT + BORDER_WIDTH))
warp_mouse(loc->client);
}
}
- else if (ev->button == Button2)
- {
- client_close(loc->client);
- }
- else if (ev->button == Button3)
- {
- mons_lower(loc->monitor, loc->client);
- }
}
-static void monocle_click(XButtonEvent* ev, Location* loc)
+static void monocled_click(XButtonEvent* ev, Location* loc)
{
if (ev->button == Button2)
{
mons_layer(loc->monitor);
}
+static void stacked_click(XButtonEvent* ev, Location* loc)
+{
+ if (ev->button == Button2)
+ {
+ client_close(loc->client);
+ }
+}
+
+static void expanded_click(XButtonEvent* ev, Location* loc)
+{
+ if (ev->button == Button2)
+ {
+ client_close(loc->client);
+ }
+}
+
void mouse_click(XButtonEvent* ev, Location* loc)
{
if (!loc->column)
}
else if (loc->column->mode == TILE_MONOCLE)
{
- monocle_click(ev, loc);
+ monocled_click(ev, loc);
}
else if (loc->column->mode == TILE_STACKED)
{
- puts("tiled (S) mouse click");
+ stacked_click(ev, loc);
}
else if (loc->column->mode == TILE_EXPAND)
{
- puts("tiled (E) mouse click");
+ expanded_click(ev, loc);
}
}
}
}
+static void monocled_drag(XMotionEvent* ev, Location* loc)
+{
+ (void)ev, (void)loc;
+}
+
+static void stacked_drag(XMotionEvent* ev, Location* loc)
+{
+ (void)ev, (void)loc;
+}
+
+static void expanded_drag(XMotionEvent* ev, Location* loc)
+{
+ (void)ev, (void)loc;
+}
+
void mouse_drag(XMotionEvent* ev, Location* loc)
{
if (!loc->column)
{
float_drag(ev, loc);
}
- else
+ else if (loc->column->mode == TILE_MONOCLE)
+ {
+ monocled_drag(ev, loc);
+ }
+ else if (loc->column->mode == TILE_STACKED)
+ {
+ stacked_drag(ev, loc);
+ }
+ else if (loc->column->mode == TILE_EXPAND)
{
- puts("tiled mouse drag");
+ expanded_drag(ev, loc);
}
}