[gtk+] API: gdk: Change get_drag_window() API



commit 44c02fcbb19da4a270622cdd73ed85f19c9f8fbe
Author: Benjamin Otte <otte redhat com>
Date:   Tue Feb 1 18:11:35 2011 +0100

    API: gdk: Change get_drag_window() API
    
    The previous function gdk_drag_get_protocol_for_display() took native
    window handles, so it had to be changed. Because it didn't do what it
    was named to do (it didn't return a protocol even though it was named
    get_protocol) and because it doesn't operate on the display anymore but
    on the actual window, it's now called gdk_window_get_drag_protocol().

 docs/reference/gdk/gdk3-sections.txt |    2 +-
 gdk/gdk.symbols                      |    2 +-
 gdk/gdkdisplay.c                     |   22 ----------------------
 gdk/gdkdisplayprivate.h              |    4 ----
 gdk/gdkdnd.h                         |    4 ----
 gdk/gdkwindow.c                      |   22 ++++++++++++++++++++++
 gdk/gdkwindow.h                      |    4 ++++
 gdk/gdkwindowimpl.h                  |    2 ++
 gdk/x11/gdkdisplay-x11.c             |    8 --------
 gdk/x11/gdkprivate-x11.h             |    6 ++++++
 gdk/x11/gdkwindow-x11.c              |   27 +++++++++++++++++++++++++++
 gtk/gtksocket.c                      |    8 ++++----
 12 files changed, 67 insertions(+), 44 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index 846eeaa..574977d 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -882,11 +882,11 @@ gdk_drag_begin
 gdk_drag_begin_for_device
 gdk_drag_motion
 gdk_drop_finish
-gdk_drag_get_protocol_for_display
 GdkDragProtocol
 GdkDragAction
 gdk_drag_status
 gdk_drag_drop_succeeded
+gdk_window_get_drag_protocol
 
 gdk_drag_context_get_actions
 gdk_drag_context_get_suggested_action
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index bf7210c..b159b1c 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -143,7 +143,6 @@ gdk_drag_context_set_device
 gdk_drag_drop
 gdk_drag_drop_succeeded
 gdk_drag_find_window_for_screen
-gdk_drag_get_protocol_for_display
 gdk_drag_get_selection
 gdk_drag_motion
 gdk_drag_protocol_get_type G_GNUC_CONST
@@ -390,6 +389,7 @@ gdk_window_get_device_cursor
 gdk_window_get_device_events
 gdk_window_get_device_position
 gdk_window_get_display
