summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2011-07-03 21:01:15 +0200
committerJasper St. Pierre <jstpierre@mecheye.net>2012-11-03 19:47:35 -0400
commit4facab385d85fab294b3c5c4a2e5ee9433cb30d9 (patch)
tree9409111124bc1ff3fe74981b8c138fe73b393c43
parentcc6dba2113ef196c500628022e0c8e063b0c9496 (diff)
downloadmutter-4facab385d85fab294b3c5c4a2e5ee9433cb30d9.tar.gz
devices: make meta_device_pointer_query_position() return a boolean
like in XQueryPointer/XIQueryPointer, the return value tells whether the pointer device is on the same screen than the passed window.
-rw-r--r--src/core/device-pointer.c15
-rw-r--r--src/core/device-pointer.h4
-rw-r--r--src/core/devices-core.c8
-rw-r--r--src/core/devices-xi2.c17
-rw-r--r--src/core/display.c13
5 files changed, 32 insertions, 25 deletions
diff --git a/src/core/device-pointer.c b/src/core/device-pointer.c
index cd78229b6..d9c96d4d8 100644
--- a/src/core/device-pointer.c
+++ b/src/core/device-pointer.c
@@ -71,7 +71,7 @@ meta_device_pointer_set_window_cursor (MetaDevicePointer *pointer,
(klass->set_window_cursor) (pointer, xwindow, cursor);
}
-void
+gboolean
meta_device_pointer_query_position (MetaDevicePointer *pointer,
Window xwindow,
Window *root_ret,
@@ -85,18 +85,19 @@ meta_device_pointer_query_position (MetaDevicePointer *pointer,
MetaDevicePointerClass *klass;
gint root_x, root_y, x, y;
Window root, child;
+ gboolean retval;
guint mask;
- g_return_if_fail (META_IS_DEVICE_POINTER (pointer));
- g_return_if_fail (xwindow != None);
+ g_return_val_if_fail (META_IS_DEVICE_POINTER (pointer), FALSE);
+ g_return_val_if_fail (xwindow != None, FALSE);
klass = META_DEVICE_POINTER_GET_CLASS (pointer);
if (!klass->query_position)
- return;
+ return FALSE;
- (klass->query_position) (pointer, xwindow, &root, &child,
- &root_x, &root_y, &x, &y, &mask);
+ retval = (klass->query_position) (pointer, xwindow, &root, &child,
+ &root_x, &root_y, &x, &y, &mask);
if (root_ret)
*root_ret = root;
@@ -118,4 +119,6 @@ meta_device_pointer_query_position (MetaDevicePointer *pointer,
if (mask_ret)
*mask_ret = mask;
+
+ return retval;
}
diff --git a/src/core/device-pointer.h b/src/core/device-pointer.h
index 1a45aacf1..6d96eef3a 100644
--- a/src/core/device-pointer.h
+++ b/src/core/device-pointer.h
@@ -61,7 +61,7 @@ struct _MetaDevicePointerClass
void (* set_window_cursor) (MetaDevicePointer *pointer,
Window xwindow,
MetaCursor cursor);
- void (* query_position) (MetaDevicePointer *pointer,
+ gboolean (* query_position) (MetaDevicePointer *pointer,
Window xwindow,
Window *root,
Window *child,
@@ -82,7 +82,7 @@ void meta_device_pointer_set_window_cursor (MetaDevicePointer *pointer,
Window xwindow,
MetaCursor cursor);
-void meta_device_pointer_query_position (MetaDevicePointer *pointer,
+gboolean meta_device_pointer_query_position (MetaDevicePointer *pointer,
Window xwindow,
Window *root,
Window *child,
diff --git a/src/core/devices-core.c b/src/core/devices-core.c
index 6848dc8c9..3f7eaebb1 100644
--- a/src/core/devices-core.c
+++ b/src/core/devices-core.c
@@ -114,7 +114,7 @@ meta_device_pointer_core_set_window_cursor (MetaDevicePointer *pointer,
XFreeCursor (display->xdisplay, xcursor);
}
-static void
+static gboolean
meta_device_pointer_core_query_position (MetaDevicePointer *pointer,
Window xwindow,
Window *root,
@@ -128,9 +128,9 @@ meta_device_pointer_core_query_position (MetaDevicePointer *pointer,
MetaDisplay *display;
display = meta_device_get_display (META_DEVICE (pointer));
- XQueryPointer (display->xdisplay, xwindow,
- root, child, root_x, root_y,
- x, y, mask);
+ return XQueryPointer (display->xdisplay, xwindow,
+ root, child, root_x, root_y,
+ x, y, mask);
}
static void
diff --git a/src/core/devices-xi2.c b/src/core/devices-xi2.c
index ab2f68d4a..cd6fb1b2e 100644
--- a/src/core/devices-xi2.c
+++ b/src/core/devices-xi2.c
@@ -193,7 +193,7 @@ meta_device_pointer_xi2_set_window_cursor (MetaDevicePointer *pointer,
XIUndefineCursor (display->xdisplay, device_id, xwindow);
}
-static void
+static gboolean
meta_device_pointer_xi2_query_position (MetaDevicePointer *pointer,
Window xwindow,
Window *root_ret,
@@ -210,16 +210,17 @@ meta_device_pointer_xi2_query_position (MetaDevicePointer *pointer,
XIButtonState buttons;
gdouble root_x, root_y, x, y;
int device_id;
+ gboolean retval;
display = meta_device_get_display (META_DEVICE (pointer));
device_id = meta_device_get_id (META_DEVICE (pointer));
- XIQueryPointer (display->xdisplay,
- device_id, xwindow,
- root_ret, child_ret,
- &root_x, &root_y, &x, &y,
- &buttons, &mods,
- &group_unused);
+ retval = XIQueryPointer (display->xdisplay,
+ device_id, xwindow,
+ root_ret, child_ret,
+ &root_x, &root_y, &x, &y,
+ &buttons, &mods,
+ &group_unused);
if (mask_ret)
{
*mask_ret = mods.effective;
@@ -243,6 +244,8 @@ meta_device_pointer_xi2_query_position (MetaDevicePointer *pointer,
if (y_ret)
*y_ret = (int) y;
+
+ return retval;
}
static void
diff --git a/src/core/display.c b/src/core/display.c
index e8ae146c1..266a422cd 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1655,12 +1655,13 @@ window_focus_on_pointer_rest_callback (gpointer data)
if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK)
goto out;
- meta_device_pointer_query_position (META_DEVICE_POINTER (device),
- screen->xroot,
- NULL,
- &child,
- &root_x, &root_y,
- NULL, NULL, NULL);
+ if (!meta_device_pointer_query_position (META_DEVICE_POINTER (device),
+ screen->xroot,
+ NULL,
+ &child,
+ &root_x, &root_y,
+ NULL, NULL, NULL))
+ goto out;
if (root_x != focus_data->pointer_x ||
root_y != focus_data->pointer_y)