File indexing completed on 2024-05-19 16:35:34

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 KWaylandServer
0016 {
0017 class AbstractDataSource;
0018 }
0019 
0020 namespace KWin
0021 {
0022 namespace Xwl
0023 {
0024 class XwlDataSource;
0025 
0026 /**
0027  * Represents the X clipboard, which is on Wayland side just called
0028  * @e selection.
0029  */
0030 class Clipboard : public Selection
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     Clipboard(xcb_atom_t atom, QObject *parent);
0036 
0037 private:
0038     void doHandleXfixesNotify(xcb_xfixes_selection_notify_event_t *event) override;
0039     void x11OffersChanged(const QStringList &added, const QStringList &removed) override;
0040     /**
0041      * React to Wl selection change.
0042      */
0043     void wlSelectionChanged(KWaylandServer::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(KWaylandServer::AbstractDataSource *dsi) const;
0054 
0055     QMetaObject::Connection m_checkConnection;
0056 
0057     Q_DISABLE_COPY(Clipboard)
0058     bool m_waitingForTargets = false;
0059     std::unique_ptr<XwlDataSource> m_selectionSource;
0060 };
0061 
0062 } // namespace Xwl
0063 } // namespace KWin