summaryrefslogtreecommitdiff
blob: 42ee58b611fec7732155c9a532de84b9228a93c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From 291eba6f8099a0fec8fbd9cf8a1fb67e5c9f4f8d Mon Sep 17 00:00:00 2001
From: Palo Kisa <palo.kisa@gmail.com>
Date: Mon, 7 Nov 2016 18:27:17 +0100
Subject: QClipboard: Fix emitting changed() in XCB

In XCB environment the QClipboard::changed() was not delivered if the
QClipboard::clear() was issued by other Qt app/process.

If the QClipboard::clear() is used, then the owner in
xcb_xfixes_selection_notify_event_t is XCB_NONE, so we need make the
decission to handle this event by the selection_timestamp and our
m_timestamp[mode].

Task-number: QTBUG-56972
Change-Id: If4c486ac02223eac506465cac7ff1a07bd02a187
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
---
 src/plugins/platforms/xcb/qxcbclipboard.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index d44ebae..40abef4 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -723,8 +723,10 @@ void QXcbClipboard::handleXFixesSelectionRequest(xcb_xfixes_selection_notify_eve
     if (mode > QClipboard::Selection)
         return;
 
-    // here we care only about the xfixes events that come from non Qt processes
-    if (event->owner != XCB_NONE && event->owner != owner()) {
+    // Note1: Here we care only about the xfixes events that come from other processes.
+    // Note2: If the QClipboard::clear() is issued, event->owner is XCB_NONE,
+    // so we check selection_timestamp to not handle our own QClipboard::clear().
+    if (event->owner != owner() && event->selection_timestamp > m_timestamp[mode]) {
         if (!m_xClipboard[mode]) {
             m_xClipboard[mode].reset(new QXcbClipboardMime(mode, this));
         } else {
-- 
cgit v1.0-4-g1e03