dnd: Drop GdkScreen from apis
authorMatthias Clasen <mclasen@redhat.com>
Tue, 31 Oct 2017 14:16:18 +0000 (10:16 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 31 Oct 2017 14:18:10 +0000 (10:18 -0400)
Drop the screen argument from gdk_dnd_find_window_for_screen
and rename the function to gdk_dnd_find_window. The screen
argument does not add anything here since the drag context
is already tied to the display. Update all backends, and
update all callers.

docs/reference/gdk/gdk4-sections.txt
gdk/broadway/gdkdnd-broadway.c
gdk/gdkdnd.c
gdk/gdkdnd.h
gdk/gdkdndprivate.h
gdk/quartz/gdkdnd-quartz.c
gdk/wayland/gdkdnd-wayland.c
gdk/win32/gdkdnd-win32.c
gdk/x11/gdkdnd-x11.c
gtk/gtkdnd.c

index a09df69f66407e5f59deae46bc5a2b034fba3a10..a0e544189a033a7bd8b8fe0d69bfc933abac7196 100644 (file)
@@ -898,7 +898,7 @@ gdk_drag_abort
 gdk_drop_reply
 gdk_drag_drop
 gdk_drag_drop_done
-gdk_drag_find_window_for_screen
+gdk_drag_find_window
 gdk_drag_begin
 gdk_drag_begin_for_device
 gdk_drag_begin_from_point
index 7c5fffeb6aea66d36de1c54b2ad4cdf004707102..46a82d484ccb26679d3b0a2fd0d5ed2e24482724 100644 (file)
@@ -113,7 +113,6 @@ _gdk_broadway_window_get_drag_protocol (GdkWindow *window,
 static GdkWindow *
 gdk_broadway_drag_context_find_window (GdkDragContext  *context,
                                       GdkWindow       *drag_window,
-                                      GdkScreen       *screen,
                                       gint             x_root,
                                       gint             y_root,
                                       GdkDragProtocol *protocol)
index f6cddd5a658e72124b23a07a2a7bc9244aa7953d..0d22e26ee144bbf0d103425542b6f64899d3ba53 100644 (file)
@@ -362,11 +362,10 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
 }
 
 /**
- * gdk_drag_find_window_for_screen:
+ * gdk_drag_find_window:
  * @context: a #GdkDragContext
  * @drag_window: a window which may be at the pointer position, but
  *     should be ignored, since it is put up by the drag source as an icon
- * @screen: the screen where the destination window is sought
  * @x_root: the x position of the pointer in root coordinates
  * @y_root: the y position of the pointer in root coordinates
  * @dest_window: (out): location to store the destination window in
@@ -381,18 +380,17 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
  * Since: 2.2
  */
 void
-gdk_drag_find_window_for_screen (GdkDragContext  *context,
-                                 GdkWindow       *drag_window,
-                                 GdkScreen       *screen,
-                                 gint             x_root,
-                                 gint             y_root,
-                                 GdkWindow      **dest_window,
-                                 GdkDragProtocol *protocol)
+gdk_drag_find_window (GdkDragContext  *context,
+                      GdkWindow       *drag_window,
+                      gint             x_root,
+                      gint             y_root,
+                      GdkWindow      **dest_window,
+                      GdkDragProtocol *protocol)
 {
   g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
 
   *dest_window = GDK_DRAG_CONTEXT_GET_CLASS (context)
-      ->find_window (context, drag_window, screen, x_root, y_root, protocol);
+      ->find_window (context, drag_window, x_root, y_root, protocol);
 }
 
 /**
index f86079c7db7f35a01d98acebcc511d465bed239f..a8b62668c20c46a626fa8233795fd9fc36e9c774 100644 (file)
@@ -168,13 +168,12 @@ GdkDragContext * gdk_drag_begin_from_point  (GdkWindow      *window,
                                              gint            y_root);
 
 GDK_AVAILABLE_IN_ALL
-void    gdk_drag_find_window_for_screen   (GdkDragContext   *context,
-                                           GdkWindow        *drag_window,
-                                           GdkScreen        *screen,
-                                           gint              x_root,
-                                           gint              y_root,
-                                           GdkWindow       **dest_window,
-                                           GdkDragProtocol  *protocol);
+void    gdk_drag_find_window (GdkDragContext   *context,
+                              GdkWindow        *drag_window,
+                              gint              x_root,
+                              gint              y_root,
+                              GdkWindow       **dest_window,
+                              GdkDragProtocol  *protocol);
 
 GDK_AVAILABLE_IN_ALL
 gboolean        gdk_drag_motion      (GdkDragContext *context,
index d37ec67ab72ce927db7ab510998c66b8e34e06ec..ad2b507bcf2b85df54ca0a333c4a90fe204fbcf2 100644 (file)
@@ -35,7 +35,6 @@ struct _GdkDragContextClass {
 
   GdkWindow * (*find_window)   (GdkDragContext  *context,
                                 GdkWindow       *drag_window,
-                                GdkScreen       *screen,
                                 gint             x_root,
                                 gint             y_root,
                                 GdkDragProtocol *protocol);
index 15b6fed3191c97cc3df461d530cb14f4ccbbac28..ac2beb9fa16daf0aa53e07eeb15936df3e629493 100644 (file)
@@ -74,7 +74,6 @@ gdk_quartz_drag_context_drag_motion (GdkDragContext  *context,
 static GdkWindow *
 gdk_quartz_drag_context_find_window (GdkDragContext  *context,
                                      GdkWindow       *drag_window,
-                                     GdkScreen       *screen,
                                      gint             x_root,
                                      gint             y_root,
                                      GdkDragProtocol *protocol)
index 23fd8baee3bff50900aeb4a7f20bb6700e33a5c2..16b8f82c868a1df26cfe548fc8436aeeee1c5042 100644 (file)
@@ -140,7 +140,6 @@ _gdk_wayland_drag_context_emit_event (GdkDragContext *context,
 static GdkWindow *
 gdk_wayland_drag_context_find_window (GdkDragContext  *context,
                                      GdkWindow       *drag_window,
-                                     GdkScreen       *screen,
                                      gint             x_root,
                                      gint             y_root,
                                      GdkDragProtocol *protocol)
index f1e9ef545145c1317cf0b42c1469bc9f74a6345b..eded6aa40da54f2c577af230694511d3bf219aa7 100644 (file)
@@ -2013,7 +2013,6 @@ find_window_enum_proc (HWND   hwnd,
 static GdkWindow *
 gdk_win32_drag_context_find_window (GdkDragContext  *context,
                                    GdkWindow       *drag_window,
-                                   GdkScreen       *screen,
                                    gint             x_root,
                                    gint             y_root,
                                    GdkDragProtocol *protocol)
@@ -2039,7 +2038,7 @@ gdk_win32_drag_context_find_window (GdkDragContext  *context,
           g_object_ref (dest_window);
         }
       else
-        dest_window = gdk_win32_window_foreign_new_for_display (gdk_screen_get_display (screen), a.result);
+        dest_window = gdk_win32_window_foreign_new_for_display (context->display, a.result);
 
       if (use_ole2_dnd)
         *protocol = GDK_DRAG_PROTO_OLE2;
index 11585dd930d793e62b885792ed749d9516cd3b42..7a9a69e6c9c47af7c3e32754f4ad853dbcd516f6 100644 (file)
@@ -65,7 +65,7 @@ typedef struct {
   GList *children;
   GHashTable *child_hash;
   guint old_event_mask;
-  GdkScreen *screen;
+  GdkDisplay *display;
   gint ref_count;
 } GdkWindowCache;
 
@@ -83,7 +83,7 @@ struct _GdkX11DragContext
   GdkDragAction xdnd_actions;  /* What is currently set in XdndActionList */
   guint version;               /* Xdnd protocol version */
 
-  GSList *window_caches;
+  GdkWindowCache *cache;
 
   GdkWindow *drag_window;
 
@@ -141,7 +141,7 @@ static GrabKey grab_keys[] = {
 
 /* Forward declarations */
 
-static GdkWindowCache *gdk_window_cache_get   (GdkScreen      *screen);
+static GdkWindowCache *gdk_window_cache_get   (GdkDisplay *display);
 static GdkWindowCache *gdk_window_cache_ref   (GdkWindowCache *cache);
 static void            gdk_window_cache_unref (GdkWindowCache *cache);
 
@@ -200,7 +200,6 @@ gdk_x11_drag_context_init (GdkX11DragContext *context)
 static void        gdk_x11_drag_context_finalize (GObject *object);
 static GdkWindow * gdk_x11_drag_context_find_window (GdkDragContext  *context,
                                                      GdkWindow       *drag_window,
-                                                     GdkScreen       *screen,
                                                      gint             x_root,
                                                      gint             y_root,
                                                      GdkDragProtocol *protocol);
@@ -284,8 +283,8 @@ gdk_x11_drag_context_finalize (GObject *object)
         xdnd_manage_source_filter (context, context->source_window, FALSE);
     }
 
-  g_slist_free_full (x11_context->window_caches, (GDestroyNotify)gdk_window_cache_unref);
-  x11_context->window_caches = NULL;
+  if (x11_context->cache)
+    gdk_window_cache_unref (x11_context->cache);
 
   contexts = g_list_remove (contexts, context);
 
@@ -411,7 +410,7 @@ gdk_window_cache_shape_filter (GdkXEvent *xev,
   XEvent *xevent = (XEvent *)xev;
   GdkWindowCache *cache = data;
 
-  GdkX11Display *display = GDK_X11_DISPLAY (gdk_screen_get_display (cache->screen));
+  GdkX11Display *display = GDK_X11_DISPLAY (cache->display);
 
   if (display->have_shapes &&
       xevent->type == display->shape_event_base + ShapeNotify)
@@ -560,9 +559,10 @@ gdk_window_cache_filter (GdkXEvent *xev,
 }
 
 static GdkWindowCache *
-gdk_window_cache_new (GdkScreen *screen)
+gdk_window_cache_new (GdkDisplay *display)
 {
   XWindowAttributes xwa;
+  GdkScreen *screen = gdk_display_get_default_screen (display);
   Display *xdisplay = GDK_SCREEN_XDISPLAY (screen);
   GdkWindow *root_window = gdk_screen_get_root_window (screen);
   GdkChildInfoX11 *children;
@@ -575,7 +575,7 @@ gdk_window_cache_new (GdkScreen *screen)
 
   result->children = NULL;
   result->child_hash = g_hash_table_new (g_direct_hash, NULL);
-  result->screen = screen;
+  result->display = display;
   result->ref_count = 1;
 
   XGetWindowAttributes (xdisplay, GDK_WINDOW_XID (root_window), &xwa);
@@ -649,8 +649,7 @@ gdk_window_cache_new (GdkScreen *screen)
 static void
 gdk_window_cache_destroy (GdkWindowCache *cache)
 {
-  GdkWindow *root_window = gdk_screen_get_root_window (cache->screen);
-  GdkDisplay *display;
+  GdkWindow *root_window = gdk_screen_get_root_window (gdk_display_get_default_screen (cache->display));
 
   XSelectInput (GDK_WINDOW_XDISPLAY (root_window),
                 GDK_WINDOW_XID (root_window),
@@ -658,11 +657,9 @@ gdk_window_cache_destroy (GdkWindowCache *cache)
   gdk_window_remove_filter (root_window, gdk_window_cache_filter, cache);
   gdk_window_remove_filter (NULL, gdk_window_cache_shape_filter, cache);
 
-  display = gdk_screen_get_display (cache->screen);
-
-  gdk_x11_display_error_trap_push (display);
-  g_list_foreach (cache->children, (GFunc)free_cache_child, display);
-  gdk_x11_display_error_trap_pop_ignored (display);
+  gdk_x11_display_error_trap_push (cache->display);
+  g_list_foreach (cache->children, (GFunc)free_cache_child, cache->display);
+  gdk_x11_display_error_trap_pop_ignored (cache->display);
 
   g_list_free (cache->children);
   g_hash_table_destroy (cache->child_hash);
@@ -693,7 +690,7 @@ gdk_window_cache_unref (GdkWindowCache *cache)
 }
 
 GdkWindowCache *
-gdk_window_cache_get (GdkScreen *screen)
+gdk_window_cache_get (GdkDisplay *display)
 {
   GSList *list;
   GdkWindowCache *cache;
@@ -701,11 +698,11 @@ gdk_window_cache_get (GdkScreen *screen)
   for (list = window_caches; list; list = list->next)
     {
       cache = list->data;
-      if (cache->screen == screen)
+      if (cache->display == display)
         return gdk_window_cache_ref (cache);
     }
 
-  cache = gdk_window_cache_new (screen);
+  cache = gdk_window_cache_new (display);
 
   window_caches = g_slist_prepend (window_caches, cache);
 
@@ -822,7 +819,7 @@ get_client_window_at_coords (GdkWindowCache *cache,
   Window retval = None;
   GdkDisplay *display;
 
-  display = gdk_screen_get_display (cache->screen);
+  display = cache->display;
 
   gdk_x11_display_error_trap_push (display);
 
@@ -861,7 +858,7 @@ get_client_window_at_coords (GdkWindowCache *cache,
   if (retval)
     return retval;
   else
-    return GDK_WINDOW_XID (gdk_screen_get_root_window (cache->screen));
+    return GDK_WINDOW_XID (gdk_screen_get_root_window (gdk_display_get_default_screen (cache->display)));
 }
 
 #ifdef G_ENABLE_DEBUG
@@ -2099,33 +2096,22 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay      *display,
 
 static GdkWindowCache *
 drag_context_find_window_cache (GdkX11DragContext *context_x11,
-                                GdkScreen         *screen)
+                                GdkDisplay        *display)
 {
-  GSList *list;
-  GdkWindowCache *cache;
+  if (!context_x11->cache)
+    context_x11->cache = gdk_window_cache_get (display);
 
-  for (list = context_x11->window_caches; list; list = list->next)
-    {
-      cache = list->data;
-      if (cache->screen == screen)
-        return cache;
-    }
-
-  cache = gdk_window_cache_get (screen);
-  context_x11->window_caches = g_slist_prepend (context_x11->window_caches, cache);
-
-  return cache;
+  return context_x11->cache;
 }
 
 static GdkWindow *
 gdk_x11_drag_context_find_window (GdkDragContext  *context,
                                   GdkWindow       *drag_window,
-                                  GdkScreen       *screen,
                                   gint             x_root,
                                   gint             y_root,
                                   GdkDragProtocol *protocol)
 {
-  GdkX11Screen *screen_x11 = GDK_X11_SCREEN(screen);
+  GdkX11Screen *screen_x11 = GDK_X11_SCREEN(gdk_display_get_default_screen (context->display));
   GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context);
   GdkWindowCache *window_cache;
   GdkDisplay *display;
@@ -2134,7 +2120,7 @@ gdk_x11_drag_context_find_window (GdkDragContext  *context,
 
   display = GDK_WINDOW_DISPLAY (context->source_window);
 
-  window_cache = drag_context_find_window_cache (context_x11, screen);
+  window_cache = drag_context_find_window_cache (context_x11, display);
 
   dest = get_client_window_at_coords (window_cache,
                                       drag_window && GDK_WINDOW_IS_X11 (drag_window) ?
@@ -2215,10 +2201,10 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context,
     {
       /* This ugly hack is necessary since GTK+ doesn't know about
        * the XDND protocol version, and in particular doesn't know
-       * that gdk_drag_find_window_for_screen() has the side-effect
+       * that gdk_drag_find_window() has the side-effect
        * of setting context_x11->version, and therefore sometimes call
        * gdk_drag_motion() without a prior call to
-       * gdk_drag_find_window_for_screen(). This happens, e.g.
+       * gdk_drag_find_window(). This happens, e.g.
        * when GTK+ is proxying DND events to embedded windows.
        */
       if (dest_window)
@@ -2955,10 +2941,9 @@ gdk_drag_update (GdkDragContext  *context,
   gdk_drag_get_current_actions (mods, GDK_BUTTON_PRIMARY, x11_context->actions,
                                 &action, &possible_actions);
 
-  gdk_drag_find_window_for_screen (context,
-                                   x11_context->drag_window,
-                                   gdk_display_get_default_screen (gdk_display_get_default ()),
-                                   x_root, y_root, &dest_window, &protocol);
+  gdk_drag_find_window (context,
+                        x11_context->drag_window,
+                        x_root, y_root, &dest_window, &protocol);
 
   gdk_drag_motion (context, dest_window, protocol, x_root, y_root,
                    action, possible_actions, evtime);
index 0992347d14ea77645941c99ee4f56273312e80d8..4986beaa57455f6eb9b1bf92b2c367b66b1b587a 100644 (file)
@@ -2077,15 +2077,15 @@ gtk_drag_update_idle (gpointer data)
     {
       time = gdk_event_get_time (info->last_event);
       gtk_drag_get_event_actions (info->last_event,
-                                  info->button, 
+                                  info->button,
                                   info->possible_actions,
                                   &action, &possible_actions);
 
       gtk_drag_update_icon_window (info);
-      gdk_drag_find_window_for_screen (info->context,
-                                       info->icon_window ? gtk_widget_get_window (info->icon_window) : NULL,
-                                       info->cur_screen, info->cur_x, info->cur_y,
-                                       &dest_window, &protocol);
+      gdk_drag_find_window (info->context,
+                            info->icon_window ? gtk_widget_get_window (info->icon_window) : NULL,
+                            info->cur_x, info->cur_y,
+                            &dest_window, &protocol);
       
       if (!gdk_drag_motion (info->context, dest_window, protocol,
                             info->cur_x, info->cur_y, action,