1 /* 2 SPDX-FileCopyrightText: 2021 Roman Gilg <subdiff@gmail.com> 3 4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only 5 */ 6 #pragma once 7 8 #include "layer_shell_v1.h" 9 10 #include "wayland/global.h" 11 #include "wayland/resource.h" 12 13 #include <QObject> 14 #include <deque> 15 16 #include <wayland-wlr-layer-shell-server-protocol.h> 17 18 namespace Wrapland::Server 19 { 20 21 class Display; 22 23 constexpr uint32_t LayerShellV1Version = 4; 24 using LayerShellV1Global = Wayland::Global<LayerShellV1, LayerShellV1Version>; 25 using LayerShellV1Bind = Wayland::Bind<LayerShellV1Global>; 26 27 using Interactivity = LayerSurfaceV1::KeyboardInteractivity; 28 using Layer = LayerSurfaceV1::Layer; 29 30 class LayerShellV1::Private : public LayerShellV1Global 31 { 32 public: 33 Private(Display* display, LayerShellV1* qptr); 34 ~Private() override; 35 36 private: 37 static void getCallback(LayerShellV1Bind* bind, 38 uint32_t id, 39 wl_resource* wlSurface, 40 wl_resource* wlOutput, 41 uint32_t wlLayer, 42 char const* nspace); 43 static void destroyCallback(LayerShellV1Bind* bind); 44 45 static const struct zwlr_layer_shell_v1_interface s_interface; 46 }; 47 48 class LayerSurfaceV1::Private : public Wayland::Resource<LayerSurfaceV1> 49 { 50 public: 51 Private(Client* client, 52 uint32_t version, 53 uint32_t id, 54 Surface* surface, 55 Output* output, 56 Layer layer, 57 std::string domain, 58 LayerSurfaceV1* qptr); 59 ~Private() override; 60 61 bool commit(); 62 void set_output(Output* output); 63 64 struct State { 65 // Protocol stipulates that size has zero width/height by default. 66 QSize size{0, 0}; 67 Qt::Edges anchor; 68 int exclusive_zone{0}; 69 QMargins margins; 70 Interactivity keyboard_interactivity{Interactivity::None}; 71 Layer layer; 72 73 bool set{false}; 74 } pending, current; 75 76 Surface* surface{nullptr}; 77 Output* output{nullptr}; 78 std::string domain; 79 80 std::deque<uint32_t> configure_serials; 81 bool closed{false}; 82 83 private: 84 static void 85 setSizeCallback(wl_client* wlClient, wl_resource* wlResource, uint32_t width, uint32_t height); 86 static void setAnchorCallback(wl_client* wlClient, wl_resource* wlResource, uint32_t anchor); 87 static void setExclusiveZoneCallback(wl_client* wlClient, wl_resource* wlResource, int zone); 88 static void setMarginCallback(wl_client* wlClient, 89 wl_resource* wlResource, 90 int top, 91 int right, 92 int bottom, 93 int left); 94 static void setKeyboardInteractivityCallback(wl_client* wlClient, 95 wl_resource* wlResource, 96 uint32_t interactivity); 97 static void 98 getPopupCallback(wl_client* wlClient, wl_resource* wlResource, wl_resource* wlPopup); 99 static void ackConfigureCallback(wl_client* wlClient, wl_resource* wlResource, uint32_t serial); 100 static void setLayerCallback(wl_client* wlClient, wl_resource* wlResource, uint32_t layer); 101 102 static const struct zwlr_layer_surface_v1_interface s_interface; 103 }; 104 105 } 106