File indexing completed on 2025-04-27 08:16:28
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #pragma once 0010 0011 #include "selection.h" 0012 0013 #include <memory> 0014 0015 namespace KWin 0016 { 0017 0018 class AbstractDataSource; 0019 0020 namespace Xwl 0021 { 0022 class XwlDataSource; 0023 0024 /** 0025 * Represents the X clipboard, which is on Wayland side just called 0026 * @e selection. 0027 */ 0028 class Clipboard : public Selection 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 Clipboard(xcb_atom_t atom, QObject *parent); 0034 0035 private: 0036 void doHandleXfixesNotify(xcb_xfixes_selection_notify_event_t *event) override; 0037 void x11OfferLost() override; 0038 void x11OffersChanged(const QStringList &added, const QStringList &removed) override; 0039 /** 0040 * React to Wl selection change. 0041 */ 0042 void wlSelectionChanged(AbstractDataSource *dsi); 0043 /** 0044 * Check the current state of the selection and if a source needs 0045 * to be created or destroyed. 0046 */ 0047 void checkWlSource(); 0048 0049 /** 0050 * Returns if dsi is managed by our data bridge 0051 */ 0052 bool ownsSelection(AbstractDataSource *dsi) const; 0053 0054 QMetaObject::Connection m_checkConnection; 0055 0056 Q_DISABLE_COPY(Clipboard) 0057 bool m_waitingForTargets = false; 0058 std::unique_ptr<XwlDataSource> m_selectionSource; 0059 }; 0060 0061 } // namespace Xwl 0062 } // namespace KWin