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.
This commit is contained in:
Christian Hergert 2020-10-14 11:32:20 -07:00
parent d5b5410b8f
commit 9f01d4fe44

View File

@ -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