summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbclipboard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbclipboard.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index 3c3469a73b..24de78861f 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -208,7 +208,7 @@ QXcbClipboard::~QXcbClipboard()
connection()->sync();
// waiting until the clipboard manager fetches the content.
- if (!waitForClipboardEvent(m_owner, XCB_SELECTION_NOTIFY, 5000)) {
+ if (!waitForClipboardEvent(m_owner, XCB_SELECTION_NOTIFY, 5000, true)) {
qWarning("QClipboard: Unable to receive an event from the "
"clipboard manager in a reasonable time");
}
@@ -726,7 +726,7 @@ namespace
};
}
-xcb_generic_event_t *QXcbClipboard::waitForClipboardEvent(xcb_window_t win, int type, int timeout)
+xcb_generic_event_t *QXcbClipboard::waitForClipboardEvent(xcb_window_t win, int type, int timeout, bool checkManager)
{
QElapsedTimer timer;
timer.start();
@@ -736,6 +736,16 @@ xcb_generic_event_t *QXcbClipboard::waitForClipboardEvent(xcb_window_t win, int
if (e)
return e;
+ if (checkManager) {
+ xcb_get_selection_owner_cookie_t cookie = xcb_get_selection_owner(xcb_connection(), atom(QXcbAtom::CLIPBOARD_MANAGER));
+ xcb_get_selection_owner_reply_t *reply = xcb_get_selection_owner_reply(xcb_connection(), cookie, 0);
+ if (!reply || reply->owner == XCB_NONE) {
+ free(reply);
+ return 0;
+ }
+ free(reply);
+ }
+
// process other clipboard events, since someone is probably requesting data from us
ClipboardEvent clipboard(connection());
e = connection()->checkEvent(clipboard);