x11: Add another mechanism to ignore crossing events

This is similar, but reserved for the crossing events induced by the
input shape changes on our overlay window. The mechanism in the previous
commit does again protect against this, so this mechanism may go away.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3267>
This commit is contained in:
Carlos Garnacho 2023-09-06 15:14:29 +02:00 committed by Marge Bot
parent 8b0da940cf
commit b567256873
3 changed files with 1 additions and 90 deletions

View File

@ -920,35 +920,6 @@ handle_window_focus_event (MetaX11Display *x11_display,
}
}
static gboolean
crossing_serial_is_ignored (MetaX11Display *x11_display,
unsigned long serial)
{
int i;
i = 0;
while (i < N_IGNORED_CROSSING_SERIALS)
{
if (x11_display->ignored_crossing_serials[i] == serial)
return TRUE;
++i;
}
return FALSE;
}
static void
reset_ignored_crossing_serials (MetaX11Display *x11_display)
{
int i;
i = 0;
while (i < N_IGNORED_CROSSING_SERIALS)
{
x11_display->ignored_crossing_serials[i] = 0;
++i;
}
}
static gboolean
handle_input_xevent (MetaX11Display *x11_display,
XIEvent *input_event,
@ -991,7 +962,7 @@ handle_input_xevent (MetaX11Display *x11_display,
/* Check if we've entered a window; do this even if window->has_focus to
* avoid races.
*/
if (window && !crossing_serial_is_ignored (x11_display, serial) &&
if (window &&
enter_event->mode != XINotifyGrab &&
enter_event->mode != XINotifyUngrab &&
enter_event->detail != XINotifyInferior &&
@ -1002,12 +973,6 @@ handle_input_xevent (MetaX11Display *x11_display,
enter_event->time,
enter_event->root_x,
enter_event->root_y);
if (window->type != META_WINDOW_DOCK)
{
/* stop ignoring stuff */
reset_ignored_crossing_serials (x11_display);
}
}
break;
case XI_Leave:

View File

@ -37,15 +37,6 @@
#include "meta-x11-stack-private.h"
#include "x11/meta-sync-counter.h"
/* This is basically a bogus number, just has to be large enough
* to handle the expected case of the alt+tab operation, where
* we want to ignore serials from UnmapNotify on the tab popup,
* and the LeaveNotify/EnterNotify from the pointer ungrab. It
* also has to be big enough to hold ignored serials from the point
* where we reshape the stage to the point where we get events back.
*/
#define N_IGNORED_CROSSING_SERIALS 10
typedef struct _MetaGroupPropHooks MetaGroupPropHooks;
typedef struct _MetaWindowPropHooks MetaWindowPropHooks;
@ -165,12 +156,6 @@ struct _MetaX11Display
guint closing : 1;
/* serials of leave/unmap events that may
* correspond to an enter event we should
* ignore
*/
unsigned long ignored_crossing_serials[N_IGNORED_CROSSING_SERIALS];
int composite_event_base;
int composite_error_base;
int composite_major_version;

View File

@ -1294,13 +1294,6 @@ meta_x11_display_new (MetaDisplay *display,
x11_display->server_focus_window = None;
x11_display->server_focus_serial = 0;
i = 0;
while (i < N_IGNORED_CROSSING_SERIALS)
{
x11_display->ignored_crossing_serials[i] = 0;
++i;
}
x11_display->prop_hooks = NULL;
meta_x11_display_init_window_prop_hooks (x11_display);
x11_display->group_prop_hooks = NULL;
@ -2333,29 +2326,6 @@ prefs_changed_callback (MetaPreference pref,
}
}
static void
meta_x11_display_add_ignored_crossing_serial (MetaX11Display *x11_display,
unsigned long serial)
{
int i;
/* don't add the same serial more than once */
if (serial ==
x11_display->ignored_crossing_serials[N_IGNORED_CROSSING_SERIALS - 1])
return;
/* shift serials to the left */
i = 0;
while (i < (N_IGNORED_CROSSING_SERIALS - 1))
{
x11_display->ignored_crossing_serials[i] =
x11_display->ignored_crossing_serials[i + 1];
++i;
}
/* put new one on the end */
x11_display->ignored_crossing_serials[i] = serial;
}
void
meta_x11_display_set_stage_input_region (MetaX11Display *x11_display,
XserverRegion region)
@ -2370,15 +2340,6 @@ meta_x11_display_set_stage_input_region (MetaX11Display *x11_display,
stage_xwindow = meta_x11_get_stage_window (stage);
XFixesSetWindowShapeRegion (xdisplay, stage_xwindow,
ShapeInput, 0, 0, region);
/*
* It's generally a good heuristic that when a crossing event is generated
* because we reshape the overlay, we don't want it to affect
* focus-follows-mouse focus - it's not the user doing something, it's the
* environment changing under the user.
*/
meta_x11_display_add_ignored_crossing_serial (x11_display,
XNextRequest (xdisplay));
XFixesSetWindowShapeRegion (xdisplay,
x11_display->composite_overlay_window,
ShapeInput, 0, 0, region);