[mutter] remote-desktop/session: Maybe emit 'owner-changed' after clipboard enabled
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] remote-desktop/session: Maybe emit 'owner-changed' after clipboard enabled
- Date: Fri, 5 Feb 2021 17:04:38 +0000 (UTC)
commit 2cdb0414c2340f648fbe511469e2e5bd6b6068ca
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Thu Nov 19 14:29:05 2020 +0100
remote-desktop/session: Maybe emit 'owner-changed' after clipboard enabled
If there is a clipboard owner when enabling the clipboard integration
without immediately overriding the owner, send an initial owner-changed
event.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
src/backends/meta-remote-desktop-session.c | 39 ++++++++++++++++++++++--------
1 file changed, 29 insertions(+), 10 deletions(-)
---
diff --git a/src/backends/meta-remote-desktop-session.c b/src/backends/meta-remote-desktop-session.c
index ba6e84ae38..ad9b7672ad 100644
--- a/src/backends/meta-remote-desktop-session.c
+++ b/src/backends/meta-remote-desktop-session.c
@@ -888,10 +888,8 @@ generate_owner_changed_variant (char **mime_types_array,
}
static void
-on_selection_owner_changed (MetaSelection *selection,
- MetaSelectionType selection_type,
- MetaSelectionSource *owner,
- MetaRemoteDesktopSession *session)
+emit_owner_changed (MetaRemoteDesktopSession *session,
+ MetaSelectionSource *owner)
{
char log_buf[255];
g_autofree char **mime_types_array = NULL;
@@ -900,14 +898,11 @@ on_selection_owner_changed (MetaSelection *selection,
GVariant *options_variant;
const char *object_path;
- if (selection_type != META_SELECTION_CLIPBOARD)
- return;
-
if (owner)
{
GList *mime_types;
- mime_types = meta_selection_source_get_mimetypes (owner);
+ mime_types = meta_selection_source_get_mimetypes (owner);
mime_types_array = g_new0 (char *, g_list_length (mime_types) + 1);
for (l = meta_selection_source_get_mimetypes (owner), i = 0;
l;
@@ -941,6 +936,18 @@ on_selection_owner_changed (MetaSelection *selection,
NULL);
}
+static void
+on_selection_owner_changed (MetaSelection *selection,
+ MetaSelectionType selection_type,
+ MetaSelectionSource *owner,
+ MetaRemoteDesktopSession *session)
+{
+ if (selection_type != META_SELECTION_CLIPBOARD)
+ return;
+
+ emit_owner_changed (session, owner);
+}
+
static gboolean
handle_enable_clipboard (MetaDBusRemoteDesktopSession *skeleton,
GDBusMethodInvocation *invocation,
@@ -951,6 +958,7 @@ handle_enable_clipboard (MetaDBusRemoteDesktopSession *skeleton,
g_autoptr (GError) error = NULL;
MetaDisplay *display = meta_get_display ();
MetaSelection *selection = meta_display_get_selection (display);
+ g_autoptr (MetaSelectionSourceRemote) source_remote = NULL;
meta_topic (META_DEBUG_REMOTE_DESKTOP,
"Enable clipboard for %s",
@@ -969,8 +977,6 @@ handle_enable_clipboard (MetaDBusRemoteDesktopSession *skeleton,
G_VARIANT_TYPE_STRING_ARRAY);
if (mime_types_variant)
{
- g_autoptr (MetaSelectionSourceRemote) source_remote = NULL;
-
source_remote = create_remote_desktop_source (session,
mime_types_variant,
&error);
@@ -982,7 +988,10 @@ handle_enable_clipboard (MetaDBusRemoteDesktopSession *skeleton,
error->message);
return TRUE;
}
+ }
+ if (source_remote)
+ {
meta_topic (META_DEBUG_REMOTE_DESKTOP,
"Setting remote desktop clipboard source: %p from %s",
source_remote, session->peer_name);
@@ -992,6 +1001,16 @@ handle_enable_clipboard (MetaDBusRemoteDesktopSession *skeleton,
META_SELECTION_CLIPBOARD,
META_SELECTION_SOURCE (source_remote));
}
+ else
+ {
+ MetaSelectionSource *owner;
+
+ owner = meta_selection_get_current_owner (selection,
+ META_SELECTION_CLIPBOARD);
+
+ if (owner)
+ emit_owner_changed (session, owner);
+ }
session->is_clipboard_enabled = TRUE;
session->owner_changed_handler_id =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]