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 "viewporter.h" 23 24 #include "wayland/client.h" 25 #include "wayland/display.h" 26 #include "wayland/global.h" 27 #include "wayland/resource.h" 28 29 #include "viewporter.h" 30 31 #include <wayland-viewporter-server-protocol.h> 32 33 namespace Wrapland::Server 34 { 35 class Display; 36 class Surface; 37 class Viewport; 38 39 constexpr uint32_t ViewporterVersion = 1; 40 using ViewporterGlobal = Wayland::Global<Viewporter, ViewporterVersion>; 41 using ViewporterBind = Wayland::Bind<ViewporterGlobal>; 42 43 class Viewporter::Private : public ViewporterGlobal 44 { 45 public: 46 Private(Display* display, Viewporter* qptr); 47 48 private: 49 void getViewport(ViewporterBind* bind, uint32_t id, wl_resource* wlSurface); 50 51 static void getViewportCallback(ViewporterBind* bind, uint32_t id, wl_resource* wlSurface); 52 53 static const struct wp_viewporter_interface s_interface; 54 }; 55 56 class Viewport::Private : public Wayland::Resource<Viewport> 57 { 58 public: 59 Private(Client* client, uint32_t version, uint32_t id, Surface* _surface, Viewport* q); 60 61 Surface* surface; 62 63 private: 64 void setSource(double x, double y, double width, double height); 65 void setDestination(int width, int height); 66 67 static void setSourceCallback(wl_client* wlClient, 68 wl_resource* wlResource, 69 wl_fixed_t x, 70 wl_fixed_t y, 71 wl_fixed_t width, 72 wl_fixed_t height); 73 static void setDestinationCallback(wl_client* wlClient, 74 wl_resource* wlResource, 75 int32_t width, 76 int32_t height); 77 78 static const struct wp_viewport_interface s_interface; 79 }; 80 81 } 82