diff options
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbclipboard.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbclipboard.cpp | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index becb9543f6..2f37ee64b5 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -1,12 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:COMM$ -** +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the @@ -15,25 +14,26 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** $QT_END_LICENSE$ -** -** -** -** -** -** -** -** -** -** -** -** -** -** -** -** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** +** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -71,7 +71,7 @@ public: break; default: - qWarning("QXcbClipboardMime: Internal error: Unsupported clipboard mode"); + qCWarning(lcQpaClipboard, "QXcbClipboardMime: Internal error: Unsupported clipboard mode"); break; } } @@ -265,7 +265,7 @@ QXcbClipboard::~QXcbClipboard() if (auto event = waitForClipboardEvent(m_owner, XCB_SELECTION_NOTIFY, true)) { free(event); } else { - qWarning("QXcbClipboard: Unable to receive an event from the " + qCWarning(lcQpaClipboard, "QXcbClipboard: Unable to receive an event from the " "clipboard manager in a reasonable time"); } } @@ -371,7 +371,7 @@ void QXcbClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) xcb_set_selection_owner(xcb_connection(), newOwner, modeAtom, connection()->time()); if (getSelectionOwner(modeAtom) != newOwner) { - qWarning("QXcbClipboard::setMimeData: Cannot set X11 selection owner"); + qCWarning(lcQpaClipboard, "QXcbClipboard::setMimeData: Cannot set X11 selection owner"); } emitChanged(mode); @@ -538,7 +538,7 @@ void QXcbClipboard::handleSelectionClearRequest(xcb_selection_clear_event_t *eve void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req) { if (requestor() && req->requestor == requestor()) { - qWarning("QXcbClipboard: Selection request should be caught before"); + qCWarning(lcQpaClipboard, "QXcbClipboard: Selection request should be caught before"); return; } @@ -553,7 +553,8 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req) QMimeData *d; QClipboard::Mode mode = modeForAtom(req->selection); if (mode > QClipboard::Selection) { - qWarning() << "QXcbClipboard: Unknown selection" << connection()->atomName(req->selection); + qCWarning(lcQpaClipboard, "QXcbClipboard: Unknown selection %s", + connection()->atomName(req->selection).constData()); xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event); return; } @@ -561,14 +562,14 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req) d = m_clientClipboard[mode]; if (!d) { - qWarning("QXcbClipboard: Cannot transfer data, no data available"); + qCWarning(lcQpaClipboard, "QXcbClipboard: Cannot transfer data, no data available"); xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event); return; } if (m_timestamp[mode] == XCB_CURRENT_TIME // we don't own the selection anymore || (req->time != XCB_CURRENT_TIME && req->time < m_timestamp[mode])) { - qWarning("QXcbClipboard: SelectionRequest too old"); + qCDebug(lcQpaClipboard, "QXcbClipboard: SelectionRequest too old"); xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event); return; } @@ -623,7 +624,7 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req) property, XCB_ATOM_INTEGER, 32, 1, &m_timestamp[mode]); ret = property; } else { - qWarning("QXcbClipboard: Invalid data timestamp"); + qCWarning(lcQpaClipboard, "QXcbClipboard: Invalid data timestamp"); } } else if (target == targetsAtom) { ret = sendTargetsSelection(d, req->requestor, property); @@ -728,7 +729,7 @@ bool QXcbClipboard::clipboardReadProperty(xcb_window_t win, xcb_atom_t property, // recover -- this shouldn't normally happen, but it doesn't // hurt to be defensive if ((int)(buffer_offset + length) > buffer->size()) { - qWarning("QXcbClipboard: buffer overflow"); + qCWarning(lcQpaClipboard, "QXcbClipboard: buffer overflow"); length = buffer->size() - buffer_offset; // escape loop @@ -835,6 +836,8 @@ QByteArray QXcbClipboard::clipboardReadIncrementalProperty(xcb_window_t win, xcb alloc_error = buf.size() != nbytes+1; } + QElapsedTimer timer; + timer.start(); for (;;) { connection()->flush(); xcb_generic_event_t *ge = waitForClipboardEvent(win, XCB_PROPERTY_NOTIFY); @@ -870,9 +873,11 @@ QByteArray QXcbClipboard::clipboardReadIncrementalProperty(xcb_window_t win, xcb tmp_buf.resize(0); offset += length; } - } else { - break; } + + const auto elapsed = timer.elapsed(); + if (elapsed > clipboard_timeout) + break; } // timed out ... create a new requestor window, otherwise the requestor @@ -921,4 +926,5 @@ QByteArray QXcbClipboard::getSelection(xcb_atom_t selection, xcb_atom_t target, QT_END_NAMESPACE +#include "moc_qxcbclipboard.cpp" #include "qxcbclipboard.moc" |