File indexing completed on 2025-04-20 04:59:59
0001 /* 0002 SPDX-FileCopyrightText: 2017 David Edmundson <kde@davidedmundson.co.uk> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 #pragma once 0007 0008 #include "kwin_export.h" 0009 0010 #include <QObject> 0011 #include <memory> 0012 0013 struct wl_resource; 0014 0015 namespace KWin 0016 { 0017 class Display; 0018 class SurfaceInterface; 0019 class ServerSideDecorationPaletteInterface; 0020 class ServerSideDecorationPaletteManagerInterfacePrivate; 0021 class ServerSideDecorationPaletteInterfacePrivate; 0022 0023 /** 0024 * Allows a client to specify a preferred palette to use for server-side window decorations 0025 * 0026 * This global can be used for clients to bind ServerSideDecorationPaletteInterface instances 0027 * and notifies when a new one is created 0028 */ 0029 class KWIN_EXPORT ServerSideDecorationPaletteManagerInterface : public QObject 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 explicit ServerSideDecorationPaletteManagerInterface(Display *display, QObject *parent = nullptr); 0035 ~ServerSideDecorationPaletteManagerInterface() override; 0036 /** 0037 * Returns any existing palette for a given surface 0038 * This returns a null pointer if no ServerSideDecorationPaletteInterface exists. 0039 */ 0040 ServerSideDecorationPaletteInterface *paletteForSurface(SurfaceInterface *); 0041 0042 Q_SIGNALS: 0043 /** 0044 * Emitted whenever a new ServerSideDecorationPaletteInterface is created. 0045 */ 0046 void paletteCreated(KWin::ServerSideDecorationPaletteInterface *); 0047 0048 private: 0049 std::unique_ptr<ServerSideDecorationPaletteManagerInterfacePrivate> d; 0050 }; 0051 0052 /** 0053 * Provides the palette 0054 * This interface is attached to a wl_surface and informs the server of a requested palette 0055 */ 0056 class KWIN_EXPORT ServerSideDecorationPaletteInterface : public QObject 0057 { 0058 Q_OBJECT 0059 public: 0060 ~ServerSideDecorationPaletteInterface() override; 0061 0062 /** 0063 * @returns the palette or an empty string if unset 0064 */ 0065 QString palette() const; 0066 0067 /** 0068 * @returns The SurfaceInterface this ServerSideDecorationPaletteInterface references. 0069 */ 0070 SurfaceInterface *surface() const; 0071 0072 Q_SIGNALS: 0073 /** 0074 * Emitted when the palette changes or is first received 0075 */ 0076 void paletteChanged(const QString &palette); 0077 0078 private: 0079 explicit ServerSideDecorationPaletteInterface(SurfaceInterface *surface, wl_resource *resource); 0080 friend class ServerSideDecorationPaletteManagerInterfacePrivate; 0081 0082 std::unique_ptr<ServerSideDecorationPaletteInterfacePrivate> d; 0083 }; 0084 0085 }