Allow passing a NULL window to gdk_device_query_state

Interpret NULL as "root window" here - we only have one
screen nowadays, so there is no choice involved, and this
will let us avoid dealing with the root window in the
fontend code.
This commit is contained in:
Matthias Clasen 2017-08-08 19:45:09 -04:00
parent c409fca703
commit 9859f8f69f
9 changed files with 32 additions and 30 deletions

View File

@ -149,14 +149,10 @@ gdk_broadway_device_query_state (GdkDevice *device,
gdouble *win_y, gdouble *win_y,
GdkModifierType *mask) GdkModifierType *mask)
{ {
GdkWindow *toplevel;
GdkWindowImplBroadway *impl;
GdkDisplay *display; GdkDisplay *display;
GdkBroadwayDisplay *broadway_display; GdkBroadwayDisplay *broadway_display;
GdkScreen *screen;
gint32 device_root_x, device_root_y; gint32 device_root_x, device_root_y;
guint32 mouse_toplevel_id; guint32 mouse_toplevel_id;
GdkWindow *mouse_toplevel;
guint32 mask32; guint32 mask32;
if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE) if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
@ -165,15 +161,11 @@ gdk_broadway_device_query_state (GdkDevice *device,
display = gdk_device_get_display (device); display = gdk_device_get_display (device);
broadway_display = GDK_BROADWAY_DISPLAY (display); broadway_display = GDK_BROADWAY_DISPLAY (display);
impl = GDK_WINDOW_IMPL_BROADWAY (window->impl);
toplevel = impl->wrapper;
_gdk_broadway_server_query_mouse (broadway_display->server, _gdk_broadway_server_query_mouse (broadway_display->server,
&mouse_toplevel_id, &mouse_toplevel_id,
&device_root_x, &device_root_x,
&device_root_y, &device_root_y,
&mask32); &mask32);
mouse_toplevel = g_hash_table_lookup (broadway_display->id_ht, GUINT_TO_POINTER (mouse_toplevel_id));
if (root_x) if (root_x)
*root_x = device_root_x; *root_x = device_root_x;
@ -187,6 +179,17 @@ gdk_broadway_device_query_state (GdkDevice *device,
*mask = mask32; *mask = mask32;
if (child_window) if (child_window)
{ {
GdkWindowImplBroadway *impl;
GdkWindow *toplevel;
GdkWindow *mouse_toplevel;
if (window == NULL)
window = gdk_get_default_root_window ();
impl = GDK_WINDOW_IMPL_BROADWAY (window->impl);
toplevel = impl->wrapper;
mouse_toplevel = g_hash_table_lookup (broadway_display->id_ht, GUINT_TO_POINTER (mouse_toplevel_id));
if (gdk_window_get_window_type (toplevel) == GDK_WINDOW_ROOT) if (gdk_window_get_window_type (toplevel) == GDK_WINDOW_ROOT)
{ {
*child_window = mouse_toplevel; *child_window = mouse_toplevel;

View File

@ -94,7 +94,6 @@ gdk_mir_keyboard_warp (GdkDevice *device,
static void static void
gdk_mir_keyboard_query_state (GdkDevice *device, gdk_mir_keyboard_query_state (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window, GdkWindow **child_window,
gdouble *root_x, gdouble *root_x,
gdouble *root_y, gdouble *root_y,

View File

@ -133,7 +133,6 @@ gdk_mir_pointer_warp (GdkDevice *device,
static void static void
gdk_mir_pointer_query_state (GdkDevice *device, gdk_mir_pointer_query_state (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window, GdkWindow **child_window,
gdouble *root_x, gdouble *root_x,
gdouble *root_y, gdouble *root_y,
@ -143,8 +142,6 @@ gdk_mir_pointer_query_state (GdkDevice *device,
{ {
GdkMirPointer *p = GDK_MIR_POINTER (device); GdkMirPointer *p = GDK_MIR_POINTER (device);
if (root_window)
*root_window = gdk_screen_get_root_window (gdk_display_get_default_screen (gdk_device_get_display (device)));
if (child_window) if (child_window)
*child_window = p->over_window; *child_window = p->over_window;
if (root_x) if (root_x)

View File

@ -258,7 +258,6 @@ gdk_quartz_device_core_query_state_helper (GdkWindow *window,
static void static void
gdk_quartz_device_core_query_state (GdkDevice *device, gdk_quartz_device_core_query_state (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window, GdkWindow **child_window,
gdouble *root_x, gdouble *root_x,
gdouble *root_y, gdouble *root_y,
@ -270,6 +269,9 @@ gdk_quartz_device_core_query_state (GdkDevice *device,
NSPoint point; NSPoint point;
gint x_tmp, y_tmp; gint x_tmp, y_tmp;
if (window == NULL)
window = _gdk_root;
found_window = gdk_quartz_device_core_query_state_helper (window, device, found_window = gdk_quartz_device_core_query_state_helper (window, device,
win_x, win_y, win_x, win_y,
mask); mask);

View File

@ -592,6 +592,9 @@ gdk_wayland_device_query_state (GdkDevice *device,
{ {
GdkWaylandPointerData *pointer; GdkWaylandPointerData *pointer;
if (window == NULL)
window = gdk_get_default_root_window ();
pointer = GDK_WAYLAND_DEVICE (device)->pointer; pointer = GDK_WAYLAND_DEVICE (device)->pointer;
if (child_window) if (child_window)

View File

@ -100,7 +100,6 @@ get_current_mask (void)
static void static void
gdk_device_win32_query_state (GdkDevice *device, gdk_device_win32_query_state (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window, GdkWindow **child_window,
gdouble *root_x, gdouble *root_x,
gdouble *root_y, gdouble *root_y,
@ -108,12 +107,12 @@ gdk_device_win32_query_state (GdkDevice *device,
gdouble *win_y, gdouble *win_y,
GdkModifierType *mask) GdkModifierType *mask)
{ {
GdkScreen *screen;
POINT point; POINT point;
HWND hwnd, hwndc; HWND hwnd, hwndc;
GdkWindowImplWin32 *impl; GdkWindowImplWin32 *impl;
screen = gdk_window_get_screen (window); if (window == NULL)
window = gdk_get_default_root_window ();
impl = GDK_WINDOW_IMPL_WIN32 (window->impl); impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
hwnd = GDK_WINDOW_HWND (window); hwnd = GDK_WINDOW_HWND (window);
@ -133,7 +132,7 @@ gdk_device_win32_query_state (GdkDevice *device,
if (win_y) if (win_y)
*win_y = point.y / impl->window_scale; *win_y = point.y / impl->window_scale;
if (window == gdk_screen_get_root_window (screen)) if (window == gdk_get_default_root_window ())
{ {
if (win_x) if (win_x)
*win_x += _gdk_offset_x; *win_x += _gdk_offset_x;
@ -158,9 +157,6 @@ gdk_device_win32_query_state (GdkDevice *device,
*child_window = NULL; /* Direct child unknown to gdk */ *child_window = NULL; /* Direct child unknown to gdk */
} }
if (root_window)
*root_window = gdk_screen_get_root_window (screen);
if (mask) if (mask)
*mask = get_current_mask (); *mask = get_current_mask ();
} }

View File

@ -109,7 +109,6 @@ gdk_device_wintab_warp (GdkDevice *device,
static void static void
gdk_device_wintab_query_state (GdkDevice *device, gdk_device_wintab_query_state (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window, GdkWindow **child_window,
gdouble *root_x, gdouble *root_x,
gdouble *root_y, gdouble *root_y,
@ -118,13 +117,13 @@ gdk_device_wintab_query_state (GdkDevice *device,
GdkModifierType *mask) GdkModifierType *mask)
{ {
GdkDeviceWintab *device_wintab; GdkDeviceWintab *device_wintab;
GdkScreen *screen;
POINT point; POINT point;
HWND hwnd, hwndc; HWND hwnd, hwndc;
GdkWindowImplWin32 *impl; GdkWindowImplWin32 *impl;
device_wintab = GDK_DEVICE_WINTAB (device); device_wintab = GDK_DEVICE_WINTAB (device);
screen = gdk_window_get_screen (window); if (window == NULL)
window = gdk_get_default_root_window ();
impl = GDK_WINDOW_IMPL_WIN32 (window->impl); impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
hwnd = GDK_WINDOW_HWND (window); hwnd = GDK_WINDOW_HWND (window);
@ -163,9 +162,6 @@ gdk_device_wintab_query_state (GdkDevice *device,
*child_window = NULL; /* Direct child unknown to gdk */ *child_window = NULL; /* Direct child unknown to gdk */
} }
if (root_window)
*root_window = gdk_screen_get_root_window (screen);
if (mask) if (mask)
{ {
*mask = get_current_mask (); *mask = get_current_mask ();

View File

@ -256,15 +256,18 @@ gdk_x11_device_core_query_state (GdkDevice *device,
gdouble *win_y, gdouble *win_y,
GdkModifierType *mask) GdkModifierType *mask)
{ {
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); GdkWindowImplX11 *impl;
GdkDisplay *display; GdkDisplay *display;
GdkScreen *default_screen; GdkScreen *default_screen;
Window xroot_window, xchild_window; Window xroot_window, xchild_window;
int xroot_x, xroot_y, xwin_x, xwin_y; int xroot_x, xroot_y, xwin_x, xwin_y;
unsigned int xmask; unsigned int xmask;
display = gdk_window_get_display (window); display = gdk_device_get_display (device);
default_screen = gdk_display_get_default_screen (display); default_screen = gdk_display_get_default_screen (display);
if (window == NULL)
window = gdk_screen_get_root_window (default_screen);
impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (!GDK_X11_DISPLAY (display)->trusted_client || if (!GDK_X11_DISPLAY (display)->trusted_client ||
!XQueryPointer (GDK_WINDOW_XDISPLAY (window), !XQueryPointer (GDK_WINDOW_XDISPLAY (window),

View File

@ -327,7 +327,7 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
gdouble *win_y, gdouble *win_y,
GdkModifierType *mask) GdkModifierType *mask)
{ {
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); GdkWindowImplX11 *impl;
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device); GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
GdkDisplay *display; GdkDisplay *display;
GdkScreen *default_screen; GdkScreen *default_screen;
@ -337,8 +337,11 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
XIModifierState mod_state; XIModifierState mod_state;
XIGroupState group_state; XIGroupState group_state;
display = gdk_window_get_display (window); display = gdk_device_get_display (device);
default_screen = gdk_display_get_default_screen (display); default_screen = gdk_display_get_default_screen (display);
if (window == NULL)
window = gdk_screen_get_root_window (default_screen);
impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_SLAVE) if (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_SLAVE)
{ {