File indexing completed on 2025-03-16 11:21:58
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: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 #pragma once 0011 0012 #include <memory> 0013 0014 #include "xwayland_interface.h" 0015 0016 #include <memory> 0017 0018 class KSelectionOwner; 0019 class QSocketNotifier; 0020 0021 namespace KWin 0022 { 0023 class Output; 0024 class Application; 0025 0026 namespace Xwl 0027 { 0028 class XrandrEventFilter; 0029 class XwaylandInputSpy; 0030 class XwaylandLauncher; 0031 class DataBridge; 0032 0033 class KWIN_EXPORT Xwayland : public QObject, public XwaylandInterface 0034 { 0035 Q_OBJECT 0036 0037 public: 0038 Xwayland(Application *app); 0039 ~Xwayland() override; 0040 0041 void start(); 0042 0043 XwaylandLauncher *xwaylandLauncher() const; 0044 0045 Q_SIGNALS: 0046 /** 0047 * This signal is emitted when the Xwayland server has been started successfully and it is 0048 * ready to accept and manage X11 clients. 0049 */ 0050 void started(); 0051 0052 /** 0053 * This signal is emitted when an error occurs with the Xwayland server. 0054 */ 0055 void errorOccurred(); 0056 0057 private Q_SLOTS: 0058 void handleXwaylandFinished(); 0059 void handleXwaylandReady(); 0060 0061 void handleSelectionLostOwnership(); 0062 void handleSelectionFailedToClaimOwnership(); 0063 void handleSelectionClaimedOwnership(); 0064 0065 private: 0066 friend class XrandrEventFilter; 0067 0068 enum class DispatchEventsMode { 0069 Poll, 0070 EventQueue 0071 }; 0072 void dispatchEvents(DispatchEventsMode mode); 0073 0074 void installSocketNotifier(); 0075 void uninstallSocketNotifier(); 0076 void updatePrimary(); 0077 void refreshEavesdropping(); 0078 0079 bool createX11Connection(); 0080 void destroyX11Connection(); 0081 0082 DragEventReply dragMoveFilter(Window *target, const QPoint &pos) override; 0083 KWaylandServer::AbstractDropHandler *xwlDropHandler() override; 0084 QSocketNotifier *m_socketNotifier = nullptr; 0085 0086 Application *m_app; 0087 std::unique_ptr<KSelectionOwner> m_selectionOwner; 0088 std::unique_ptr<DataBridge> m_dataBridge; 0089 0090 XrandrEventFilter *m_xrandrEventsFilter = nullptr; 0091 XwaylandLauncher *m_launcher; 0092 std::unique_ptr<XwaylandInputSpy> m_inputSpy; 0093 0094 Q_DISABLE_COPY(Xwayland) 0095 }; 0096 0097 } // namespace Xwl 0098 } // namespace KWin