Skip to content

Commit

Permalink
toggelfullscreen: addressing focus change issue when exiting fullscre…
Browse files Browse the repository at this point in the history
…en properly
  • Loading branch information
bakkeby committed May 12, 2021
1 parent ef89eb7 commit 0b5bc76
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions dwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2817,19 +2817,7 @@ resizeclient(Client *c, int x, int y, int w, int h)
#endif // NOBORDER_PATCH
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
#if FAKEFULLSCREEN_CLIENT_PATCH
if (c->fakefullscreen == 1)
/* Exception: if the client was in actual fullscreen and we exit out to fake fullscreen
* mode, then the focus would drift to whichever window is under the mouse cursor at the
* time. To avoid this we pass True to XSync which will make the X server disregard any
* other events in the queue thus cancelling the EnterNotify event that would otherwise
* have changed focus. */
XSync(dpy, True);
else
XSync(dpy, False);
#else
XSync(dpy, False);
#endif // FAKEFULLSCREEN_CLIENT_PATCH
}

void
Expand Down Expand Up @@ -3277,6 +3265,7 @@ setfocus(Client *c)
void
setfullscreen(Client *c, int fullscreen)
{
XEvent ev;
int savestate = 0, restorestate = 0;

if ((c->fakefullscreen == 0 && fullscreen && !c->isfullscreen) // normal fullscreen
Expand Down Expand Up @@ -3334,6 +3323,13 @@ setfullscreen(Client *c, int fullscreen)
restack(c->mon);
} else
resizeclient(c, c->x, c->y, c->w, c->h);

/* Exception: if the client was in actual fullscreen and we exit out to fake fullscreen
* mode, then the focus would sometimes drift to whichever window is under the mouse cursor
* at the time. To avoid this we ask X for all EnterNotify events and just ignore them.
*/
if (!c->isfullscreen)
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
#else
void
Expand Down

0 comments on commit 0b5bc76

Please sign in to comment.