+gdk_window_get_drag_protocol
 gdk_window_get_effective_parent
 gdk_window_get_effective_toplevel
 gdk_window_get_events
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index 4caadef..e4b518e 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -1664,28 +1664,6 @@ gdk_display_get_app_launch_context (GdkDisplay *display)
 }
 
 /**
- * gdk_drag_get_protocol_for_display:
- * @display: the #GdkDisplay where the destination window resides
- * @xid: the windowing system id of the destination window.
- * @protocol: (out): location where the supported DND protocol is returned.
- *
- * Finds out the DND protocol supported by a window.
- *
- * Return value: the windowing system id of the window where the drop
- *    should happen. This may be @xid or the id of a proxy window,
- *    or zero if @xid does not support Drag and Drop.
- *
- * Since: 2.2
- */
-GdkNativeWindow
-gdk_drag_get_protocol_for_display (GdkDisplay      *display,
-                                   GdkNativeWindow  xid,
-                                   GdkDragProtocol *protocol)
-{
-  return GDK_DISPLAY_GET_CLASS (display)->get_drag_protocol (display, xid, protocol, NULL);
-}
-
-/**
  * gdk_display_open:
  * @display_name: the name of the display to open
  *
diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h
index 7f7259a..1126d96 100644
--- a/gdk/gdkdisplayprivate.h
+++ b/gdk/gdkdisplayprivate.h
@@ -164,10 +164,6 @@ struct _GdkDisplayClass
 
   GList *                    (*list_devices)       (GdkDisplay *display);
   GdkAppLaunchContext *      (*get_app_launch_context) (GdkDisplay *display);
-  GdkNativeWindow            (*get_drag_protocol)      (GdkDisplay      *display,
-                                                        GdkNativeWindow  winid,
-                                                        GdkDragProtocol *protocol,
-                                                        guint           *version);
 
   void                       (*before_process_all_updates) (GdkDisplay *display);
   void                       (*after_process_all_updates)  (GdkDisplay *display);
diff --git a/gdk/gdkdnd.h b/gdk/gdkdnd.h
index 5840569..85f9305 100644
--- a/gdk/gdkdnd.h
+++ b/gdk/gdkdnd.h
@@ -128,10 +128,6 @@ GdkDragContext * gdk_drag_begin_for_device (GdkWindow      *window,
                                             GdkDevice      *device,
                                             GList          *targets);
 
-GdkNativeWindow gdk_drag_get_protocol_for_display (GdkDisplay       *display,
-                                                   GdkNativeWindow   xid,
-                                                   GdkDragProtocol  *protocol);
-
 void    gdk_drag_find_window_for_screen   (GdkDragContext   *context,
                                            GdkWindow        *drag_window,
                                            GdkScreen        *screen,
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 019b0ea..5b1d43f 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -10658,6 +10658,28 @@ gdk_window_register_dnd (GdkWindow *window)
 }
 
 /**
+ * gdk_window_get_drag_protocol:
+ * @window: the destination window
+ * @target: (out) (allow-none) (transfer full): location of the window
+ *    where the drop should happen. This may be @window or a proxy window,
+ *    or %NULL if @window does not support Drag and Drop.
+ *
+ * Finds out the DND protocol supported by a window.
+ *
+ * Returns: the supported DND protocol.
+ *
+ * Since: 3.0
+ */
+GdkDragProtocol
+gdk_window_get_drag_protocol (GdkWindow  *window,
+                              GdkWindow **target)
+{
+  g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_DRAG_PROTO_NONE);
+
+  return GDK_WINDOW_IMPL_GET_CLASS (window->impl)->get_drag_protocol (window, target);
+}
+
+/**
  * gdk_drag_begin:
  * @window: the source window for this drag.
  * @targets: (transfer none) (element-type GdkAtom): the offered targets,
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index 1cac906..b400ee4 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -780,6 +780,10 @@ void          gdk_window_set_opacity     (GdkWindow       *window,
                                           gdouble          opacity);
 void          gdk_window_register_dnd    (GdkWindow       *window);
 
+GdkDragProtocol
+              gdk_window_get_drag_protocol(GdkWindow      *window,
+                                          GdkWindow      **target);
+
 void gdk_window_begin_resize_drag (GdkWindow     *window,
                                    GdkWindowEdge  edge,
                                    gint           button,
diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h
index fd9add2..e088813 100644
--- a/gdk/gdkwindowimpl.h
+++ b/gdk/gdkwindowimpl.h
@@ -248,6 +248,8 @@ struct _GdkWindowImplClass
   void         (* set_composited)       (GdkWindow *window,
                                          gboolean   composited);
   void         (* destroy_notify)       (GdkWindow *window);
+  GdkDragProtocol (* get_drag_protocol) (GdkWindow *window,
+                                         GdkWindow **target);
   void         (* register_dnd)         (GdkWindow *window);
   GdkDragContext * (*drag_begin)        (GdkWindow *window,
                                          GdkDevice *device,
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 2e30695..2cf17ca 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -2556,13 +2556,6 @@ gdk_x11_display_error_trap_pop_ignored (GdkDisplay *display)
   gdk_x11_display_error_trap_pop_internal (display, FALSE);
 }
 
-extern GdkAppLaunchContext *_gdk_x11_display_get_app_launch_context (GdkDisplay *display);
-extern GdkNativeWindow      _gdk_x11_display_get_drag_protocol      (GdkDisplay *display,
-                                                                     GdkNativeWindow  xid,
-                                                                     GdkDragProtocol *protocol,
-                                                                     guint           *version);
-
-
 /**
  * gdk_x11_set_sm_client_id:
  * @sm_client_id: the client id assigned by the session manager when the
@@ -2665,7 +2658,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
   display_class->supports_composite = gdk_x11_display_supports_composite;
   display_class->list_devices = gdk_x11_display_list_devices;
   display_class->get_app_launch_context = _gdk_x11_display_get_app_launch_context;
-  display_class->get_drag_protocol = _gdk_x11_display_get_drag_protocol;
   display_class->get_cursor_for_type = _gdk_x11_display_get_cursor_for_type;
   display_class->get_cursor_for_name = _gdk_x11_display_get_cursor_for_name;
   display_class->get_cursor_for_pixbuf = _gdk_x11_display_get_cursor_for_pixbuf;
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 36e340f..bac0b13 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -182,6 +182,12 @@ void _gdk_x11_display_update_grab_info_ungrab (GdkDisplay *display,
 void _gdk_x11_display_queue_events            (GdkDisplay *display);
 
 
+GdkAppLaunchContext *_gdk_x11_display_get_app_launch_context (GdkDisplay *display);
+GdkNativeWindow      _gdk_x11_display_get_drag_protocol      (GdkDisplay *display,
+                                                              GdkNativeWindow  xid,
+                                                              GdkDragProtocol *protocol,
+                                                              guint           *version);
+
 gboolean    _gdk_x11_display_set_selection_owner   (GdkDisplay *display,
                                                     GdkWindow  *owner,
                                                     GdkAtom     selection,
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 4f2d2e9..dd42088 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -1108,6 +1108,32 @@ gdk_x11_window_destroy_notify (GdkWindow *window)
   g_object_unref (window);
 }
 
+static GdkDragProtocol
+gdk_x11_window_get_drag_protocol (GdkWindow *window,
+                                  GdkWindow **target)
+{
+  GdkDragProtocol protocol;
+  GdkDisplay *display;
+  guint version;
+  Window xid;
+
+  display = gdk_window_get_display (window);
+  xid = _gdk_x11_display_get_drag_protocol (display,
+                                            GDK_WINDOW_XID (window->impl_window),
+                                            &protocol,
+                                            &version);
+
+  if (target)
+    {
+      if (xid != None)
+        *target = gdk_x11_window_foreign_new_for_display (display, xid);
+      else
+        *target = NULL;
+    }
+
+  return protocol;
+}
+
 static void
 update_wm_hints (GdkWindow *window,
 		 gboolean   force)
@@ -4779,6 +4805,7 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
   impl_class->set_opacity = gdk_x11_window_set_opacity;
   impl_class->set_composited = gdk_x11_window_set_composited;
   impl_class->destroy_notify = gdk_x11_window_destroy_notify;
+  impl_class->get_drag_protocol = gdk_x11_window_get_drag_protocol;
   impl_class->register_dnd = _gdk_x11_window_register_dnd;
   impl_class->drag_begin = _gdk_x11_window_drag_begin;
   impl_class->process_updates_recurse = gdk_x11_window_process_updates_recurse;
diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c
index 174ea93..d88f756 100644
--- a/gtk/gtksocket.c
+++ b/gtk/gtksocket.c
@@ -1112,7 +1112,8 @@ gtk_socket_add_window (GtkSocket       *socket,
 
       private->need_map = private->is_mapped;
 
-      if (gdk_drag_get_protocol_for_display (display, xid, &protocol))
+      protocol = gdk_window_get_drag_protocol (private->plug_window, NULL);
+      if (protocol)
 	gtk_drag_dest_set_proxy (GTK_WIDGET (socket), private->plug_window,
 				 protocol, TRUE);
 
@@ -1524,9 +1525,8 @@ gtk_socket_filter_func (GdkXEvent *gdk_xevent,
 	      (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_RECEIVER_INFO")))
 	    {
 	      gdk_error_trap_push ();
-	      if (gdk_drag_get_protocol_for_display (display,
-						     xevent->xproperty.window,
-						     &protocol))
+              protocol = gdk_window_get_drag_protocol (private->plug_window, NULL);
+              if (protocol)
 		gtk_drag_dest_set_proxy (GTK_WIDGET (socket),
 					 private->plug_window,
 					 protocol, TRUE);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]