1 /* 2 * Copyright (C) 2017-2018 Team Kodi 3 * This file is part of Kodi - https://kodi.tv 4 * 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 * See LICENSES/README.md for more information. 7 */ 8 9 #pragma once 10 11 #include "utils/Geometry.h" 12 13 #include <bitset> 14 #include <cstdint> 15 16 #include <wayland-client.hpp> 17 18 namespace KODI 19 { 20 namespace WINDOWING 21 { 22 namespace WAYLAND 23 { 24 25 class IShellSurfaceHandler; 26 27 /** 28 * Abstraction for shell surfaces to support multiple protocols 29 * such as wl_shell (for compatibility) and xdg_shell (for features) 30 * 31 * The interface itself is modeled after xdg_shell, so see there for the meaning 32 * of e.g. the surface states 33 */ 34 class IShellSurface 35 { 36 public: 37 // Not enum class since it must be used like a bitfield 38 enum State 39 { 40 STATE_MAXIMIZED = 0, 41 STATE_FULLSCREEN, 42 STATE_RESIZING, 43 STATE_ACTIVATED, 44 STATE_COUNT 45 }; 46 using StateBitset = std::bitset<STATE_COUNT>; 47 static std::string StateToString(StateBitset state); 48 49 /** 50 * Initialize shell surface 51 * 52 * The event loop thread MUST NOT be running when this function is called. 53 * The difference to the constructor is that in this function callbacks may 54 * already be called. 55 */ 56 virtual void Initialize() = 0; 57 58 virtual void SetFullScreen(wayland::output_t const& output, float refreshRate) = 0; 59 virtual void SetWindowed() = 0; 60 virtual void SetMaximized() = 0; 61 virtual void UnsetMaximized() = 0; 62 virtual void SetMinimized() = 0; 63 virtual void SetWindowGeometry(CRectInt geometry) = 0; 64 65 virtual void AckConfigure(std::uint32_t serial) = 0; 66 67 virtual void StartMove(wayland::seat_t const& seat, std::uint32_t serial) = 0; 68 virtual void StartResize(wayland::seat_t const& seat, std::uint32_t serial, wayland::shell_surface_resize edge) = 0; 69 virtual void ShowShellContextMenu(wayland::seat_t const& seat, std::uint32_t serial, CPointInt position) = 0; 70 71 virtual ~IShellSurface() = default; 72 73 protected: 74 IShellSurface() noexcept = default; 75 76 private: 77 IShellSurface(IShellSurface const& other) = delete; 78 IShellSurface& operator=(IShellSurface const& other) = delete; 79 }; 80 81 class IShellSurfaceHandler 82 { 83 public: 84 virtual void OnConfigure(std::uint32_t serial, CSizeInt size, IShellSurface::StateBitset state) = 0; 85 virtual void OnClose() = 0; 86 87 virtual ~IShellSurfaceHandler() = default; 88 }; 89 90 } 91 } 92 } 93