diff options
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbclipboard.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbclipboard.cpp | 93 |
1 files changed, 29 insertions, 64 deletions
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index 54fdcf620b..40e2f47354 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qxcbclipboard.h" @@ -67,7 +31,7 @@ public: break; case QClipboard::Clipboard: - modeAtom = m_clipboard->atom(QXcbAtom::CLIPBOARD); + modeAtom = m_clipboard->atom(QXcbAtom::AtomCLIPBOARD); break; default: @@ -92,12 +56,12 @@ protected: if (isEmpty()) return QStringList(); - if (!formatList.count()) { + if (!formatList.size()) { QXcbClipboardMime *that = const_cast<QXcbClipboardMime *>(this); // get the list of targets from the current clipboard owner - we do this // once so that multiple calls to this function don't require multiple // server round trips... - that->format_atoms = m_clipboard->getDataInFormat(modeAtom, m_clipboard->atom(QXcbAtom::TARGETS)); + that->format_atoms = m_clipboard->getDataInFormat(modeAtom, m_clipboard->atom(QXcbAtom::AtomTARGETS)); if (format_atoms.size() > 0) { const xcb_atom_t *targets = (const xcb_atom_t *) format_atoms.data(); @@ -162,7 +126,7 @@ QXcbClipboardTransaction::QXcbClipboardTransaction(QXcbClipboard *clipboard, xcb xcb_change_window_attributes(m_clipboard->xcb_connection(), m_window, XCB_CW_EVENT_MASK, values); - m_abortTimerId = startTimer(m_clipboard->clipboardTimeout()); + m_abortTimerId = startTimer(std::chrono::milliseconds{m_clipboard->clipboardTimeout()}); } QXcbClipboardTransaction::~QXcbClipboardTransaction() @@ -181,7 +145,7 @@ bool QXcbClipboardTransaction::updateIncrementalProperty(const xcb_property_noti // restart the timer if (m_abortTimerId) killTimer(m_abortTimerId); - m_abortTimerId = startTimer(m_clipboard->clipboardTimeout()); + m_abortTimerId = startTimer(std::chrono::milliseconds{m_clipboard->clipboardTimeout()}); uint bytes_left = uint(m_data.size()) - m_offset; if (bytes_left > 0) { @@ -239,7 +203,7 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c) xcb_xfixes_select_selection_input_checked(xcb_connection(), connection()->qtSelectionOwner(), XCB_ATOM_PRIMARY, mask); xcb_xfixes_select_selection_input_checked(xcb_connection(), connection()->qtSelectionOwner(), - atom(QXcbAtom::CLIPBOARD), mask); + atom(QXcbAtom::AtomCLIPBOARD), mask); } // xcb_change_property_request_t and xcb_get_property_request_t are the same size @@ -254,13 +218,13 @@ QXcbClipboard::~QXcbClipboard() m_timestamp[QClipboard::Selection] != XCB_CURRENT_TIME) { // First we check if there is a clipboard manager. - if (connection()->selectionOwner(atom(QXcbAtom::CLIPBOARD_MANAGER)) != XCB_NONE) { + if (connection()->selectionOwner(atom(QXcbAtom::AtomCLIPBOARD_MANAGER)) != XCB_NONE) { // we delete the property so the manager saves all TARGETS. xcb_delete_property(xcb_connection(), connection()->qtSelectionOwner(), - atom(QXcbAtom::_QT_SELECTION)); + atom(QXcbAtom::Atom_QT_SELECTION)); xcb_convert_selection(xcb_connection(), connection()->qtSelectionOwner(), - atom(QXcbAtom::CLIPBOARD_MANAGER), atom(QXcbAtom::SAVE_TARGETS), - atom(QXcbAtom::_QT_SELECTION), connection()->time()); + atom(QXcbAtom::AtomCLIPBOARD_MANAGER), atom(QXcbAtom::AtomSAVE_TARGETS), + atom(QXcbAtom::Atom_QT_SELECTION), connection()->time()); connection()->sync(); // waiting until the clipboard manager fetches the content. @@ -295,7 +259,7 @@ bool QXcbClipboard::handlePropertyNotify(const xcb_generic_event_t *event) xcb_atom_t QXcbClipboard::atomForMode(QClipboard::Mode mode) const { if (mode == QClipboard::Clipboard) - return atom(QXcbAtom::CLIPBOARD); + return atom(QXcbAtom::AtomCLIPBOARD); if (mode == QClipboard::Selection) return XCB_ATOM_PRIMARY; return XCB_NONE; @@ -305,7 +269,7 @@ QClipboard::Mode QXcbClipboard::modeForAtom(xcb_atom_t a) const { if (a == XCB_ATOM_PRIMARY) return QClipboard::Selection; - if (a == atom(QXcbAtom::CLIPBOARD)) + if (a == atom(QXcbAtom::AtomCLIPBOARD)) return QClipboard::Clipboard; // not supported enum value, used to detect errors return QClipboard::FindBuffer; @@ -448,10 +412,10 @@ xcb_atom_t QXcbClipboard::sendTargetsSelection(QMimeData *d, xcb_window_t window types.append(atoms.at(j)); } } - types.append(atom(QXcbAtom::TARGETS)); - types.append(atom(QXcbAtom::MULTIPLE)); - types.append(atom(QXcbAtom::TIMESTAMP)); - types.append(atom(QXcbAtom::SAVE_TARGETS)); + types.append(atom(QXcbAtom::AtomTARGETS)); + types.append(atom(QXcbAtom::AtomMULTIPLE)); + types.append(atom(QXcbAtom::AtomTIMESTAMP)); + types.append(atom(QXcbAtom::AtomSAVE_TARGETS)); xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window, property, XCB_ATOM_ATOM, 32, types.size(), (const void *)types.constData()); @@ -475,7 +439,7 @@ xcb_atom_t QXcbClipboard::sendSelection(QMimeData *d, xcb_atom_t target, xcb_win // don't allow INCR transfers when using MULTIPLE or to // Motif clients (since Motif doesn't support INCR) - static xcb_atom_t motif_clip_temporary = atom(QXcbAtom::CLIP_TEMPORARY); + static xcb_atom_t motif_clip_temporary = atom(QXcbAtom::AtomCLIP_TEMPORARY); bool allow_incr = property != motif_clip_temporary; // This 'bool' can be removed once there is a proper fix for QTBUG-32853 if (m_clipboard_closing) @@ -484,7 +448,7 @@ xcb_atom_t QXcbClipboard::sendSelection(QMimeData *d, xcb_atom_t target, xcb_win if (data.size() > m_maxPropertyRequestDataBytes && allow_incr) { long bytes = data.size(); xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window, property, - atom(QXcbAtom::INCR), 32, 1, (const void *)&bytes); + atom(QXcbAtom::AtomINCR), 32, 1, (const void *)&bytes); auto transaction = new QXcbClipboardTransaction(this, window, property, data, atomFormat, dataFormat); m_transactions.insert(window, transaction); return property; @@ -568,9 +532,9 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req) return; } - xcb_atom_t targetsAtom = atom(QXcbAtom::TARGETS); - xcb_atom_t multipleAtom = atom(QXcbAtom::MULTIPLE); - xcb_atom_t timestampAtom = atom(QXcbAtom::TIMESTAMP); + xcb_atom_t targetsAtom = atom(QXcbAtom::AtomTARGETS); + xcb_atom_t multipleAtom = atom(QXcbAtom::AtomMULTIPLE); + xcb_atom_t timestampAtom = atom(QXcbAtom::AtomTIMESTAMP); struct AtomPair { xcb_atom_t target; xcb_atom_t property; } *multi = nullptr; xcb_atom_t multi_type = XCB_NONE; @@ -744,7 +708,7 @@ bool QXcbClipboard::clipboardReadProperty(xcb_window_t win, xcb_atom_t property, // correct size, not 0-term. if (size) *size = buffer_offset; - if (*type == atom(QXcbAtom::INCR)) + if (*type == atom(QXcbAtom::AtomINCR)) m_incr_receive_time = connection()->getTimestamp(); if (deleteProperty) xcb_delete_property(xcb_connection(), win, property); @@ -783,12 +747,12 @@ xcb_generic_event_t *QXcbClipboard::waitForClipboardEvent(xcb_window_t window, i const QXcbEventNode *flushedTailNode = queue->flushedTail(); if (checkManager) { - if (connection()->selectionOwner(atom(QXcbAtom::CLIPBOARD_MANAGER)) == XCB_NONE) + if (connection()->selectionOwner(atom(QXcbAtom::AtomCLIPBOARD_MANAGER)) == XCB_NONE) return nullptr; } // process other clipboard events, since someone is probably requesting data from us - auto clipboardAtom = atom(QXcbAtom::CLIPBOARD); + auto clipboardAtom = atom(QXcbAtom::AtomCLIPBOARD); e = queue->peek([clipboardAtom](xcb_generic_event_t *event, int type) { xcb_atom_t selection = XCB_ATOM_NONE; if (type == XCB_SELECTION_REQUEST) @@ -882,7 +846,7 @@ QByteArray QXcbClipboard::clipboardReadIncrementalProperty(xcb_window_t win, xcb QByteArray QXcbClipboard::getDataInFormat(xcb_atom_t modeAtom, xcb_atom_t fmtAtom) { - return getSelection(modeAtom, fmtAtom, atom(QXcbAtom::_QT_SELECTION)); + return getSelection(modeAtom, fmtAtom, atom(QXcbAtom::Atom_QT_SELECTION)); } QByteArray QXcbClipboard::getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property, xcb_timestamp_t time) @@ -906,7 +870,7 @@ QByteArray QXcbClipboard::getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t type; if (clipboardReadProperty(win, property, true, &buf, nullptr, &type, nullptr)) { - if (type == atom(QXcbAtom::INCR)) { + if (type == atom(QXcbAtom::AtomINCR)) { int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0; buf = clipboardReadIncrementalProperty(win, property, nbytes, false); } @@ -919,4 +883,5 @@ QByteArray QXcbClipboard::getSelection(xcb_atom_t selection, xcb_atom_t target, QT_END_NAMESPACE +#include "moc_qxcbclipboard.cpp" #include "qxcbclipboard.moc" |