1 /**************************************************************************** 2 Copyright 2020 Adrien Faveraux <ad1rie3@hotmail.fr> 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) version 3, or any 8 later version accepted by the membership of KDE e.V. (or its 9 successor approved by the membership of KDE e.V.), which shall 10 act as a proxy defined in Section 6 of version 3 of the license. 11 12 This library is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 Lesser General Public License for more details. 16 17 You should have received a copy of the GNU Lesser General Public 18 License along with this library. If not, see <http://www.gnu.org/licenses/>. 19 ****************************************************************************/ 20 #pragma once 21 22 #include "display.h" 23 #include "server_decoration_palette.h" 24 #include "surface.h" 25 26 #include "wayland/client.h" 27 #include "wayland/global.h" 28 #include "wayland/resource.h" 29 30 #include <wayland-server_decoration_palette-server-protocol.h> 31 32 namespace Wrapland::Server 33 { 34 35 constexpr uint32_t ServerSideDecorationPaletteManagerVersion = 1; 36 using ServerSideDecorationPaletteManagerGlobal 37 = Wayland::Global<ServerSideDecorationPaletteManager, 38 ServerSideDecorationPaletteManagerVersion>; 39 using ServerSideDecorationPaletteManagerBind 40 = Wayland::Bind<ServerSideDecorationPaletteManagerGlobal>; 41 42 class ServerSideDecorationPaletteManager::Private : public ServerSideDecorationPaletteManagerGlobal 43 { 44 public: 45 Private(Display* display, ServerSideDecorationPaletteManager* qptr); 46 47 std::vector<ServerSideDecorationPalette*> palettes; 48 49 private: 50 static void 51 createCallback(ServerSideDecorationPaletteManagerBind* bind, uint32_t id, wl_resource* surface); 52 53 static const struct org_kde_kwin_server_decoration_palette_manager_interface s_interface; 54 }; 55 56 class ServerSideDecorationPalette::Private : public Wayland::Resource<ServerSideDecorationPalette> 57 { 58 public: 59 Private(Client* client, 60 uint32_t version, 61 uint32_t id, 62 Surface* surface, 63 ServerSideDecorationPalette* qptr); 64 65 Surface* surface; 66 QString palette; 67 68 private: 69 static void 70 setPaletteCallback(wl_client* wlClient, wl_resource* wlResource, const char* palette); 71 72 static ServerSideDecorationPalette* get(Surface* surface); 73 74 static const struct org_kde_kwin_server_decoration_palette_interface s_interface; 75 }; 76 77 } 78