GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit 4042d5f2 authored by Benjamin Otte's avatar Benjamin Otte

gdk: Remove ability to own a selection

With this, the GDK_EVENT_SELECTION_REQUEST and GDK_EVENT_SELECTION_CLEAR
and the associated GtkWidget signals are gone, too.
parent 53081bd1
......@@ -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
......
......@@ -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
......
......@@ -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;
......
......@@ -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,
......
......@@ -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,
......
......@@ -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));
......
......@@ -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,
......
......@@ -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;
......
......@@ -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,
......
......@@ -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.
......
......@@ -60,55 +60,6 @@
* X Inter-client Communication Conventions Manual (ICCCM).
*/
/**
* 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.
......@@ -133,67 +84,6 @@ gdk_selection_send_notify (GdkWindow *requestor,
target, property, time);
}
/**
* 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
......
......@@ -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.
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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,
......
......@@ -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,
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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,
......
......@@ -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