[gtk/wip/chergert/gdk-macos-fixes: 3/3] macos: fix coordinates and state when querying device
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/gdk-macos-fixes: 3/3] macos: fix coordinates and state when querying device
- Date: Wed, 14 Oct 2020 18:34:50 +0000 (UTC)
commit 9f01d4fe4405cfed733528d9765cd0ff8c9f56e1
Author: Christian Hergert <chergert redhat com>
Date: Wed Oct 14 11:32:20 2020 -0700
macos: fix coordinates and state when querying device
When querying a device, we need to ensure we are providing coordinates
in the coordinate system of the surface. Further, we need to actually
provide the button and keyboard state.
This fixes some issues related to dragging scrollbars and selecting list
box rows more reliably.
gdk/macos/gdkmacossurface.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c
index 8139d2c84d..4b8fedcaf4 100644
--- a/gdk/macos/gdkmacossurface.c
+++ b/gdk/macos/gdkmacossurface.c
@@ -238,8 +238,6 @@ gdk_macos_surface_get_device_state (GdkSurface *surface,
GdkDisplay *display;
NSWindow *nswindow;
NSPoint point;
- int x_tmp;
- int y_tmp;
g_assert (GDK_IS_MACOS_SURFACE (surface));
g_assert (GDK_IS_MACOS_DEVICE (device));
@@ -247,18 +245,20 @@ gdk_macos_surface_get_device_state (GdkSurface *surface,
g_assert (y != NULL);
g_assert (mask != NULL);
+ if (GDK_SURFACE_DESTROYED (surface))
+ return FALSE;
+
display = gdk_surface_get_display (surface);
nswindow = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (surface));
point = [nswindow mouseLocationOutsideOfEventStream];
- _gdk_macos_display_from_display_coords (GDK_MACOS_DISPLAY (display),
- point.x, point.y,
- &x_tmp, &y_tmp);
+ *mask = _gdk_macos_display_get_current_keyboard_modifiers (GDK_MACOS_DISPLAY (display))
+ | _gdk_macos_display_get_current_mouse_modifiers (GDK_MACOS_DISPLAY (display));
- *x = x_tmp;
- *y = x_tmp;
+ *x = point.x;
+ *y = point.y - surface->height;
- return TRUE;
+ return *x >= 0 && *y >= 0 && *x < surface->width && *y < surface->height;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]