fennec
Loading...
Searching...
No Matches
display_server.h
Go to the documentation of this file.
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_INTERFACE_DISPLAY_SERVER_H
32#define FENNEC_PLATFORM_INTERFACE_DISPLAY_SERVER_H
33
35
36#include <fennec/platform/interface/fwd.h>
38
40
41#include <fennec/rtti/enable.h>
43
44namespace fennec
45{
46
47class display_server;
48
57class display_server : public type_registry<display_server, platform*> {
58// Typedefs/Constants/Enums ============================================================================================
59public:
60
61enum feature_ : uint32_t {
62 feature_subwindows = 0,
63 feature_icon,
64
65 feature_window_drag,
66
67 feature_mouse,
68 feature_cursors,
69 feature_custom_cursors,
70
71 feature_clipboard,
72 feature_clipboard_primary,
73 feature_virtual_keyboard,
74
75 feature_status_indicators,
76 feature_dialogues,
77 feature_input_dialogues,
78 feature_file_dialogues,
79 feature_filtered_file_dialogues,
80
81 feature_orientation,
82 feature_hidpi,
83 feature_hdr,
84 feature_swap_buffers,
85 feature_window_transparency,
86
87 feature_screen_reader,
88 feature_text_to_speech,
89 feature_touchscreen,
90 feature_system_theme,
91
92 feature_count,
93 };
94
96 using window_id = uint32_t;
98
99
100// Public Members ======================================================================================================
101 platform* const platform;
102
104 : platform(p) {
105 }
106
107 virtual ~display_server() {
108 }
109
110
111 bool has_feature(uint32_t feature) const {
112 return features.test(feature);
113 }
114
115 virtual window* create_window(const window::config&, window* = nullptr) = 0;
116
117 virtual void connect() = 0;
118 virtual void disconnect() = 0;
119 virtual bool connected() const = 0;
120
121 virtual void dispatch() = 0;
122
123 virtual void* get_native_handle() = 0;
124
125 gfxcontext* get_gfx_context() {
126 return gfx_context.get();
127 }
128
129protected:
130 featureset_t features;
131 unique_ptr<gfxcontext> gfx_context;
132
133 FENNEC_RTTI_CLASS_ENABLE() {
134 }
135};
136
137template<typename DisplayT, typename WindowT>
138class display_server_base : public display_server, public type_registry<gfxcontext, DisplayT*> {
139public:
140 display_server_base(fennec::platform* p)
141 : display_server(p) {
142 }
143
144 using ctx_registry = type_registry<gfxcontext, DisplayT*>;
145 using window_t = WindowT;
146};
147
148}
149
150#endif // FENNEC_PLATFORM_INTERFACE_DISPLAY_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
Definition pointers.h:87
Struct which holds a pool of objects associated with ids.
Definition object_pool.h:46
::uint32_t uint32_t
Unsigned 32-bit integer.
Definition types.h:274