#include <stdlib.h>
#include <string.h>
#include <X11/Xatom.h>
+#include <X11/Xutil.h>
-#include "util.h"
-#include "wm.h"
+#include "dwm.h"
-void (*arrange)(void *aux);
+static void (*arrange)(void *) = floating;
void
max(void *aux)
if(!stack)
return;
stack->x = sx;
- stack->y = bh;
+ stack->y = sy;
stack->w = sw - 2 * stack->border;
- stack->h = sh - bh - 2 * stack->border;
+ stack->h = sh - 2 * stack->border;
+ craise(stack);
resize(stack);
discard_events(EnterWindowMask);
}
}
void
-grid(void *aux)
+tiling(void *aux)
{
Client *c;
int n, cols, rows, gw, gh, i, j;
float rt, fd;
- arrange = grid;
+ arrange = tiling;
if(!clients)
return;
for(n = 0, c = clients; c; c = c->next, n++);
cols = rows;
gw = (sw - 2) / cols;
- gh = (sh - bh - 2) / rows;
+ gh = (sh - 2) / rows;
for(i = j = 0, c = clients; c; c = c->next) {
c->x = i * gw;
- c->y = j * gh + bh;
+ c->y = j * gh;
c->w = gw;
c->h = gh;
resize(c);
for(c = stack; c && c->snext; c = c->snext);
if(!c)
c = stack;
- raise(c);
+ craise(c);
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
focus(c);
}
void
-kill(void *aux)
+ckill(void *aux)
{
Client *c = stack;
c->tw = 0;
for(i = 0; i < TLast; i++)
if(c->tags[i])
- c->tw += textw(&brush.font, c->tags[i]) + bh;
- c->tw += textw(&brush.font, c->name) + bh;
+ c->tw += textw(c->tags[i]) + dc.font.height;
+ c->tw += textw(c->name) + dc.font.height;
if(c->tw > c->w)
c->tw = c->w + 2;
c->tx = c->x + c->w - c->tw + 2;
}
void
-raise(Client *c)
+craise(Client *c)
{
XRaiseWindow(dpy, c->win);
XRaiseWindow(dpy, c->title);
c->snext = stack;
stack = c;
if(old && old != c) {
+ XSetWindowBorder(dpy, old->win, dc.bg);
XMapWindow(dpy, old->title);
draw_client(old);
}
XUnmapWindow(dpy, c->title);
+ XSetWindowBorder(dpy, c->win, dc.fg);
draw_client(c);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
XFlush(dpy);
+ discard_events(EnterWindowMask);
}
void
c->win = w;
c->tx = c->x = wa->x;
c->ty = c->y = wa->y;
- if(c->y < bh)
- c->ty = c->y += bh;
c->tw = c->w = wa->width;
c->h = wa->height;
- c->th = bh;
+ c->th = th;
c->border = 1;
update_size(c);
- XSetWindowBorderWidth(dpy, c->win, 1);
- XSetWindowBorder(dpy, c->win, brush.border);
XSelectInput(dpy, c->win,
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
XGetTransientForHint(dpy, c->win, &c->trans);
for(l=&clients; *l; l=&(*l)->next);
c->next = *l; /* *l == nil */
*l = c;
+ XSetWindowBorderWidth(dpy, c->win, 1);
XMapRaised(dpy, c->win);
XMapRaised(dpy, c->title);
XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
GrabModeAsync, GrabModeSync, None, None);
arrange(NULL);
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
focus(c);
}
}
static int
-dummy_error_handler(Display *dpy, XErrorEvent *error)
+dummy_error_handler(Display *dsply, XErrorEvent *err)
{
return 0;
}
XDestroyWindow(dpy, c->title);
for(l=&clients; *l && *l != c; l=&(*l)->next);
- eassert(*l == c);
*l = c->next;
for(l=&stack; *l && *l != c; l=&(*l)->snext);
- eassert(*l == c);
*l = c->snext;
free(c);
draw_client(Client *c)
{
int i;
- if(c == stack) {
- draw_bar();
+ if(c == stack)
return;
- }
- brush.x = brush.y = 0;
- brush.h = c->th;
+ dc.x = dc.y = 0;
+ dc.h = c->th;
- brush.w = 0;
+ dc.w = 0;
for(i = 0; i < TLast; i++) {
if(c->tags[i]) {
- brush.x += brush.w;
- brush.w = textw(&brush.font, c->tags[i]) + bh;
- draw(dpy, &brush, True, c->tags[i]);
+ dc.x += dc.w;
+ dc.w = textw(c->tags[i]) + dc.font.height;
+ draw(True, c->tags[i]);
}
}
- brush.x += brush.w;
- brush.w = textw(&brush.font, c->name) + bh;
- draw(dpy, &brush, True, c->name);
- XCopyArea(dpy, brush.drawable, c->title, brush.gc,
+ dc.x += dc.w;
+ dc.w = textw(c->name) + dc.font.height;
+ draw(True, c->name);
+ XCopyArea(dpy, dc.drawable, c->title, dc.gc,
0, 0, c->tw, c->th, 0, 0);
XFlush(dpy);
}