[gtk+/gdk-backend] Add vfuncs for get/set_selection_owner



commit 20db86d8a8f58a439f7aa156c6fc5fd200a15393
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Dec 16 19:22:44 2010 -0500

    Add vfuncs for get/set_selection_owner

 gdk/gdkdisplayprivate.h    |    8 +++++
 gdk/gdkselection.c         |   62 +++++++++++++++++++++++++++++++++++++++++-
 gdk/x11/gdkdisplay-x11.c   |    2 +
 gdk/x11/gdkprivate-x11.h   |   10 +++++++
 gdk/x11/gdkselection-x11.c |   65 ++++++++-----------------------------------
 5 files changed, 93 insertions(+), 54 deletions(-)
---
diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h
index 2db3e28..9e6c35b 100644
--- a/gdk/gdkdisplayprivate.h
+++ b/gdk/gdkdisplayprivate.h
@@ -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);
diff --git a/gdk/gdkselection.c b/gdk/gdkselection.c
index 9468604..57b8584 100644
--- a/gdk/gdkselection.c
+++ b/gdk/gdkselection.c
@@ -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);
+}
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 7bcb5de..cb67128 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -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;
 }
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 70cffc7..7c380d4 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -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);
diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c
index 74437f2..7cc6827 100644
--- a/gdk/x11/gdkselection-x11.c
+++ b/gdk/x11/gdkselection-x11.c
@@ -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));



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