File indexing completed on 2025-03-23 11:14:46
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 KWaylandServer 0017 { 0018 class AbstractDataSource; 0019 } 0020 0021 namespace KWin 0022 { 0023 namespace Xwl 0024 { 0025 class XwlDataSource; 0026 0027 /** 0028 * Represents the X clipboard, which is on Wayland side just called 0029 * @e selection. 0030 */ 0031 class Primary : public Selection 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 Primary(xcb_atom_t atom, QObject *parent); 0037 ~Primary() override; 0038 0039 private: 0040 void doHandleXfixesNotify(xcb_xfixes_selection_notify_event_t *event) override; 0041 void x11OffersChanged(const QStringList &added, const QStringList &removed) override; 0042 /** 0043 * React to Wl selection change. 0044 */ 0045 void wlPrimarySelectionChanged(KWaylandServer::AbstractDataSource *dsi); 0046 /** 0047 * Check the current state of the selection and if a source needs 0048 * to be created or destroyed. 0049 */ 0050 void checkWlSource(); 0051 0052 /** 0053 * Returns if dsi is managed by our data bridge 0054 */ 0055 bool ownsSelection(KWaylandServer::AbstractDataSource *dsi) const; 0056 0057 QMetaObject::Connection m_checkConnection; 0058 0059 Q_DISABLE_COPY(Primary) 0060 bool m_waitingForTargets = false; 0061 std::unique_ptr<XwlDataSource> m_primarySelectionSource; 0062 }; 0063 0064 } // namespace Xwl 0065 } // namespace KWin