Debian Codegraph @

xbmc/windowing/wayland/ShellSurfaceWlShell.cpp

raw
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 #include "ShellSurfaceWlShell.h"
10
11 #include "Registry.h"
12
13 #include <cmath>
14
15 using namespace KODI::WINDOWING::WAYLAND;
16 using namespace std::placeholders;
17
18 CShellSurfaceWlShell::CShellSurfaceWlShell(IShellSurfaceHandler& handler,
19 CConnection& connection,
20 const wayland::surface_t& surface,
21 const std::string& title,
22 const std::string& class_)
23 : m_handler{handler}
24 {
25 {
26 CRegistry registry{connection};
27 registry.RequestSingleton(m_shell, 1, 1);
28 registry.Bind();
29 }
30
31 m_shellSurface = m_shell.get_shell_surface(surface);
32
33 m_surfaceState.set(STATE_ACTIVATED);
34 m_shellSurface.set_class(class_);
35 m_shellSurface.set_title(title);
36 m_shellSurface.on_ping() = [this](std::uint32_t serial)
37 {
38 m_shellSurface.pong(serial);
39 };
40 m_shellSurface.on_configure() = [this](const wayland::shell_surface_resize&, std::int32_t width,
41 std::int32_t height) {
42 // wl_shell does not have serials
43 m_handler.OnConfigure(0, {width, height}, m_surfaceState);
44 };
45 }
46
47 void CShellSurfaceWlShell::AckConfigure(std::uint32_t)
48 {
49 }
50
51 void CShellSurfaceWlShell::Initialize()
52 {
53 // Nothing to do here - constructor already handles it
54 // This is not a problem since the constructor is guaranteed not to call
55 // handler functions since the event loop is not running.
56 }
57
58 void CShellSurfaceWlShell::SetFullScreen(const wayland::output_t& output, float refreshRate)
59 {
60 m_shellSurface.set_fullscreen(wayland::shell_surface_fullscreen_method::driver, std::round(refreshRate * 1000.0f), output);
61 m_surfaceState.set(STATE_FULLSCREEN);
62 }
63
64 void CShellSurfaceWlShell::SetWindowed()
65 {
66 m_shellSurface.set_toplevel();
67 m_surfaceState.reset(STATE_FULLSCREEN);
68 }
69
70 void CShellSurfaceWlShell::SetMaximized()
71 {
72 m_shellSurface.set_maximized(wayland::output_t());
73 m_surfaceState.set(STATE_MAXIMIZED);
74 }
75
76 void CShellSurfaceWlShell::UnsetMaximized()
77 {
78 m_surfaceState.reset(STATE_MAXIMIZED);
79 }
80
81 void CShellSurfaceWlShell::SetMinimized()
82 {
83 }
84
85 void CShellSurfaceWlShell::SetWindowGeometry(CRectInt)
86 {
87 }
88
89 void CShellSurfaceWlShell::StartMove(const wayland::seat_t& seat, std::uint32_t serial)
90 {
91 m_shellSurface.move(seat, serial);
92 }
93
94 void CShellSurfaceWlShell::StartResize(const wayland::seat_t& seat, std::uint32_t serial, wayland::shell_surface_resize edge)
95 {
96 m_shellSurface.resize(seat, serial, edge);
97 }
98
99 void CShellSurfaceWlShell::ShowShellContextMenu(const wayland::seat_t&, std::uint32_t, CPointInt)
100 {
101 }