Skip to content

Commit 0b5bc76

Browse files
committed
toggelfullscreen: addressing focus change issue when exiting fullscreen properly
1 parent ef89eb7 commit 0b5bc76

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

dwm.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2817,19 +2817,7 @@ resizeclient(Client *c, int x, int y, int w, int h)
28172817
#endif // NOBORDER_PATCH
28182818
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
28192819
configure(c);
2820-
#if FAKEFULLSCREEN_CLIENT_PATCH
2821-
if (c->fakefullscreen == 1)
2822-
/* Exception: if the client was in actual fullscreen and we exit out to fake fullscreen
2823-
* mode, then the focus would drift to whichever window is under the mouse cursor at the
2824-
* time. To avoid this we pass True to XSync which will make the X server disregard any
2825-
* other events in the queue thus cancelling the EnterNotify event that would otherwise
2826-
* have changed focus. */
2827-
XSync(dpy, True);
2828-
else
2829-
XSync(dpy, False);
2830-
#else
28312820
XSync(dpy, False);
2832-
#endif // FAKEFULLSCREEN_CLIENT_PATCH
28332821
}
28342822

28352823
void
@@ -3277,6 +3265,7 @@ setfocus(Client *c)
32773265
void
32783266
setfullscreen(Client *c, int fullscreen)
32793267
{
3268+
XEvent ev;
32803269
int savestate = 0, restorestate = 0;
32813270

32823271
if ((c->fakefullscreen == 0 && fullscreen && !c->isfullscreen) // normal fullscreen
@@ -3334,6 +3323,13 @@ setfullscreen(Client *c, int fullscreen)
33343323
restack(c->mon);
33353324
} else
33363325
resizeclient(c, c->x, c->y, c->w, c->h);
3326+
3327+
/* Exception: if the client was in actual fullscreen and we exit out to fake fullscreen
3328+
* mode, then the focus would sometimes drift to whichever window is under the mouse cursor
3329+
* at the time. To avoid this we ask X for all EnterNotify events and just ignore them.
3330+
*/
3331+
if (!c->isfullscreen)
3332+
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
33373333
}
33383334
#else
33393335
void

0 commit comments

Comments
 (0)