[gtk+/xi2: 1081/1239] GdkDevice: Add select_window_events() vmethod.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/xi2: 1081/1239] GdkDevice: Add select_window_events() vmethod.
- Date: Tue, 29 Sep 2009 10:55:38 +0000 (UTC)
commit 536875ee0e41325269c8b6917c121c43e516341f
Author: Carlos Garnacho <carlos gnome org>
Date: Sun Sep 6 21:52:13 2009 +0200
GdkDevice: Add select_window_events() vmethod.
This is now implemented in X11 core and XI2 code.
gdk/gdkdeviceprivate.h | 3 ++
gdk/x11/gdkdevice-core.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++
gdk/x11/gdkdevice-xi2.c | 24 ++++++++++++++++++++
3 files changed, 81 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h
index 7511688..4373f08 100644
--- a/gdk/gdkdeviceprivate.h
+++ b/gdk/gdkdeviceprivate.h
@@ -82,6 +82,9 @@ struct _GdkDeviceClass
gint *win_x,
gint *win_y,
GdkModifierType *mask);
+ void (* select_window_events) (GdkDevice *device,
+ GdkWindow *window,
+ GdkEventMask event_mask);
};
void _gdk_device_set_relative (GdkDevice *device,
diff --git a/gdk/x11/gdkdevice-core.c b/gdk/x11/gdkdevice-core.c
index ff4fb33..72840fb 100644
--- a/gdk/x11/gdkdevice-core.c
+++ b/gdk/x11/gdkdevice-core.c
@@ -55,6 +55,9 @@ static GdkWindow * gdk_device_core_window_at_position (GdkDevice *device,
gint *win_x,
gint *win_y,
GdkModifierType *mask);
+static void gdk_device_core_select_window_events (GdkDevice *device,
+ GdkWindow *window,
+ GdkEventMask event_mask);
G_DEFINE_TYPE (GdkDeviceCore, gdk_device_core, GDK_TYPE_DEVICE)
@@ -76,6 +79,7 @@ gdk_device_core_class_init (GdkDeviceCoreClass *klass)
device_class->grab = gdk_device_core_grab;
device_class->ungrab = gdk_device_core_ungrab;
device_class->window_at_position = gdk_device_core_window_at_position;
+ device_class->select_window_events = gdk_device_core_select_window_events;
}
static void
@@ -352,3 +356,53 @@ gdk_device_core_window_at_position (GdkDevice *device,
return window;
}
+
+static void
+gdk_device_core_select_window_events (GdkDevice *device,
+ GdkWindow *window,
+ GdkEventMask event_mask)
+{
+ GdkEventMask filter_mask, window_mask;
+ guint xmask = 0;
+ gint i;
+
+ window_mask = gdk_window_get_events (window);
+ filter_mask = (GDK_POINTER_MOTION_MASK &
+ GDK_POINTER_MOTION_HINT_MASK &
+ GDK_BUTTON_MOTION_MASK &
+ GDK_BUTTON1_MOTION_MASK &
+ GDK_BUTTON2_MOTION_MASK &
+ GDK_BUTTON3_MOTION_MASK &
+ GDK_BUTTON_PRESS_MASK &
+ GDK_BUTTON_RELEASE_MASK &
+ GDK_KEY_PRESS_MASK &
+ GDK_KEY_RELEASE_MASK &
+ GDK_ENTER_NOTIFY_MASK &
+ GDK_LEAVE_NOTIFY_MASK &
+ GDK_FOCUS_CHANGE_MASK &
+ GDK_PROXIMITY_IN_MASK &
+ GDK_PROXIMITY_OUT_MASK &
+ GDK_SCROLL_MASK);
+
+ /* Filter out non-device events */
+ event_mask &= filter_mask;
+
+ /* Unset device events on window mask */
+ window_mask &= ~(filter_mask);
+
+ /* Combine masks */
+ event_mask |= window_mask;
+
+ for (i = 0; i < _gdk_nenvent_masks; i++)
+ {
+ if (event_mask & (1 << (i + 1)))
+ xmask |= _gdk_event_mask_table[i];
+ }
+
+ if (GDK_WINDOW_XID (window) != GDK_WINDOW_XROOTWIN (window))
+ xmask |= StructureNotifyMask | PropertyChangeMask;
+
+ XSelectInput (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XWINDOW (window),
+ xmask);
+}
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index f4b1a34..7bc1c68 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -76,6 +76,9 @@ static GdkWindow * gdk_device_xi2_window_at_position (GdkDevice *device,
gint *win_x,
gint *win_y,
GdkModifierType *mask);
+static void gdk_device_xi2_select_window_events (GdkDevice *device,
+ GdkWindow *window,
+ GdkEventMask event_mask);
G_DEFINE_TYPE (GdkDeviceXI2, gdk_device_xi2, GDK_TYPE_DEVICE)
@@ -101,6 +104,7 @@ gdk_device_xi2_class_init (GdkDeviceXI2Class *klass)
device_class->grab = gdk_device_xi2_grab;
device_class->ungrab = gdk_device_xi2_ungrab;
device_class->window_at_position = gdk_device_xi2_window_at_position;
+ device_class->select_window_events = gdk_device_xi2_select_window_events;
g_object_class_install_property (object_class,
PROP_DEVICE_ID,
@@ -416,6 +420,26 @@ gdk_device_xi2_window_at_position (GdkDevice *device,
return window;
}
+static void
+gdk_device_xi2_select_window_events (GdkDevice *device,
+ GdkWindow *window,
+ GdkEventMask event_mask)
+{
+ GdkDeviceXI2Private *priv;
+ XIEventMask evmask;
+
+ priv = GDK_DEVICE_XI2_GET_PRIVATE (device);
+
+ evmask.deviceid = priv->device_id;
+ evmask.mask = gdk_device_xi2_translate_event_mask (event_mask, &evmask.mask_len);
+
+ XISelectEvents (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XWINDOW (window),
+ &evmask, 1);
+
+ g_free (evmask.mask);
+}
+
guchar *
gdk_device_xi2_translate_event_mask (GdkEventMask event_mask,
int *len)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]