File indexing completed on 2025-04-20 05:00:03
0001 /* 0002 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #pragma once 0008 0009 #include "kwin_export.h" 0010 0011 #include <QObject> 0012 #include <memory> 0013 0014 struct wl_resource; 0015 0016 namespace KWin 0017 { 0018 class Display; 0019 class XdgDecorationManagerV1InterfacePrivate; 0020 class XdgToplevelDecorationV1Interface; 0021 class XdgToplevelDecorationV1InterfacePrivate; 0022 class XdgToplevelInterface; 0023 0024 /** 0025 * The XdgDecorationManagerV1Interface class provides a way for the compositor and an xdg-shell 0026 * client to negotiate the use of server-side window decorations. 0027 * 0028 * XdgDecorationManagerV1Interface corresponds to the interface \c zxdg_decoration_manager_v1. 0029 */ 0030 class KWIN_EXPORT XdgDecorationManagerV1Interface : public QObject 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 /** 0036 * Constructs a decoration manager with the given \a display and \a parent. 0037 */ 0038 XdgDecorationManagerV1Interface(Display *display, QObject *parent = nullptr); 0039 /** 0040 * Destructs the XdgDecorationManagerV1Interface object. 0041 */ 0042 ~XdgDecorationManagerV1Interface() override; 0043 0044 Q_SIGNALS: 0045 /** 0046 * This signal is emitted when a new \a decoration has been created. 0047 */ 0048 void decorationCreated(XdgToplevelDecorationV1Interface *decoration); 0049 0050 private: 0051 std::unique_ptr<XdgDecorationManagerV1InterfacePrivate> d; 0052 }; 0053 0054 /** 0055 * The XdgToplevelDecorationV1Interface class allows the compositor to toggle server-side window 0056 * decoration on an xdg-toplevel surface. 0057 * 0058 * XdgToplevelDecorationV1Interface corresponds to the interface \c zxdg_toplevel_decoration_v1. 0059 */ 0060 class KWIN_EXPORT XdgToplevelDecorationV1Interface : public QObject 0061 { 0062 Q_OBJECT 0063 0064 public: 0065 enum class Mode { 0066 Undefined, 0067 None, 0068 Client, 0069 Server, 0070 }; 0071 Q_ENUM(Mode) 0072 0073 /** 0074 * Constructs a XdgToplevelDecorationV1Interface for the given \a toplevel and initializes 0075 * it with \a resource. 0076 */ 0077 XdgToplevelDecorationV1Interface(XdgToplevelInterface *toplevel, ::wl_resource *resource); 0078 /** 0079 * Destructs the XdgToplevelDecorationV1Interface object. 0080 */ 0081 ~XdgToplevelDecorationV1Interface() override; 0082 0083 /** 0084 * Returns the toplevel for this XdgToplevelDecorationV1Interface. 0085 */ 0086 XdgToplevelInterface *toplevel() const; 0087 /** 0088 * Returns the decoration mode preferred by the client. 0089 */ 0090 Mode preferredMode() const; 0091 /** 0092 * Sends a configure event to the client. \a mode indicates the decoration mode the client 0093 * should be using. The client must send an ack_configure in response to this event. 0094 * 0095 * \see XdgToplevelInterface::sendConfigure 0096 */ 0097 void sendConfigure(Mode mode); 0098 0099 /** 0100 * Returns the XdgToplevelDecorationV1Interface for the specified \a toplevel. 0101 */ 0102 static XdgToplevelDecorationV1Interface *get(XdgToplevelInterface *toplevel); 0103 0104 Q_SIGNALS: 0105 /** 0106 * This signal is emitted when the client has specified the preferred decoration mode. The 0107 * compositor can decide not to use the client's mode and enforce a different mode instead. 0108 */ 0109 void preferredModeChanged(KWin::XdgToplevelDecorationV1Interface::Mode mode); 0110 0111 private: 0112 std::unique_ptr<XdgToplevelDecorationV1InterfacePrivate> d; 0113 }; 0114 0115 } // namespace KWin