|
|
a547b4 |
From 3ff64705a7802e4944fcb5e7a027126127043bc8 Mon Sep 17 00:00:00 2001
|
|
|
a547b4 |
From: =?UTF-8?q?Jakub=20Jank=C5=AF?= <jjanku@redhat.com>
|
|
|
a547b4 |
Date: Thu, 21 Feb 2019 21:25:57 +0100
|
|
|
a547b4 |
Subject: [PATCH] x11: invalidate requests for targets on grab from client
|
|
|
a547b4 |
MIME-Version: 1.0
|
|
|
a547b4 |
Content-Type: text/plain; charset=UTF-8
|
|
|
a547b4 |
Content-Transfer-Encoding: 8bit
|
|
|
a547b4 |
|
|
|
a547b4 |
If XSetSelectionOwner() is invoked during the time
|
|
|
a547b4 |
we are waiting for the requested clipboard targets,
|
|
|
a547b4 |
the targets we eventually receive are no longer valid.
|
|
|
a547b4 |
|
|
|
a547b4 |
To solve this, ignore the same count of target notifications
|
|
|
a547b4 |
as we expected at the time we received grab from the client.
|
|
|
a547b4 |
|
|
|
a547b4 |
Otherwise we end up in a situation when vdagent holds
|
|
|
a547b4 |
the clipboard grab in the guest but cannot provide data to the
|
|
|
a547b4 |
apps that request it - this can be observed in the log:
|
|
|
a547b4 |
|
|
|
a547b4 |
clipboard: received selection request event for target *, while not owning client clipboard
|
|
|
a547b4 |
|
|
|
a547b4 |
Signed-off-by: Jakub Janků <jjanku@redhat.com>
|
|
|
a547b4 |
Acked-by: Victor Toso <victortoso@redhat.com>
|
|
|
a547b4 |
---
|
|
|
a547b4 |
src/vdagent-x11-priv.h | 1 +
|
|
|
a547b4 |
src/vdagent-x11.c | 11 +++++++++++
|
|
|
a547b4 |
2 files changed, 12 insertions(+)
|
|
|
a547b4 |
|
|
|
a547b4 |
diff --git a/src/vdagent-x11-priv.h b/src/vdagent-x11-priv.h
|
|
|
a547b4 |
index 38f852e..29018a3 100644
|
|
|
a547b4 |
--- a/src/vdagent-x11-priv.h
|
|
|
a547b4 |
+++ b/src/vdagent-x11-priv.h
|
|
|
a547b4 |
@@ -97,6 +97,7 @@ struct vdagent_x11 {
|
|
|
a547b4 |
int xfixes_event_base;
|
|
|
a547b4 |
int max_prop_size;
|
|
|
a547b4 |
int expected_targets_notifies[256];
|
|
|
a547b4 |
+ int ignore_targets_notifies[256];
|
|
|
a547b4 |
int clipboard_owner[256];
|
|
|
a547b4 |
int clipboard_type_count[256];
|
|
|
a547b4 |
uint32_t clipboard_agent_types[256][256];
|
|
|
a547b4 |
diff --git a/src/vdagent-x11.c b/src/vdagent-x11.c
|
|
|
a547b4 |
index 5ac2cf7..3d752c1 100644
|
|
|
a547b4 |
--- a/src/vdagent-x11.c
|
|
|
a547b4 |
+++ b/src/vdagent-x11.c
|
|
|
a547b4 |
@@ -894,6 +894,12 @@ static void vdagent_x11_handle_targets_notify(struct vdagent_x11 *x11,
|
|
|
a547b4 |
|
|
|
a547b4 |
x11->expected_targets_notifies[selection]--;
|
|
|
a547b4 |
|
|
|
a547b4 |
+ if (x11->ignore_targets_notifies[selection] > 0) {
|
|
|
a547b4 |
+ x11->ignore_targets_notifies[selection]--;
|
|
|
a547b4 |
+ VSELPRINTF("ignoring selection notify TARGETS");
|
|
|
a547b4 |
+ return;
|
|
|
a547b4 |
+ }
|
|
|
a547b4 |
+
|
|
|
a547b4 |
/* If we have more targets_notifies pending, ignore this one, we
|
|
|
a547b4 |
are only interested in the targets list of the current owner
|
|
|
a547b4 |
(which is the last one we've requested a targets list from) */
|
|
|
a547b4 |
@@ -1194,6 +1200,11 @@ void vdagent_x11_clipboard_grab(struct vdagent_x11 *x11, uint8_t selection,
|
|
|
a547b4 |
x11->selection_window, CurrentTime);
|
|
|
a547b4 |
vdagent_x11_set_clipboard_owner(x11, selection, owner_client);
|
|
|
a547b4 |
|
|
|
a547b4 |
+ /* If there're pending requests for targets, ignore the returned
|
|
|
a547b4 |
+ * targets as the XSetSelectionOwner() call above made them invalid */
|
|
|
a547b4 |
+ x11->ignore_targets_notifies[selection] =
|
|
|
a547b4 |
+ x11->expected_targets_notifies[selection];
|
|
|
a547b4 |
+
|
|
|
a547b4 |
/* Flush output buffers and consume any pending events */
|
|
|
a547b4 |
vdagent_x11_do_read(x11);
|
|
|
a547b4 |
}
|
|
|
a547b4 |
--
|
|
|
a547b4 |
2.20.1
|
|
|
a547b4 |
|