fennec
Loading...
Searching...
No Matches
window.h
1// =====================================================================================================================
2// fennec, a free and open source game engine
3// Copyright © 2025 Medusa Slockbower
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <https://www.gnu.org/licenses/>.
17// =====================================================================================================================
18
30
31#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
32#define FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
33
36
37struct wl_array;
38struct wl_callback;
39struct wl_output;
40struct wl_surface;
41
42struct xdg_surface;
43struct xdg_toplevel;
44
45struct libdecor_frame;
46struct libdecor_configuration;
47
48namespace fennec
49{
50
51class wayland_window : public window_base<wayland_server> {
52public:
53 wayland_window(display_server* server, const config& cfg, window* parent);
54 ~wayland_window();
55
56 void initialize() override;
57 void shutdown() override;
58
59 void* get_native_handle() override;
60
61 bool set_flag(uint8_t flag, bool val) override;
62
63
64// Fields ==============================================================================================================
65private:
66 wl_surface* surface;
67 xdg_surface* xdgsurface;
68 xdg_toplevel* xdgtoplevel;
69 wl_callback* frame_callback;
70
71#if FENNEC_HAS_LIBDECOR
72 libdecor_frame* libdecorframe;
73 libdecor_configuration* libdecorcfg;
74#endif
75
76
77// Helpers =============================================================================================================
78
79 void _update_size(const ivec2& size);
80
81
82// Listeners ===========================================================================================================
83
84 static void _wl_surface_listen_enter(void*, wl_surface*, wl_output*);
85 static void _wl_surface_listen_leave(void*, wl_surface*, wl_output*);
86 static void _wl_surface_listen_preferred_buffer_scale(void*, wl_surface*, int32_t);
87 static void _wl_surface_listen_preferred_buffer_transform(void*, wl_surface*, uint32_t);
88
89 static void _wl_frame_listen_done(void*, wl_callback*, uint32_t);
90
91 static void _xdg_surface_listen_configure(void*, xdg_surface*, uint32_t);
92
93 static void _xdg_toplevel_listen_configure(void*, xdg_toplevel*, int32_t, int32_t, wl_array*);
94 static void _xdg_toplevel_listen_configure_bounds(void*, xdg_toplevel*, int32_t, int32_t);
95 static void _xdg_toplevel_listen_close(void*, xdg_toplevel*);
96 static void _xdg_toplevel_listen_wm_capabilities(void*, xdg_toplevel*, wl_array*);
97
98#if FENNEC_HAS_LIBDECOR
99 static void _libdecor_frame_listen_configure(libdecor_frame*, libdecor_configuration*, void*);
100 static void _libdecor_frame_listen_close(libdecor_frame*, void*);
101 static void _libdecor_frame_listen_commit(libdecor_frame*, void*);
102 static void _libdecor_frame_listen_dismiss_popup(libdecor_frame*, const char*, void*);
103#endif
104};
105
106}
107
108#endif // FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H