[gtk+/xi2: 1147/1239] GdkDevice: Respect GDK_MODE_DISABLED.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/xi2: 1147/1239] GdkDevice: Respect GDK_MODE_DISABLED.
- Date: Tue, 29 Sep 2009 10:56:44 +0000 (UTC)
commit 36fb2634df3d63f00b1e10485da613332ca29e4b
Author: Carlos Garnacho <carlos gnome org>
Date: Tue Sep 15 14:39:19 2009 +0200
GdkDevice: Respect GDK_MODE_DISABLED.
Old behavior was added back, where setting mode to disabled in some device
would run through the input windows, unselecting events for that device.
gdk/gdkdevice.c | 10 ++++++++
gdk/gdkdeviceprivate.h | 3 ++
gdk/x11/gdkinput.c | 57 +++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 67 insertions(+), 3 deletions(-)
---
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index 7af4d32..e614641 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -313,9 +313,19 @@ gdk_device_set_mode (GdkDevice *device,
{
g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
+ if (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER)
+ return FALSE;
+
+ if (device->mode == mode)
+ return TRUE;
+
+ /* FIXME: setting has_cursor when mode is window? */
+
device->mode = mode;
g_object_notify (G_OBJECT (device), "input-mode");
+ _gdk_input_check_extension_events (device);
+
return TRUE;
}
diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h
index 4373f08..ac6fb69 100644
--- a/gdk/gdkdeviceprivate.h
+++ b/gdk/gdkdeviceprivate.h
@@ -107,6 +107,9 @@ gboolean _gdk_device_translate_axis (GdkDevice *device,
gdouble value,
gdouble *axis_value);
+void _gdk_input_check_extension_events (GdkDevice *device);
+
+
G_END_DECLS
#endif /* __GDK_DEVICE_PRIVATE_H__ */
diff --git a/gdk/x11/gdkinput.c b/gdk/x11/gdkinput.c
index a3910f7..adfd018 100644
--- a/gdk/x11/gdkinput.c
+++ b/gdk/x11/gdkinput.c
@@ -27,8 +27,6 @@
#include "config.h"
#include <stdlib.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
#include "gdkx.h"
#include "gdkinput.h"
@@ -36,6 +34,7 @@
#include "gdkinputprivate.h"
#include "gdkscreen-x11.h"
#include "gdkdisplay-x11.h"
+#include "gdkwindow.h"
#include "gdkalias.h"
#if 0
@@ -352,6 +351,42 @@ gdk_device_free_history (GdkTimeCoord **events,
#endif
static void
+_gdk_input_select_device_events (GdkWindow *impl_window,
+ GdkDevice *dev)
+{
+ guint event_mask;
+ GdkWindowObject *w;
+ GdkInputWindow *iw;
+ GdkInputMode *mode;
+ gboolean has_cursor;
+ GList *l;
+
+ event_mask = 0;
+ iw = ((GdkWindowObject *)impl_window)->input_window;
+
+ g_object_get (dev,
+ "input-mode", &mode,
+ "has-cursor", &has_cursor,
+ NULL);
+
+ if (iw != NULL && mode != GDK_MODE_DISABLED)
+ {
+ for (l = iw->windows; l != NULL; l = l->next)
+ {
+ w = l->data;
+ if (has_cursor || (w->extension_events & GDK_ALL_DEVICES_MASK))
+ event_mask |= w->extension_events;
+ }
+ }
+ event_mask &= ~GDK_ALL_DEVICES_MASK;
+
+ if (event_mask)
+ event_mask |= GDK_PROXIMITY_OUT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK;
+
+ gdk_window_set_device_events (impl_window, dev, event_mask);
+}
+
+static void
unset_extension_events (GdkWindow *window)
{
GdkWindowObject *window_private;
@@ -445,7 +480,7 @@ gdk_input_set_extension_events (GdkWindow *window, gint mask,
for (tmp_list = display_x11->input_devices; tmp_list; tmp_list = tmp_list->next)
{
GdkDevice *dev = tmp_list->data;
- gdk_window_set_device_events (window, dev, mask);
+ _gdk_input_select_device_events (window, dev);
}
}
@@ -455,6 +490,22 @@ _gdk_input_window_destroy (GdkWindow *window)
unset_extension_events (window);
}
+void
+_gdk_input_check_extension_events (GdkDevice *device)
+{
+ GdkDisplayX11 *display_impl;
+ GdkInputWindow *input_window;
+ GList *tmp_list;
+
+ display_impl = GDK_DISPLAY_X11 (gdk_device_get_display (device));
+
+ for (tmp_list = display_impl->input_windows; tmp_list; tmp_list = tmp_list->next)
+ {
+ input_window = tmp_list->data;
+ _gdk_input_select_device_events (input_window->impl_window, device);
+ }
+}
+
#if 0
/**
* gdk_device_get_axis:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]