1 /**************************************************************************** 2 Copyright © 2020 Roman Gilg <subdiff@gmail.com> 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 "xdg_shell.h" 23 #include "xdg_shell_surface.h" 24 25 #include "wayland/resource.h" 26 27 #include <wayland-xdg-shell-server-protocol.h> 28 29 #include <QSize> 30 31 #include <deque> 32 33 namespace Wrapland::Server 34 { 35 36 class XdgShellSurface::Private : public Wayland::Resource<XdgShellSurface> 37 { 38 public: 39 Private(Client* client, 40 uint32_t version, 41 uint32_t id, 42 XdgShell* shell, 43 Surface* surface, 44 XdgShellSurface* q); 45 46 // Implement here? 47 void close(); 48 49 uint32_t configure(States states, const QSize& size); 50 QRect windowGeometry() const; 51 QSize minimumSize() const; 52 QSize maximumSize() const; 53 54 XdgShell* m_shell; 55 Surface* m_surface; 56 57 // Effectively a union, only one of these should be populated. A surface can't have two roles. 58 XdgShellToplevel* toplevel = nullptr; 59 XdgShellPopup* popup = nullptr; 60 61 std::deque<uint32_t> configureSerials; 62 63 struct state { 64 QRect window_geometry; 65 bool window_geometry_set{false}; 66 }; 67 68 state current_state; 69 state pending_state; 70 71 private: 72 static void getTopLevelCallback(wl_client* wlClient, wl_resource* wlResource, uint32_t id); 73 static void getPopupCallback(wl_client* wlClient, 74 wl_resource* wlResource, 75 uint32_t id, 76 wl_resource* wlParent, 77 wl_resource* wlPositioner); 78 static void ackConfigureCallback(wl_client* wlClient, wl_resource* wlResource, uint32_t serial); 79 static void setWindowGeometryCallback(wl_client* wlClient, 80 wl_resource* wlResource, 81 int32_t x, 82 int32_t y, 83 int32_t width, 84 int32_t height); 85 86 bool check_creation_error(); 87 88 static const struct xdg_surface_interface s_interface; 89 }; 90 91 } 92