device: remove get_toplevel from surface_at_position vfunc
authorChristian Hergert <chergert@redhat.com>
Tue, 19 May 2020 19:00:32 +0000 (12:00 -0700)
committerChristian Hergert <chergert@redhat.com>
Tue, 19 May 2020 20:07:38 +0000 (13:07 -0700)
This is not used anymore now that surfaces are always toplevel in the
semantics of GdkWindow where child windows were available. We can drop
that and simplify the vfunc just a bit more.

Fixes #2765

gdk/broadway/gdkdevice-broadway.c
gdk/gdkdevice.c
gdk/gdkdeviceprivate.h
gdk/gdkdisplay.c
gdk/wayland/gdkdevice-wayland.c
gdk/win32/gdkdevice-win32.c
gdk/win32/gdkdevice-win32.h
gdk/win32/gdkdevice-wintab.c
gdk/x11/gdkdevice-xi2.c

index 837b48b4f0c9ea05da318c91f7b8d89be891afe8..a936d36d365abae53992f05fda05fb88c4300913 100644 (file)
@@ -54,8 +54,7 @@ static void          gdk_broadway_device_ungrab (GdkDevice     *device,
 static GdkSurface * gdk_broadway_device_surface_at_position (GdkDevice       *device,
                                                              gdouble         *win_x,
                                                              gdouble         *win_y,
-                                                             GdkModifierType *mask,
-                                                             gboolean         get_toplevel);
+                                                             GdkModifierType *mask);
 
 
 G_DEFINE_TYPE (GdkBroadwayDevice, gdk_broadway_device, GDK_TYPE_DEVICE)
