X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=8b67cea49b2c3cc582b9b3ae2ad83135ee5fa237;hp=d39f11fbdc7077a04881db7a4298037945100da3;hb=c0ba635c50dc53f06e4fc96392415b3d19b25826;hpb=51336aa4a38e82cc796edce790a989298e817a5a diff --git a/dwm.c b/dwm.c index d39f11f..8b67cea 100644 --- a/dwm.c +++ b/dwm.c @@ -40,6 +40,8 @@ #include #endif /* XINERAMA */ +#include "draw.h" + /* macros */ #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) @@ -60,7 +62,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ enum { NetSupported, NetWMName, NetWMState, NetWMFullscreen, NetActiveWindow, NetWMWindowType, - NetWMWindowTypeDialog, NetLast }; /* EWMH atoms */ + NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ @@ -238,6 +240,7 @@ static void unmapnotify(XEvent *e); static Bool updategeom(void); static void updatebarpos(Monitor *m); static void updatebars(void); +static void updateclientlist(void); static void updatenumlockmask(void); static void updatesizehints(Client *c); static void updatestatus(void); @@ -499,6 +502,7 @@ cleanup(void) { cleanupmon(mons); XSync(dpy, False); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); + XDeleteProperty(dpy, root, netatom[NetActiveWindow]); } void @@ -573,8 +577,9 @@ configurenotify(XEvent *e) { XConfigureEvent *ev = &e->xconfigure; Bool dirty; + // TODO: updategeom handling sucks, needs to be simplified if(ev->window == root) { - dirty = (sw != ev->width); + dirty = (sw != ev->width || sh != ev->height); sw = ev->width; sh = ev->height; if(updategeom() || dirty) { @@ -858,8 +863,10 @@ focus(Client *c) { XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]); setfocus(c); } - else + else { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); + XDeleteProperty(dpy, root, netatom[NetActiveWindow]); + } selmon->sel = c; drawbars(); } @@ -880,7 +887,8 @@ focusmon(const Arg *arg) { return; if((m = dirtomon(arg->i)) == selmon) return; - unfocus(selmon->sel, True); + unfocus(selmon->sel, False); /* s/True/False/ fixes input focus issues + in gedit and anjuta */ selmon = m; focus(NULL); } @@ -1157,6 +1165,8 @@ manage(Window w, XWindowAttributes *wa) { XRaiseWindow(dpy, c->win); attach(c); attachstack(c); + XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, + (unsigned char *) &(c->win), 1); XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */ setclientstate(c, NormalState); if (c->mon == selmon) @@ -1212,6 +1222,7 @@ motionnotify(XEvent *e) { if(ev->window != root) return; if((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { + unfocus(selmon->sel, True); selmon = m; focus(NULL); } @@ -1227,6 +1238,8 @@ movemouse(const Arg *arg) { if(!(c = selmon->sel)) return; + if(c->isfullscreen) /* no support moving fullscreen windows by mouse */ + return; restack(selmon); ocx = c->x; ocy = c->y; @@ -1371,6 +1384,8 @@ resizemouse(const Arg *arg) { if(!(c = selmon->sel)) return; + if(c->isfullscreen) /* no support resizing fullscreen windows by mouse */ + return; restack(selmon); ocx = c->x; ocy = c->y; @@ -1520,8 +1535,12 @@ sendevent(Client *c, Atom proto) { void setfocus(Client *c) { - if(!c->neverfocus) + if(!c->neverfocus) { XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); + XChangeProperty(dpy, root, netatom[NetActiveWindow], + XA_WINDOW, 32, PropModeReplace, + (unsigned char *) &(c->win), 1); + } sendevent(c, wmatom[WMTakeFocus]); } @@ -1607,6 +1626,7 @@ setup(void) { netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); + netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); /* init cursors */ cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); @@ -1629,6 +1649,7 @@ setup(void) { /* EWMH support per view */ XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, PropModeReplace, (unsigned char *) netatom, NetLast); + XDeleteProperty(dpy, root, netatom[NetClientList]); /* select for events */ wa.cursor = cursor[CurNormal]; wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask @@ -1739,6 +1760,8 @@ void togglefloating(const Arg *arg) { if(!selmon->sel) return; + if(selmon->sel->isfullscreen) /* no support for fullscreen windows */ + return; selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; if(selmon->sel->isfloating) resize(selmon->sel, selmon->sel->x, selmon->sel->y, @@ -1777,8 +1800,10 @@ unfocus(Client *c, Bool setfocus) { return; grabbuttons(c, False); XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]); - if(setfocus) + if(setfocus) { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); + XDeleteProperty(dpy, root, netatom[NetActiveWindow]); + } } void @@ -1802,6 +1827,7 @@ unmanage(Client *c, Bool destroyed) { } free(c); focus(NULL); + updateclientlist(); arrange(m); } @@ -1850,6 +1876,19 @@ updatebarpos(Monitor *m) { m->by = -bh; } +void +updateclientlist() { + Client *c; + Monitor *m; + + XDeleteProperty(dpy, root, netatom[NetClientList]); + for(m = mons; m; m = m->next) + for(c = m->clients; c; c = c->next) + XChangeProperty(dpy, root, netatom[NetClientList], + XA_WINDOW, 32, PropModeAppend, + (unsigned char *) &(c->win), 1); +} + Bool updategeom(void) { Bool dirty = False; @@ -2019,7 +2058,6 @@ updatewindowtype(Client *c) { if(state == netatom[NetWMFullscreen]) setfullscreen(c, True); - if(wtype == netatom[NetWMWindowTypeDialog]) c->isfloating = True; }