fennec
Loading...
Searching...
No Matches
server.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_SERVER_H
32#define FENNEC_PLATFORM_LINUX_WAYLAND_SERVER_H
33
36
37#if FENNEC_HAS_LIBDECOR
39#endif
40
41// forward defs to avoid flooding global namespace
42struct wl_display;
43struct wl_shm;
44struct wl_compositor;
45struct wl_registry;
46struct wl_seat;
47
48struct wp_viewporter;
49struct xdg_wm_base;
50
51namespace fennec
52{
53
56class wayland_server : public display_server_base<wayland_server, wayland_window> {
57public:
59 ~wayland_server() override;
60
61 void connect() override;
62 void disconnect() override;
63 bool connected() const override;
64
65 void dispatch() override;
66
67 window* create_window(const window::config& conf, window* parent) override;
68
69 void* get_native_handle() override { return display; }
70
71
72// Fields ==============================================================================================================
73private:
74 wl_display* display;
75 wl_registry* registry;
76
77 wl_compositor* compositor;
78 xdg_wm_base* xdg;
79 wl_seat* seat;
80 bool fifo, has_libdecor;
81
82#if FENNEC_HAS_LIBDECOR
83 libdecor* libdecor;
84#endif
85
86
87// Listeners ===========================================================================================================
88
89 static void _wl_registry_listen_global(void*, wl_registry*, uint32_t, const char*, uint32_t);
90 static void _wl_registry_on_global_remove(void*, wl_registry*, uint32_t);
91
92 static void _wl_seat_listen_capabilities(void*, wl_seat*, uint32_t);
93 static void _wl_seat_listen_name(void*, wl_seat*, const char*);
94
95 static void _xdg_listen_ping(void*, xdg_wm_base*, uint32_t);
96
97#if FENNEC_HAS_LIBDECOR
98 static void _libdecor_on_error(struct libdecor*, libdecor_error error, const char* message);
99#endif
100
101 FENNEC_RTTI_CLASS_ENABLE(display_server) {
102 display_server::register_type<wayland_server>(1);
103 }
104
105 friend class wayland_window;
106};
107
108}
109
110#endif // FENNEC_PLATFORM_LINUX_WAYLAND_SERVER_H
Interface resembling the API for a display server of an operating system, e.g. Linux X11/Wayland.
Definition display_server.h:57
Main platform class.
Definition platform.h:66
Class for handling the Wayland Display Server.
Definition server.h:56
::uint32_t uint32_t
Unsigned 32-bit integer.
Definition types.h:274