[gtk+/xi2: 921/1239] Make gdk_windowing_pointer_grab() Use GdkDevice methods.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/xi2: 921/1239] Make gdk_windowing_pointer_grab() Use GdkDevice methods.
- Date: Tue, 29 Sep 2009 10:53:32 +0000 (UTC)
commit bb544e3222d3385e3dedcfa725bfb5cf49f60af6
Author: Carlos Garnacho <carlos lanedo com>
Date: Fri Aug 28 18:03:03 2009 +0200
Make gdk_windowing_pointer_grab() Use GdkDevice methods.
The behavior of this function isn't exactly the same than we can find
on non-XI2-aware clients with multiple pointers, but it's the best we
can achieve without knowing the device that generated the grab request.
gdk/x11/gdkmain-x11.c | 112 +++++++++++++++++----------------------------
gdk/x11/gdkprivate-x11.h | 3 +
2 files changed, 45 insertions(+), 70 deletions(-)
---
diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c
index 7a9f62b..aea89b0 100644
--- a/gdk/x11/gdkmain-x11.c
+++ b/gdk/x11/gdkmain-x11.c
@@ -47,10 +47,13 @@
#include "gdkasync.h"
#include "gdkdisplay-x11.h"
#include "gdkinternals.h"
+#include "gdkprivate-x11.h"
#include "gdkintl.h"
#include "gdkregion-generic.h"
#include "gdkalias.h"
+#include <gdk/gdkdeviceprivate.h>
+
typedef struct _GdkPredicate GdkPredicate;
typedef struct _GdkErrorTrap GdkErrorTrap;
@@ -115,7 +118,7 @@ gdk_get_use_xshm (void)
return GDK_DISPLAY_X11 (gdk_display_get_default ())->use_xshm;
}
-static GdkGrabStatus
+GdkGrabStatus
gdk_x11_convert_grab_status (gint status)
{
switch (status)
@@ -155,89 +158,58 @@ _gdk_windowing_pointer_grab (GdkWindow *window,
GdkCursor *cursor,
guint32 time)
{
- gint return_val;
- GdkCursorPrivate *cursor_private;
- GdkDisplayX11 *display_x11;
- guint xevent_mask;
- Window xwindow;
- Window xconfine_to;
- Cursor xcursor;
- int i;
-
- if (confine_to)
- confine_to = _gdk_window_get_impl_window (confine_to);
-
- display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (native));
+ GdkDeviceManager *device_manager;
+ GdkDisplay *display;
+ GList *devices, *dev;
+ GdkGrabStatus status = GDK_GRAB_SUCCESS;
+ GdkDevice *device;
- cursor_private = (GdkCursorPrivate*) cursor;
+ if (!window || GDK_WINDOW_DESTROYED (window))
+ return GDK_GRAB_NOT_VIEWABLE;
- xwindow = GDK_WINDOW_XID (native);
+ display = gdk_drawable_get_display (window);
+ device_manager = gdk_device_manager_get_for_display (display);
+ devices = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
- if (!confine_to || GDK_WINDOW_DESTROYED (confine_to))
- xconfine_to = None;
- else
- xconfine_to = GDK_WINDOW_XID (confine_to);
+ /* FIXME: What to do with floating devices the window is listening to? */
- if (!cursor)
- xcursor = None;
- else
+ for (dev = devices; dev; dev = dev->next)
{
- _gdk_x11_cursor_update_theme (cursor);
- xcursor = cursor_private->xcursor;
- }
+ device = dev->data;
- xevent_mask = 0;
- for (i = 0; i < _gdk_nenvent_masks; i++)
- {
- if (event_mask & (1 << (i + 1)))
- xevent_mask |= _gdk_event_mask_table[i];
- }
+ if (device->source != GDK_SOURCE_MOUSE)
+ continue;
- /* We don't want to set a native motion hint mask, as we're emulating motion
- * hints. If we set a native one we just wouldn't get any events.
- */
- xevent_mask &= ~PointerMotionHintMask;
+ status = GDK_DEVICE_GET_CLASS (device)->grab (device,
+ native,
+ owner_events,
+ event_mask,
+ confine_to,
+ cursor,
+ time);
-#if 0
- return_val = _gdk_input_grab_pointer (window,
- native,
- owner_events,
- event_mask,
- confine_to,
- time);
-#else
- return_val = GrabSuccess;
-#endif
+ if (status != GDK_GRAB_SUCCESS)
+ break;
+ }
- if (return_val == GrabSuccess ||
- G_UNLIKELY (!display_x11->trusted_client && return_val == AlreadyGrabbed))
+ if (status != GDK_GRAB_SUCCESS)
{
- if (!GDK_WINDOW_DESTROYED (native))
- {
-#ifdef G_ENABLE_DEBUG
- if (_gdk_debug_flags & GDK_DEBUG_NOGRABS)
- return_val = GrabSuccess;
- else
-#endif
- return_val = XGrabPointer (GDK_WINDOW_XDISPLAY (native),
- xwindow,
- owner_events,
- xevent_mask,
- GrabModeAsync, GrabModeAsync,
- xconfine_to,
- xcursor,
- time);
- }
- else
- return_val = AlreadyGrabbed;
+ /* Something went wrong, ungrab already grabbed devices */
+ while (dev)
+ {
+ device = dev->data;
+ dev = dev->prev;
+
+ if (device->source == GDK_SOURCE_MOUSE)
+ GDK_DEVICE_GET_CLASS (device)->ungrab (device, time);
+ }
}
- if (return_val == GrabSuccess)
- _gdk_x11_roundtrip_async (GDK_DISPLAY_OBJECT (display_x11),
+ if (status == GDK_GRAB_SUCCESS)
+ _gdk_x11_roundtrip_async (display,
has_pointer_grab_callback,
NULL);
-
- return gdk_x11_convert_grab_status (return_val);
+ return status;
}
/*
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index b925d19..de14347 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -193,6 +193,9 @@ gboolean _gdk_x11_get_xft_setting (GdkScreen *screen,
const gchar *name,
GValue *value);
+GdkGrabStatus gdk_x11_convert_grab_status (gint status);
+
+
extern GdkDrawableClass _gdk_x11_drawable_class;
extern gboolean _gdk_use_xshm;
extern const int _gdk_nenvent_masks;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]