[gtk+/xi2: 1171/1239] GdkEventSource: Make code to handle non-wm case generic.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/xi2: 1171/1239] GdkEventSource: Make code to handle non-wm case generic.
- Date: Tue, 29 Sep 2009 10:57:24 +0000 (UTC)
commit 7eabfd850ed81ad91e77aa83ce14d16dde2ae18e
Author: Carlos Garnacho <carlos gnome org>
Date: Wed Sep 16 14:17:16 2009 +0200
GdkEventSource: Make code to handle non-wm case generic.
This previously lived in GdkDeviceManagerCore, now this is handled in a
generic way for all device manager implementations.
gdk/x11/gdkdevicemanager-core.c | 32 ---------------------------
gdk/x11/gdkeventsource.c | 46 +++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 32 deletions(-)
---
diff --git a/gdk/x11/gdkdevicemanager-core.c b/gdk/x11/gdkdevicemanager-core.c
index 4a7955a..42207f3 100644
--- a/gdk/x11/gdkdevicemanager-core.c
+++ b/gdk/x11/gdkdevicemanager-core.c
@@ -642,22 +642,6 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator,
break;
}
- /* Handle focusing (in the case where no window manager is running */
- if (toplevel && xevent->xcrossing.detail != NotifyInferior)
- {
- toplevel->has_pointer = TRUE;
-
- if (xevent->xcrossing.focus && !toplevel->has_focus_window)
- {
- gboolean had_focus = HAS_FOCUS (toplevel);
-
- toplevel->has_pointer_focus = TRUE;
-
- if (HAS_FOCUS (toplevel) != had_focus)
- generate_focus_event (device_manager, window, TRUE);
- }
- }
-
event->crossing.type = GDK_ENTER_NOTIFY;
event->crossing.window = window;
event->crossing.device = device_manager->core_pointer;
@@ -702,22 +686,6 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator,
break;
}
- /* Handle focusing (in the case where no window manager is running */
- if (toplevel && xevent->xcrossing.detail != NotifyInferior)
- {
- toplevel->has_pointer = FALSE;
-
- if (xevent->xcrossing.focus && !toplevel->has_focus_window)
- {
- gboolean had_focus = HAS_FOCUS (toplevel);
-
- toplevel->has_pointer_focus = FALSE;
-
- if (HAS_FOCUS (toplevel) != had_focus)
- generate_focus_event (device_manager, window, FALSE);
- }
- }
-
event->crossing.type = GDK_LEAVE_NOTIFY;
event->crossing.window = window;
event->crossing.device = device_manager->core_pointer;
diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c
index d521807..0d3b3dc 100644
--- a/gdk/x11/gdkeventsource.c
+++ b/gdk/x11/gdkeventsource.c
@@ -29,6 +29,9 @@ static gboolean gdk_event_source_dispatch (GSource *source,
gpointer user_data);
static void gdk_event_source_finalize (GSource *source);
+#define HAS_FOCUS(toplevel) \
+ ((toplevel)->has_focus || (toplevel)->has_pointer_focus)
+
struct _GdkEventSource
{
GSource source;
@@ -86,6 +89,41 @@ gdk_event_source_get_filter_window (GdkEventSource *event_source,
return window;
}
+static void
+handle_focus_change (GdkEventCrossing *event)
+{
+ GdkToplevelX11 *toplevel;
+ gboolean focus_in;
+
+ toplevel = _gdk_x11_window_get_toplevel (event->window);
+ focus_in = (event->type == GDK_ENTER_NOTIFY);
+
+ if (toplevel && event->detail != GDK_NOTIFY_INFERIOR)
+ {
+ toplevel->has_pointer = focus_in;
+
+ if (event->focus && !toplevel->has_focus_window)
+ {
+ gboolean had_focus = HAS_FOCUS (toplevel);
+
+ toplevel->has_pointer_focus = focus_in;
+
+ if (HAS_FOCUS (toplevel) != had_focus)
+ {
+ GdkEvent focus_event;
+
+ focus_event.type = GDK_FOCUS_CHANGE;
+ focus_event.focus_change.window = event->window;
+ focus_event.focus_change.send_event = FALSE;
+ focus_event.focus_change.in = focus_in;
+ focus_event.focus_change.device = event->device;
+
+ gdk_event_put (&focus_event);
+ }
+ }
+ }
+}
+
static GdkEvent *
gdk_event_source_translate_event (GdkEventSource *event_source,
XEvent *xevent)
@@ -152,6 +190,14 @@ gdk_event_source_translate_event (GdkEventSource *event_source,
xevent);
}
+ if (event &&
+ (event->type == GDK_ENTER_NOTIFY ||
+ event->type == GDK_LEAVE_NOTIFY))
+ {
+ /* Handle focusing (in the case where no window manager is running */
+ handle_focus_change (&event->crossing);
+ }
+
return event;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]