@@ -292,8 +291,7 @@ static GdkSurface *
 gdk_broadway_device_surface_at_position (GdkDevice       *device,
                                          gdouble         *win_x,
                                          gdouble         *win_y,
-                                         GdkModifierType *mask,
-                                         gboolean         get_toplevel)
+                                         GdkModifierType *mask)
 {
   GdkSurface *surface = NULL;
 
index 907c53ce62ced6f9b39e15eea840966a77fc570b..8918ee50a3dda95f717748e1c5e02672086e7da5 100644 (file)
@@ -628,7 +628,7 @@ gdk_device_get_surface_at_position (GdkDevice *device,
   g_return_val_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_SLAVE ||
                         gdk_display_device_is_grabbed (gdk_device_get_display (device), device), NULL);
 
-  surface = _gdk_device_surface_at_position (device, &tmp_x, &tmp_y, NULL, FALSE);
+  surface = _gdk_device_surface_at_position (device, &tmp_x, &tmp_y, NULL);
 
   if (win_x)
     *win_x = tmp_x;
@@ -1588,17 +1588,15 @@ _gdk_device_query_state (GdkDevice        *device,
 }
 
 GdkSurface *
-_gdk_device_surface_at_position (GdkDevice        *device,
-                                gdouble          *win_x,
-                                gdouble          *win_y,
-                                GdkModifierType  *mask,
-                                gboolean          get_toplevel)
+_gdk_device_surface_at_position (GdkDevice       *device,
+                                 gdouble         *win_x,
+                                 gdouble         *win_y,
+                                 GdkModifierType *mask)
 {
   return GDK_DEVICE_GET_CLASS (device)->surface_at_position (device,
-                                                            win_x,
-                                                            win_y,
-                                                            mask,
-                                                            get_toplevel);
+                                                             win_x,
+                                                             win_y,
+                                                             mask);
 }
 
 /**
index ea6b3e1a5506e1951e82fe710207a2ad02467e53..55d4f0beef0a7be5f4b6e8ea2743b5918244affc 100644 (file)
@@ -105,8 +105,7 @@ struct _GdkDeviceClass
   GdkSurface * (* surface_at_position) (GdkDevice       *device,
                                         double          *win_x,
                                         double          *win_y,
-                                        GdkModifierType *mask,
-                                        gboolean         get_toplevel);
+                                        GdkModifierType *mask);
 };
 
 void  _gdk_device_set_associated_device (GdkDevice *device,
@@ -167,8 +166,7 @@ void _gdk_device_query_state                  (GdkDevice        *device,
 GdkSurface * _gdk_device_surface_at_position  (GdkDevice        *device,
                                                gdouble          *win_x,
                                                gdouble          *win_y,
-                                               GdkModifierType  *mask,
-                                               gboolean          get_toplevel);
+                                               GdkModifierType  *mask);
 
 void  gdk_device_set_seat  (GdkDevice *device,
                             GdkSeat   *seat);
index 0cbf1476c78190e41eb5ebb4251ae3acfd09edfd..2babfacf65353a5e824365eea7d9c7ad10a6587e 100644 (file)
@@ -589,7 +589,7 @@ get_current_toplevel (GdkDisplay      *display,
   gdouble x, y;
   GdkModifierType state;
 
-  pointer_surface = _gdk_device_surface_at_position (device, &x, &y, &state, TRUE);
+  pointer_surface = _gdk_device_surface_at_position (device, &x, &y, &state);
 
   if (pointer_surface != NULL &&
       GDK_SURFACE_DESTROYED (pointer_surface))
index 65e556abee257dfa57a2e24b7e9967c70a8881d1..c0708bc8afae2989b38389073dc269d16427802d 100644 (file)
@@ -802,10 +802,9 @@ gdk_wayland_device_ungrab (GdkDevice *device,
 
 static GdkSurface *
 gdk_wayland_device_surface_at_position (GdkDevice       *device,
-                                       gdouble         *win_x,
-                                       gdouble         *win_y,
-                                       GdkModifierType *mask,
-                                       gboolean         get_toplevel)
+                                        gdouble         *win_x,
+                                        gdouble         *win_y,
+                                        GdkModifierType *mask)
 {
   GdkWaylandPointerData *pointer;
 
index dffb8d8c7d7c25f59b15de548e40e92718478a51..588e624db3a9e2a31bc02f9bed4cfd5c254a3a05 100644 (file)
@@ -177,10 +177,9 @@ screen_to_client (HWND hwnd, POINT screen_pt, POINT *client_pt)
 
 GdkSurface *
 _gdk_device_win32_surface_at_position (GdkDevice       *device,
-                                      gdouble         *win_x,
-                                      gdouble         *win_y,
-                                      GdkModifierType *mask,
-                                      gboolean         get_toplevel)
+                                       gdouble         *win_x,
+                                       gdouble         *win_y,
+                                       GdkModifierType *mask)
 {
   GdkSurface *window = NULL;
   GdkWin32Surface *impl = NULL;
@@ -190,60 +189,33 @@ _gdk_device_win32_surface_at_position (GdkDevice       *device,
 
   GetCursorPos (&screen_pt);
 
-  if (get_toplevel)
-    {
-      /* Only consider visible children of the desktop to avoid the various
-       * non-visible windows you often find on a running Windows box. These
-       * might overlap our windows and cause our walk to fail. As we assume
-       * WindowFromPoint() can find our windows, we follow similar logic
-       * here, and ignore invisible and disabled windows.
-       */
-      hwnd = GetDesktopWindow ();
-      do {
-        window = gdk_win32_handle_table_lookup (hwnd);
-
-        if (window != NULL)
-          break;
-
-        screen_to_client (hwnd, screen_pt, &client_pt);
-        hwndc = ChildWindowFromPointEx (hwnd, client_pt, CWP_SKIPDISABLED  |
-                                                         CWP_SKIPINVISIBLE);
-
-       /* Verify that we're really inside the client area of the window */
-       if (hwndc != hwnd)
-         {
-           GetClientRect (hwndc, &rect);
-           screen_to_client (hwndc, screen_pt, &client_pt);
-           if (!PtInRect (&rect, client_pt))
-             hwndc = hwnd;
-         }
-
-      } while (hwndc != hwnd && (hwnd = hwndc, 1));
-
-    }
-  else
-    {
-      hwnd = WindowFromPoint (screen_pt);
-
-      /* Verify that we're really inside the client area of the window */
-      GetClientRect (hwnd, &rect);
-      screen_to_client (hwnd, screen_pt, &client_pt);
-      if (!PtInRect (&rect, client_pt))
-       hwnd = NULL;
-
-      /* If we didn't hit any window at that point, return the desktop */
-      if (hwnd == NULL)
-        {
-          if (win_x)
-            *win_x = screen_pt.x + _gdk_offset_x;
-          if (win_y)
-            *win_y = screen_pt.y + _gdk_offset_y;
-
-          return NULL;
-        }
-
-      window = gdk_win32_handle_table_lookup (hwnd);
-    }
+  /* Only consider visible children of the desktop to avoid the various
+   * non-visible windows you often find on a running Windows box. These
+   * might overlap our windows and cause our walk to fail. As we assume
+   * WindowFromPoint() can find our windows, we follow similar logic
+   * here, and ignore invisible and disabled windows.
+   */
+  hwnd = GetDesktopWindow ();
+  do {
+    window = gdk_win32_handle_table_lookup (hwnd);
+
+    if (window != NULL)
+      break;
+
+    screen_to_client (hwnd, screen_pt, &client_pt);
+    hwndc = ChildWindowFromPointEx (hwnd, client_pt, CWP_SKIPDISABLED  |
+                                                    CWP_SKIPINVISIBLE);
+
+    /* Verify that we're really inside the client area of the window */
+    if (hwndc != hwnd)
+      {
+       GetClientRect (hwndc, &rect);
+       screen_to_client (hwndc, screen_pt, &client_pt);
+       if (!PtInRect (&rect, client_pt))
+         hwndc = hwnd;
+      }
+
+  } while (hwndc != hwnd && (hwnd = hwndc, 1));
 
   if (window && (win_x || win_y))
     {
index ff2c94ce5b58b2c1932bae42f5eb94df423a2964..b59d775f9906a2ab2dc8f7285735fb6d42cfdf96 100644 (file)
@@ -45,10 +45,9 @@ struct _GdkDeviceWin32Class
 GType gdk_device_win32_get_type (void) G_GNUC_CONST;
 
 GdkSurface *_gdk_device_win32_surface_at_position (GdkDevice       *device,
-                                                 gdouble         *win_x,
-                                                 gdouble         *win_y,
-                                                 GdkModifierType *mask,
-                                                 gboolean         get_toplevel);
+                                                   gdouble         *win_x,
+                                                   gdouble         *win_y,
+                                                   GdkModifierType *mask);
 
 G_END_DECLS
 
