enum { BarTop, BarBot, BarOff }; /* bar position */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
-enum { NetSupported, NetWMCheck, NetWMName, NetLast }; /* EWMH atoms */
+enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
/* typedefs */
struct Client {
char name[256];
int x, y, w, h;
- int rx, ry, rw, rh; /* revert geometry */
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int minax, maxax, minay, maxay;
long flags;
unsigned int border, oldborder;
- Bool isbanned, isfixed, ismax, isfloating, wasfloating;
+ Bool isbanned, isfixed, isfloating;
Bool *tags;
Client *next;
Client *prev;
void expose(XEvent *e);
void floating(void); /* default floating layout */
void focus(Client *c);
+void focusin(XEvent *e);
void focusnext(const char *arg);
void focusprev(const char *arg);
Client *getclient(Window w);
void manage(Window w, XWindowAttributes *wa);
void mappingnotify(XEvent *e);
void maprequest(XEvent *e);
+void maximize(const char *arg);
void movemouse(Client *c);
Client *nexttiled(Client *c);
void propertynotify(XEvent *e);
void quit(const char *arg);
+void reapply(const char *arg);
void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
void resizemouse(Client *c);
void restack(void);
void tile(void);
void togglebar(const char *arg);
void togglefloating(const char *arg);
-void togglemax(const char *arg);
void toggletag(const char *arg);
void toggleview(const char *arg);
void unban(Client *c);
[ConfigureNotify] = configurenotify,
[DestroyNotify] = destroynotify,
[EnterNotify] = enternotify,
- [LeaveNotify] = leavenotify,
[Expose] = expose,
+ [FocusIn] = focusin,
[KeyPress] = keypress,
+ [LeaveNotify] = leavenotify,
[MappingNotify] = mappingnotify,
[MapRequest] = maprequest,
[PropertyNotify] = propertynotify,
XWindowChanges wc;
if((c = getclient(ev->window))) {
- c->ismax = False;
if(ev->value_mask & CWBorderWidth)
c->border = ev->border_width;
if(c->isfixed || c->isfloating || (floating == layout->arrange)) {
dc.x = x;
if(sel) {
drawtext(sel->name, dc.sel);
- drawsquare(sel->ismax, sel->isfloating, dc.sel);
+ drawsquare(False, sel->isfloating, dc.sel);
}
else
drawtext(NULL, dc.norm);
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
}
+void
+focusin(XEvent *e) { /* there are some broken focus acquiring clients */
+ XFocusChangeEvent *ev = &e->xfocus;
+
+ if(sel && ev->window != sel->win)
+ XSetInputFocus(dpy, sel->win, RevertToPointerRoot, CurrentTime);
+}
+
void
focusnext(const char *arg) {
Client *c;
XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
configure(c); /* propagates border_width, if size doesn't change */
updatesizehints(c);
- XSelectInput(dpy, w,
- StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
+ XSelectInput(dpy, w, EnterWindowMask | FocusChangeMask | PropertyChangeMask | StructureNotifyMask);
grabbuttons(c, False);
updatetitle(c);
if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
manage(ev->window, &wa);
}
+void
+maximize(const char *arg) {
+ if(!sel || (!sel->isfloating && layout->arrange != floating))
+ return;
+ resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True);
+}
+
void
movemouse(Client *c) {
int x1, y1, ocx, ocy, di, nx, ny;
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurMove], CurrentTime) != GrabSuccess)
return;
- c->ismax = False;
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
for(;;) {
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
readin = running = False;
}
+void
+reapply(const char *arg) {
+ static Bool zerotags[LENGTH(tags)] = { 0 };
+ Client *c;
+
+ for(c = clients; c; c = c->next) {
+ memcpy(c->tags, zerotags, sizeof zerotags);
+ applyrules(c);
+ }
+ arrange();
+}
void
resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurResize], CurrentTime) != GrabSuccess)
return;
- c->ismax = False;
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
for(;;) {
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev);
setup(void) {
int d;
unsigned int i, j, mask;
- Atom utf8string;
Window w;
XModifierKeymap *modmap;
XSetWindowAttributes wa;
/* init atoms */
- utf8string = XInternAtom(dpy, "UTF8_STRING", False);
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
wmatom[WMName] = XInternAtom(dpy, "WM_NAME", False);
wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
- netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False);
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
+ XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
+ PropModeReplace, (unsigned char *) netatom, NetLast);
/* init cursors */
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
/* multihead support */
selscreen = XQueryPointer(dpy, root, &w, &w, &d, &d, &d, &d, &mask);
- /* EWMH properties */
- XChangeProperty(dpy, barwin, netatom[NetWMCheck], XA_WINDOW, 32,
- PropModeReplace, (unsigned char *) &barwin, 1);
- /* HACK: dwm identifies itself as LookingGlass to workaround the XToolkit bug of Sun JDK */
- XChangeProperty(dpy, barwin, netatom[NetWMName], utf8string, 8,
- PropModeReplace, (unsigned char *) "LG3D", 4);
- XChangeProperty(dpy, root, netatom[NetWMCheck], XA_WINDOW, 32,
- PropModeReplace, (unsigned char *) &barwin, 1);
- XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
- PropModeReplace, (unsigned char *) netatom, NetLast);
}
void
ny = way;
nw = 0; /* gcc stupidity requires this */
for(i = 0, c = mc = nexttiled(clients); c; c = nexttiled(c->next), i++) {
- c->ismax = False;
if(i == 0) { /* master */
nw = mw - 2 * c->border;
nh = wah - 2 * c->border;
arrange();
}
-void
-togglemax(const char *arg) {
- XEvent ev;
-
- if(!sel || sel->isfixed)
- return;
- if((sel->ismax = !sel->ismax)) {
- if((layout->arrange == floating) || sel->isfloating)
- sel->wasfloating = True;
- else {
- togglefloating(NULL);
- sel->wasfloating = False;
- }
- sel->rx = sel->x;
- sel->ry = sel->y;
- sel->rw = sel->w;
- sel->rh = sel->h;
- resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True);
- }
- else {
- resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
- if(!sel->wasfloating)
- togglefloating(NULL);
- }
- drawbar();
- while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
-}
-
void
toggletag(const char *arg) {
unsigned int i, j;