Commit db4a6040 authored by Benjamin Otte's avatar Benjamin Otte

x11: Avoid spurious focus events on grabs

We want to avoid handling focus events for the private focus window,
otherwise the keyboard grab taken by for example buttons will cause a
spurious FOCUS_OUT/FOCUS_IN on the toplevel.

The code that did this seems to have been lost in the XI2 transition for
GTK3.

https://bugzilla.gnome.org/show_bug.cgi?id=657578
parent 2ea328df
...@@ -665,6 +665,7 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator, ...@@ -665,6 +665,7 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
case FocusIn: case FocusIn:
case FocusOut: case FocusOut:
_gdk_device_manager_core_handle_focus (window, _gdk_device_manager_core_handle_focus (window,
xevent->xfocus.window,
device_manager->core_keyboard, device_manager->core_keyboard,
NULL, NULL,
xevent->type == FocusIn, xevent->type == FocusIn,
...@@ -795,6 +796,7 @@ _gdk_x11_event_translate_keyboard_string (GdkEventKey *event) ...@@ -795,6 +796,7 @@ _gdk_x11_event_translate_keyboard_string (GdkEventKey *event)
*/ */
void void
_gdk_device_manager_core_handle_focus (GdkWindow *window, _gdk_device_manager_core_handle_focus (GdkWindow *window,
Window original,
GdkDevice *device, GdkDevice *device,
GdkDevice *source_device, GdkDevice *source_device,
gboolean focus_in, gboolean focus_in,
...@@ -819,6 +821,9 @@ _gdk_device_manager_core_handle_focus (GdkWindow *window, ...@@ -819,6 +821,9 @@ _gdk_device_manager_core_handle_focus (GdkWindow *window,
if (!toplevel) if (!toplevel)
return; return;
if (toplevel->focus_window == original)
return;
had_focus = HAS_FOCUS (toplevel); had_focus = HAS_FOCUS (toplevel);
switch (detail) switch (detail)
......
...@@ -1228,6 +1228,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator, ...@@ -1228,6 +1228,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
GUINT_TO_POINTER (xev->sourceid)); GUINT_TO_POINTER (xev->sourceid));
_gdk_device_manager_core_handle_focus (window, _gdk_device_manager_core_handle_focus (window,
xev->event,
device, device,
source_device, source_device,
(ev->evtype == XI_FocusIn) ? TRUE : FALSE, (ev->evtype == XI_FocusIn) ? TRUE : FALSE,
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#ifndef __GDK_DEVICE_MANAGER_PRIVATE_CORE_H__ #ifndef __GDK_DEVICE_MANAGER_PRIVATE_CORE_H__
#define __GDK_DEVICE_MANAGER_PRIVATE_CORE_H__ #define __GDK_DEVICE_MANAGER_PRIVATE_CORE_H__
#include <X11/Xlib.h>
#include "gdkx11devicemanager-core.h" #include "gdkx11devicemanager-core.h"
#include "gdkdevicemanagerprivate.h" #include "gdkdevicemanagerprivate.h"
...@@ -38,6 +40,7 @@ struct _GdkX11DeviceManagerCoreClass ...@@ -38,6 +40,7 @@ struct _GdkX11DeviceManagerCoreClass
}; };
void _gdk_device_manager_core_handle_focus (GdkWindow *window, void _gdk_device_manager_core_handle_focus (GdkWindow *window,
Window original,
GdkDevice *device, GdkDevice *device,
GdkDevice *source_device, GdkDevice *source_device,
gboolean focus_in, gboolean focus_in,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment