]> Pileus Git - ~andy/gtk/commitdiff
Add vfuncs for get/set_selection_owner
authorMatthias Clasen <mclasen@redhat.com>
Fri, 17 Dec 2010 00:22:44 +0000 (19:22 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 21 Dec 2010 17:07:03 +0000 (12:07 -0500)
gdk/gdkdisplayprivate.h
gdk/gdkselection.c
gdk/x11/gdkdisplay-x11.c
gdk/x11/gdkprivate-x11.h
gdk/x11/gdkselection-x11.c

index f3e48fb56b57158b85abe20c4a884918ee877673..4764909d00d3bee5b1d5c0d39db66cb680a5ebc0 100644 (file)
@@ -196,6 +196,14 @@ struct _GdkDisplayClass
   gint                       (*pop_error_trap)     (GdkDisplay    *display,
                                                     gboolean       ignore);
 
+  GdkWindow *                (*get_selection_owner) (GdkDisplay   *display,
+                                                     GdkAtom       selection);
+  gboolean                   (*set_selection_owner) (GdkDisplay   *display,
+                                                     GdkWindow    *owner,
+                                                     GdkAtom       selection,
+                                                     guint32       time,
+                                                     gboolean      send_event);
+
   /* Signals */
   void (*closed) (GdkDisplay *display,
                   gboolean    is_error);
index 9468604fe61f4e6e40615b23282f31ba169d8adb..57b85840c43238022dbfdfeb2904a7288983d00f 100644 (file)
@@ -29,7 +29,7 @@
 #include "gdkselection.h"
 
 #include "gdkproperty.h"
-#include "gdkdisplay.h"
+#include "gdkdisplayprivate.h"
 
 
 /**
@@ -246,3 +246,63 @@ gdk_utf8_to_compound_text (const gchar *str,
                                                str, encoding, format, 
                                                ctext, length);
 }
+
+/**
+ * gdk_selection_owner_set_for_display:
+ * @display: the #GdkDisplay
+ * @owner: a #GdkWindow or %NULL to indicate that the owner for
+ *         the given should be unset
+ * @selection: an atom identifying a selection
+ * @time_: timestamp to use when setting the selection
+ *         If this is older than the timestamp given last time the owner was
+ *         set for the given selection, the request will be ignored
+ * @send_event: if %TRUE, and the new owner is different from the current
+ *              owner, the current owner will be sent a SelectionClear event
+ *
+ * Sets the #GdkWindow @owner as the current owner of the selection @selection.
+ *
+ * Returns: %TRUE if the selection owner was successfully changed to owner,
+ *    otherwise %FALSE.
+ *
+ * Since: 2.2
+ */
+gboolean
+gdk_selection_owner_set_for_display (GdkDisplay *display,
+                                     GdkWindow  *owner,
+                                     GdkAtom     selection,
+                                     guint32     time,
+                                     gboolean    send_event)
+{
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
+  g_return_val_if_fail (selection != GDK_NONE, FALSE);
+
+  return GDK_DISPLAY_GET_CLASS (display)
+           ->set_selection_owner (display, owner, selection, time, send_event);
+}
+
+/**
+ * gdk_selection_owner_get_for_display:
+ * @display: a #GdkDisplay
+ * @selection: an atom indentifying a selection
+ *
+ * Determine the owner of the given selection.
+ *
+ * Note that the return value may be owned by a different
+ * process if a foreign window was previously created for that
+ * window, but a new foreign window will never be created by this call.
+ *
+ * Returns: (transfer none): if there is a selection owner for this window,
+ *    and it is a window known to the current process, the #GdkWindow that
+ *    owns the selection, otherwise %NULL.
+ *
+ * Since: 2.2
+ */
+GdkWindow *
+gdk_selection_owner_get_for_display (GdkDisplay *display,
+                                     GdkAtom     selection)
+{
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+  g_return_val_if_fail (selection != GDK_NONE, NULL);
+
+  return GDK_DISPLAY_GET_CLASS (display)->get_selection_owner (display, selection);
+}
index 7bcb5dec74a8ad5e96e682079786572d46abaf81..cb6712811f5aec6aa33b7db423533b5ec3405548 100644 (file)
@@ -2760,4 +2760,6 @@ _gdk_display_x11_class_init (GdkDisplayX11Class * class)
   display_class->get_keymap = gdk_x11_display_get_keymap;
   display_class->push_error_trap = gdk_x11_display_error_trap_push;
   display_class->pop_error_trap = pop_error_trap;
+  display_class->get_selection_owner = _gdk_x11_display_get_selection_owner;
+  display_class->set_selection_owner = _gdk_x11_display_set_selection_owner;
 }
