summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-09-27 14:51:23 +0000
committerMatthias Clasen <mclasen@redhat.com>2020-09-27 14:51:23 +0000
commit6f823cd0bdcdef6708c6849f5d4a20575abb42ca (patch)
tree9828c609f1fc432213b03935825d53f8527a61e4
parent97d052ef1b821af1d43db65c336a69db6fa532fa (diff)
parent9ea0469ab0a97fa5bdb515098559e681739127ba (diff)
downloadgtk+-6f823cd0bdcdef6708c6849f5d4a20575abb42ca.tar.gz
Merge branch 'issue2627-gtk4' into 'master'
gdk/wayland: Replace gtk-primary-selection with primary-selection-unstable-v1 See merge request GNOME/gtk!2630
-rw-r--r--gdk/wayland/gdkdisplay-wayland.c4
-rw-r--r--gdk/wayland/gdkdisplay-wayland.h3
-rw-r--r--gdk/wayland/gdkprimary-wayland.c84
-rw-r--r--gdk/wayland/gdkprimary-wayland.h1
-rw-r--r--gdk/wayland/gdkprivate-wayland.h1
-rw-r--r--gdk/wayland/meson.build2
-rw-r--r--gdk/wayland/protocol/gtk-primary-selection.xml225
7 files changed, 47 insertions, 273 deletions
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index 6ca4b8f152..52dd6dcf5d 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -497,11 +497,11 @@ gdk_registry_handle_global (void *data,
wl_registry_bind (display_wayland->wl_registry,
id, &zwp_pointer_gestures_v1_interface, version);
}
- else if (strcmp (interface, "gtk_primary_selection_device_manager") == 0)
+ else if (strcmp (interface, "zwp_primary_selection_device_manager_v1") == 0)
{
display_wayland->primary_selection_manager =
wl_registry_bind(display_wayland->wl_registry, id,
- &gtk_primary_selection_device_manager_interface, 1);
+ &zwp_primary_selection_device_manager_v1_interface, 1);
}
else if (strcmp (interface, "zwp_tablet_manager_v2") == 0)
{
diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h
index daf157dbcc..49794d159e 100644
--- a/gdk/wayland/gdkdisplay-wayland.h
+++ b/gdk/wayland/gdkdisplay-wayland.h
@@ -36,6 +36,7 @@
#include <gdk/wayland/server-decoration-client-protocol.h>
#include <gdk/wayland/xdg-output-unstable-v1-client-protocol.h>
#include <gdk/wayland/idle-inhibit-unstable-v1-client-protocol.h>
+#include <gdk/wayland/primary-selection-unstable-v1-client-protocol.h>
#include <glib.h>
#include <gdk/gdkkeys.h>
@@ -103,7 +104,7 @@ struct _GdkWaylandDisplay
struct wl_data_device_manager *data_device_manager;
struct wl_subcompositor *subcompositor;
struct zwp_pointer_gestures_v1 *pointer_gestures;
- struct gtk_primary_selection_device_manager *primary_selection_manager;
+ struct zwp_primary_selection_device_manager_v1 *primary_selection_manager;
struct zwp_tablet_manager_v2 *tablet_manager;
struct zxdg_exporter_v1 *xdg_exporter;
struct zxdg_importer_v1 *xdg_importer;
diff --git a/gdk/wayland/gdkprimary-wayland.c b/gdk/wayland/gdkprimary-wayland.c
index 767371527e..0cb436a82d 100644
--- a/gdk/wayland/gdkprimary-wayland.c
+++ b/gdk/wayland/gdkprimary-wayland.c
@@ -35,15 +35,15 @@ struct _GdkWaylandPrimary
{
GdkClipboard parent;
- struct gtk_primary_selection_device *primary_data_device;
+ struct zwp_primary_selection_device_v1 *primary_data_device;
- struct gtk_primary_selection_offer *pending;
+ struct zwp_primary_selection_offer_v1 *pending;
GdkContentFormatsBuilder *pending_builder;
- struct gtk_primary_selection_offer *offer;
+ struct zwp_primary_selection_offer_v1 *offer;
GdkContentFormats *offer_formats;
- struct gtk_primary_selection_source *source;
+ struct zwp_primary_selection_source_v1 *source;
};
struct _GdkWaylandPrimaryClass
@@ -62,20 +62,20 @@ gdk_wayland_primary_discard_pending (GdkWaylandPrimary *cb)
gdk_content_formats_unref (ignore);
cb->pending_builder = NULL;
}
- g_clear_pointer (&cb->pending, gtk_primary_selection_offer_destroy);
+ g_clear_pointer (&cb->pending, zwp_primary_selection_offer_v1_destroy);
}
static void
gdk_wayland_primary_discard_offer (GdkWaylandPrimary *cb)
{
g_clear_pointer (&cb->offer_formats, gdk_content_formats_unref);
- g_clear_pointer (&cb->offer, gtk_primary_selection_offer_destroy);
+ g_clear_pointer (&cb->offer, zwp_primary_selection_offer_v1_destroy);
}
static void
gdk_wayland_primary_discard_source (GdkWaylandPrimary *cb)
{
- g_clear_pointer (&cb->source, gtk_primary_selection_source_destroy);
+ g_clear_pointer (&cb->source, zwp_primary_selection_source_v1_destroy);
}
static void
@@ -91,9 +91,9 @@ gdk_wayland_primary_finalize (GObject *object)
}
static void
-gdk_wayland_primary_claim_remote (GdkWaylandPrimary *cb,
- struct gtk_primary_selection_offer *offer,
- GdkContentFormats *formats)
+gdk_wayland_primary_claim_remote (GdkWaylandPrimary *cb,
+ struct zwp_primary_selection_offer_v1 *offer,
+ GdkContentFormats *formats)
{
g_return_if_fail (GDK_IS_WAYLAND_PRIMARY (cb));
@@ -117,9 +117,9 @@ gdk_wayland_primary_claim_remote (GdkWaylandPrimary *cb,
}
static void
-primary_offer_offer (void *data,
- struct gtk_primary_selection_offer *offer,
- const char *type)
+primary_offer_offer (void *data,
+ struct zwp_primary_selection_offer_v1 *offer,
+ const char *type)
{
GdkWaylandPrimary *cb = data;
@@ -133,14 +133,14 @@ primary_offer_offer (void *data,
gdk_content_formats_builder_add_mime_type (cb->pending_builder, type);
}
-static const struct gtk_primary_selection_offer_listener primary_offer_listener = {
+static const struct zwp_primary_selection_offer_v1_listener primary_offer_listener = {
primary_offer_offer,
};
static void
-primary_selection_data_offer (void *data,
- struct gtk_primary_selection_device *device,
- struct gtk_primary_selection_offer *offer)
+primary_selection_data_offer (void *data,
+ struct zwp_primary_selection_device_v1 *device,
+ struct zwp_primary_selection_offer_v1 *offer)
{
GdkWaylandPrimary *cb = data;
@@ -150,17 +150,17 @@ primary_selection_data_offer (void *data,
gdk_wayland_primary_discard_pending (cb);
cb->pending = offer;
- gtk_primary_selection_offer_add_listener (offer,
- &primary_offer_listener,
- cb);
+ zwp_primary_selection_offer_v1_add_listener (offer,
+ &primary_offer_listener,
+ cb);
cb->pending_builder = gdk_content_formats_builder_new ();
}
static void
-primary_selection_selection (void *data,
- struct gtk_primary_selection_device *device,
- struct gtk_primary_selection_offer *offer)
+primary_selection_selection (void *data,
+ struct zwp_primary_selection_device_v1 *device,
+ struct zwp_primary_selection_offer_v1 *offer)
{
GdkWaylandPrimary *cb = data;
GdkContentFormats *formats;
@@ -185,7 +185,7 @@ primary_selection_selection (void *data,
gdk_wayland_primary_claim_remote (cb, offer, formats);
}
-static const struct gtk_primary_selection_device_listener primary_selection_device_listener = {
+static const struct zwp_primary_selection_device_v1_listener primary_selection_device_listener = {
primary_selection_data_offer,
primary_selection_selection,
};
@@ -205,10 +205,10 @@ gdk_wayland_primary_write_done (GObject *clipboard,
}
static void
-gdk_wayland_primary_data_source_send (void *data,
- struct gtk_primary_selection_source *source,
- const char *mime_type,
- int32_t fd)
+gdk_wayland_primary_data_source_send (void *data,
+ struct zwp_primary_selection_source_v1 *source,
+ const char *mime_type,
+ int32_t fd)
{
GdkWaylandPrimary *cb = GDK_WAYLAND_PRIMARY (data);
GOutputStream *stream;
@@ -230,8 +230,8 @@ gdk_wayland_primary_data_source_send (void *data,
}
static void
-gdk_wayland_primary_data_source_cancelled (void *data,
- struct gtk_primary_selection_source *source)
+gdk_wayland_primary_data_source_cancelled (void *data,
+ struct zwp_primary_selection_source_v1 *source)
{
GdkWaylandPrimary *cb = GDK_WAYLAND_PRIMARY (data);
@@ -244,7 +244,7 @@ gdk_wayland_primary_data_source_cancelled (void *
}
}
-static const struct gtk_primary_selection_source_listener primary_source_listener = {
+static const struct zwp_primary_selection_source_v1_listener primary_source_listener = {
gdk_wayland_primary_data_source_send,
gdk_wayland_primary_data_source_cancelled,
};
@@ -266,18 +266,18 @@ gdk_wayland_primary_claim (GdkClipboard *clipboard,
gdk_wayland_primary_discard_offer (cb);
gdk_wayland_primary_discard_source (cb);
- cb->source = gtk_primary_selection_device_manager_create_source (wdisplay->primary_selection_manager);
- gtk_primary_selection_source_add_listener (cb->source, &primary_source_listener, cb);
+ cb->source = zwp_primary_selection_device_manager_v1_create_source (wdisplay->primary_selection_manager);
+ zwp_primary_selection_source_v1_add_listener (cb->source, &primary_source_listener, cb);
mime_types = gdk_content_formats_get_mime_types (formats, &n_mime_types);
for (i = 0; i < n_mime_types; i++)
{
- gtk_primary_selection_source_offer (cb->source, mime_types[i]);
+ zwp_primary_selection_source_v1_offer (cb->source, mime_types[i]);
}
- gtk_primary_selection_device_set_selection (cb->primary_data_device,
- cb->source,
- _gdk_wayland_display_get_serial (wdisplay));
+ zwp_primary_selection_device_v1_set_selection (cb->primary_data_device,
+ cb->source,
+ _gdk_wayland_display_get_serial (wdisplay));
}
return GDK_CLIPBOARD_CLASS (gdk_wayland_primary_parent_class)->claim (clipboard, formats, local, content);
@@ -323,7 +323,7 @@ gdk_wayland_primary_read_async (GdkClipboard *clipboard,
return;
}
- gtk_primary_selection_offer_receive (cb->offer, mime_type, pipe_fd[1]);
+ zwp_primary_selection_offer_v1_receive (cb->offer, mime_type, pipe_fd[1]);
stream = g_unix_input_stream_new (pipe_fd[0], TRUE);
close (pipe_fd[1]);
g_task_return_pointer (task, stream, g_object_unref);
@@ -390,10 +390,10 @@ gdk_wayland_primary_new (GdkWaylandSeat *seat)
NULL);
cb->primary_data_device =
- gtk_primary_selection_device_manager_get_device (wdisplay->primary_selection_manager,
- gdk_wayland_seat_get_wl_seat (GDK_SEAT (seat)));
- gtk_primary_selection_device_add_listener (cb->primary_data_device,
- &primary_selection_device_listener, cb);
+ zwp_primary_selection_device_manager_v1_get_device (wdisplay->primary_selection_manager,
+ gdk_wayland_seat_get_wl_seat (GDK_SEAT (seat)));
+ zwp_primary_selection_device_v1_add_listener (cb->primary_data_device,
+ &primary_selection_device_listener, cb);
return GDK_CLIPBOARD (cb);
}
diff --git a/gdk/wayland/gdkprimary-wayland.h b/gdk/wayland/gdkprimary-wayland.h
index 106ef5ee83..bce4dccc7b 100644
--- a/gdk/wayland/gdkprimary-wayland.h
+++ b/gdk/wayland/gdkprimary-wayland.h
@@ -22,7 +22,6 @@
#include "gdkseat-wayland.h"
#include <wayland-client.h>
-#include "gtk-primary-selection-client-protocol.h"
G_BEGIN_DECLS
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
index 11c6cefed4..19a4e91c0b 100644
--- a/gdk/wayland/gdkprivate-wayland.h
+++ b/gdk/wayland/gdkprivate-wayland.h
@@ -39,7 +39,6 @@
#include <xkbcommon/xkbcommon.h>
#include "gdkinternals.h"
-#include "wayland/gtk-primary-selection-client-protocol.h"
#define WL_SURFACE_HAS_BUFFER_SCALE 3
#define WL_POINTER_HAS_FRAME 5
diff --git a/gdk/wayland/meson.build b/gdk/wayland/meson.build
index 67ebb63da5..4217eb2a93 100644
--- a/gdk/wayland/meson.build
+++ b/gdk/wayland/meson.build
@@ -45,7 +45,7 @@ wayland_scanner = find_program('wayland-scanner')
# - protocol version (if stability is 'unstable')
proto_sources = [
['gtk-shell', 'private', ],
- ['gtk-primary-selection', 'private', ],
+ ['primary-selection', 'unstable', 'v1', ],
['pointer-gestures', 'unstable', 'v1', ],
['xdg-shell', 'unstable', 'v6', ],
['xdg-shell', 'stable', ],
diff --git a/gdk/wayland/protocol/gtk-primary-selection.xml b/gdk/wayland/protocol/gtk-primary-selection.xml
deleted file mode 100644
index 02cab94fcb..0000000000
--- a/gdk/wayland/protocol/gtk-primary-selection.xml
+++ /dev/null
@@ -1,225 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<protocol name="gtk_primary_selection">
- <copyright>
- Copyright © 2015, 2016 Red Hat
-
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and associated documentation files (the "Software"),
- to deal in the Software without restriction, including without limitation
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
- and/or sell copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice (including the next
- paragraph) shall be included in all copies or substantial portions of the
- Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
- </copyright>
-
- <description summary="Primary selection protocol">
- This protocol provides the ability to have a primary selection device to
- match that of the X server. This primary selection is a shortcut to the
- common clipboard selection, where text just needs to be selected in order
- to allow copying it elsewhere. The de facto way to perform this action
- is the middle mouse button, although it is not limited to this one.
-
- Clients wishing to honor primary selection should create a primary
- selection source and set it as the selection through
- wp_primary_selection_device.set_selection whenever the text selection
- changes. In order to minimize calls in pointer-driven text selection,
- it should happen only once after the operation finished. Similarly,
- a NULL source should be set when text is unselected.
-
- wp_primary_selection_offer objects are first announced through the
- wp_primary_selection_device.data_offer event. Immediately after this event,
- the primary data offer will emit wp_primary_selection_offer.offer events
- to let know of the mime types being offered.
-
- When the primary selection changes, the client with the keyboard focus
- will receive wp_primary_selection_device.selection events. Only the client
- with the keyboard focus will receive such events with a non-NULL
- wp_primary_selection_offer. Across keyboard focus changes, previously
- focused clients will receive wp_primary_selection_device.events with a
- NULL wp_primary_selection_offer.
-
- In order to request the primary selection data, the client must pass
- a recent serial pertaining to the press event that is triggering the
- operation, if the compositor deems the serial valid and recent, the
- wp_primary_selection_source.send event will happen in the other end
- to let the transfer begin. The client owning the primary selection
- should write the requested data, and close the file descriptor
- immediately.
-
- If the primary selection owner client disappeared during the transfer,
- the client reading the data will receive a
- wp_primary_selection_device.selection event with a NULL
- wp_primary_selection_offer, the client should take this as a hint
- to finish the reads related to the no longer existing offer.
-
- The primary selection owner should be checking for errors during
- writes, merely cancelling the ongoing transfer if any happened.
- </description>
-
- <interface name="gtk_primary_selection_device_manager" version="1">
- <description summary="X primary selection emulation">
- The primary selection device manager is a singleton global object that
- provides access to the primary selection. It allows to create
- wp_primary_selection_source objects, as well as retrieving the per-seat
- wp_primary_selection_device objects.
- </description>
-
- <request name="create_source">
- <description summary="create a new primary selection source">
- Create a new primary selection source.
- </description>
- <arg name="id" type="new_id" interface="gtk_primary_selection_source"/>
- </request>
-
- <request name="get_device">
- <description summary="create a new primary selection device">
- Create a new data device for a given seat.
- </description>
- <arg name="id" type="new_id" interface="gtk_primary_selection_device"/>
- <arg name="seat" type="object" interface="wl_seat"/>
- </request>
-
- <request name="destroy" type="destructor">
- <description summary="destroy the primary selection device manager">
- Destroy the primary selection device manager.
- </description>
- </request>
- </interface>
-
- <interface name="gtk_primary_selection_device" version="1">
- <request name="set_selection">
- <description summary="set the primary selection">
- Replaces the current selection. The previous owner of the primary selection
- will receive a wp_primary_selection_source.cancelled event.
-
- To unset the selection, set the source to NULL.
- </description>
- <arg name="source" type="object" interface="gtk_primary_selection_source" allow-null="true"/>
- <arg name="serial" type="uint" summary="serial of the event that triggered this request"/>
- </request>
-
- <event name="data_offer">
- <description summary="introduce a new wp_primary_selection_offer">
- Introduces a new wp_primary_selection_offer object that may be used
- to receive the current primary selection. Immediately following this
- event, the new wp_primary_selection_offer object will send
- wp_primary_selection_offer.offer events to describe the offered mime
- types.
- </description>
- <arg name="offer" type="new_id" interface="gtk_primary_selection_offer"/>
- </event>
-
- <event name="selection">
- <description summary="advertise a new primary selection">
- The wp_primary_selection_device.selection event is sent to notify the
- client of a new primary selection. This event is sent after the
- wp_primary_selection.data_offer event introducing this object, and after
- the offer has announced its mimetypes through
- wp_primary_selection_offer.offer.
-
- The data_offer is valid until a new offer or NULL is received
- or until the client loses keyboard focus. The client must destroy the
- previous selection data_offer, if any, upon receiving this event.
- </description>
- <arg name="id" type="object" interface="gtk_primary_selection_offer" allow-null="true"/>
- </event>
-
- <request name="destroy" type="destructor">
- <description summary="destroy the primary selection device">
- Destroy the primary selection device.
- </description>
- </request>
- </interface>
-
- <interface name="gtk_primary_selection_offer" version="1">
- <description summary="offer to transfer primary selection contents">
- A wp_primary_selection_offer represents an offer to transfer the contents
- of the primary selection clipboard to the client. Similar to
- wl_data_offer, the offer also describes the mime types that the source
- will transferthat the
- data can be converted to and provides the mechanisms for transferring the
- data directly to the client.
- </description>
-
- <request name="receive">
- <description summary="request that the data is transferred">
- To transfer the contents of the primary selection clipboard, the client
- issues this request and indicates the mime type that it wants to
- receive. The transfer happens through the passed file descriptor
- (typically created with the pipe system call). The source client writes
- the data in the mime type representation requested and then closes the
- file descriptor.
-
- The receiving client reads from the read end of the pipe until EOF and
- closes its end, at which point the transfer is complete.
- </description>
- <arg name="mime_type" type="string"/>
- <arg name="fd" type="fd"/>
- </request>
-
- <request name="destroy" type="destructor">
- <description summary="destroy the primary selection offer">
- Destroy the primary selection offer.
- </description>
- </request>
-
- <event name="offer">
- <description summary="advertise offered mime type">
- Sent immediately after creating announcing the wp_primary_selection_offer
- through wp_primary_selection_device.data_offer. One event is sent per
- offered mime type.
- </description>
- <arg name="mime_type" type="string"/>
- </event>
- </interface>
-
- <interface name="gtk_primary_selection_source" version="1">
- <description summary="offer to replace the contents of the primary selection">
- The source side of a wp_primary_selection_offer, it provides a way to
- describe the offered data and respond to requests to transfer the
- requested contents of the primary selection clipboard.
- </description>
-
- <request name="offer">
- <description summary="add an offered mime type">
- This request adds a mime type to the set of mime types advertised to
- targets. Can be called several times to offer multiple types.
- </description>
- <arg name="mime_type" type="string"/>
- </request>
-
- <request name="destroy" type="destructor">
- <description summary="destroy the primary selection source">
- Destroy the primary selection source.
- </description>
- </request>
-
- <event name="send">
- <description summary="send the primary selection contents">
- Request for the current primary selection contents from the client.
- Send the specified mime type over the passed file descriptor, then
- close it.
- </description>
- <arg name="mime_type" type="string"/>
- <arg name="fd" type="fd"/>
- </event>
-
- <event name="cancelled">
- <description summary="request for primary selection contents was canceled">
- This primary selection source is no longer valid. The client should
- clean up and destroy this primary selection source.
- </description>
- </event>
- </interface>
-</protocol>