summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-08-26 22:34:08 +0000
committerMatthias Clasen <mclasen@redhat.com>2020-08-26 22:34:08 +0000
commit70ae073394caf836fc48bc964740a9ba5c28e052 (patch)
treead81cb49b25d4c95042118ba57be3cc829016f11
parent1e4c6cde100f4a3052b340cc1f40eaa85d58fd60 (diff)
parent1c44910dfee8d4b81e9f69fa6b80001d7009e2c4 (diff)
downloadgtk+-70ae073394caf836fc48bc964740a9ba5c28e052.tar.gz
Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master See merge request GNOME/gtk!2488
-rw-r--r--gdk/broadway/gdkdevice-broadway.c50
-rw-r--r--gdk/broadway/gdkdevice-broadway.h6
-rw-r--r--gdk/broadway/gdksurface-broadway.c10
-rw-r--r--gdk/gdkdevice.c16
-rw-r--r--gdk/gdkdeviceprivate.h17
-rw-r--r--gdk/gdksurfaceprivate.h12
-rw-r--r--gdk/macos/gdkmacosdevice-private.h36
-rw-r--r--gdk/macos/gdkmacosdevice.c5
-rw-r--r--gdk/macos/gdkmacosdrag.c3
-rw-r--r--gdk/macos/gdkmacossurface.c3
-rw-r--r--gdk/wayland/gdkdevice-wayland-private.h13
-rw-r--r--gdk/wayland/gdkdevice-wayland.c29
-rw-r--r--gdk/wayland/gdksurface-wayland.c20
-rw-r--r--gdk/win32/gdkdevice-virtual.c11
-rw-r--r--gdk/win32/gdkdevice-virtual.h9
-rw-r--r--gdk/win32/gdkdevice-win32.c19
-rw-r--r--gdk/win32/gdkdevice-win32.h7
-rw-r--r--gdk/win32/gdkdevice-wintab.c3
-rw-r--r--gdk/win32/gdkdevice-wintab.h8
-rw-r--r--gdk/win32/gdkdrag-win32.c5
-rw-r--r--gdk/win32/gdksurface-win32.c18
-rw-r--r--gdk/x11/gdkdevice-xi2-private.h9
-rw-r--r--gdk/x11/gdkdevice-xi2.c14
-rw-r--r--gdk/x11/gdkdrag-x11.c5
-rw-r--r--gdk/x11/gdksurface-x11.c21
25 files changed, 198 insertions, 151 deletions
diff --git a/gdk/broadway/gdkdevice-broadway.c b/gdk/broadway/gdkdevice-broadway.c
index 8ed1a9ccf4..37be4fa1ef 100644
--- a/gdk/broadway/gdkdevice-broadway.c
+++ b/gdk/broadway/gdkdevice-broadway.c
@@ -26,12 +26,6 @@
static void gdk_broadway_device_set_surface_cursor (GdkDevice *device,
GdkSurface *surface,
GdkCursor *cursor);
-static void gdk_broadway_device_query_state (GdkDevice *device,
- GdkSurface *surface,
- GdkSurface **child_surface,
- double *win_x,
- double *win_y,
- GdkModifierType *mask);
static GdkGrabStatus gdk_broadway_device_grab (GdkDevice *device,
GdkSurface *surface,
gboolean owner_events,
@@ -55,7 +49,6 @@ gdk_broadway_device_class_init (GdkBroadwayDeviceClass *klass)
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
device_class->set_surface_cursor = gdk_broadway_device_set_surface_cursor;
- device_class->query_state = gdk_broadway_device_query_state;
device_class->grab = gdk_broadway_device_grab;
device_class->ungrab = gdk_broadway_device_ungrab;
device_class->surface_at_position = gdk_broadway_device_surface_at_position;
@@ -79,10 +72,9 @@ gdk_broadway_device_set_surface_cursor (GdkDevice *device,
{
}
-static void
+void
gdk_broadway_device_query_state (GdkDevice *device,
GdkSurface *surface,
- GdkSurface **child_surface,
double *win_x,
double *win_y,
GdkModifierType *mask)
@@ -111,18 +103,6 @@ gdk_broadway_device_query_state (GdkDevice *device,
*win_y = device_root_y;
if (mask)
*mask = mask32;
- if (child_surface)
- {
- GdkSurface *mouse_toplevel;
-
- mouse_toplevel = g_hash_table_lookup (broadway_display->id_ht, GUINT_TO_POINTER (mouse_toplevel_id));
- if (surface == NULL)
- *child_surface = mouse_toplevel;
- else
- *child_surface = NULL;
- }
-
- return;
}
void
@@ -253,10 +233,32 @@ gdk_broadway_device_surface_at_position (GdkDevice *device,
double *win_y,
GdkModifierType *mask)
{
- GdkSurface *surface = NULL;
+ GdkDisplay *display;
+ GdkBroadwayDisplay *broadway_display;
+ gint32 device_root_x, device_root_y;
+ guint32 mouse_toplevel_id;
+ guint32 mask32;
+
+ if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
+ return NULL;
+
+ display = gdk_device_get_display (device);
+ broadway_display = GDK_BROADWAY_DISPLAY (display);
+
+ _gdk_broadway_server_query_mouse (broadway_display->server,
+ &mouse_toplevel_id,
+ &device_root_x,
+ &device_root_y,
+ &mask32);
- gdk_broadway_device_query_state (device, NULL, &surface, win_x, win_y, mask);
+ if (win_x)
+ *win_x = device_root_x;
+ if (win_y)
+ *win_y = device_root_y;
+ if (mask)
+ *mask = mask32;
- return surface;
+ return g_hash_table_lookup (broadway_display->id_ht,
+ GUINT_TO_POINTER (mouse_toplevel_id));
}
diff --git a/gdk/broadway/gdkdevice-broadway.h b/gdk/broadway/gdkdevice-broadway.h
index 3ee51db4c6..cde76b4c6e 100644
--- a/gdk/broadway/gdkdevice-broadway.h
+++ b/gdk/broadway/gdkdevice-broadway.h
@@ -45,6 +45,12 @@ struct _GdkBroadwayDeviceClass
G_GNUC_INTERNAL
GType gdk_broadway_device_get_type (void) G_GNUC_CONST;
+void gdk_broadway_device_query_state (GdkDevice *device,
+ GdkSurface *surface,
+ double *win_x,
+ double *win_y,
+ GdkModifierType *mask);
+
G_END_DECLS
#endif /* __GDK_DEVICE_BROADWAY_H__ */
diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c
index 0f3240f833..f0f152203f 100644
--- a/gdk/broadway/gdksurface-broadway.c
+++ b/gdk/broadway/gdksurface-broadway.c
@@ -30,6 +30,7 @@
#include "gdkbroadwaydisplay.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplay-broadway.h"
+#include "gdkdevice-broadway.h"
#include "gdkdisplay.h"
#include "gdkdragsurfaceprivate.h"
#include "gdkeventsource.h"
@@ -749,17 +750,14 @@ gdk_broadway_surface_get_device_state (GdkSurface *surface,
double *y,
GdkModifierType *mask)
{
- GdkSurface *child;
-
g_return_val_if_fail (surface == NULL || GDK_IS_SURFACE (surface), FALSE);
if (GDK_SURFACE_DESTROYED (surface))
return FALSE;
- GDK_DEVICE_GET_CLASS (device)->query_state (device, surface,
- &child,
- x, y, mask);
- return child != NULL;
+ gdk_broadway_device_query_state (device, surface, x, y, mask);
+
+ return *x >= 0 && *y >= 0 && *x < surface->width && *y < surface->height;
}
static void
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index d812290b9f..8b4b27cd82 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -1069,22 +1069,6 @@ _gdk_device_translate_axis (GdkDevice *device,
return TRUE;
}
-void
-_gdk_device_query_state (GdkDevice *device,
- GdkSurface *surface,
- GdkSurface **child_surface,
- double *win_x,
- double *win_y,
- GdkModifierType *mask)
-{
- GDK_DEVICE_GET_CLASS (device)->query_state (device,
- surface,
- child_surface,
- win_x,
- win_y,
- mask);
-}
-
GdkSurface *
_gdk_device_surface_at_position (GdkDevice *device,
double *win_x,
diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h
index 39fdba34f0..79d24378a0 100644
--- a/gdk/gdkdeviceprivate.h
+++ b/gdk/gdkdeviceprivate.h
@@ -96,21 +96,10 @@ struct _GdkDeviceClass
{
GObjectClass parent_class;
- void (* get_state) (GdkDevice *device,
- GdkSurface *surface,
- double *axes,
- GdkModifierType *mask);
-
void (* set_surface_cursor)(GdkDevice *device,
GdkSurface *surface,
GdkCursor *cursor);
- void (* query_state) (GdkDevice *device,
- GdkSurface *surface,
- GdkSurface **child_surface,
- double *win_x,
- double *win_y,
- GdkModifierType *mask);
GdkGrabStatus (* grab) (GdkDevice *device,
GdkSurface *surface,
gboolean owner_events,
@@ -174,12 +163,6 @@ void _gdk_device_add_physical_device (GdkDevice *device,
void _gdk_device_remove_physical_device (GdkDevice *device,
GdkDevice *physical);
-void _gdk_device_query_state (GdkDevice *device,
- GdkSurface *surface,
- GdkSurface **child_surface,
- double *win_x,
- double *win_y,
- GdkModifierType *mask);
GdkSurface * _gdk_device_surface_at_position (GdkDevice *device,
double *win_x,
double *win_y,
diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h
index e0a0c20b50..36db8286af 100644
--- a/gdk/gdksurfaceprivate.h
+++ b/gdk/gdksurfaceprivate.h
@@ -108,25 +108,23 @@ struct _GdkSurfaceClass
GObjectClass parent_class;
cairo_surface_t *
- (* ref_cairo_surface) (GdkSurface *surface);
-
- void (* hide) (GdkSurface *surface);
- void (* get_geometry) (GdkSurface *surface,
+ (* ref_cairo_surface) (GdkSurface *surface);
+ void (* hide) (GdkSurface *surface);
+ void (* get_geometry) (GdkSurface *surface,
int *x,
int *y,
int *width,
int *height);
- void (* get_root_coords) (GdkSurface *surface,
+ void (* get_root_coords) (GdkSurface *surface,
int x,
int y,
int *root_x,
int *root_y);
- gboolean (* get_device_state) (GdkSurface *surface,
+ gboolean (* get_device_state) (GdkSurface *surface,
GdkDevice *device,
double *x,
double *y,
GdkModifierType *mask);
-
void (* set_input_region) (GdkSurface *surface,
cairo_region_t *shape_region);
diff --git a/gdk/macos/gdkmacosdevice-private.h b/gdk/macos/gdkmacosdevice-private.h
new file mode 100644
index 0000000000..6daafa8135
--- /dev/null
+++ b/gdk/macos/gdkmacosdevice-private.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2020 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GDK_MACOS_DEVICE_PRIVATE_H__
+#define __GDK_MACOS_DEVICE_PRIVATE_H__
+
+#include "gdkdeviceprivate.h"
+
+G_BEGIN_DECLS
+
+void gdk_macos_device_query_state (GdkDevice *device,
+ GdkSurface *surface,
+ GdkSurface **child_surface,
+ double *win_x,
+ double *win_y,
+ GdkModifierType *mask);
+
+G_END_DECLS
+
+#endif /* __GDK_MACOS_DEVICE_PRIVATE_H__ */
diff --git a/gdk/macos/gdkmacosdevice.c b/gdk/macos/gdkmacosdevice.c
index 94ecbd4041..b4c71c2e51 100644
--- a/gdk/macos/gdkmacosdevice.c
+++ b/gdk/macos/gdkmacosdevice.c
@@ -29,7 +29,7 @@
#include "gdkmacoscursor-private.h"
#include "gdkmacosdevice.h"
#include "gdkmacosdisplay-private.h"
-#include "gdkmacossurface-private.h"
+#include "gdkmacosdevice-private.h"
struct _GdkMacosDevice
{
@@ -126,7 +126,7 @@ gdk_macos_device_ungrab (GdkDevice *device,
_gdk_display_device_grab_update (display, device, 0);
}
-static void
+void
gdk_macos_device_query_state (GdkDevice *device,
GdkSurface *surface,
GdkSurface **child_surface,
@@ -173,7 +173,6 @@ gdk_macos_device_class_init (GdkMacosDeviceClass *klass)
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
device_class->grab = gdk_macos_device_grab;
- device_class->query_state = gdk_macos_device_query_state;
device_class->set_surface_cursor = gdk_macos_device_set_surface_cursor;
device_class->surface_at_position = gdk_macos_device_surface_at_position;
device_class->ungrab = gdk_macos_device_ungrab;
diff --git a/gdk/macos/gdkmacosdrag.c b/gdk/macos/gdkmacosdrag.c
index fcc75e6078..c89b01948f 100644
--- a/gdk/macos/gdkmacosdrag.c
+++ b/gdk/macos/gdkmacosdrag.c
@@ -22,6 +22,7 @@
#include "gdkdeviceprivate.h"
#include "gdkintl.h"
+#include "gdkmacosdevice-private.h"
#include "gdkmacoscursor-private.h"
#include "gdkmacosdisplay-private.h"
#include "gdkmacosdrag-private.h"
@@ -473,7 +474,7 @@ gdk_dnd_handle_key_event (GdkDrag *drag,
* to query it here. We could use XGetModifierMapping, but
* that would be overkill.
*/
- _gdk_device_query_state (pointer, NULL, NULL, NULL, NULL, &state);
+ gdk_macos_device_query_state (pointer, NULL, NULL, NULL, NULL, &state);
if (dx != 0 || dy != 0)
{
diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c
index 5f719bb923..bddbbaf038 100644
--- a/gdk/macos/gdkmacossurface.c
+++ b/gdk/macos/gdkmacossurface.c
@@ -32,6 +32,7 @@
#include "gdksurfaceprivate.h"
#include "gdkmacosdevice.h"
+#include "gdkmacosdevice-private.h"
#include "gdkmacosdisplay-private.h"
#include "gdkmacosdrag-private.h"
#include "gdkmacosdragsurface-private.h"
@@ -307,7 +308,7 @@ gdk_macos_surface_drag_begin (GdkSurface *surface,
g_assert (GDK_IS_CONTENT_PROVIDER (content));
seat = gdk_device_get_seat (device);
- _gdk_device_query_state (device, surface, NULL, &px, &py, NULL);
+ gdk_macos_device_query_state (device, surface, NULL, &px, &py, NULL);
_gdk_macos_surface_get_root_coords (GDK_MACOS_SURFACE (surface), &sx, &sy);
drag_surface = _gdk_macos_surface_new (GDK_MACOS_DISPLAY (surface->display),
GDK_SURFACE_TEMP,
diff --git a/gdk/wayland/gdkdevice-wayland-private.h b/gdk/wayland/gdkdevice-wayland-private.h
new file mode 100644
index 0000000000..3dae422081
--- /dev/null
+++ b/gdk/wayland/gdkdevice-wayland-private.h
@@ -0,0 +1,13 @@
+#ifndef __GDK_DEVICE_WAYLAND_PRIVATE_H__
+#define __GDK_DEVICE_WAYLAND_PRIVATE_H__
+
+#include "gdkwaylanddevice.h"
+
+void
+gdk_wayland_device_query_state (GdkDevice *device,
+ GdkSurface *surface,
+ double *win_x,
+ double *win_y,
+ GdkModifierType *mask);
+
+#endif
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 4436269217..fbbceacb65 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -35,6 +35,7 @@
#include "gdkdeviceprivate.h"
#include "gdkdevicepadprivate.h"
#include "gdkdevicetoolprivate.h"
+#include "gdkdevice-wayland-private.h"
#include "gdkdropprivate.h"
#include "gdkprimary-wayland.h"
#include "gdkseatprivate.h"
@@ -517,32 +518,35 @@ device_get_modifiers (GdkDevice *device)
return mask;
}
-static void
+void
gdk_wayland_device_query_state (GdkDevice *device,
GdkSurface *surface,
- GdkSurface **child_surface,
double *win_x,
double *win_y,
GdkModifierType *mask)
{
GdkWaylandPointerData *pointer;
- GList *children = NULL;
+ double x, y;
- if (surface == NULL)
- children = gdk_wayland_display_get_toplevel_surfaces (gdk_device_get_display (device));
+ if (mask)
+ *mask = device_get_modifiers (device);
pointer = GDK_WAYLAND_DEVICE (device)->pointer;
- if (child_surface)
- /* Set child only if actually a child of the given surface, as XIQueryPointer() does */
- *child_surface = g_list_find (children, pointer->focus) ? pointer->focus : NULL;
- if (mask)
- *mask = device_get_modifiers (device);
+ if (pointer->focus == surface)
+ {
+ x = pointer->surface_x;
+ y = pointer->surface_y;
+ }
+ else
+ {
+ x = y = -1;
+ }
if (win_x)
- *win_x = pointer->surface_x;
+ *win_x = x;
if (win_y)
- *win_y = pointer->surface_y;
+ *win_y = y;
}
static void
@@ -796,7 +800,6 @@ gdk_wayland_device_class_init (GdkWaylandDeviceClass *klass)
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
device_class->set_surface_cursor = gdk_wayland_device_set_surface_cursor;
- device_class->query_state = gdk_wayland_device_query_state;
device_class->grab = gdk_wayland_device_grab;
device_class->ungrab = gdk_wayland_device_ungrab;
device_class->surface_at_position = gdk_wayland_device_surface_at_position;
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index a444a4ee44..0fc030f9b4 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -36,6 +36,7 @@
#include "gdkseat-wayland.h"
#include "gdksurfaceprivate.h"
#include "gdktoplevelprivate.h"
+#include "gdkdevice-wayland-private.h"
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
@@ -3169,23 +3170,12 @@ gdk_wayland_surface_get_device_state (GdkSurface *surface,
double *y,
GdkModifierType *mask)
{
- gboolean return_val;
-
- g_return_val_if_fail (surface == NULL || GDK_IS_SURFACE (surface), FALSE);
-
- return_val = TRUE;
-
- if (!GDK_SURFACE_DESTROYED (surface))
- {
- GdkSurface *child;
+ if (GDK_SURFACE_DESTROYED (surface))
+ return FALSE;
- GDK_DEVICE_GET_CLASS (device)->query_state (device, surface,
- &child,
- x, y, mask);
- return_val = (child != NULL);
- }
+ gdk_wayland_device_query_state (device, surface, x, y, mask);
- return return_val;
+ return *x >= 0 && *y >= 0 && *x < surface->width && *y < surface->height;
}
static void
diff --git a/gdk/win32/gdkdevice-virtual.c b/gdk/win32/gdkdevice-virtual.c
index cff071de1b..83742c7763 100644
--- a/gdk/win32/gdkdevice-virtual.c
+++ b/gdk/win32/gdkdevice-virtual.c
@@ -83,7 +83,7 @@ gdk_device_virtual_set_surface_cursor (GdkDevice *device,
g_set_object (&GDK_WIN32_SURFACE (window)->cursor, win32_hcursor);
}
-static void
+void
gdk_device_virtual_query_state (GdkDevice *device,
GdkSurface *window,
GdkSurface **child_window,
@@ -93,10 +93,10 @@ gdk_device_virtual_query_state (GdkDevice *device,
{
GdkDeviceVirtual *virtual = GDK_DEVICE_VIRTUAL (device);
- _gdk_device_query_state (virtual->active_device,
- window, child_window,
- win_x, win_y,
- mask);
+ _gdk_device_win32_query_state (virtual->active_device,
+ window, child_window,
+ win_x, win_y,
+ mask);
}
static GdkGrabStatus
@@ -160,7 +160,6 @@ gdk_device_virtual_class_init (GdkDeviceVirtualClass *klass)
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
device_class->set_surface_cursor = gdk_device_virtual_set_surface_cursor;
- device_class->query_state = gdk_device_virtual_query_state;
device_class->grab = gdk_device_virtual_grab;
device_class->ungrab = gdk_device_virtual_ungrab;
device_class->surface_at_position = _gdk_device_win32_surface_at_position;
diff --git a/gdk/win32/gdkdevice-virtual.h b/gdk/win32/gdkdevice-virtual.h
index e44e7339b8..3a98dd05c1 100644
--- a/gdk/win32/gdkdevice-virtual.h
+++ b/gdk/win32/gdkdevice-virtual.h
@@ -48,6 +48,15 @@ GType gdk_device_virtual_get_type (void) G_GNUC_CONST;
void _gdk_device_virtual_set_active (GdkDevice *device,
GdkDevice *new_active);
+void
+gdk_device_virtual_query_state (GdkDevice *device,
+ GdkSurface *window,
+ GdkSurface **child_window,
+ double *win_x,
+ double *win_y,
+ GdkModifierType *mask);
+
+
G_END_DECLS
diff --git a/gdk/win32/gdkdevice-win32.c b/gdk/win32/gdkdevice-win32.c
index bf74f608e7..90fae48ac1 100644
--- a/gdk/win32/gdkdevice-win32.c
+++ b/gdk/win32/gdkdevice-win32.c
@@ -26,6 +26,8 @@
#include "gdkdevice-win32.h"
#include "gdkwin32.h"
#include "gdkdisplay-win32.h"
+#include "gdkdevice-virtual.h"
+#include "gdkdevice-wintab.h"
G_DEFINE_TYPE (GdkDeviceWin32, gdk_device_win32, GDK_TYPE_DEVICE)
@@ -121,6 +123,22 @@ gdk_device_win32_query_state (GdkDevice *device,
*mask = get_current_mask ();
}
+void
+_gdk_device_win32_query_state (GdkDevice *device,
+ GdkSurface *window,
+ GdkSurface **child_window,
+ double *win_x,
+ double *win_y,
+ GdkModifierType *mask)
+{
+ if (GDK_IS_DEVICE_VIRTUAL (device))
+ gdk_device_virtual_query_state (device, window, child_window, win_x, win_y, mask);
+ else if (GDK_IS_DEVICE_WINTAB (device))
+ gdk_device_wintab_query_state (device, window, child_window, win_x, win_y, mask);
+ else
+ gdk_device_win32_query_state (device, window, child_window, win_x, win_y, mask);
+}
+
static GdkGrabStatus
gdk_device_win32_grab (GdkDevice *device,
GdkSurface *window,
@@ -208,7 +226,6 @@ gdk_device_win32_class_init (GdkDeviceWin32Class *klass)
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
device_class->set_surface_cursor = gdk_device_win32_set_surface_cursor;
- device_class->query_state = gdk_device_win32_query_state;
device_class->grab = gdk_device_win32_grab;
device_class->ungrab = gdk_device_win32_ungrab;
device_class->surface_at_position = _gdk_device_win32_surface_at_position;
diff --git a/gdk/win32/gdkdevice-win32.h b/gdk/win32/gdkdevice-win32.h
index 2559412426..478afb15bd 100644
--- a/gdk/win32/gdkdevice-win32.h
+++ b/gdk/win32/gdkdevice-win32.h
@@ -48,6 +48,13 @@ GdkSurface *_gdk_device_win32_surface_at_position (GdkDevice *device,
double *win_x,
double *win_y,
GdkModifierType *mask);
+void _gdk_device_win32_query_state (GdkDevice *device,
+ GdkSurface *surface,
+ GdkSurface **child_surface,
+ double *win_x,
+ double *win_y,
+ GdkModifierType *mask);
+
G_END_DECLS
diff --git a/gdk/win32/gdkdevice-wintab.c b/gdk/win32/gdkdevice-wintab.c
index 50fc2c2e87..6e94545767 100644
--- a/gdk/win32/gdkdevice-wintab.c
+++ b/gdk/win32/gdkdevice-wintab.c
@@ -61,7 +61,7 @@ gdk_device_wintab_set_surface_cursor (GdkDevice *device,
{
}
-static void
+void
gdk_device_wintab_query_state (GdkDevice *device,
GdkSurface *window,
GdkSurface **child_window,
@@ -230,7 +230,6 @@ gdk_device_wintab_class_init (GdkDeviceWintabClass *klass)
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
device_class->set_surface_cursor = gdk_device_wintab_set_surface_cursor;
- device_class->query_state = gdk_device_wintab_query_state;
device_class->grab = gdk_device_wintab_grab;
device_class->ungrab = gdk_device_wintab_ungrab;
device_class->surface_at_position = gdk_device_wintab_surface_at_position;
diff --git a/gdk/win32/gdkdevice-wintab.h b/gdk/win32/gdkdevice-wintab.h
index 088a84e7f4..bac77b5cd3 100644
--- a/gdk/win32/gdkdevice-wintab.h
+++ b/gdk/win32/gdkdevice-wintab.h
@@ -66,6 +66,14 @@ void _gdk_device_wintab_translate_axes (GdkDeviceWintab *device,
double *x,
double *y);
+void
+gdk_device_wintab_query_state (GdkDevice *device,
+ GdkSurface *window,
+ GdkSurface **child_window,
+ double *win_x,
+ double *win_y,
+ GdkModifierType *mask);
+
G_END_DECLS
#endif /* __GDK_DEVICE_WINTAB_H__ */
diff --git a/gdk/win32/gdkdrag-win32.c b/gdk/win32/gdkdrag-win32.c
index 53a949b851..c21ac6a476 100644
--- a/gdk/win32/gdkdrag-win32.c
+++ b/gdk/win32/gdkdrag-win32.c
@@ -205,6 +205,7 @@
#include "gdk/gdkdragprivate.h"
#include "gdkwin32dnd-private.h"
#include "gdkdisplay-win32.h"
+#include "gdkdevice-win32.h"
#include "gdkdeviceprivate.h"
#include "gdkhdataoutputstream-win32.h"
@@ -1730,7 +1731,7 @@ _gdk_win32_surface_drag_begin (GdkSurface *surface,
GDK_NOTE (DND, g_print ("_gdk_win32_surface_drag_begin\n"));
- _gdk_device_query_state (device, NULL, NULL, &px, &py, NULL);
+ _gdk_device_win32_query_state (device, NULL, NULL, &px, &py, NULL);
x_root = round (px + dx);
y_root = round (py + dy);
@@ -2440,7 +2441,7 @@ gdk_dnd_handle_key_event (GdkDrag *drag,
/* The state is not yet updated in the event, so we need
* to query it here.
*/
- _gdk_device_query_state (pointer, NULL, NULL, NULL, NULL, &state);
+ _gdk_device_win32_query_state (pointer, NULL, NULL, NULL, NULL, &state);
if (dx != 0 || dy != 0)
{
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c
index 4078635148..33a279f8e1 100644
--- a/gdk/win32/gdksurface-win32.c
+++ b/gdk/win32/gdksurface-win32.c
@@ -1724,20 +1724,16 @@ gdk_win32_surface_get_root_coords (GdkSurface *window,
}
static gboolean
-gdk_surface_win32_get_device_state (GdkSurface *window,
- GdkDevice *device,
- double *x,
- double *y,
- GdkModifierType *mask)
+gdk_surface_win32_get_device_state (GdkSurface *window,
+ GdkDevice *device,
+ double *x,
+ double *y,
+ GdkModifierType *mask)
{
- GdkSurface *child;
+ _gdk_device_win32_query_state (device, window, NULL, x, y, mask);
- g_return_val_if_fail (window == NULL || GDK_IS_SURFACE (window), FALSE);
+ return *x >= 0 && *y >= 0 && *x < window->width && *y < window->height;
- GDK_DEVICE_GET_CLASS (device)->query_state (device, window,
- &child,
- x, y, mask);
- return (child != NULL);
}
static void
diff --git a/gdk/x11/gdkdevice-xi2-private.h b/gdk/x11/gdkdevice-xi2-private.h
new file mode 100644
index 0000000000..1ca4dc033d
--- /dev/null
+++ b/gdk/x11/gdkdevice-xi2-private.h
@@ -0,0 +1,9 @@
+#ifndef __GDK_DEVICE_XI2_PRIVATE_H__
+#define __GDK_DEVICE_XI2_PRIVATE_H__
+
+void gdk_x11_device_xi2_query_state (GdkDevice *device,
+ GdkSurface *surface,
+ double *win_x,
+ double *win_y,
+ GdkModifierType *mask);
+#endif
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index 0a239f2d8a..0102f65c7a 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -19,6 +19,7 @@
#include "gdkx11device-xi2.h"
#include "gdkdeviceprivate.h"
+#include "gdkdevice-xi2-private.h"
#include "gdkintl.h"
#include "gdkasync.h"
@@ -74,12 +75,6 @@ static void gdk_x11_device_xi2_set_property (GObject *object,
static void gdk_x11_device_xi2_set_surface_cursor (GdkDevice *device,
GdkSurface *surface,
GdkCursor *cursor);
-static void gdk_x11_device_xi2_query_state (GdkDevice *device,
- GdkSurface *surface,
- GdkSurface **child_surface,
- double *win_x,
- double *win_y,
- GdkModifierType *mask);
static GdkGrabStatus gdk_x11_device_xi2_grab (GdkDevice *device,
GdkSurface *surface,
@@ -113,7 +108,6 @@ gdk_x11_device_xi2_class_init (GdkX11DeviceXI2Class *klass)
object_class->set_property = gdk_x11_device_xi2_set_property;
device_class->set_surface_cursor = gdk_x11_device_xi2_set_surface_cursor;
- device_class->query_state = gdk_x11_device_xi2_query_state;
device_class->grab = gdk_x11_device_xi2_grab;
device_class->ungrab = gdk_x11_device_xi2_ungrab;
device_class->surface_at_position = gdk_x11_device_xi2_surface_at_position;
@@ -205,10 +199,9 @@ gdk_x11_device_xi2_set_surface_cursor (GdkDevice *device,
GDK_SURFACE_XID (surface));
}
-static void
+void
gdk_x11_device_xi2_query_state (GdkDevice *device,
GdkSurface *surface,
- GdkSurface **child_surface,
double *win_x,
double *win_y,
GdkModifierType *mask)
@@ -271,9 +264,6 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
XDestroyWindow (xdisplay, w);
}
- if (child_surface)
- *child_surface = gdk_x11_surface_lookup_for_display (display, xchild_window);
-
if (win_x)
*win_x = xwin_x / scale;
diff --git a/gdk/x11/gdkdrag-x11.c b/gdk/x11/gdkdrag-x11.c
index cc6afd9e90..639d62f194 100644
--- a/gdk/x11/gdkdrag-x11.c
+++ b/gdk/x11/gdkdrag-x11.c
@@ -31,6 +31,7 @@
#include "gdkclipboardprivate.h"
#include "gdkclipboard-x11.h"
#include "gdkdeviceprivate.h"
+#include "gdkdevice-xi2-private.h"
#include "gdkdisplay-x11.h"
#include "gdkdragprivate.h"
#include "gdksurfaceprivate.h"
@@ -2010,7 +2011,7 @@ _gdk_x11_surface_drag_begin (GdkSurface *surface,
precache_target_list (drag);
- _gdk_device_query_state (device, surface, NULL, &px, &py, NULL);
+ gdk_x11_device_xi2_query_state (device, surface, &px, &py, NULL);
gdk_x11_surface_get_root_coords (surface,
round (px + dx),
@@ -2270,7 +2271,7 @@ gdk_dnd_handle_key_event (GdkDrag *drag,
* to query it here. We could use XGetModifierMapping, but
* that would be overkill.
*/
- _gdk_device_query_state (pointer, NULL, NULL, NULL, NULL, &state);
+ gdk_x11_device_xi2_query_state (pointer, NULL, NULL, NULL, &state);
if (dx != 0 || dy != 0)
{
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index dc76c6544e..3e9d83ad24 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -34,6 +34,7 @@
#include "gdkvisual-x11.h"
#include "gdkinternals.h"
#include "gdkdeviceprivate.h"
+#include "gdkdevice-xi2-private.h"
#include "gdkframeclockidleprivate.h"
#include "gdkasync.h"
#include "gdkeventsource.h"
@@ -2658,22 +2659,18 @@ gdk_x11_surface_get_frame_extents (GdkSurface *surface,
}
static gboolean
-gdk_x11_surface_get_device_state (GdkSurface *surface,
- GdkDevice *device,
- double *x,
- double *y,
- GdkModifierType *mask)
+gdk_x11_surface_get_device_state (GdkSurface *surface,
+ GdkDevice *device,
+ double *x,
+ double *y,
+ GdkModifierType *mask)
{
- GdkSurface *child;
-
if (GDK_SURFACE_DESTROYED (surface))
return FALSE;
- /*HIDPI: handle coords here?*/
- GDK_DEVICE_GET_CLASS (device)->query_state (device, surface,
- &child,
- x, y, mask);
- return child != NULL;
+ gdk_x11_device_xi2_query_state (device, surface, x, y, mask);
+
+ return *x >= 0 && *y >= 0 && *x < surface->width && *y < surface->height;
}
static void