index 5aed3e053a986cd92a12bef59031c6570b49e828..a05b56e2c46f6201c23da1971102e05e74652d5e 100644 (file)
@@ -188,10 +188,9 @@ gdk_device_wintab_ungrab (GdkDevice *device,
 
 static GdkSurface *
 gdk_device_wintab_surface_at_position (GdkDevice       *device,
-                                      gdouble         *win_x,
-                                      gdouble         *win_y,
-                                      GdkModifierType *mask,
-                                      gboolean         get_toplevel)
+                                       gdouble         *win_x,
+                                       gdouble         *win_y,
+                                       GdkModifierType *mask)
 {
   return NULL;
 }
index 8ec598f311d9076530c7c36e01e22435ef31f287..04cacfd9a2a873f47b7e49162653470018fbfe8f 100644 (file)
@@ -95,10 +95,9 @@ static void          gdk_x11_device_xi2_ungrab (GdkDevice     *device,
                                                 guint32        time_);
 
 static GdkSurface * gdk_x11_device_xi2_surface_at_position (GdkDevice       *device,
-                                                          gdouble         *win_x,
-                                                          gdouble         *win_y,
-                                                          GdkModifierType *mask,
-                                                          gboolean         get_toplevel);
+                                                            gdouble         *win_x,
+                                                            gdouble         *win_y,
+                                                            GdkModifierType *mask);
 
 
 enum {
@@ -448,10 +447,9 @@ gdk_x11_device_xi2_ungrab (GdkDevice *device,
 
 static GdkSurface *
 gdk_x11_device_xi2_surface_at_position (GdkDevice       *device,
-                                       gdouble         *win_x,
-                                       gdouble         *win_y,
-                                       GdkModifierType *mask,
-                                       gboolean         get_toplevel)
+                                        gdouble         *win_x,
+                                        gdouble         *win_y,
+                                        GdkModifierType *mask)
 {
   GdkX11Surface *impl;
   GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
@@ -587,7 +585,7 @@ gdk_x11_device_xi2_surface_at_position (GdkDevice       *device,
       if (!retval)
         break;
 
-      if (get_toplevel && last != root &&
+      if (last != root &&
           (surface = gdk_x11_surface_lookup_for_display (display, last)) != NULL)
         {
           xwindow = last;