[gtk+/wip/matthiasc/drop-root-window: 3/7] Allow passing a NULL window to gdk_device_query_state
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/drop-root-window: 3/7] Allow passing a NULL window to gdk_device_query_state
- Date: Wed, 9 Aug 2017 01:07:39 +0000 (UTC)
commit 3fbd86aaae7b2f4bb7e1c6872d28e65c01f820af
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Aug 8 19:45:09 2017 -0400
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.
gdk/broadway/gdkdevice-broadway.c | 19 +++++++++++--------
gdk/mir/gdkmirkeyboard.c | 1 -
gdk/mir/gdkmirpointer.c | 3 ---
gdk/quartz/gdkdevice-core-quartz.c | 4 +++-
gdk/wayland/gdkdevice-wayland.c | 3 +++
gdk/win32/gdkdevice-win32.c | 10 +++-------
gdk/win32/gdkdevice-wintab.c | 8 ++------
gdk/x11/gdkdevice-core-x11.c | 7 +++++--
gdk/x11/gdkdevice-xi2.c | 7 +++++--
9 files changed, 32 insertions(+), 30 deletions(-)
---
diff --git a/gdk/broadway/gdkdevice-broadway.c b/gdk/broadway/gdkdevice-broadway.c
index b3abec0..4a6bf68 100644
--- a/gdk/broadway/gdkdevice-broadway.c
+++ b/gdk/broadway/gdkdevice-broadway.c
@@ -149,14 +149,10 @@ gdk_broadway_device_query_state (GdkDevice *device,
gdouble *win_y,
GdkModifierType *mask)
{
- GdkWindow *toplevel;
- GdkWindowImplBroadway *impl;
GdkDisplay *display;
GdkBroadwayDisplay *broadway_display;
- GdkScreen *screen;
gint32 device_root_x, device_root_y;
guint32 mouse_toplevel_id;
- GdkWindow *mouse_toplevel;
guint32 mask32;
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);
broadway_display = GDK_BROADWAY_DISPLAY (display);
- impl = GDK_WINDOW_IMPL_BROADWAY (window->impl);
- toplevel = impl->wrapper;
-
_gdk_broadway_server_query_mouse (broadway_display->server,
&mouse_toplevel_id,
&device_root_x,
&device_root_y,
&mask32);
- mouse_toplevel = g_hash_table_lookup (broadway_display->id_ht, GUINT_TO_POINTER (mouse_toplevel_id));
if (root_x)
*root_x = device_root_x;
@@ -187,6 +179,17 @@ gdk_broadway_device_query_state (GdkDevice *device,
*mask = mask32;
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)
{
*child_window = mouse_toplevel;
diff --git a/gdk/mir/gdkmirkeyboard.c b/gdk/mir/gdkmirkeyboard.c
index 289473a..01a1411 100644
--- a/gdk/mir/gdkmirkeyboard.c
+++ b/gdk/mir/gdkmirkeyboard.c
@@ -94,7 +94,6 @@ gdk_mir_keyboard_warp (GdkDevice *device,
static void
gdk_mir_keyboard_query_state (GdkDevice *device,
GdkWindow *window,
- GdkWindow **root_window,
GdkWindow **child_window,
gdouble *root_x,
gdouble *root_y,
diff --git a/gdk/mir/gdkmirpointer.c b/gdk/mir/gdkmirpointer.c
index b550424..08afee8 100644
--- a/gdk/mir/gdkmirpointer.c
+++ b/gdk/mir/gdkmirpointer.c
@@ -133,7 +133,6 @@ gdk_mir_pointer_warp (GdkDevice *device,
static void
gdk_mir_pointer_query_state (GdkDevice *device,
GdkWindow *window,
- GdkWindow **root_window,
GdkWindow **child_window,
gdouble *root_x,
gdouble *root_y,
@@ -143,8 +142,6 @@ gdk_mir_pointer_query_state (GdkDevice *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)
*child_window = p->over_window;
if (root_x)
diff --git a/gdk/quartz/gdkdevice-core-quartz.c b/gdk/quartz/gdkdevice-core-quartz.c
index da85990..76f1152 100644
--- a/gdk/quartz/gdkdevice-core-quartz.c
+++ b/gdk/quartz/gdkdevice-core-quartz.c
@@ -258,7 +258,6 @@ gdk_quartz_device_core_query_state_helper (GdkWindow *window,
static void
gdk_quartz_device_core_query_state (GdkDevice *device,
GdkWindow *window,
- GdkWindow **root_window,
GdkWindow **child_window,
gdouble *root_x,
gdouble *root_y,
@@ -270,6 +269,9 @@ gdk_quartz_device_core_query_state (GdkDevice *device,
NSPoint point;
gint x_tmp, y_tmp;
+ if (window == NULL)
+ window = _gdk_root;
+
found_window = gdk_quartz_device_core_query_state_helper (window, device,
win_x, win_y,
mask);
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 664eebe..1bc142a 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -592,6 +592,9 @@ gdk_wayland_device_query_state (GdkDevice *device,
{
GdkWaylandPointerData *pointer;
+ if (window == NULL)
+ window = gdk_get_default_root_window ();
+
pointer = GDK_WAYLAND_DEVICE (device)->pointer;
if (child_window)
diff --git a/gdk/win32/gdkdevice-win32.c b/gdk/win32/gdkdevice-win32.c
index 190372d..fa74db6 100644
--- a/gdk/win32/gdkdevice-win32.c
+++ b/gdk/win32/gdkdevice-win32.c
@@ -100,7 +100,6 @@ get_current_mask (void)
static void
gdk_device_win32_query_state (GdkDevice *device,
GdkWindow *window,
- GdkWindow **root_window,
GdkWindow **child_window,
gdouble *root_x,
gdouble *root_y,
@@ -108,12 +107,12 @@ gdk_device_win32_query_state (GdkDevice *device,
gdouble *win_y,
GdkModifierType *mask)
{
- GdkScreen *screen;
POINT point;
HWND hwnd, hwndc;
GdkWindowImplWin32 *impl;
- screen = gdk_window_get_screen (window);
+ if (window == NULL)
+ window = gdk_get_default_root_window ();
impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
hwnd = GDK_WINDOW_HWND (window);
@@ -133,7 +132,7 @@ gdk_device_win32_query_state (GdkDevice *device,
if (win_y)
*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)
*win_x += _gdk_offset_x;
@@ -158,9 +157,6 @@ gdk_device_win32_query_state (GdkDevice *device,
*child_window = NULL; /* Direct child unknown to gdk */
}
- if (root_window)
- *root_window = gdk_screen_get_root_window (screen);
-
if (mask)
*mask = get_current_mask ();
}
diff --git a/gdk/win32/gdkdevice-wintab.c b/gdk/win32/gdkdevice-wintab.c
index 06037d8..6e11036 100644
--- a/gdk/win32/gdkdevice-wintab.c
+++ b/gdk/win32/gdkdevice-wintab.c
@@ -109,7 +109,6 @@ gdk_device_wintab_warp (GdkDevice *device,
static void
gdk_device_wintab_query_state (GdkDevice *device,
GdkWindow *window,
- GdkWindow **root_window,
GdkWindow **child_window,
gdouble *root_x,
gdouble *root_y,
@@ -118,13 +117,13 @@ gdk_device_wintab_query_state (GdkDevice *device,
GdkModifierType *mask)
{
GdkDeviceWintab *device_wintab;
- GdkScreen *screen;
POINT point;
HWND hwnd, hwndc;
GdkWindowImplWin32 *impl;
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);
hwnd = GDK_WINDOW_HWND (window);
@@ -163,9 +162,6 @@ gdk_device_wintab_query_state (GdkDevice *device,
*child_window = NULL; /* Direct child unknown to gdk */
}
- if (root_window)
- *root_window = gdk_screen_get_root_window (screen);
-
if (mask)
{
*mask = get_current_mask ();
diff --git a/gdk/x11/gdkdevice-core-x11.c b/gdk/x11/gdkdevice-core-x11.c
index 574a45b..e0d34ed 100644
--- a/gdk/x11/gdkdevice-core-x11.c
+++ b/gdk/x11/gdkdevice-core-x11.c
@@ -256,15 +256,18 @@ gdk_x11_device_core_query_state (GdkDevice *device,
gdouble *win_y,
GdkModifierType *mask)
{
- GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
+ GdkWindowImplX11 *impl;
GdkDisplay *display;
GdkScreen *default_screen;
Window xroot_window, xchild_window;
int xroot_x, xroot_y, xwin_x, xwin_y;
unsigned int xmask;
- display = gdk_window_get_display (window);
+ display = gdk_device_get_display (device);
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 ||
!XQueryPointer (GDK_WINDOW_XDISPLAY (window),
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index 6b22abb..23857a5 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -327,7 +327,7 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
gdouble *win_y,
GdkModifierType *mask)
{
- GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
+ GdkWindowImplX11 *impl;
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
GdkDisplay *display;
GdkScreen *default_screen;
@@ -337,8 +337,11 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
XIModifierState mod_state;
XIGroupState group_state;
- display = gdk_window_get_display (window);
+ display = gdk_device_get_display (device);
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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]