From 5bc04bc07be16732e0ec2ddecbb0fcfc46a929c7 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 1 Feb 2011 17:22:04 +0100 Subject: [PATCH] API: gdk: Make GdkEventSelection.requestor a GdkWindow instead of a GdkNativeWindow. Also change gdk_selection_notify() API to take a GdkWindow to match this change. --- gdk/gdkdisplayprivate.h | 2 +- gdk/gdkevents.c | 15 +++++++++++++++ gdk/gdkevents.h | 4 ++-- gdk/gdkselection.c | 6 +++--- gdk/gdkselection.h | 6 ++---- gdk/x11/gdkdisplay-x11.c | 6 +++++- gdk/x11/gdkprivate-x11.h | 2 +- gdk/x11/gdkselection-x11.c | 6 +++--- gdk/x11/gdkwindow-x11.c | 4 +++- gtk/gtkselection.c | 10 +--------- 10 files changed, 36 insertions(+), 25 deletions(-) diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h index 7438b66c0b..7f7259ab7a 100644 --- a/gdk/gdkdisplayprivate.h +++ b/gdk/gdkdisplayprivate.h @@ -202,7 +202,7 @@ struct _GdkDisplayClass guint32 time, gboolean send_event); void (*send_selection_notify) (GdkDisplay *dispay, - GdkNativeWindow requestor, + GdkWindow *requestor, GdkAtom selection, GdkAtom target, GdkAtom property, diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index cf603492aa..64fc49f5be 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -573,6 +573,14 @@ gdk_event_copy (const GdkEvent *event) g_object_ref (new_event->owner_change.owner); break; + case GDK_SELECTION_CLEAR: + case GDK_SELECTION_NOTIFY: + case GDK_SELECTION_REQUEST: + new_event->selection.requestor = event->selection.requestor; + if (new_event->selection.requestor) + g_object_unref (new_event->selection.requestor); + break; + default: break; } @@ -647,6 +655,13 @@ gdk_event_free (GdkEvent *event) g_object_unref (event->owner_change.owner); break; + case GDK_SELECTION_CLEAR: + case GDK_SELECTION_NOTIFY: + case GDK_SELECTION_REQUEST: + if (event->selection.requestor) + g_object_unref (event->selection.requestor); + break; + default: break; } diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h index 97e3f3f707..f1684ba66e 100644 --- a/gdk/gdkevents.h +++ b/gdk/gdkevents.h @@ -798,7 +798,7 @@ struct _GdkEventProperty * @target: the target to which the selection should be converted. * @property: the property in which to place the result of the conversion. * @time: the time of the event in milliseconds. - * @requestor: the native window on which to place @property. + * @requestor: the window on which to place @property or %NULL if none. * * Generated when a selection is requested or ownership of a selection * is taken over by another client application. @@ -812,7 +812,7 @@ struct _GdkEventSelection GdkAtom target; GdkAtom property; guint32 time; - GdkNativeWindow requestor; + GdkWindow *requestor; }; /** diff --git a/gdk/gdkselection.c b/gdk/gdkselection.c index 3e29a4bcfe..23c2cb4243 100644 --- a/gdk/gdkselection.c +++ b/gdk/gdkselection.c @@ -126,13 +126,13 @@ gdk_selection_owner_get (GdkAtom selection) * Sends a response to SelectionRequest event. */ void -gdk_selection_send_notify (GdkNativeWindow requestor, +gdk_selection_send_notify (GdkWindow *requestor, GdkAtom selection, GdkAtom target, GdkAtom property, guint32 time) { - gdk_selection_send_notify_for_display (gdk_display_get_default (), + gdk_selection_send_notify_for_display (gdk_window_get_display (requestor), requestor, selection, target, property, time); } @@ -213,7 +213,7 @@ gdk_selection_owner_get_for_display (GdkDisplay *display, */ void gdk_selection_send_notify_for_display (GdkDisplay *display, - GdkNativeWindow requestor, + GdkWindow *requestor, GdkAtom selection, GdkAtom target, GdkAtom property, diff --git a/gdk/gdkselection.h b/gdk/gdkselection.h index 897e0c77cf..53f3b0b9cb 100644 --- a/gdk/gdkselection.h +++ b/gdk/gdkselection.h @@ -192,16 +192,14 @@ gint gdk_selection_property_get (GdkWindow *requestor, GdkAtom *prop_type, gint *prop_format); -#ifndef GDK_MULTIHEAD_SAFE -void gdk_selection_send_notify (GdkNativeWindow requestor, +void gdk_selection_send_notify (GdkWindow *requestor, GdkAtom selection, GdkAtom target, GdkAtom property, guint32 time_); -#endif /* GDK_MULTIHEAD_SAFE */ void gdk_selection_send_notify_for_display (GdkDisplay *display, - GdkNativeWindow requestor, + GdkWindow *requestor, GdkAtom selection, GdkAtom target, GdkAtom property, diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index acc78a8ff7..2e30695e3a 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -814,7 +814,11 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator, event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.selection); event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.target); event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.property); - event->selection.requestor = xevent->xselectionrequest.requestor; + if (xevent->xselectionrequest.requestor != None) + event->selection.requestor = gdk_x11_window_foreign_new_for_display (display, + xevent->xselectionrequest.requestor); + else + event->selection.requestor = NULL; event->selection.time = xevent->xselectionrequest.time; break; diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index 7a69805bbf..36e340f07b 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -190,7 +190,7 @@ gboolean _gdk_x11_display_set_selection_owner (GdkDisplay *display, GdkWindow * _gdk_x11_display_get_selection_owner (GdkDisplay *display, GdkAtom selection); void _gdk_x11_display_send_selection_notify (GdkDisplay *display, - GdkNativeWindow requestor, + GdkWindow *requestor, GdkAtom selection, GdkAtom target, GdkAtom property, diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c index 66ddd21beb..2e9d629422 100644 --- a/gdk/x11/gdkselection-x11.c +++ b/gdk/x11/gdkselection-x11.c @@ -308,7 +308,7 @@ _gdk_x11_display_get_selection_property (GdkDisplay *display, void _gdk_x11_display_send_selection_notify (GdkDisplay *display, - GdkNativeWindow requestor, + GdkWindow *requestor, GdkAtom selection, GdkAtom target, GdkAtom property, @@ -319,7 +319,7 @@ _gdk_x11_display_send_selection_notify (GdkDisplay *display, xevent.type = SelectionNotify; xevent.serial = 0; xevent.send_event = True; - xevent.requestor = requestor; + xevent.requestor = GDK_WINDOW_XID (requestor); xevent.selection = gdk_x11_atom_to_xatom_for_display (display, selection); xevent.target = gdk_x11_atom_to_xatom_for_display (display, target); if (property == GDK_NONE) @@ -328,7 +328,7 @@ _gdk_x11_display_send_selection_notify (GdkDisplay *display, xevent.property = gdk_x11_atom_to_xatom_for_display (display, property); xevent.time = time; - _gdk_x11_display_send_xevent (display, requestor, False, NoEventMask, (XEvent*) & xevent); + _gdk_x11_display_send_xevent (display, xevent.requestor, False, NoEventMask, (XEvent*) & xevent); } /** diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index f02bed4c1c..4f2d2e92e6 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -876,7 +876,9 @@ x_event_mask_to_gdk_event_mask (long mask) * @display: the #GdkDisplay where the window handle comes from. * @window: an XLib Window * - * Wraps a native window in a #GdkWindow. + * Wraps a native window in a #GdkWindow. The function will try to + * look up the window using gdk_x11_window_lookup_for_display() first. + * If it does not find it there, it will create a new window. * * This may fail if the window has been destroyed. If the window * was already known to GDK, a new reference to the existing diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c index 105acb8a31..7fbc996d4a 100644 --- a/gtk/gtkselection.c +++ b/gtk/gtkselection.c @@ -2324,15 +2324,7 @@ _gtk_selection_request (GtkWidget *widget, info->selection = event->selection; info->num_incrs = 0; - - /* Create GdkWindow structure for the requestor */ - -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (display)) - info->requestor = gdk_x11_window_foreign_new_for_display (display, event->requestor); - else -#endif - info->requestor = NULL; + info->requestor = g_object_ref (event->requestor); /* Determine conversions we need to perform */ if (event->target == gtk_selection_atoms[MULTIPLE])