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 "subcompositor.h" 23 #include "surface_p.h" 24 25 #include "wayland/resource.h" 26 27 #include <QPoint> 28 29 #include <wayland-server.h> 30 31 namespace Wrapland::Server 32 { 33 34 class Subsurface::Private : public Wayland::Resource<Subsurface> 35 { 36 public: 37 Private(Client* client, 38 uint32_t version, 39 uint32_t id, 40 Surface* surface, 41 Surface* parent, 42 Subsurface* q); 43 44 /** 45 * Initializes the subsurface in relation to its parent. Needs to be after the subsurface 46 * is created already since we access its data from outside. 47 */ 48 void init(); 49 50 void applyCached(bool force); 51 void commit(); 52 53 QPoint pos = QPoint(0, 0); 54 QPoint scheduledPos = QPoint(); 55 bool scheduledPosChange = false; 56 Mode mode = Mode::Synchronized; 57 58 Surface* surface = nullptr; 59 Surface* parent = nullptr; 60 SurfaceState cached; 61 62 private: 63 void setMode(Mode mode); 64 void setPosition(const QPoint& pos); 65 void placeAbove(Surface* sibling); 66 void placeBelow(Surface* sibling); 67 68 static void 69 setPositionCallback(wl_client* wlClient, wl_resource* wlResource, int32_t x, int32_t y); 70 static void 71 placeAboveCallback(wl_client* wlClient, wl_resource* wlResource, wl_resource* wlSibling); 72 static void 73 placeBelowCallback(wl_client* wlClient, wl_resource* wlResource, wl_resource* wlSibling); 74 static void setSyncCallback(wl_client* wlClient, wl_resource* wlResource); 75 static void setDeSyncCallback(wl_client* wlClient, wl_resource* wlResource); 76 77 static const struct wl_subsurface_interface s_interface; 78 }; 79 80 } 81