diff options
34 files changed, 5 insertions, 1544 deletions
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index e18a2d5abf..f4a40d8991 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -425,10 +425,6 @@ GDK_SELECTION_TYPE_INTEGER GDK_SELECTION_TYPE_PIXMAP GDK_SELECTION_TYPE_WINDOW GDK_SELECTION_TYPE_STRING -gdk_selection_owner_set -gdk_selection_owner_set_for_display -gdk_selection_owner_get -gdk_selection_owner_get_for_display gdk_selection_convert gdk_selection_property_get gdk_selection_send_notify diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index b72ddaa2ed..de57bc1c30 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -5185,8 +5185,6 @@ gtk_css_section_get_type <FILE>gtkselection</FILE> <TITLE>Selections</TITLE> GtkSelectionData -gtk_selection_owner_set -gtk_selection_owner_set_for_display gtk_selection_convert gtk_selection_data_set gtk_selection_data_set_text diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c index 321571fdb2..f3335beac9 100644 --- a/gdk/broadway/gdkdisplay-broadway.c +++ b/gdk/broadway/gdkdisplay-broadway.c @@ -573,8 +573,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class) display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete; display_class->create_window_impl = _gdk_broadway_display_create_window_impl; display_class->get_keymap = _gdk_broadway_display_get_keymap; - display_class->get_selection_owner = _gdk_broadway_display_get_selection_owner; - display_class->set_selection_owner = _gdk_broadway_display_set_selection_owner; display_class->send_selection_notify = _gdk_broadway_display_send_selection_notify; display_class->get_selection_property = _gdk_broadway_display_get_selection_property; display_class->convert_selection = _gdk_broadway_display_convert_selection; diff --git a/gdk/broadway/gdkprivate-broadway.h b/gdk/broadway/gdkprivate-broadway.h index 34221a4dba..5639ad0520 100644 --- a/gdk/broadway/gdkprivate-broadway.h +++ b/gdk/broadway/gdkprivate-broadway.h @@ -83,7 +83,6 @@ gboolean _gdk_broadway_moveresize_configure_done (GdkDisplay *display, void _gdk_broadway_roundtrip_notify (GdkWindow *window, guint32 tag, gboolean local_reply); -void _gdk_broadway_selection_window_destroyed (GdkWindow *window); void _gdk_broadway_window_grab_check_destroy (GdkWindow *window); void _gdk_broadway_window_grab_check_unmap (GdkWindow *window, gulong serial); @@ -124,13 +123,6 @@ void _gdk_broadway_display_create_window_impl (GdkDisplay *display, GdkWindow *real_parent, GdkEventMask event_mask, GdkWindowAttr *attributes); -gboolean _gdk_broadway_display_set_selection_owner (GdkDisplay *display, - GdkWindow *owner, - GdkAtom selection, - guint32 time, - gboolean send_event); -GdkWindow * _gdk_broadway_display_get_selection_owner (GdkDisplay *display, - GdkAtom selection); gint _gdk_broadway_display_get_selection_property (GdkDisplay *display, GdkWindow *requestor, guchar **data, diff --git a/gdk/broadway/gdkselection-broadway.c b/gdk/broadway/gdkselection-broadway.c index 2f30842b34..843c8a8778 100644 --- a/gdk/broadway/gdkselection-broadway.c +++ b/gdk/broadway/gdkselection-broadway.c @@ -33,101 +33,6 @@ #include <string.h> -typedef struct _OwnerInfo OwnerInfo; - -struct _OwnerInfo -{ - GdkAtom selection; - GdkWindow *owner; - gulong serial; -}; - -static GSList *owner_list; - -/* When a window is destroyed we check if it is the owner - * of any selections. This is somewhat inefficient, but - * owner_list is typically short, and it is a low memory, - * low code solution - */ -void -_gdk_broadway_selection_window_destroyed (GdkWindow *window) -{ - GSList *tmp_list = owner_list; - while (tmp_list) - { - OwnerInfo *info = tmp_list->data; - tmp_list = tmp_list->next; - - if (info->owner == window) - { - owner_list = g_slist_remove (owner_list, info); - g_free (info); - } - } -} - -gboolean -_gdk_broadway_display_set_selection_owner (GdkDisplay *display, - GdkWindow *owner, - GdkAtom selection, - guint32 time, - gboolean send_event) -{ - GSList *tmp_list; - OwnerInfo *info; - - if (gdk_display_is_closed (display)) - return FALSE; - - tmp_list = owner_list; - while (tmp_list) - { - info = tmp_list->data; - if (info->selection == selection) - { - owner_list = g_slist_remove (owner_list, info); - g_free (info); - break; - } - tmp_list = tmp_list->next; - } - - if (owner) - { - info = g_new (OwnerInfo, 1); - info->owner = owner; - info->serial = _gdk_display_get_next_serial (display); - - info->selection = selection; - - owner_list = g_slist_prepend (owner_list, info); - } - - return TRUE; -} - -GdkWindow * -_gdk_broadway_display_get_selection_owner (GdkDisplay *display, - GdkAtom selection) -{ - GSList *tmp_list; - OwnerInfo *info; - - if (gdk_display_is_closed (display)) - return NULL; - - tmp_list = owner_list; - while (tmp_list) - { - info = tmp_list->data; - if (info->selection == selection) - return info->owner; - tmp_list = tmp_list->next; - } - - return NULL; -} - void _gdk_broadway_display_convert_selection (GdkDisplay *display, GdkWindow *requestor, diff --git a/gdk/broadway/gdkwindow-broadway.c b/gdk/broadway/gdkwindow-broadway.c index 1656c07100..89d79b8221 100644 --- a/gdk/broadway/gdkwindow-broadway.c +++ b/gdk/broadway/gdkwindow-broadway.c @@ -265,7 +265,6 @@ _gdk_broadway_window_destroy (GdkWindow *window, if (impl->node_data_textures) g_ptr_array_unref (impl->node_data_textures); - _gdk_broadway_selection_window_destroyed (window); _gdk_broadway_window_grab_check_destroy (window); broadway_display = GDK_BROADWAY_DISPLAY (gdk_window_get_display (window)); diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h index b46bf4704b..3dd13a82d7 100644 --- a/gdk/gdkdisplayprivate.h +++ b/gdk/gdkdisplayprivate.h @@ -167,13 +167,6 @@ struct _GdkDisplayClass GdkKeymap * (*get_keymap) (GdkDisplay *display); - GdkWindow * (*get_selection_owner) (GdkDisplay *display, - GdkAtom selection); - gboolean (*set_selection_owner) (GdkDisplay *display, - GdkWindow *owner, - GdkAtom selection, - guint32 time, - gboolean send_event); void (*send_selection_notify) (GdkDisplay *dispay, GdkWindow *requestor, GdkAtom selection, diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 054ca11206..624c1d2f37 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -587,9 +587,7 @@ gdk_event_copy (const GdkEvent *event) sizeof (gdouble) * gdk_device_get_n_axes (event->motion.device)); 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_ref (new_event->selection.requestor); @@ -675,9 +673,7 @@ gdk_event_free (GdkEvent *event) g_free (event->motion.axes); break; - case GDK_SELECTION_CLEAR: case GDK_SELECTION_NOTIFY: - case GDK_SELECTION_REQUEST: if (event->selection.requestor) g_object_unref (event->selection.requestor); break; @@ -754,8 +750,6 @@ gdk_event_get_time (const GdkEvent *event) return event->crossing.time; case GDK_PROPERTY_NOTIFY: return event->property.time; - case GDK_SELECTION_CLEAR: - case GDK_SELECTION_REQUEST: case GDK_SELECTION_NOTIFY: return event->selection.time; case GDK_PROXIMITY_IN: @@ -852,8 +846,6 @@ gdk_event_get_state (const GdkEvent *event, case GDK_CLIENT_EVENT: case GDK_CONFIGURE: case GDK_FOCUS_CHANGE: - case GDK_SELECTION_CLEAR: - case GDK_SELECTION_REQUEST: case GDK_SELECTION_NOTIFY: case GDK_PROXIMITY_IN: case GDK_PROXIMITY_OUT: @@ -2720,9 +2712,7 @@ gdk_event_get_selection (const GdkEvent *event, if (!event) return FALSE; - if (event->type == GDK_SELECTION_CLEAR || - event->type == GDK_SELECTION_NOTIFY || - event->type == GDK_SELECTION_REQUEST) + if (event->type == GDK_SELECTION_NOTIFY) { *selection = event->selection.selection; return TRUE; @@ -2749,9 +2739,7 @@ gdk_event_get_selection_property (const GdkEvent *event, if (!event) return FALSE; - if (event->type == GDK_SELECTION_CLEAR || - event->type == GDK_SELECTION_NOTIFY || - event->type == GDK_SELECTION_REQUEST) + if (event->type == GDK_SELECTION_NOTIFY) { if (property) *property = event->selection.property; diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h index e9e6f030f8..f2893cc5d3 100644 --- a/gdk/gdkevents.h +++ b/gdk/gdkevents.h @@ -304,8 +304,6 @@ typedef enum GDK_MAP = 14, GDK_UNMAP = 15, GDK_PROPERTY_NOTIFY = 16, - GDK_SELECTION_CLEAR = 17, - GDK_SELECTION_REQUEST = 18, GDK_SELECTION_NOTIFY = 19, GDK_PROXIMITY_IN = 20, GDK_PROXIMITY_OUT = 21, diff --git a/gdk/gdkeventsprivate.h b/gdk/gdkeventsprivate.h index 7f2e7ca0b9..bf57607182 100644 --- a/gdk/gdkeventsprivate.h +++ b/gdk/gdkeventsprivate.h @@ -406,8 +406,7 @@ struct _GdkEventProperty /** * GdkEventSelection: - * @type: the type of the event (%GDK_SELECTION_CLEAR, - * %GDK_SELECTION_NOTIFY or %GDK_SELECTION_REQUEST). + * @type: the type of the event (%GDK_SELECTION_NOTIFY). * @window: the window which received the event. * @send_event: %TRUE if the event was sent explicitly. * @selection: the selection. diff --git a/gdk/gdkselection.c b/gdk/gdkselection.c index 38dc054197..76c5f19fc4 100644 --- a/gdk/gdkselection.c +++ b/gdk/gdkselection.c @@ -61,55 +61,6 @@ */ /** - * gdk_selection_owner_set: - * @owner: (allow-none): a #GdkWindow or %NULL to indicate that the - * 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 owner of the given selection. - * - * Returns: %TRUE if the selection owner was successfully - * changed to @owner, otherwise %FALSE. - */ -gboolean -gdk_selection_owner_set (GdkWindow *owner, - GdkAtom selection, - guint32 time, - gboolean send_event) -{ - return gdk_selection_owner_set_for_display (gdk_display_get_default (), - owner, selection, - time, send_event); -} - -/** - * gdk_selection_owner_get: - * @selection: an atom indentifying a selection. - * - * Determines the owner of the given selection. - * - * Returns: (nullable) (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. 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. - */ -GdkWindow* -gdk_selection_owner_get (GdkAtom selection) -{ - return gdk_selection_owner_get_for_display (gdk_display_get_default (), - selection); -} - -/** * gdk_selection_send_notify: * @requestor: window to which to deliver response. * @selection: selection that was requested. @@ -134,67 +85,6 @@ gdk_selection_send_notify (GdkWindow *requestor, } /** - * gdk_selection_owner_set_for_display: - * @display: the #GdkDisplay - * @owner: (nullable): 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 != NULL, 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: (nullable) (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 != NULL, NULL); - - return GDK_DISPLAY_GET_CLASS (display)->get_selection_owner (display, selection); -} - -/** * gdk_selection_send_notify_for_display: * @display: the #GdkDisplay where @requestor is realized * @requestor: window to which to deliver response diff --git a/gdk/gdkselection.h b/gdk/gdkselection.h index 8146a5158c..7d6e7d9443 100644 --- a/gdk/gdkselection.h +++ b/gdk/gdkselection.h @@ -152,23 +152,6 @@ G_BEGIN_DECLS /* Selections */ -GDK_AVAILABLE_IN_ALL -gboolean gdk_selection_owner_set (GdkWindow *owner, - GdkAtom selection, - guint32 time_, - gboolean send_event); -GDK_AVAILABLE_IN_ALL -GdkWindow* gdk_selection_owner_get (GdkAtom selection); -GDK_AVAILABLE_IN_ALL -gboolean gdk_selection_owner_set_for_display (GdkDisplay *display, - GdkWindow *owner, - GdkAtom selection, - guint32 time_, - gboolean send_event); -GDK_AVAILABLE_IN_ALL -GdkWindow *gdk_selection_owner_get_for_display (GdkDisplay *display, - GdkAtom selection); - /** * gdk_selection_convert: * @requestor: a #GdkWindow. diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index a9a15c7eec..89202ad087 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -5468,8 +5468,6 @@ _gdk_make_event (GdkWindow *window, event->property.state = the_state; break; - case GDK_SELECTION_CLEAR: - case GDK_SELECTION_REQUEST: case GDK_SELECTION_NOTIFY: event->selection.time = the_time; break; diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c index 1086d62173..f98b1e062b 100644 --- a/gdk/mir/gdkmirdisplay.c +++ b/gdk/mir/gdkmirdisplay.c @@ -496,45 +496,6 @@ gdk_mir_display_pop_error_trap (GdkDisplay *display, return 0; } -static GdkWindow * -gdk_mir_display_get_selection_owner (GdkDisplay *display, - GdkAtom selection) -{ - return NULL; -} - -static gboolean -gdk_mir_display_set_selection_owner (GdkDisplay *display, - GdkWindow *owner, - GdkAtom selection, - guint32 time, - gboolean send_event) -{ - GdkEvent *event; - - if (selection == GDK_SELECTION_CLIPBOARD) - { - if (owner) - { - event = gdk_event_new (GDK_SELECTION_REQUEST); - event->selection.window = g_object_ref (owner); - event->selection.send_event = FALSE; - event->selection.selection = selection; - event->selection.target = gdk_atom_intern_static_string ("TARGETS"); - event->selection.property = gdk_atom_intern_static_string ("AVAILABLE_TARGETS"); - event->selection.time = GDK_CURRENT_TIME; - event->selection.requestor = g_object_ref (owner); - - gdk_event_put (event); - gdk_event_free (event); - - return TRUE; - } - } - - return FALSE; -} - static void gdk_mir_display_send_selection_notify (GdkDisplay *display, GdkWindow *requestor, @@ -1215,8 +1176,6 @@ gdk_mir_display_class_init (GdkMirDisplayClass *klass) display_class->get_keymap = gdk_mir_display_get_keymap; display_class->push_error_trap = gdk_mir_display_push_error_trap; display_class->pop_error_trap = gdk_mir_display_pop_error_trap; - display_class->get_selection_owner = gdk_mir_display_get_selection_owner; - display_class->set_selection_owner = gdk_mir_display_set_selection_owner; display_class->send_selection_notify = gdk_mir_display_send_selection_notify; display_class->get_selection_property = gdk_mir_display_get_selection_property; display_class->convert_selection = gdk_mir_display_convert_selection; diff --git a/gdk/quartz/gdkdisplay-quartz.c b/gdk/quartz/gdkdisplay-quartz.c index fcef6702ab..f2342aec41 100644 --- a/gdk/quartz/gdkdisplay-quartz.c +++ b/gdk/quartz/gdkdisplay-quartz.c @@ -276,8 +276,6 @@ gdk_quartz_display_class_init (GdkQuartzDisplayClass *class) display_class->event_data_free = _gdk_quartz_display_event_data_free; display_class->create_window_impl = _gdk_quartz_display_create_window_impl; display_class->get_keymap = _gdk_quartz_display_get_keymap; - display_class->get_selection_owner = _gdk_quartz_display_get_selection_owner; - display_class->set_selection_owner = _gdk_quartz_display_set_selection_owner; display_class->get_selection_property = _gdk_quartz_display_get_selection_property; display_class->convert_selection = _gdk_quartz_display_convert_selection; display_class->text_property_to_utf8_list = _gdk_quartz_display_text_property_to_utf8_list; diff --git a/gdk/quartz/gdkdisplay-quartz.h b/gdk/quartz/gdkdisplay-quartz.h index 6738c27297..77a222adc7 100644 --- a/gdk/quartz/gdkdisplay-quartz.h +++ b/gdk/quartz/gdkdisplay-quartz.h @@ -72,13 +72,6 @@ void _gdk_quartz_display_create_window_impl (GdkDisplay *display, GdkKeymap * _gdk_quartz_display_get_keymap (GdkDisplay *display); /* Display methods - selection */ -gboolean _gdk_quartz_display_set_selection_owner (GdkDisplay *display, - GdkWindow *owner, - GdkAtom selection, - guint32 time, - gboolean send_event); -GdkWindow * _gdk_quartz_display_get_selection_owner (GdkDisplay *display, - GdkAtom selection); gint _gdk_quartz_display_get_selection_property (GdkDisplay *display, GdkWindow *requestor, guchar **data, diff --git a/gdk/quartz/gdkselection-quartz.c b/gdk/quartz/gdkselection-quartz.c index c6014a2579..16f3569426 100644 --- a/gdk/quartz/gdkselection-quartz.c +++ b/gdk/quartz/gdkselection-quartz.c @@ -24,25 +24,6 @@ #include "gdkproperty.h" #include "gdkquartz.h" -gboolean -_gdk_quartz_display_set_selection_owner (GdkDisplay *display, - GdkWindow *owner, - GdkAtom selection, - guint32 time, - gint send_event) -{ - /* FIXME: Implement */ - return TRUE; -} - -GdkWindow* -_gdk_quartz_display_get_selection_owner (GdkDisplay *display, - GdkAtom selection) -{ - /* FIXME: Implement */ - return NULL; -} - void _gdk_quartz_display_convert_selection (GdkDisplay *display, GdkWindow *requestor, diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index b1d0a00d26..5bd5c85f3f 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -1102,10 +1102,8 @@ data_device_enter (void *data, gdk_wayland_drop_context_update_targets (seat->drop_context); selection = gdk_drag_get_selection (seat->drop_context); - dnd_owner = gdk_selection_owner_get_for_display (seat->display, selection); - if (!dnd_owner) - dnd_owner = seat->foreign_dnd_window; + dnd_owner = seat->foreign_dnd_window; _gdk_wayland_drag_context_set_source_window (seat->drop_context, dnd_owner); diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 8403938f3b..d276cf1b59 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -1019,8 +1019,6 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class) display_class->notify_startup_complete = gdk_wayland_display_notify_startup_complete; display_class->create_window_impl = _gdk_wayland_display_create_window_impl; display_class->get_keymap = _gdk_wayland_display_get_keymap; - display_class->get_selection_owner = _gdk_wayland_display_get_selection_owner; - display_class->set_selection_owner = _gdk_wayland_display_set_selection_owner; display_class->send_selection_notify = _gdk_wayland_display_send_selection_notify; display_class->get_selection_property = _gdk_wayland_display_get_selection_property; display_class->convert_selection = _gdk_wayland_display_convert_selection; diff --git a/gdk/wayland/gdkdnd-wayland.c b/gdk/wayland/gdkdnd-wayland.c index ac849741a9..34cf3f35d1 100644 --- a/gdk/wayland/gdkdnd-wayland.c +++ b/gdk/wayland/gdkdnd-wayland.c @@ -80,15 +80,6 @@ gdk_wayland_drag_context_finalize (GObject *object) if (context->is_source) { - GdkDisplay *display = gdk_window_get_display (context->source_window); - GdkAtom selection; - GdkWindow *selection_owner; - - selection = gdk_drag_get_selection (context); - selection_owner = gdk_selection_owner_get_for_display (display, selection); - if (selection_owner == context->source_window) - gdk_wayland_selection_unset_data_source (display, selection); - gdk_drag_context_set_cursor (context, NULL); } diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h index f1ec0c79c2..b35a02fb7a 100644 --- a/gdk/wayland/gdkprivate-wayland.h +++ b/gdk/wayland/gdkprivate-wayland.h @@ -129,13 +129,6 @@ void _gdk_wayland_display_create_window_impl (GdkDisplay *display, GdkEventMask event_mask, GdkWindowAttr *attributes); -GdkWindow *_gdk_wayland_display_get_selection_owner (GdkDisplay *display, - GdkAtom selection); -gboolean _gdk_wayland_display_set_selection_owner (GdkDisplay *display, - GdkWindow *owner, - GdkAtom selection, - guint32 time, - gboolean send_event); void _gdk_wayland_display_send_selection_notify (GdkDisplay *dispay, GdkWindow *requestor, GdkAtom selection, diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c index b456318918..7d1b30ae2f 100644 --- a/gdk/wayland/gdkselection-wayland.c +++ b/gdk/wayland/gdkselection-wayland.c @@ -98,12 +98,10 @@ struct _GdkWaylandSelection StoredSelection stored_selection; struct wl_data_source *dnd_source; /* Owned by the GdkDragContext */ - GdkWindow *dnd_owner; }; static void selection_buffer_read (SelectionBuffer *buffer); static void async_write_data_write (AsyncWriteData *write_data); -static void emit_selection_clear (GdkDisplay *display, GdkAtom selection); static void _gdk_display_put_event (GdkDisplay *display, @@ -550,26 +548,6 @@ gdk_wayland_selection_get_targets (GdkDisplay *display, return NULL; } -static void -gdk_wayland_selection_emit_request (GdkWindow *window, - GdkAtom selection, - GdkAtom target) -{ - GdkEvent *event; - - event = gdk_event_new (GDK_SELECTION_REQUEST); - event->selection.window = g_object_ref (window); - event->selection.send_event = FALSE; - event->selection.selection = selection; - event->selection.target = target; - event->selection.property = gdk_atom_intern_static_string ("GDK_SELECTION"); - event->selection.time = GDK_CURRENT_TIME; - event->selection.requestor = g_object_ref (window); - - _gdk_display_put_event (gdk_window_get_display (window), event); - gdk_event_free (event); -} - static AsyncWriteData * async_write_data_new (GdkWaylandSelection *selection) { @@ -826,8 +804,6 @@ data_source_cancelled (void *data, if (context) gdk_drag_context_cancel (context, GDK_DRAG_CANCEL_ERROR); - emit_selection_clear (display, atom); - gdk_selection_owner_set (NULL, atom, GDK_CURRENT_TIME, TRUE); gdk_wayland_selection_unset_data_source (display, atom); } @@ -856,15 +832,7 @@ data_source_dnd_finished (void *data, if (!context) return; - if (context->action == GDK_ACTION_MOVE) - { - gdk_wayland_selection_emit_request (context->source_window, - atoms[ATOM_DND], - gdk_atom_intern_static_string ("DELETE")); - } - g_signal_emit_by_name (context, "dnd-finished"); - gdk_selection_owner_set (NULL, atoms[ATOM_DND], GDK_CURRENT_TIME, TRUE); } static void @@ -907,8 +875,7 @@ gdk_wayland_selection_get_data_source (GdkWindow *owner, if (selection == atoms[ATOM_DND]) { - if (wayland_selection->dnd_source && - (!owner || owner == wayland_selection->dnd_owner)) + if (wayland_selection->dnd_source) return wayland_selection->dnd_source; } else @@ -942,36 +909,6 @@ gdk_wayland_selection_unset_data_source (GdkDisplay *display, } } -GdkWindow * -_gdk_wayland_display_get_selection_owner (GdkDisplay *display, - GdkAtom selection) -{ - GdkWaylandSelection *wayland_selection = gdk_wayland_display_get_selection (display); - - if (selection == atoms[ATOM_DND]) - return wayland_selection->dnd_owner; - - return NULL; -} - -gboolean -_gdk_wayland_display_set_selection_owner (GdkDisplay *display, - GdkWindow *owner, - GdkAtom selection, - guint32 time, - gboolean send_event) -{ - GdkWaylandSelection *wayland_selection = gdk_wayland_display_get_selection (display); - - if (selection == atoms[ATOM_DND]) - { - wayland_selection->dnd_owner = owner; - return TRUE; - } - - return FALSE; -} - void _gdk_wayland_display_send_selection_notify (GdkDisplay *dispay, GdkWindow *requestor, @@ -1047,28 +984,6 @@ emit_empty_selection_notify (GdkWindow *requestor, gdk_event_free (event); } -static void -emit_selection_clear (GdkDisplay *display, - GdkAtom selection) -{ - GdkEvent *event; - GdkWindow *window; - - event = gdk_event_new (GDK_SELECTION_CLEAR); - event->selection.selection = selection; - event->selection.time = GDK_CURRENT_TIME; - - window = _gdk_wayland_display_get_selection_owner (display, selection); - if (window != NULL) - { - event->selection.window = g_object_ref (window); - event->selection.requestor = g_object_ref (window); - } - - _gdk_display_put_event (display, event); - gdk_event_free (event); -} - void _gdk_wayland_display_convert_selection (GdkDisplay *display, GdkWindow *requestor, diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index 71a14abd99..840e463600 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -1244,8 +1244,6 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass) display_class->create_window_impl = _gdk_win32_display_create_window_impl; display_class->get_keymap = _gdk_win32_display_get_keymap; - display_class->get_selection_owner = _gdk_win32_display_get_selection_owner; - display_class->set_selection_owner = _gdk_win32_display_set_selection_owner; display_class->send_selection_notify = _gdk_win32_display_send_selection_notify; display_class->get_selection_property = _gdk_win32_display_get_selection_property; display_class->convert_selection = _gdk_win32_display_convert_selection; diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h index 515a0971cf..e5016b078a 100644 --- a/gdk/win32/gdkprivate-win32.h +++ b/gdk/win32/gdkprivate-win32.h @@ -379,13 +379,6 @@ gboolean _gdk_win32_selection_owner_set_for_display (GdkDisplay *display, GdkAtom selection, guint32 time, gboolean send_event); -GdkWindow *_gdk_win32_display_get_selection_owner (GdkDisplay *display, - GdkAtom selection); -gboolean _gdk_win32_display_set_selection_owner (GdkDisplay *display, - GdkWindow *owner, - GdkAtom selection, - guint32 time, - gboolean send_event); void _gdk_win32_display_send_selection_notify (GdkDisplay *display, GdkWindow *requestor, GdkAtom selection, diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index b138d7313d..fa780476cd 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -1051,45 +1051,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator, break; - case SelectionClear: - GDK_NOTE (EVENTS, - g_message ("selection clear:\twindow: %ld", - xevent->xproperty.window)); - - if (_gdk_x11_selection_filter_clear_event (&xevent->xselectionclear)) - { - event->selection.type = GDK_SELECTION_CLEAR; - event->selection.window = window; - event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionclear.selection); - event->selection.time = xevent->xselectionclear.time; - } - else - return_val = FALSE; - - break; - - case SelectionRequest: - GDK_NOTE (EVENTS, - g_message ("selection request:\twindow: %ld", - xevent->xproperty.window)); - - event->selection.type = GDK_SELECTION_REQUEST; - event->selection.window = window; - 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); - if (xevent->xselectionrequest.property == None) - event->selection.property = event->selection.target; - else - event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.property); - 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; - case SelectionNotify: GDK_NOTE (EVENTS, g_message ("selection notify:\twindow: %ld", @@ -3218,8 +3179,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class) display_class->notify_startup_complete = gdk_x11_display_notify_startup_complete; display_class->create_window_impl = _gdk_x11_display_create_window_impl; display_class->get_keymap = gdk_x11_display_get_keymap; - display_class->get_selection_owner = _gdk_x11_display_get_selection_owner; - display_class->set_selection_owner = _gdk_x11_display_set_selection_owner; display_class->send_selection_notify = _gdk_x11_display_send_selection_notify; display_class->get_selection_property = _gdk_x11_display_get_selection_property; display_class->convert_selection = _gdk_x11_display_convert_selection; diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index 4930d69945..81864e2f15 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -102,9 +102,6 @@ void _gdk_x11_window_translate (GdkWindow *window, void _gdk_x11_display_free_translate_queue (GdkDisplay *display); -void _gdk_x11_selection_window_destroyed (GdkWindow *window); -gboolean _gdk_x11_selection_filter_clear_event (const XSelectionClearEvent *event); - cairo_region_t* _gdk_x11_xwindow_get_shape (Display *xdisplay, Window window, gint scale, @@ -148,13 +145,6 @@ void _gdk_x11_display_queue_events (GdkDisplay *display); GdkAppLaunchContext *_gdk_x11_display_get_app_launch_context (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_display_send_selection_notify (GdkDisplay *display, GdkWindow *requestor, GdkAtom selection, diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c index abef9b02ff..2ad8c2023f 100644 --- a/gdk/x11/gdkselection-x11.c +++ b/gdk/x11/gdkselection-x11.c @@ -34,154 +34,6 @@ #include <string.h> -typedef struct _OwnerInfo OwnerInfo; - -struct _OwnerInfo -{ - GdkAtom selection; - GdkWindow *owner; - gulong serial; -}; - -static GSList *owner_list; - -/* When a window is destroyed we check if it is the owner - * of any selections. This is somewhat inefficient, but - * owner_list is typically short, and it is a low memory, - * low code solution - */ -void -_gdk_x11_selection_window_destroyed (GdkWindow *window) -{ - GSList *tmp_list = owner_list; - while (tmp_list) - { - OwnerInfo *info = tmp_list->data; - tmp_list = tmp_list->next; - - if (info->owner == window) - { - owner_list = g_slist_remove (owner_list, info); - g_free (info); - } - } -} - -/* We only pass through those SelectionClear events that actually - * reflect changes to the selection owner that we didn’t make ourself. - */ -gboolean -_gdk_x11_selection_filter_clear_event (const XSelectionClearEvent *event) -{ - GSList *tmp_list = owner_list; - GdkDisplay *display = gdk_x11_lookup_xdisplay (event->display); - - while (tmp_list) - { - OwnerInfo *info = tmp_list->data; - - if (gdk_window_get_display (info->owner) == display && - info->selection == gdk_x11_xatom_to_atom_for_display (display, event->selection)) - { - if ((GDK_WINDOW_XID (info->owner) == event->window && - event->serial >= info->serial)) - { - owner_list = g_slist_remove (owner_list, info); - g_free (info); - return TRUE; - } - else - return FALSE; - } - tmp_list = tmp_list->next; - } - - return FALSE; -} - -gboolean -_gdk_x11_display_set_selection_owner (GdkDisplay *display, - GdkWindow *owner, - GdkAtom selection, - guint32 time, - gboolean send_event) -{ - Display *xdisplay; - Window xwindow; - Atom xselection; - GSList *tmp_list; - OwnerInfo *info; - - if (gdk_display_is_closed (display)) - return FALSE; - - if (owner) - { - if (GDK_WINDOW_DESTROYED (owner) || !GDK_WINDOW_IS_X11 (owner)) - return FALSE; - - if (!gdk_window_has_native (owner)) - { - g_warning ("Can't use selectors on non-native window"); - return FALSE; - } - xdisplay = GDK_WINDOW_XDISPLAY (owner); - xwindow = GDK_WINDOW_XID (owner); - } - else - { - xdisplay = GDK_DISPLAY_XDISPLAY (display); - xwindow = None; - } - - xselection = gdk_x11_atom_to_xatom_for_display (display, selection); - - tmp_list = owner_list; - while (tmp_list) - { - info = tmp_list->data; - if (info->selection == selection) - { - owner_list = g_slist_remove (owner_list, info); - g_free (info); - break; - } - tmp_list = tmp_list->next; - } - - if (owner) - { - info = g_new (OwnerInfo, 1); - info->owner = owner; - info->serial = NextRequest (GDK_WINDOW_XDISPLAY (owner)); - info->selection = selection; - - owner_list = g_slist_prepend (owner_list, info); - } - - XSetSelectionOwner (xdisplay, xselection, xwindow, time); - - return (XGetSelectionOwner (xdisplay, xselection) == xwindow); -} - -GdkWindow * -_gdk_x11_display_get_selection_owner (GdkDisplay *display, - GdkAtom selection) -{ - Window xwindow; - - if (gdk_display_is_closed (display)) - return NULL; - - xwindow = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), - gdk_x11_atom_to_xatom_for_display (display, - selection)); - if (xwindow == None) - return NULL; - - return gdk_x11_window_lookup_for_display (display, xwindow); -} - void _gdk_x11_display_convert_selection (GdkDisplay *display, GdkWindow *requestor, diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 3675ae6175..16521b79fd 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -1179,8 +1179,6 @@ gdk_x11_window_destroy (GdkWindow *window, g_return_if_fail (GDK_IS_WINDOW (window)); - _gdk_x11_selection_window_destroyed (window); - toplevel = _gdk_x11_window_get_toplevel (window); if (toplevel) gdk_toplevel_x11_free_contents (GDK_WINDOW_DISPLAY (window), toplevel); diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index f1eb45559e..077db5e3b2 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -1823,8 +1823,6 @@ gtk_main_do_event (GdkEvent *event) case GDK_CONFIGURE: case GDK_MAP: case GDK_UNMAP: - case GDK_SELECTION_CLEAR: - case GDK_SELECTION_REQUEST: case GDK_SELECTION_NOTIFY: case GDK_CLIENT_EVENT: case GDK_WINDOW_STATE: diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c index ec23053807..fad6aec4f9 100644 --- a/gtk/gtkselection.c +++ b/gtk/gtkselection.c @@ -132,19 +132,10 @@ enum { LAST_ATOM }; -typedef struct _GtkSelectionInfo GtkSelectionInfo; typedef struct _GtkIncrConversion GtkIncrConversion; typedef struct _GtkIncrInfo GtkIncrInfo; typedef struct _GtkRetrievalInfo GtkRetrievalInfo; -struct _GtkSelectionInfo -{ - GdkAtom selection; - GtkWidget *widget; /* widget that owns selection */ - guint32 time; /* time used to acquire selection */ - GdkDisplay *display; /* needed in gtk_selection_remove_all */ -}; - struct _GtkIncrConversion { GdkAtom target; /* Requested target */ @@ -187,7 +178,6 @@ struct _GtkRetrievalInfo /* Local Functions */ static void gtk_selection_init (void); -static gboolean gtk_selection_incr_timeout (GtkIncrInfo *info); static gboolean gtk_selection_retrieval_timeout (GtkRetrievalInfo *info); static void gtk_selection_retrieval_report (GtkRetrievalInfo *info, GdkAtom type, @@ -195,21 +185,14 @@ static void gtk_selection_retrieval_report (GtkRetrievalInfo *info, guchar *buffer, gint length, guint32 time); -static void gtk_selection_invoke_handler (GtkWidget *widget, - GtkSelectionData *data, - guint time); -static void gtk_selection_default_handler (GtkWidget *widget, - GtkSelectionData *data); static int gtk_selection_bytes_per_item (gint format); /* Local Data */ static gint initialize = TRUE; static GList *current_retrievals = NULL; static GList *current_incrs = NULL; -static GList *current_selections = NULL; static GdkAtom gtk_selection_atoms[LAST_ATOM]; -static const char gtk_selection_handler_key[] = "gtk-selection-handlers"; /**************** * Target Lists * @@ -381,177 +364,6 @@ gtk_content_formats_add_uri_targets (GdkContentFormats *list) } /** - * gtk_selection_owner_set_for_display: - * @display: the #GdkDisplay where the selection is set - * @widget: (allow-none): new selection owner (a #GtkWidget), or %NULL. - * @selection: an interned atom representing the selection to claim. - * @time_: timestamp with which to claim the selection - * - * Claim ownership of a given selection for a particular widget, or, - * if @widget is %NULL, release ownership of the selection. - * - * Returns: TRUE if the operation succeeded - * - * Since: 2.2 - */ -gboolean -gtk_selection_owner_set_for_display (GdkDisplay *display, - GtkWidget *widget, - GdkAtom selection, - guint32 time) -{ - GList *tmp_list; - GtkWidget *old_owner; - GtkSelectionInfo *selection_info = NULL; - GdkWindow *window; - - g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE); - g_return_val_if_fail (selection != NULL, FALSE); - g_return_val_if_fail (widget == NULL || gtk_widget_get_realized (widget), FALSE); - g_return_val_if_fail (widget == NULL || gtk_widget_get_display (widget) == display, FALSE); - - if (widget == NULL) - window = NULL; - else - window = gtk_widget_get_window (widget); - - tmp_list = current_selections; - while (tmp_list) - { - if (((GtkSelectionInfo *)tmp_list->data)->selection == selection) - { - selection_info = tmp_list->data; - break; - } - - tmp_list = tmp_list->next; - } - - if (gdk_selection_owner_set_for_display (display, window, selection, time, TRUE)) - { - old_owner = NULL; - - if (widget == NULL) - { - if (selection_info) - { - old_owner = selection_info->widget; - current_selections = g_list_remove_link (current_selections, - tmp_list); - g_list_free (tmp_list); - g_slice_free (GtkSelectionInfo, selection_info); - } - } - else - { - if (selection_info == NULL) - { - selection_info = g_slice_new (GtkSelectionInfo); - selection_info->selection = selection; - selection_info->widget = widget; - selection_info->time = time; - selection_info->display = display; - current_selections = g_list_prepend (current_selections, - selection_info); - } - else - { - old_owner = selection_info->widget; - selection_info->widget = widget; - selection_info->time = time; - selection_info->display = display; - } - } - /* If another widget in the application lost the selection, - * send it a GDK_SELECTION_CLEAR event. - */ - if (old_owner && old_owner != widget) - { - GdkEvent *event = gdk_event_new (GDK_SELECTION_CLEAR); - - gdk_event_set_selection (event, gtk_widget_get_window (old_owner), selection, time); - gtk_widget_event (old_owner, event); - - gdk_event_free (event); - } - return TRUE; - } - else - return FALSE; -} - -/** - * gtk_selection_owner_set: - * @widget: (allow-none): a #GtkWidget, or %NULL. - * @selection: an interned atom representing the selection to claim - * @time_: timestamp with which to claim the selection - * - * Claims ownership of a given selection for a particular widget, - * or, if @widget is %NULL, release ownership of the selection. - * - * Returns: %TRUE if the operation succeeded - **/ -gboolean -gtk_selection_owner_set (GtkWidget *widget, - GdkAtom selection, - guint32 time) -{ - GdkDisplay *display; - - g_return_val_if_fail (widget == NULL || gtk_widget_get_realized (widget), FALSE); - g_return_val_if_fail (selection != NULL, FALSE); - - if (widget) - display = gtk_widget_get_display (widget); - else - { - GTK_NOTE (MULTIHEAD, - g_warning ("gtk_selection_owner_set (NULL,...) is not multihead safe")); - - display = gdk_display_get_default (); - } - - return gtk_selection_owner_set_for_display (display, widget, - selection, time); -} - -typedef struct _GtkSelectionTargetList GtkSelectionTargetList; - -struct _GtkSelectionTargetList { - GdkAtom selection; - GdkContentFormats *list; -}; - -static GdkContentFormats * -gtk_selection_target_list_get (GtkWidget *widget, - GdkAtom selection) -{ - GtkSelectionTargetList *sellist; - GList *tmp_list; - GList *lists; - - lists = g_object_get_data (G_OBJECT (widget), gtk_selection_handler_key); - - tmp_list = lists; - while (tmp_list) - { - sellist = tmp_list->data; - if (sellist->selection == selection) - return sellist->list; - tmp_list = tmp_list->next; - } - - sellist = g_slice_new (GtkSelectionTargetList); - sellist->selection = selection; - sellist->list = gdk_content_formats_new (NULL, 0); - - lists = g_list_prepend (lists, sellist); - g_object_set_data (G_OBJECT (widget), I_(gtk_selection_handler_key), lists); - - return sellist->list; -} - -/** * gtk_selection_remove_all: * @widget: a #GtkWidget * @@ -565,7 +377,6 @@ gtk_selection_remove_all (GtkWidget *widget) { GList *tmp_list; GList *next; - GtkSelectionInfo *selection_info; g_return_if_fail (GTK_IS_WIDGET (widget)); @@ -584,29 +395,6 @@ gtk_selection_remove_all (GtkWidget *widget) } tmp_list = next; } - - /* Disclaim ownership of any selections */ - - tmp_list = current_selections; - while (tmp_list) - { - next = tmp_list->next; - selection_info = (GtkSelectionInfo *)tmp_list->data; - - if (selection_info->widget == widget) - { - gdk_selection_owner_set_for_display (selection_info->display, - NULL, - selection_info->selection, - GDK_CURRENT_TIME, FALSE); - current_selections = g_list_remove_link (current_selections, - tmp_list); - g_list_free (tmp_list); - g_slice_free (GtkSelectionInfo, selection_info); - } - - tmp_list = next; - } } @@ -633,8 +421,6 @@ gtk_selection_convert (GtkWidget *widget, { GtkRetrievalInfo *info; GList *tmp_list; - GdkWindow *owner_window; - GdkDisplay *display; guint id; g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); @@ -670,57 +456,6 @@ gtk_selection_convert (GtkWidget *widget, info->buffer = NULL; info->offset = -1; - /* Check if this process has current owner. If so, call handler - procedure directly to avoid deadlocks with INCR. */ - - display = gtk_widget_get_display (widget); - owner_window = gdk_selection_owner_get_for_display (display, selection); - -#ifdef GDK_WINDOWING_WIN32 - /* Special handling for DELETE requests, - * make sure this goes down into GDK layer. - */ - if (GDK_IS_WIN32_DISPLAY (display) && - target == gdk_atom_intern_static_string ("DELETE")) - owner_window = NULL; -#endif - - if (owner_window != NULL) - { - GtkWidget *owner_widget; - gpointer owner_widget_ptr; - GtkSelectionData selection_data = {0}; - - selection_data.selection = selection; - selection_data.target = target; - selection_data.length = -1; - selection_data.display = display; - - gdk_window_get_user_data (owner_window, &owner_widget_ptr); - owner_widget = owner_widget_ptr; - - if (owner_widget != NULL) - { - gtk_selection_invoke_handler (owner_widget, - &selection_data, - time_); - - gtk_selection_retrieval_report (info, - selection_data.type, - selection_data.format, - selection_data.data, - selection_data.length, - time_); - - g_free (selection_data.data); - selection_data.data = NULL; - selection_data.length = -1; - - g_slice_free (GtkRetrievalInfo, info); - return TRUE; - } - } - /* Otherwise, we need to go through X */ current_retrievals = g_list_append (current_retrievals, info); @@ -1856,373 +1591,6 @@ gtk_selection_init (void) initialize = FALSE; } -/** - * _gtk_selection_clear: - * @widget: a #GtkWidget - * @event: the event - * - * The default handler for the #GtkWidget::selection-clear-event - * signal. - * - * Returns: %TRUE if the event was handled, otherwise false - **/ -gboolean -_gtk_selection_clear (GtkWidget *widget, - GdkEventSelection *event) -{ - /* Note that we filter clear events in gdkselection-x11.c, so - * that we only will get here if the clear event actually - * represents a change that we didn't do ourself. - */ - GList *tmp_list; - GtkSelectionInfo *selection_info = NULL; - GdkAtom selection; - - gdk_event_get_selection ((GdkEvent *)event, &selection); - - tmp_list = current_selections; - while (tmp_list) - { - selection_info = (GtkSelectionInfo *)tmp_list->data; - - if ((selection_info->selection == selection) && - (selection_info->widget == widget)) - break; - - tmp_list = tmp_list->next; - } - - if (tmp_list) - { - current_selections = g_list_remove_link (current_selections, tmp_list); - g_list_free (tmp_list); - g_slice_free (GtkSelectionInfo, selection_info); - } - - return TRUE; -} - - -/************************************************************* - * _gtk_selection_request: - * Handler for “selection_request_event” - * arguments: - * widget: - * event: - * results: - *************************************************************/ - -gboolean -_gtk_selection_request (GtkWidget *widget, - GdkEventSelection *event) -{ - GdkDisplay *display = gtk_widget_get_display (widget); - GtkIncrInfo *info; - GList *tmp_list; - int i; - gulong selection_max_size; - guint32 time; - GdkAtom selection; - GdkAtom property; - GdkAtom target; - GdkWindow *requestor; - - time = gdk_event_get_time ((GdkEvent *)event); - gdk_event_get_selection ((GdkEvent *)event, &selection); - gdk_event_get_selection_property ((GdkEvent *)event, &property, &target, &requestor); - - if (requestor == NULL) - return FALSE; - - if (initialize) - gtk_selection_init (); - - selection_max_size = GTK_SELECTION_MAX_SIZE (display); - - /* Check if we own selection */ - - tmp_list = current_selections; - while (tmp_list) - { - GtkSelectionInfo *selection_info = (GtkSelectionInfo *)tmp_list->data; - - if ((selection_info->selection == selection) && - (selection_info->widget == widget)) - break; - - tmp_list = tmp_list->next; - } - - if (tmp_list == NULL) - return FALSE; - - info = g_slice_new (GtkIncrInfo); - - g_object_ref (widget); - - info->selection = selection; - info->num_incrs = 0; - info->requestor = g_object_ref (requestor); - - /* Determine conversions we need to perform */ - if (target == gtk_selection_atoms[MULTIPLE]) - { - GdkAtom type; - guchar *mult_atoms; - gint format; - gint length; - - mult_atoms = NULL; - -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (display)) - gdk_x11_display_error_trap_push (display); -#endif - if (!gdk_property_get (info->requestor, property, NULL, /* AnyPropertyType */ - 0, selection_max_size, FALSE, - &type, &format, &length, &mult_atoms)) - { - gdk_selection_send_notify_for_display (display, - requestor, - selection, - target, - NULL, - time); - g_free (mult_atoms); - g_slice_free (GtkIncrInfo, info); - -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (display)) - gdk_x11_display_error_trap_pop_ignored (display); -#endif - return TRUE; - } -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (display)) - gdk_x11_display_error_trap_pop_ignored (display); - - /* This is annoying; the ICCCM doesn't specify the property type - * used for the property contents, so the autoconversion for - * ATOM / ATOM_PAIR in GDK doesn't work properly. - */ - if (type != GDK_SELECTION_TYPE_ATOM && - type != gdk_atom_intern_static_string ("ATOM_PAIR")) - { - info->num_conversions = length / (2*sizeof (glong)); - info->conversions = g_new (GtkIncrConversion, info->num_conversions); - - for (i=0; i<info->num_conversions; i++) - { - info->conversions[i].target = gdk_x11_xatom_to_atom_for_display (display, - ((glong *)mult_atoms)[2*i]); - info->conversions[i].property = gdk_x11_xatom_to_atom_for_display (display, - ((glong *)mult_atoms)[2*i + 1]); - } - - g_free (mult_atoms); - } - else -#endif - { - info->num_conversions = length / (2*sizeof (GdkAtom)); - info->conversions = g_new (GtkIncrConversion, info->num_conversions); - - for (i=0; i<info->num_conversions; i++) - { - info->conversions[i].target = ((GdkAtom *)mult_atoms)[2*i]; - info->conversions[i].property = ((GdkAtom *)mult_atoms)[2*i+1]; - } - - g_free (mult_atoms); - } - } - else /* only a single conversion */ - { - info->conversions = g_new (GtkIncrConversion, 1); - info->num_conversions = 1; - info->conversions[0].target = target; - info->conversions[0].property = property; - } - - /* Loop through conversions and determine which of these are big - enough to require doing them via INCR */ - for (i=0; i<info->num_conversions; i++) - { - GtkSelectionData data; - glong items; - - data.selection = selection; - data.target = info->conversions[i].target; - data.data = NULL; - data.length = -1; - data.display = gtk_widget_get_display (widget); - -#ifdef DEBUG_SELECTION - g_message ("Selection %ld, target %ld (%s) requested by 0x%x (property = %ld)", - selection, - info->conversions[i].target, - gdk_atom_name (info->conversions[i].target), - event->requestor, info->conversions[i].property); -#endif - - gtk_selection_invoke_handler (widget, &data, time); - if (data.length < 0) - { - info->conversions[i].property = NULL; - continue; - } - - g_return_val_if_fail ((data.format >= 8) && (data.format % 8 == 0), FALSE); - - items = data.length / gtk_selection_bytes_per_item (data.format); - - if (data.length > selection_max_size) - { - /* Sending via INCR */ -#ifdef DEBUG_SELECTION - g_message ("Target larger (%d) than max. request size (%ld), sending incrementally\n", - data.length, selection_max_size); -#endif - - info->conversions[i].offset = 0; - info->conversions[i].data = data; - info->num_incrs++; - -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (display)) - gdk_x11_display_error_trap_push (display); -#endif - gdk_property_change (info->requestor, - info->conversions[i].property, - gtk_selection_atoms[INCR], - 32, - GDK_PROP_MODE_REPLACE, - (guchar *)&items, 1); - -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (display)) - gdk_x11_display_error_trap_pop_ignored (display); -#endif - } - else - { - info->conversions[i].offset = -1; - -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (display)) - gdk_x11_display_error_trap_push (display); -#endif - - gdk_property_change (info->requestor, - info->conversions[i].property, - data.type, - data.format, - GDK_PROP_MODE_REPLACE, - data.data, items); - -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (display)) - gdk_x11_display_error_trap_pop_ignored (display); -#endif - - - g_free (data.data); - } - } - - /* If we have some INCR's, we need to send the rest of the data in - a callback */ - - if (info->num_incrs > 0) - { - guint id; - - /* FIXME: this could be dangerous if window doesn't still - exist */ - -#ifdef DEBUG_SELECTION - g_message ("Starting INCR..."); -#endif - -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (display)) - gdk_x11_display_error_trap_push (display); -#endif - - gdk_window_set_events (info->requestor, - gdk_window_get_events (info->requestor) | - GDK_PROPERTY_CHANGE_MASK); - -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (display)) - gdk_x11_display_error_trap_pop_ignored (display); -#endif - - current_incrs = g_list_append (current_incrs, info); - id = gdk_threads_add_timeout (1000, (GSourceFunc) gtk_selection_incr_timeout, info); - g_source_set_name_by_id (id, "[gtk+] gtk_selection_incr_timeout"); - } - - /* If it was a MULTIPLE request, set the property to indicate which - conversions succeeded */ - if (target == gtk_selection_atoms[MULTIPLE]) - { - GdkAtom *mult_atoms = g_new (GdkAtom, 2 * info->num_conversions); - for (i = 0; i < info->num_conversions; i++) - { - mult_atoms[2*i] = info->conversions[i].target; - mult_atoms[2*i+1] = info->conversions[i].property; - } - -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (display)) - gdk_x11_display_error_trap_push (display); -#endif - - gdk_property_change (info->requestor, property, - gdk_atom_intern_static_string ("ATOM_PAIR"), 32, - GDK_PROP_MODE_REPLACE, - (guchar *)mult_atoms, 2*info->num_conversions); - -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (display)) - gdk_x11_display_error_trap_pop_ignored (display); -#endif - g_free (mult_atoms); - } - - if (info->num_conversions == 1 && - info->conversions[0].property == NULL) - { - /* Reject the entire conversion */ - gdk_selection_send_notify_for_display (gtk_widget_get_display (widget), - requestor, - selection, - target, - NULL, - time); - } - else - { - gdk_selection_send_notify_for_display (gtk_widget_get_display (widget), - requestor, - selection, - target, - property, - time); - } - - if (info->num_incrs == 0) - { - g_free (info->conversions); - g_slice_free (GtkIncrInfo, info); - } - - g_object_unref (widget); - - return TRUE; -} - /************************************************************* * _gtk_selection_incr_event: * Called whenever an PropertyNotify event occurs for an @@ -2360,59 +1728,6 @@ _gtk_selection_incr_event (GdkWindow *window, } /************************************************************* - * gtk_selection_incr_timeout: - * Timeout callback for the sending portion of the INCR - * protocol - * arguments: - * info: Information about this incr - * results: - *************************************************************/ - -static gint -gtk_selection_incr_timeout (GtkIncrInfo *info) -{ - GList *tmp_list; - gboolean retval; - - /* Determine if retrieval has finished by checking if it still in - list of pending retrievals */ - - tmp_list = current_incrs; - while (tmp_list) - { - if (info == (GtkIncrInfo *)tmp_list->data) - break; - tmp_list = tmp_list->next; - } - - /* If retrieval is finished */ - if (!tmp_list || info->idle_time >= IDLE_ABORT_TIME) - { - if (tmp_list && info->idle_time >= IDLE_ABORT_TIME) - { - current_incrs = g_list_remove_link (current_incrs, tmp_list); - g_list_free (tmp_list); - } - - g_free (info->conversions); - /* FIXME: we should check if requestor window is still in use, - and if not, remove it? */ - - g_slice_free (GtkIncrInfo, info); - - retval = FALSE; /* remove timeout */ - } - else - { - info->idle_time++; - - retval = TRUE; /* timeout will happen again */ - } - - return retval; -} - -/************************************************************* * _gtk_selection_notify: * Handler for “selection-notify-event” signals on windows * where a retrieval is currently in process. The selection @@ -2702,131 +2017,6 @@ gtk_selection_retrieval_report (GtkRetrievalInfo *info, &data, time); } -/************************************************************* - * gtk_selection_invoke_handler: - * Finds and invokes handler for specified - * widget/selection/target combination, calls - * gtk_selection_default_handler if none exists. - * - * arguments: - * widget: selection owner - * data: selection data [INOUT] - * time: time from requeset - * - * results: - * Number of bytes written to buffer, -1 if error - *************************************************************/ - -static void -gtk_selection_invoke_handler (GtkWidget *widget, - GtkSelectionData *data, - guint time) -{ - GdkContentFormats *target_list; - - g_return_if_fail (widget != NULL); - - target_list = gtk_selection_target_list_get (widget, data->selection); - if (data->target != gtk_selection_atoms[SAVE_TARGETS] && - target_list && - gdk_content_formats_contain_mime_type (target_list, data->target)) - { - g_signal_emit_by_name (widget, - "selection-get", - data, - time); - } - else - gtk_selection_default_handler (widget, data); -} - -/************************************************************* - * gtk_selection_default_handler: - * Handles some default targets that exist for any widget - * If it can’t fit results into buffer, returns -1. This - * won’t happen in any conceivable case, since it would - * require 1000 selection targets! - * - * arguments: - * widget: selection owner - * data: selection data [INOUT] - * - *************************************************************/ - -static void -gtk_selection_default_handler (GtkWidget *widget, - GtkSelectionData *data) -{ - if (data->target == gtk_selection_atoms[TIMESTAMP]) - { - /* Time which was used to obtain selection */ - GList *tmp_list; - GtkSelectionInfo *selection_info; - - tmp_list = current_selections; - while (tmp_list) - { - selection_info = (GtkSelectionInfo *)tmp_list->data; - if ((selection_info->widget == widget) && - (selection_info->selection == data->selection)) - { - gulong time = selection_info->time; - - gtk_selection_data_set (data, - GDK_SELECTION_TYPE_INTEGER, - 32, - (guchar *)&time, - sizeof (time)); - return; - } - - tmp_list = tmp_list->next; - } - - data->length = -1; - } - else if (data->target == gtk_selection_atoms[TARGETS]) - { - /* List of all targets supported for this widget/selection pair */ - GdkAtom *p; - const char * const *atoms; - gsize count, i; - GdkContentFormats *target_list; - - target_list = gtk_selection_target_list_get (widget, - data->selection); - atoms = gdk_content_formats_get_mime_types (target_list, &count); - - data->type = GDK_SELECTION_TYPE_ATOM; - data->format = 32; - data->length = (count + 3) * sizeof (GdkAtom); - - /* selection data is always terminated by a trailing \0 - */ - p = g_malloc (data->length + 1); - data->data = (guchar *)p; - data->data[data->length] = '\0'; - - *p++ = gtk_selection_atoms[TIMESTAMP]; - *p++ = gtk_selection_atoms[TARGETS]; - *p++ = gtk_selection_atoms[MULTIPLE]; - - for (i = 0; i < count; i++) - *p++ = atoms[i]; - } - else if (data->target == gtk_selection_atoms[SAVE_TARGETS]) - { - gtk_selection_data_set (data, - gdk_atom_intern_static_string ("NULL"), - 32, NULL, 0); - } - else - { - data->length = -1; - } -} - - /** * gtk_selection_data_copy: * @data: a pointer to a #GtkSelectionData-struct. diff --git a/gtk/gtkselection.h b/gtk/gtkselection.h index edfb676491..8f79cd7cb9 100644 --- a/gtk/gtkselection.h +++ b/gtk/gtkselection.h @@ -45,16 +45,6 @@ GDK_AVAILABLE_IN_ALL GdkContentFormats * gtk_content_formats_add_uri_targets (GdkContentFormats *list) G_GNUC_WARN_UNUSED_RESULT; GDK_AVAILABLE_IN_ALL -gboolean gtk_selection_owner_set (GtkWidget *widget, - GdkAtom selection, - guint32 time_); -GDK_AVAILABLE_IN_ALL -gboolean gtk_selection_owner_set_for_display (GdkDisplay *display, - GtkWidget *widget, - GdkAtom selection, - guint32 time_); - -GDK_AVAILABLE_IN_ALL gboolean gtk_selection_convert (GtkWidget *widget, GdkAtom selection, GdkAtom target, diff --git a/gtk/gtkselectionprivate.h b/gtk/gtkselectionprivate.h index 72f748c097..cd3678c8d6 100644 --- a/gtk/gtkselectionprivate.h +++ b/gtk/gtkselectionprivate.h @@ -47,10 +47,6 @@ struct _GtkSelectionData GdkDisplay *display; }; -gboolean _gtk_selection_clear (GtkWidget *widget, - GdkEventSelection *event); -gboolean _gtk_selection_request (GtkWidget *widget, - GdkEventSelection *event); gboolean _gtk_selection_incr_event (GdkWindow *window, GdkEventProperty *event); gboolean _gtk_selection_notify (GtkWidget *widget, diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 6d3ffc0db7..b1e859b608 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -521,8 +521,6 @@ enum { MAP_EVENT, UNMAP_EVENT, PROPERTY_NOTIFY_EVENT, - SELECTION_CLEAR_EVENT, - SELECTION_REQUEST_EVENT, SELECTION_NOTIFY_EVENT, SELECTION_GET, SELECTION_RECEIVED, @@ -1048,8 +1046,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) klass->unmap_event = NULL; klass->window_state_event = NULL; klass->property_notify_event = _gtk_selection_property_notify; - klass->selection_clear_event = _gtk_selection_clear; - klass->selection_request_event = _gtk_selection_request; klass->selection_notify_event = _gtk_selection_notify; klass->selection_received = NULL; klass->proximity_in_event = NULL; @@ -2434,55 +2430,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) _gtk_marshal_BOOLEAN__BOXEDv); /** - * GtkWidget::selection-clear-event: - * @widget: the object which received the signal - * @event: (type Gdk.EventSelection): the #GdkEventSelection which triggered - * this signal. - * - * The ::selection-clear-event signal will be emitted when the - * the @widget's window has lost ownership of a selection. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - */ - widget_signals[SELECTION_CLEAR_EVENT] = - g_signal_new (I_("selection-clear-event"), - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DEPRECATED, - G_STRUCT_OFFSET (GtkWidgetClass, selection_clear_event), - _gtk_boolean_handled_accumulator, NULL, - _gtk_marshal_BOOLEAN__BOXED, - G_TYPE_BOOLEAN, 1, - GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); - g_signal_set_va_marshaller (widget_signals[SELECTION_CLEAR_EVENT], G_TYPE_FROM_CLASS (klass), - _gtk_marshal_BOOLEAN__BOXEDv); - - /** - * GtkWidget::selection-request-event: - * @widget: the object which received the signal - * @event: (type Gdk.EventSelection): the #GdkEventSelection which triggered - * this signal. - * - * The ::selection-request-event signal will be emitted when - * another client requests ownership of the selection owned by - * the @widget's window. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - */ - widget_signals[SELECTION_REQUEST_EVENT] = - g_signal_new (I_("selection-request-event"), - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DEPRECATED, - G_STRUCT_OFFSET (GtkWidgetClass, selection_request_event), - _gtk_boolean_handled_accumulator, NULL, - _gtk_marshal_BOOLEAN__BOXED, - G_TYPE_BOOLEAN, 1, - GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); - g_signal_set_va_marshaller (widget_signals[SELECTION_REQUEST_EVENT], G_TYPE_FROM_CLASS (klass), - _gtk_marshal_BOOLEAN__BOXEDv); - - /** * GtkWidget::selection-notify-event: * @widget: the object which received the signal. * @event: (type Gdk.EventSelection): @@ -6676,8 +6623,6 @@ gtk_widget_event_internal (GtkWidget *widget, case GDK_UNMAP: case GDK_WINDOW_STATE: case GDK_PROPERTY_NOTIFY: - case GDK_SELECTION_CLEAR: - case GDK_SELECTION_REQUEST: case GDK_SELECTION_NOTIFY: return gtk_widget_emit_event_signals (widget, event); default: @@ -6798,12 +6743,6 @@ gtk_widget_emit_event_signals (GtkWidget *widget, case GDK_PROPERTY_NOTIFY: signal_num = PROPERTY_NOTIFY_EVENT; break; - case GDK_SELECTION_CLEAR: - signal_num = SELECTION_CLEAR_EVENT; - break; - case GDK_SELECTION_REQUEST: - signal_num = SELECTION_REQUEST_EVENT; - break; case GDK_SELECTION_NOTIFY: signal_num = SELECTION_NOTIFY_EVENT; break; diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index e0b68690d5..5e7de3a505 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -224,11 +224,6 @@ struct _GtkWidget * unmapped. * @property_notify_event: Signal will be emitted when a property on * the widget’s window has been changed or deleted. - * @selection_clear_event: Signal will be emitted when the the - * widget’s window has lost ownership of a selection. - * @selection_request_event: Signal will be emitted when another - * client requests ownership of the selection owned by the widget's - * window. * @selection_notify_event: * @proximity_in_event: * @proximity_out_event: |