File indexing completed on 2024-05-12 05:32:35
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 SPDX-FileCopyrightText: 2021 David Redondo <kde@david-redondo.de> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 #pragma once 0011 0012 #include "selection.h" 0013 0014 #include <memory> 0015 0016 namespace KWin 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 Primary : public Selection 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 Primary(xcb_atom_t atom, QObject *parent); 0034 ~Primary() override; 0035 0036 private: 0037 void doHandleXfixesNotify(xcb_xfixes_selection_notify_event_t *event) override; 0038 void x11OfferLost() override; 0039 void x11OffersChanged(const QStringList &added, const QStringList &removed) override; 0040 /** 0041 * React to Wl selection change. 0042 */ 0043 void wlPrimarySelectionChanged(AbstractDataSource *dsi); 0044 /** 0045 * Check the current state of the selection and if a source needs 0046 * to be created or destroyed. 0047 */ 0048 void checkWlSource(); 0049 0050 /** 0051 * Returns if dsi is managed by our data bridge 0052 */ 0053 bool ownsSelection(AbstractDataSource *dsi) const; 0054 0055 QMetaObject::Connection m_checkConnection; 0056 0057 Q_DISABLE_COPY(Primary) 0058 bool m_waitingForTargets = false; 0059 std::unique_ptr<XwlDataSource> m_primarySelectionSource; 0060 }; 0061 0062 } // namespace Xwl 0063 } // namespace KWin