client_reconfig(x, c);
}
+void client_grow(XConf* x, Client* c) {
+ Client* curr;
+ int nclients = 0, nexty = 0;
+ int sh = HeightOfScreen(DefaultScreenOfDisplay(x->display));
+ for (curr = Clients; curr; curr = curr->next, nclients++);
+ for (curr = Clients; curr; curr = curr->next) {
+ nclients--;
+ curr->y = nexty;
+ if (curr == c)
+ curr->h = sh - nexty - (nclients * BARHEIGHT(x));
+ else
+ curr->h = BARHEIGHT(x);
+ client_reconfig(x, curr);
+ nexty += curr->h;
+ }
+}
+
+void client_maximize(XConf* xs, Client* c) {
+ int y = c->y, h = c->h;
+ c->y = 0, c->h = HeightOfScreen(DefaultScreenOfDisplay(xs->display));
+ client_reconfig(xs, c);
+ client_raise(xs, c);
+ c->y = y, c->h = h;
+}
+
/* X11 Event Handling
*****************************************************************************/
/*
** B1 Grow window a little
** B1 Drag: Resize vertically or move to column
- * B2: Stack windows with titlebars visible but only one window expanded
- * B3: Maximize in column
+ ** B2: Stack windows with titlebars visible but only one window expanded
+ ** B3: Maximize in column
* B1+B2: Kill window
* Shift+B1: Move one column to the left
- * Shift+B1: Move one column to the right
+ * Shift+B2: Move one column to the right
*/
static void xbtnpress(XConf* x, XEvent* e) {
XDefineCursor(X.display, e->xbutton.window, Move_Cursor);
StartY = e->xbutton.y;
} else if (Button2 == e->xbutton.button) {
- if (e->xbutton.state & (1 << (Button1 + 7))) {
- puts("kill");
- } else {
- puts("grow");
-// client_grow(x, c);
- }
+ if (e->xbutton.state & (1 << (Button1 + 7)))
+ XDestroyWindow(x->display, e->xbutton.window);
+ else
+ client_grow(x, c);
} else if (Button3 == e->xbutton.button) {
- puts("maximize");
+ client_maximize(x, c);
}
XSync(X.display, False);