index 70cffc731057876e692fe31a2869a6a2e5853e41..7c380d40e5bf5fe7a89b6922f0d055be3bb920e2 100644 (file)
@@ -187,6 +187,16 @@ void _gdk_x11_display_update_grab_info_ungrab (GdkDisplay *display,
                                                guint32     time,
                                                gulong      serial);
 void _gdk_x11_display_queue_events            (GdkDisplay *display);
+
+
+gboolean    _gdk_x11_display_set_selection_owner (GdkDisplay *display,
+                                                  GdkWindow  *owner,
+                                                  GdkAtom     selection,
+                                                  guint32     time,
+                                                  gboolean    send_event);
+GdkWindow * _gdk_x11_display_get_selection_owner (GdkDisplay *display,
+                                                  GdkAtom     selection);
+
 void _gdk_x11_device_check_extension_events   (GdkDevice  *device);
 
 GdkDeviceManager *_gdk_x11_device_manager_new (GdkDisplay *display);
index 74437f2474cc5ce0f237346ec7662697255cdd81..7cc682716d0b19c704a656f51c29ad9fc448dda5 100644 (file)
@@ -101,31 +101,13 @@ _gdk_selection_filter_clear_event (XSelectionClearEvent *event)
 
   return FALSE;
 }
-/**
- * gdk_selection_owner_set_for_display:
- * @display: the #GdkDisplay.
- * @owner: a #GdkWindow or %NULL to indicate that the owner for
- *         the given should be unset.
- * @selection: an atom identifying a selection.
- * @time_: timestamp to use when setting the selection. 
- *         If this is older than the timestamp given last time the owner was 
- *         set for the given selection, the request will be ignored.
- * @send_event: if %TRUE, and the new owner is different from the current
- *              owner, the current owner will be sent a SelectionClear event.
- *
- * Sets the #GdkWindow @owner as the current owner of the selection @selection.
- * 
- * Returns: %TRUE if the selection owner was successfully changed to owner,
- *         otherwise %FALSE. 
- *
- * Since: 2.2
- */
+
 gboolean
-gdk_selection_owner_set_for_display (GdkDisplay *display,
-                                    GdkWindow  *owner,
-                                    GdkAtom     selection,
-                                    guint32     time, 
-                                    gboolean    send_event)
+_gdk_x11_display_set_selection_owner (GdkDisplay *display,
+                                      GdkWindow  *owner,
+                                      GdkAtom     selection,
+                                      guint32     time,
+                                      gboolean    send_event)
 {
   Display *xdisplay;
   Window xwindow;
@@ -133,17 +115,14 @@ gdk_selection_owner_set_for_display (GdkDisplay *display,
   GSList *tmp_list;
   OwnerInfo *info;
 
-  g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
-  g_return_val_if_fail (selection != GDK_NONE, FALSE);
-
   if (gdk_display_is_closed (display))
     return FALSE;
 
-  if (owner) 
+  if (owner)
     {
       if (GDK_WINDOW_DESTROYED (owner) || !GDK_WINDOW_IS_X11 (owner))
-       return FALSE;
-      
+        return FALSE;
+
       gdk_window_ensure_native (owner);
       xdisplay = GDK_WINDOW_XDISPLAY (owner);
       xwindow = GDK_WINDOW_XID (owner);
@@ -184,35 +163,15 @@ gdk_selection_owner_set_for_display (GdkDisplay *display,
   return (XGetSelectionOwner (xdisplay, xselection) == xwindow);
 }
 
-/**
- * gdk_selection_owner_get_for_display:
- * @display: a #GdkDisplay.
- * @selection: an atom indentifying a selection.
- *
- * Determine the owner of the given selection.
- *
- * Note that the return value may be owned by a different 
- * process if a foreign window was previously created for that
- * window, but a new foreign window will never be created by this call. 
- *
- * Returns: (transfer none): if there is a selection owner for this window,
- *    and it is a window known to the current process, the #GdkWindow that
- *    owns the selection, otherwise %NULL.
- *
- * Since: 2.2
- */ 
 GdkWindow *
-gdk_selection_owner_get_for_display (GdkDisplay *display,
-                                    GdkAtom     selection)
+_gdk_x11_display_get_selection_owner (GdkDisplay *display,
+                                      GdkAtom     selection)
 {
   Window xwindow;
-  
-  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
-  g_return_val_if_fail (selection != GDK_NONE, NULL);
 
   if (gdk_display_is_closed (display))
     return NULL;
-  
+
   xwindow = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display),
                                gdk_x11_atom_to_xatom_for_display (display, 
                                                                   selection));