Skip to content

Commit

Permalink
Improve DISPLAY_SWITCH_IN/OUT events on Linux.
Browse files Browse the repository at this point in the history
There were two issues.

- GNOME sends a different event type when alt-tabbing, at least on
Ubuntu 22.04. Adjusted the code to use this alternate event type.
- When GTK_TOPLEVEL flag is on, we were getting duplicate events with
Wayland. Adjusted the code to not listen to the duplicate events.

Fixes liballeg#1390, liballeg#1367
  • Loading branch information
SiegeLordEx authored and SiegeLord committed Dec 10, 2022
1 parent 266f4d7 commit 95cda44
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/x/xdisplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,17 @@ static bool xdpy_create_display_window(ALLEGRO_SYSTEM_XGLX *system,
StructureNotifyMask |
EnterWindowMask |
LeaveWindowMask |
FocusChangeMask |
ExposureMask |
PropertyChangeMask |
ButtonPressMask |
ButtonReleaseMask |
PointerMotionMask;

/* We handle these events via GTK-sent XEmbed events. */
if (!(display->flags & ALLEGRO_GTK_TOPLEVEL_INTERNAL)) {
swa.event_mask |= FocusChangeMask;
}

/* For a non-compositing window manager, a black background can look
* less broken if the application doesn't react to expose events fast
* enough. However in some cases like resizing, the black background
Expand Down Expand Up @@ -1105,13 +1109,13 @@ void _al_xglx_display_configure_event(ALLEGRO_DISPLAY *d, XEvent *xevent)
void _al_xwin_display_switch_handler(ALLEGRO_DISPLAY *display,
XFocusChangeEvent *xevent)
{
/* Anything but NotifyNormal seem to indicate the switch is not "real".
* TODO: Find out details?
/* Mouse click in/out tend to set NotifyNormal events. For Alt-Tab,
* there are also accompanying NotifyGrab/NotifyUngrab events which we don't
* care about. At this point, some WMs either send NotifyNormal (KDE) or
* NotifyWhileGrabbed (GNOME).
*/
if (xevent->mode != NotifyNormal)
return;

_al_xwin_display_switch_handler_inner(display, (xevent->type == FocusIn));
if (xevent->mode == NotifyNormal || xevent->mode == NotifyWhileGrabbed)
_al_xwin_display_switch_handler_inner(display, (xevent->type == FocusIn));
}


Expand Down

0 comments on commit 95cda44

Please sign in to comment.