fix(wm,tray,replace): fix fullscreen focus, systray XEmbed race, and display-scoped cleanup
This commit is contained in:
1 parent
be7e3a3155
commit
8da5c5d1cb
4 files changed
+989
-69
No files matched your search
+244
-66
@@ -60,7 +60,7 @@ enum { SchemeNorm, SchemeSel };
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation,
|
||||
NetSystemTrayOrientationHorz, NetSystemTrayVisual,
|
||||
NetWMFullscreen, NetActiveWindow, NetWorkarea,
|
||||
NetWMFullscreen, NetWMFocused, NetActiveWindow, NetWorkarea,
|
||||
NetWMWindowType, NetWMWindowTypeDialog, NetWMWindowTypeDock,
|
||||
NetWMStrutPartial, NetWMStrut, NetClientList, NetWMPid, NetLast };
|
||||
enum { Manager, Xembed, XembedInfo, XLast };
|
||||
@@ -160,6 +160,7 @@ struct DockWin {
|
||||
};
|
||||
|
||||
/* function declarations */
|
||||
static void addwmstate(Client *c, Atom state);
|
||||
static void applyrules(Client *c);
|
||||
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
||||
static void arrange(Monitor *m);
|
||||
@@ -184,10 +185,12 @@ static void drawbars(void);
|
||||
static void enternotify(XEvent *e);
|
||||
static void expose(XEvent *e);
|
||||
static void focus(Client *c);
|
||||
static void focusarranged(Monitor *m);
|
||||
static void focusin(XEvent *e);
|
||||
static void focusmon(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
static Atom getatomprop(Client *c, Atom prop);
|
||||
static int extracteventtime(const XEvent *e, Time *out);
|
||||
static Time getfocustime(void);
|
||||
static int getrootptr(int *x, int *y);
|
||||
static long getstate(Window w);
|
||||
static unsigned int getsystraywidth(void);
|
||||
@@ -195,6 +198,7 @@ static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||
static void grabbuttons(Client *c, int focused);
|
||||
static void grabkeys(void);
|
||||
static void grid(Monitor *m);
|
||||
static int hasatomprop(Client *c, Atom prop, Atom target);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void keypress(XEvent *e);
|
||||
static void keyrelease(XEvent *e);
|
||||
@@ -213,7 +217,9 @@ static void propertynotify(XEvent *e);
|
||||
static void quit(const Arg *arg);
|
||||
static Monitor *recttomon(int x, int y, int w, int h);
|
||||
static void reloadxres(const Arg *arg);
|
||||
static unsigned long readatomlist(Client *c, Atom prop, Atom *out, unsigned long max_atoms);
|
||||
static void removesystrayicon(Client *i);
|
||||
static void removewmstate(Client *c, Atom state);
|
||||
static void resize(Client *c, int x, int y, int w, int h, int interact);
|
||||
static void resizebarwin(Monitor *m);
|
||||
static void resizeclient(Client *c, int x, int y, int w, int h);
|
||||
@@ -226,6 +232,7 @@ static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, lon
|
||||
static void sendmon(Client *c, Monitor *m);
|
||||
static void setclientstate(Client *c, long state);
|
||||
static void setfocus(Client *c);
|
||||
static void setnofocus(void);
|
||||
static void setfullscreen(Client *c, int fullscreen);
|
||||
static void setlayout(const Arg *arg);
|
||||
static void setmfact(const Arg *arg);
|
||||
@@ -338,7 +345,8 @@ static Display *dpy;
|
||||
static Drw *drw;
|
||||
static Fnt *dwmfont = NULL;
|
||||
static Monitor *mons, *selmon;
|
||||
static Window root, wmcheckwin;
|
||||
static Window root, wmcheckwin, nofocuswin;
|
||||
static Time last_event_time = CurrentTime;
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -662,10 +670,15 @@ static void cleanup(void) {
|
||||
free(scheme);
|
||||
XSelectInput(dpy, root, 0);
|
||||
XDeleteProperty(dpy, root, netatom[NetWMCheck]);
|
||||
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
if (nofocuswin != None) {
|
||||
XDestroyWindow(dpy, nofocuswin);
|
||||
nofocuswin = None;
|
||||
}
|
||||
XDestroyWindow(dpy, wmcheckwin);
|
||||
wmcheckwin = None;
|
||||
drw_free(drw);
|
||||
XSync(dpy, False);
|
||||
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
|
||||
}
|
||||
|
||||
@@ -691,33 +704,29 @@ static void clientmessage(XEvent *e) {
|
||||
cme->message_type == netatom[NetSystemTrayOP]) {
|
||||
if (cme->data.l[1] == SYSTEM_TRAY_REQUEST_DOCK) {
|
||||
Window iw = (Window)cme->data.l[2];
|
||||
long flags = 0;
|
||||
if (!iw || wintosystrayicon(iw))
|
||||
return;
|
||||
if (!XGetWindowAttributes(dpy, iw, &wa))
|
||||
return;
|
||||
if (!(c = (Client *)calloc(1, sizeof(Client))))
|
||||
die("fatal: could not malloc() %zu bytes\n", sizeof(Client));
|
||||
c->win = iw;
|
||||
c->mon = systraytomon(NULL);
|
||||
c->next = systray->icons;
|
||||
systray->icons = c;
|
||||
if (!XGetWindowAttributes(dpy, c->win, &wa)) {
|
||||
wa.width = bh;
|
||||
wa.height = bh;
|
||||
wa.border_width = 0;
|
||||
wa.depth = DefaultDepth(dpy, screen);
|
||||
}
|
||||
c->x = c->oldx = c->y = c->oldy = 0;
|
||||
c->w = c->oldw = wa.width;
|
||||
c->h = c->oldh = wa.height;
|
||||
c->oldbw = wa.border_width;
|
||||
c->bw = 0;
|
||||
c->isfloating = True;
|
||||
long flags = 0;
|
||||
XAddToSaveSet(dpy, c->win);
|
||||
XReparentWindow(dpy, c->win, systray->win, 0, 0);
|
||||
XSelectInput(dpy, c->win, StructureNotifyMask | SubstructureNotifyMask | PropertyChangeMask | ResizeRedirectMask);
|
||||
c->tags = getxembedflags(c->win, &flags) ? ((flags & XEMBED_MAPPED) ? 1 : 0) : 1;
|
||||
updatesizehints(c);
|
||||
updatesystrayicongeom(c, wa.width, wa.height);
|
||||
XAddToSaveSet(dpy, c->win);
|
||||
XSelectInput(dpy, c->win, StructureNotifyMask | SubstructureNotifyMask | PropertyChangeMask | ResizeRedirectMask);
|
||||
XReparentWindow(dpy, c->win, systray->win, 0, 0);
|
||||
if (!systray->use_argb && wa.depth == DefaultDepth(dpy, screen)) {
|
||||
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
XChangeWindowAttributes(dpy, c->win, CWBackPixel, &swa);
|
||||
@@ -730,6 +739,7 @@ static void clientmessage(XEvent *e) {
|
||||
sendevent(c->win, xatom[Xembed], StructureNotifyMask, CurrentTime,
|
||||
XEMBED_WINDOW_ACTIVATE, 0, (long)systray->win, XEMBED_EMBEDDED_VERSION_VAL);
|
||||
} else {
|
||||
XUnmapWindow(dpy, c->win);
|
||||
setclientstate(c, WithdrawnState);
|
||||
}
|
||||
XSync(dpy, False);
|
||||
@@ -747,8 +757,15 @@ static void clientmessage(XEvent *e) {
|
||||
(cme->data.l[0] == 2 && !c->isfullscreen)));
|
||||
}
|
||||
} else if (cme->message_type == netatom[NetActiveWindow]) {
|
||||
if (c != selmon->sel && !c->isurgent)
|
||||
if (ISVISIBLE(c) && c->mon == selmon) {
|
||||
if (c != selmon->sel)
|
||||
focus(c);
|
||||
else
|
||||
setfocus(c);
|
||||
restack(selmon);
|
||||
} else if (c != selmon->sel && !c->isurgent) {
|
||||
seturgent(c, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -801,9 +818,12 @@ static void configurerequest(XEvent *e) {
|
||||
XWindowChanges wc;
|
||||
|
||||
if ((c = wintoclient(ev->window))) {
|
||||
if (ev->value_mask & CWBorderWidth)
|
||||
if (c->isfullscreen) {
|
||||
if (ISVISIBLE(c))
|
||||
configure(c);
|
||||
} else if (ev->value_mask & CWBorderWidth) {
|
||||
c->bw = ev->border_width;
|
||||
else if (c->isfloating || !selmon->lt[selmon->sellt]->arrange) {
|
||||
} else if (c->isfloating || !selmon->lt[selmon->sellt]->arrange) {
|
||||
m = c->mon;
|
||||
if (ev->value_mask & CWX) { c->oldx = c->x; c->x = m->mx + ev->x; }
|
||||
if (ev->value_mask & CWY) { c->oldy = c->y; c->y = m->my + ev->y; }
|
||||
@@ -1012,19 +1032,51 @@ static void focus(Client *c) {
|
||||
attachstack(c);
|
||||
grabbuttons(c, 1);
|
||||
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
|
||||
addwmstate(c, netatom[NetWMFocused]);
|
||||
setfocus(c);
|
||||
} else {
|
||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
|
||||
Window none = None;
|
||||
setnofocus();
|
||||
XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32,
|
||||
PropModeReplace, (unsigned char *)&none, 1);
|
||||
}
|
||||
selmon->sel = c;
|
||||
drawbars();
|
||||
}
|
||||
|
||||
static void focusarranged(Monitor *m) {
|
||||
Client *c;
|
||||
if (!m) m = selmon;
|
||||
for (c = m->stack; c && !ISVISIBLE(c); c = c->snext) ;
|
||||
if (m->sel && m->sel != c)
|
||||
unfocus(m->sel, (m == selmon && !c) ? 1 : 0);
|
||||
if (m == selmon) {
|
||||
if (m->sel != c)
|
||||
setnofocus();
|
||||
XUngrabKeyboard(dpy, CurrentTime);
|
||||
}
|
||||
m->sel = c;
|
||||
if (c) {
|
||||
detachstack(c);
|
||||
attachstack(c);
|
||||
}
|
||||
arrange(m);
|
||||
if (m == selmon)
|
||||
focus(c);
|
||||
else
|
||||
drawbar(m);
|
||||
}
|
||||
|
||||
static void focusin(XEvent *e) {
|
||||
Client *c;
|
||||
XFocusChangeEvent *ev = &e->xfocus;
|
||||
if (ev->mode == NotifyGrab || ev->mode == NotifyWhileGrabbed)
|
||||
return;
|
||||
if (ev->detail == NotifyPointer || ev->detail == NotifyInferior ||
|
||||
ev->detail == NotifyDetailNone || ev->window == root)
|
||||
return;
|
||||
if (!(c = wintoclient(ev->window)) || !ISVISIBLE(c))
|
||||
return;
|
||||
if (selmon->sel && ev->window != selmon->sel->win)
|
||||
setfocus(selmon->sel);
|
||||
}
|
||||
@@ -1035,6 +1087,8 @@ static void focusmon(const Arg *arg) {
|
||||
if ((m = dirtomon(arg->i)) == selmon) return;
|
||||
Monitor *oldm = selmon;
|
||||
unfocus(selmon->sel, 0);
|
||||
setnofocus();
|
||||
XUngrabKeyboard(dpy, CurrentTime);
|
||||
selmon = m;
|
||||
if (showsystray && !systraypinning) {
|
||||
resizebarwin(oldm);
|
||||
@@ -1060,22 +1114,94 @@ static void focusstack(const Arg *arg) {
|
||||
if (ISVISIBLE(i)) c = i;
|
||||
}
|
||||
if (c) {
|
||||
if (c != selmon->sel)
|
||||
setnofocus();
|
||||
XUngrabKeyboard(dpy, CurrentTime);
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
}
|
||||
}
|
||||
|
||||
static Atom getatomprop(Client *c, Atom prop) {
|
||||
static int extracteventtime(const XEvent *e, Time *out) {
|
||||
switch (e->type) {
|
||||
case KeyPress:
|
||||
case KeyRelease: *out = e->xkey.time; return 1;
|
||||
case ButtonPress:
|
||||
case ButtonRelease: *out = e->xbutton.time; return 1;
|
||||
case MotionNotify: *out = e->xmotion.time; return 1;
|
||||
case EnterNotify:
|
||||
case LeaveNotify: *out = e->xcrossing.time; return 1;
|
||||
case PropertyNotify: *out = e->xproperty.time; return 1;
|
||||
case SelectionClear: *out = e->xselectionclear.time; return 1;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static Time getfocustime(void) {
|
||||
if (wmcheckwin != None) {
|
||||
Time t = getservertime(wmcheckwin);
|
||||
if (t != CurrentTime)
|
||||
last_event_time = t;
|
||||
}
|
||||
return last_event_time;
|
||||
}
|
||||
|
||||
static unsigned long readatomlist(Client *c, Atom prop, Atom *out, unsigned long max_atoms) {
|
||||
int di;
|
||||
unsigned long dl;
|
||||
unsigned long dl, n = 0, copied = 0;
|
||||
unsigned char *p = NULL;
|
||||
Atom da, atom = None;
|
||||
if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
|
||||
&da, &di, &dl, &dl, &p) == Success && p) {
|
||||
atom = *(Atom *)p;
|
||||
Atom da = None;
|
||||
if (XGetWindowProperty(dpy, c->win, prop, 0L, (long)max_atoms, False, XA_ATOM,
|
||||
&da, &di, &n, &dl, &p) == Success && p) {
|
||||
if (di == 32 && da == XA_ATOM) {
|
||||
Atom *atoms = (Atom *)p;
|
||||
copied = MIN(n, max_atoms);
|
||||
for (unsigned long i = 0; i < copied; i++)
|
||||
out[i] = atoms[i];
|
||||
}
|
||||
XFree(p);
|
||||
}
|
||||
return atom;
|
||||
return copied;
|
||||
}
|
||||
|
||||
static int hasatomprop(Client *c, Atom prop, Atom target) {
|
||||
Atom atoms[64];
|
||||
unsigned long n = readatomlist(c, prop, atoms, LENGTH(atoms));
|
||||
for (unsigned long i = 0; i < n; i++)
|
||||
if (atoms[i] == target)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void addwmstate(Client *c, Atom state) {
|
||||
Atom atoms[64];
|
||||
unsigned long n = readatomlist(c, netatom[NetWMState], atoms, LENGTH(atoms) - 1);
|
||||
for (unsigned long i = 0; i < n; i++)
|
||||
if (atoms[i] == state)
|
||||
return;
|
||||
atoms[n++] = state;
|
||||
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char *)atoms, (int)n);
|
||||
}
|
||||
|
||||
static void removewmstate(Client *c, Atom state) {
|
||||
Atom atoms[64], out[64];
|
||||
unsigned long n = readatomlist(c, netatom[NetWMState], atoms, LENGTH(atoms));
|
||||
unsigned long m = 0;
|
||||
int removed = 0;
|
||||
for (unsigned long i = 0; i < n; i++) {
|
||||
if (atoms[i] == state)
|
||||
removed = 1;
|
||||
else
|
||||
out[m++] = atoms[i];
|
||||
}
|
||||
if (!removed)
|
||||
return;
|
||||
if (m > 0)
|
||||
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char *)out, (int)m);
|
||||
else
|
||||
XDeleteProperty(dpy, c->win, netatom[NetWMState]);
|
||||
}
|
||||
|
||||
static int getrootptr(int *x, int *y) {
|
||||
@@ -1158,14 +1284,14 @@ static void grabkeys(void) {
|
||||
|
||||
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||
|
||||
/* Monitor Super_L (Fn+Alt) for comfortable one-shot tap-latch fallback */
|
||||
/* Monitor Super_L (Fn+Alt) for comfortable one-shot tap-latch fallback without freezing pointer */
|
||||
KeyCode super_kc = XKeysymToKeycode(dpy, XK_Super_L);
|
||||
if (super_kc) {
|
||||
for (j = 0; j < LENGTH(modifiers); j++) {
|
||||
XGrabKey(dpy, super_kc, modifiers[j], root, True, GrabModeSync, GrabModeAsync);
|
||||
XGrabKey(dpy, super_kc, Mod5Mask | modifiers[j], root, True, GrabModeSync, GrabModeAsync);
|
||||
XGrabKey(dpy, super_kc, Mod1Mask | modifiers[j], root, True, GrabModeSync, GrabModeAsync);
|
||||
XGrabKey(dpy, super_kc, Mod1Mask | Mod5Mask | modifiers[j], root, True, GrabModeSync, GrabModeAsync);
|
||||
XGrabKey(dpy, super_kc, modifiers[j], root, True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(dpy, super_kc, Mod5Mask | modifiers[j], root, True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(dpy, super_kc, Mod1Mask | modifiers[j], root, True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(dpy, super_kc, Mod1Mask | Mod5Mask | modifiers[j], root, True, GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1249,7 +1375,6 @@ static void keypress(XEvent *e) {
|
||||
super_down = 1;
|
||||
super_dirty = 0;
|
||||
super_down_ms = t;
|
||||
XAllowEvents(dpy, ReplayKeyboard, ev->time);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1288,7 +1413,12 @@ static void keypress(XEvent *e) {
|
||||
matched = 1;
|
||||
}
|
||||
if (matched && keys[i].func) {
|
||||
if (super_down) {
|
||||
super_down = 0;
|
||||
super_dirty = 1;
|
||||
}
|
||||
keys[i].func(&(keys[i].arg));
|
||||
XUngrabKeyboard(dpy, CurrentTime);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1546,10 +1676,21 @@ static void mappingnotify(XEvent *e) {
|
||||
}
|
||||
|
||||
static void mapnotify(XEvent *e) {
|
||||
Client *i;
|
||||
XMapEvent *ev = &e->xmap;
|
||||
if (ev->window == root || (systray && ev->window == systray->win))
|
||||
return;
|
||||
if (!wintoclient(ev->window) && !wintosystrayicon(ev->window) && isdockwin(ev->window)) {
|
||||
if ((i = wintosystrayicon(ev->window))) {
|
||||
long flags = 0;
|
||||
if (!i->tags && (!getxembedflags(i->win, &flags) || (flags & XEMBED_MAPPED))) {
|
||||
i->tags = 1;
|
||||
setclientstate(i, NormalState);
|
||||
updatesystray(1);
|
||||
drawbars();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!wintoclient(ev->window) && isdockwin(ev->window)) {
|
||||
XSelectInput(dpy, ev->window, PropertyChangeMask);
|
||||
dockadd(ev->window);
|
||||
}
|
||||
@@ -1893,7 +2034,10 @@ static void run(void) {
|
||||
grabkeys();
|
||||
}
|
||||
while (XPending(dpy) > 0) {
|
||||
Time evtime = CurrentTime;
|
||||
XNextEvent(dpy, &ev);
|
||||
if (extracteventtime(&ev, &evtime) && evtime != CurrentTime)
|
||||
last_event_time = evtime;
|
||||
if (handler[ev.type])
|
||||
handler[ev.type](&ev);
|
||||
}
|
||||
@@ -1933,7 +2077,9 @@ static void scan(void) {
|
||||
}
|
||||
|
||||
static void sendmon(Client *c, Monitor *m) {
|
||||
Monitor *oldm;
|
||||
if (c->mon == m) return;
|
||||
oldm = c->mon;
|
||||
unfocus(c, 1);
|
||||
detach(c);
|
||||
detachstack(c);
|
||||
@@ -1941,8 +2087,8 @@ static void sendmon(Client *c, Monitor *m) {
|
||||
c->tags = m->tagset[m->seltags];
|
||||
attach(c);
|
||||
attachstack(c);
|
||||
focus(NULL);
|
||||
arrange(NULL);
|
||||
focusarranged(oldm);
|
||||
focusarranged(m);
|
||||
}
|
||||
|
||||
static void setclientstate(Client *c, long state) {
|
||||
@@ -1983,34 +2129,47 @@ static int sendevent(Window w, Atom proto, int mask, long d0, long d1, long d2,
|
||||
}
|
||||
|
||||
static void setfocus(Client *c) {
|
||||
if (!c->neverfocus) {
|
||||
Time ts;
|
||||
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->win, wmatom[WMTakeFocus], NoEventMask, (long)wmatom[WMTakeFocus], CurrentTime, 0, 0, 0);
|
||||
ts = getfocustime();
|
||||
sendevent(c->win, wmatom[WMTakeFocus], NoEventMask,
|
||||
(long)wmatom[WMTakeFocus], (long)ts, 0, 0, 0);
|
||||
XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32,
|
||||
PropModeReplace, (unsigned char *)&(c->win), 1);
|
||||
}
|
||||
|
||||
static void setnofocus(void) {
|
||||
XSetInputFocus(dpy, nofocuswin != None ? nofocuswin : root,
|
||||
RevertToPointerRoot, CurrentTime);
|
||||
}
|
||||
|
||||
static void setfullscreen(Client *c, int fullscreen) {
|
||||
if (fullscreen && !c->isfullscreen) {
|
||||
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char *)&netatom[NetWMFullscreen], 1);
|
||||
addwmstate(c, netatom[NetWMFullscreen]);
|
||||
c->isfullscreen = 1;
|
||||
c->oldstate = c->isfloating;
|
||||
c->oldbw = c->bw;
|
||||
c->bw = 0;
|
||||
c->isfloating = 1;
|
||||
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
|
||||
XRaiseWindow(dpy, c->win);
|
||||
if (ISVISIBLE(c)) {
|
||||
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
|
||||
XRaiseWindow(dpy, c->win);
|
||||
} else {
|
||||
c->oldx = c->x; c->oldy = c->y;
|
||||
c->oldw = c->w; c->oldh = c->h;
|
||||
c->x = c->mon->mx; c->y = c->mon->my;
|
||||
c->w = c->mon->mw; c->h = c->mon->mh;
|
||||
}
|
||||
} else if (!fullscreen && c->isfullscreen) {
|
||||
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char *)0, 0);
|
||||
removewmstate(c, netatom[NetWMFullscreen]);
|
||||
c->isfullscreen = 0;
|
||||
c->isfloating = c->oldstate;
|
||||
c->bw = c->oldbw;
|
||||
c->x = c->oldx; c->y = c->oldy;
|
||||
c->w = c->oldw; c->h = c->oldh;
|
||||
resizeclient(c, c->x, c->y, c->w, c->h);
|
||||
if (ISVISIBLE(c))
|
||||
resizeclient(c, c->x, c->y, c->w, c->h);
|
||||
arrange(c->mon);
|
||||
}
|
||||
}
|
||||
@@ -2087,6 +2246,7 @@ static void setup(void) {
|
||||
netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
|
||||
netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False);
|
||||
netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
|
||||
netatom[NetWMFocused] = XInternAtom(dpy, "_NET_WM_STATE_FOCUSED", False);
|
||||
netatom[NetWorkarea] = XInternAtom(dpy, "_NET_WORKAREA", False);
|
||||
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
|
||||
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
||||
@@ -2112,6 +2272,16 @@ static void setup(void) {
|
||||
updateworkarea();
|
||||
updatestatus();
|
||||
|
||||
{
|
||||
XSetWindowAttributes nwa;
|
||||
nwa.override_redirect = True;
|
||||
nwa.event_mask = NoEventMask;
|
||||
nofocuswin = XCreateWindow(dpy, root, -10, -10, 1, 1, 0,
|
||||
0, InputOnly, CopyFromParent,
|
||||
CWOverrideRedirect | CWEventMask, &nwa);
|
||||
XMapWindow(dpy, nofocuswin);
|
||||
}
|
||||
|
||||
XChangeProperty(dpy, wmcheckwin, netatom[NetWMCheck], XA_WINDOW, 32,
|
||||
PropModeReplace, (unsigned char *)&wmcheckwin, 1);
|
||||
XChangeProperty(dpy, wmcheckwin, netatom[NetWMName], utf8string, 8,
|
||||
@@ -2131,8 +2301,7 @@ static void setup(void) {
|
||||
wa.cursor = cursor[CurNormal]->cursor;
|
||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask |
|
||||
ButtonPressMask | PointerMotionMask | EnterWindowMask |
|
||||
LeaveWindowMask | StructureNotifyMask | PropertyChangeMask |
|
||||
FocusChangeMask;
|
||||
LeaveWindowMask | StructureNotifyMask | PropertyChangeMask;
|
||||
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
|
||||
XSelectInput(dpy, root, wa.event_mask);
|
||||
grabkeys();
|
||||
@@ -2151,9 +2320,19 @@ static void seturgent(Client *c, int urg) {
|
||||
static void showhide(Client *c) {
|
||||
if (!c) return;
|
||||
if (ISVISIBLE(c)) {
|
||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||
if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
|
||||
resize(c, c->x, c->y, c->w, c->h, 0);
|
||||
if (c->isfullscreen) {
|
||||
c->bw = 0;
|
||||
c->x = c->mon->mx;
|
||||
c->y = c->mon->my;
|
||||
c->w = c->mon->mw;
|
||||
c->h = c->mon->mh;
|
||||
XMoveResizeWindow(dpy, c->win, c->x, c->y, (unsigned int)c->w, (unsigned int)c->h);
|
||||
configure(c);
|
||||
} else {
|
||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||
if (!c->mon->lt[c->mon->sellt]->arrange || c->isfloating)
|
||||
resize(c, c->x, c->y, c->w, c->h, 0);
|
||||
}
|
||||
showhide(c->snext);
|
||||
} else {
|
||||
showhide(c->snext);
|
||||
@@ -2207,8 +2386,7 @@ static Monitor *systraytomon(Monitor *m) {
|
||||
static void tag(const Arg *arg) {
|
||||
if (selmon->sel && (arg->ui & TAGMASK)) {
|
||||
selmon->sel->tags = arg->ui & TAGMASK;
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
focusarranged(selmon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2274,8 +2452,7 @@ static void toggletag(const Arg *arg) {
|
||||
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
|
||||
if (newtags) {
|
||||
selmon->sel->tags = newtags;
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
focusarranged(selmon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2283,8 +2460,7 @@ static void toggleview(const Arg *arg) {
|
||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
||||
if (newtagset) {
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
focusarranged(selmon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2292,9 +2468,12 @@ static void unfocus(Client *c, int setfocus) {
|
||||
if (!c) return;
|
||||
grabbuttons(c, 0);
|
||||
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
|
||||
removewmstate(c, netatom[NetWMFocused]);
|
||||
if (setfocus) {
|
||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
|
||||
Window none = None;
|
||||
setnofocus();
|
||||
XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32,
|
||||
PropModeReplace, (unsigned char *)&none, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2831,10 +3010,10 @@ static void updatetitle(Client *c) {
|
||||
}
|
||||
|
||||
static void updatewindowtype(Client *c) {
|
||||
Atom state = getatomprop(c, netatom[NetWMState]);
|
||||
Atom wtype = getatomprop(c, netatom[NetWMWindowType]);
|
||||
if (state == netatom[NetWMFullscreen]) setfullscreen(c, 1);
|
||||
if (wtype == netatom[NetWMWindowTypeDialog]) c->isfloating = 1;
|
||||
if (hasatomprop(c, netatom[NetWMState], netatom[NetWMFullscreen]))
|
||||
setfullscreen(c, 1);
|
||||
if (hasatomprop(c, netatom[NetWMWindowType], netatom[NetWMWindowTypeDialog]))
|
||||
c->isfloating = 1;
|
||||
}
|
||||
|
||||
static void updatewmhints(Client *c) {
|
||||
@@ -2858,8 +3037,7 @@ static void view(const Arg *arg) {
|
||||
selmon->seltags ^= 1;
|
||||
if (arg->ui & TAGMASK)
|
||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
focusarranged(selmon);
|
||||
}
|
||||
|
||||
static Client *wintoclient(Window w) {
|
||||
|
||||
Reference in new issue
Block a user