feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef DETECT_PRIME_EGL_H
#define DETECT_PRIME_EGL_H
#pragma once
#ifdef GLES3_ENABLED
#ifdef EGL_ENABLED
@ -77,13 +76,11 @@ private:
{ nullptr, 0 }
};
public:
static void create_context(EGLenum p_platform_enum);
public:
static int detect_prime(EGLenum p_platform_enum);
};
#endif // GLES3_ENABLED
#endif // EGL_ENABLED
#endif // DETECT_PRIME_EGL_H

File diff suppressed because it is too large Load diff

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef DISPLAY_SERVER_WAYLAND_H
#define DISPLAY_SERVER_WAYLAND_H
#pragma once
#ifdef WAYLAND_ENABLED
@ -53,6 +52,7 @@
#endif
#ifdef DBUS_ENABLED
#include "freedesktop_at_spi_monitor.h"
#include "freedesktop_portal_desktop.h"
#include "freedesktop_screensaver.h"
#endif
@ -67,9 +67,18 @@
#undef CursorShape
class DisplayServerWayland : public DisplayServer {
// No need to register with GDCLASS, it's platform-specific and nothing is added.
GDSOFTCLASS(DisplayServerWayland, DisplayServer);
struct WindowData {
WindowID id;
WindowID id = INVALID_WINDOW_ID;
WindowID parent_id = INVALID_WINDOW_ID;
// For popups.
WindowID root_id = INVALID_WINDOW_ID;
// For toplevels.
List<WindowID> popup_stack;
Rect2i rect;
Size2i max_size;
@ -77,6 +86,8 @@ class DisplayServerWayland : public DisplayServer {
Rect2i safe_rect;
bool emulate_vsync = false;
#ifdef GLES3_ENABLED
struct wl_egl_window *wl_egl_window = nullptr;
#endif
@ -120,16 +131,25 @@ class DisplayServerWayland : public DisplayServer {
HashMap<CursorShape, CustomCursor> custom_cursors;
WindowData main_window;
HashMap<WindowID, WindowData> windows;
WindowID window_id_counter = MAIN_WINDOW_ID;
WaylandThread wayland_thread;
Context context;
bool swap_cancel_ok = false;
// NOTE: These are the based on WINDOW_FLAG_POPUP, which does NOT imply what it
// seems. It's particularly confusing for our usecase, but just know that these
// are the "take all input thx" windows while the `popup_stack` variable keeps
// track of all the generic floating window concept.
List<WindowID> popup_menu_list;
BitField<MouseButtonMask> last_mouse_monitor_mask = MouseButtonMask::NONE;
String ime_text;
Vector2i ime_selection;
SuspendState suspend_state = SuspendState::NONE;
bool emulate_vsync = false;
String rendering_driver;
@ -149,23 +169,24 @@ class DisplayServerWayland : public DisplayServer {
#if DBUS_ENABLED
FreeDesktopPortalDesktop *portal_desktop = nullptr;
FreeDesktopAtSPIMonitor *atspi_monitor = nullptr;
FreeDesktopScreenSaver *screensaver = nullptr;
bool screensaver_inhibited = false;
#endif
static String _get_app_id_from_context(Context p_context);
void _send_window_event(WindowEvent p_event);
void _send_window_event(WindowEvent p_event, WindowID p_window_id = MAIN_WINDOW_ID);
static void dispatch_input_events(const Ref<InputEvent> &p_event);
void _dispatch_input_event(const Ref<InputEvent> &p_event);
void _resize_window(const Size2i &p_size);
virtual void _show_window();
void _update_window_rect(const Rect2i &p_rect, WindowID p_window_id = MAIN_WINDOW_ID);
void try_suspend();
void initialize_tts() const;
public:
virtual bool has_feature(Feature p_feature) const override;
@ -185,10 +206,11 @@ public:
#ifdef DBUS_ENABLED
virtual bool is_dark_mode_supported() const override;
virtual bool is_dark_mode() const override;
virtual Color get_accent_color() const override;
virtual void set_system_theme_change_callback(const Callable &p_callable) override;
virtual Error file_dialog_show(const String &p_title, const String &p_current_directory, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback) override;
virtual Error file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback) override;
virtual Error file_dialog_show(const String &p_title, const String &p_current_directory, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback, WindowID p_window_id) override;
virtual Error file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback, WindowID p_window_id) override;
#endif
virtual void beep() const override;
@ -224,6 +246,14 @@ public:
virtual Vector<DisplayServer::WindowID> get_window_list() const override;
virtual WindowID create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i(), bool p_exclusive = false, WindowID p_transient_parent = INVALID_WINDOW_ID) override;
virtual void show_window(WindowID p_id) override;
virtual void delete_sub_window(WindowID p_id) override;
virtual WindowID window_get_active_popup() const override;
virtual void window_set_popup_safe_rect(WindowID p_window, const Rect2i &p_rect) override;
virtual Rect2i window_get_popup_safe_rect(WindowID p_window) const override;
virtual int64_t window_get_native_handle(HandleType p_handle_type, WindowID p_window = MAIN_WINDOW_ID) const override;
virtual WindowID get_window_at_screen_position(const Point2i &p_position) const override;
@ -280,6 +310,9 @@ public:
virtual void window_set_ime_active(const bool p_active, WindowID p_window_id = MAIN_WINDOW_ID) override;
virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window_id = MAIN_WINDOW_ID) override;
virtual int accessibility_should_increase_contrast() const override;
virtual int accessibility_screen_reader_active() const override;
virtual Point2i ime_get_selection() const override;
virtual String ime_get_text() const override;
@ -293,6 +326,8 @@ public:
virtual CursorShape cursor_get_shape() const override;
virtual void cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) override;
virtual bool get_swap_cancel_ok() override;
virtual int keyboard_get_layout_count() const override;
virtual int keyboard_get_current_layout() const override;
virtual void keyboard_set_current_layout(int p_index) override;
@ -300,6 +335,8 @@ public:
virtual String keyboard_get_layout_name(int p_index) const override;
virtual Key keyboard_get_keycode_from_physical(Key p_keycode) const override;
virtual bool color_picker(const Callable &p_callback) override;
virtual void process_events() override;
virtual void release_rendering_thread() override;
@ -319,5 +356,3 @@ public:
};
#endif // WAYLAND_ENABLED
#endif // DISPLAY_SERVER_WAYLAND_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef EGL_MANAGER_WAYLAND_H
#define EGL_MANAGER_WAYLAND_H
#pragma once
#ifdef WAYLAND_ENABLED
#ifdef EGL_ENABLED
@ -49,5 +48,3 @@ public:
#endif // GLES3_ENABLED
#endif // EGL_ENABLED
#endif // WAYLAND_ENABLED
#endif // EGL_MANAGER_WAYLAND_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef EGL_MANAGER_WAYLAND_GLES_H
#define EGL_MANAGER_WAYLAND_GLES_H
#pragma once
#ifdef WAYLAND_ENABLED
#ifdef EGL_ENABLED
@ -49,5 +48,3 @@ public:
#endif // GLES3_ENABLED
#endif // EGL_ENABLED
#endif // WAYLAND_ENABLED
#endif // EGL_MANAGER_WAYLAND_GLES_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef KEY_MAPPING_XKB_H
#define KEY_MAPPING_XKB_H
#pragma once
#include "core/os/keyboard.h"
#include "core/templates/hash_map.h"
@ -61,5 +60,3 @@ public:
static Key get_scancode(unsigned int p_code);
static KeyLocation get_location(unsigned int p_code);
};
#endif // KEY_MAPPING_XKB_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RENDERING_CONTEXT_DRIVER_VULKAN_WAYLAND_H
#define RENDERING_CONTEXT_DRIVER_VULKAN_WAYLAND_H
#pragma once
#ifdef VULKAN_ENABLED
@ -53,5 +52,3 @@ public:
};
#endif // VULKAN_ENABLED
#endif // RENDERING_CONTEXT_DRIVER_VULKAN_WAYLAND_H

File diff suppressed because it is too large Load diff

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef WAYLAND_THREAD_H
#define WAYLAND_THREAD_H
#pragma once
#ifdef WAYLAND_ENABLED
@ -89,41 +88,62 @@ class WaylandThread {
public:
// Messages used for exchanging information between Godot's and Wayland's thread.
class Message : public RefCounted {
GDSOFTCLASS(Message, RefCounted);
public:
Message() {}
virtual ~Message() = default;
};
class WindowMessage : public Message {
GDSOFTCLASS(WindowMessage, Message);
public:
DisplayServer::WindowID id = DisplayServer::INVALID_WINDOW_ID;
};
// Message data for window rect changes.
class WindowRectMessage : public Message {
class WindowRectMessage : public WindowMessage {
GDSOFTCLASS(WindowRectMessage, WindowMessage);
public:
// NOTE: This is in "scaled" terms. For example, if there's a 1920x1080 rect
// with a scale factor of 2, the actual value of `rect` will be 3840x2160.
Rect2i rect;
};
class WindowEventMessage : public Message {
class WindowEventMessage : public WindowMessage {
GDSOFTCLASS(WindowEventMessage, WindowMessage);
public:
DisplayServer::WindowEvent event;
};
class InputEventMessage : public Message {
GDSOFTCLASS(InputEventMessage, Message);
public:
Ref<InputEvent> event;
};
class DropFilesEventMessage : public Message {
class DropFilesEventMessage : public WindowMessage {
GDSOFTCLASS(DropFilesEventMessage, WindowMessage);
public:
Vector<String> files;
};
class IMEUpdateEventMessage : public Message {
class IMEUpdateEventMessage : public WindowMessage {
GDSOFTCLASS(IMEUpdateEventMessage, WindowMessage);
public:
String text;
Vector2i selection;
};
class IMECommitEventMessage : public Message {
class IMECommitEventMessage : public WindowMessage {
GDSOFTCLASS(IMECommitEventMessage, WindowMessage);
public:
String text;
};
@ -202,7 +222,8 @@ public:
// TODO: Make private?
struct WindowState {
DisplayServer::WindowID id;
DisplayServer::WindowID id = DisplayServer::INVALID_WINDOW_ID;
DisplayServer::WindowID parent_id = DisplayServer::INVALID_WINDOW_ID;
Rect2i rect;
DisplayServer::WindowMode mode = DisplayServer::WINDOW_MODE_WINDOWED;
@ -224,6 +245,7 @@ public:
// be called even after being destroyed, pointing to probably invalid window
// data by then and segfaulting hard.
struct wl_callback *frame_callback = nullptr;
uint64_t last_frame_time = 0;
struct wl_surface *wl_surface = nullptr;
struct xdg_surface *xdg_surface = nullptr;
@ -237,6 +259,8 @@ public:
struct zxdg_exported_v2 *xdg_exported_v2 = nullptr;
struct xdg_popup *xdg_popup = nullptr;
String exported_handle;
// Currently applied buffer scale.
@ -317,11 +341,14 @@ public:
Vector2 relative_motion;
uint32_t relative_motion_time = 0;
BitField<MouseButtonMask> pressed_button_mask;
BitField<MouseButtonMask> pressed_button_mask = MouseButtonMask::NONE;
MouseButton last_button_pressed = MouseButton::NONE;
Point2 last_pressed_position;
DisplayServer::WindowID pointed_id = DisplayServer::INVALID_WINDOW_ID;
DisplayServer::WindowID last_pointed_id = DisplayServer::INVALID_WINDOW_ID;
// This is needed to check for a new double click every time.
bool double_click_begun = false;
@ -344,27 +371,24 @@ public:
Vector2 tilt;
uint32_t pressure = 0;
BitField<MouseButtonMask> pressed_button_mask;
BitField<MouseButtonMask> pressed_button_mask = MouseButtonMask::NONE;
MouseButton last_button_pressed = MouseButton::NONE;
Point2 last_pressed_position;
bool double_click_begun = false;
// Note: the protocol doesn't have it (I guess that this isn't really meant to
// be used as a mouse...), but we'll hack one in with the current ticks.
uint64_t button_time = 0;
uint64_t motion_time = 0;
DisplayServer::WindowID proximal_id = DisplayServer::INVALID_WINDOW_ID;
DisplayServer::WindowID last_proximal_id = DisplayServer::INVALID_WINDOW_ID;
uint32_t proximity_serial = 0;
struct wl_surface *proximal_surface = nullptr;
};
struct TabletToolState {
struct wl_seat *wl_seat = nullptr;
struct wl_surface *last_surface = nullptr;
bool is_eraser = false;
TabletToolData data_pending;
@ -388,9 +412,6 @@ public:
uint32_t pointer_enter_serial = 0;
struct wl_surface *pointed_surface = nullptr;
struct wl_surface *last_pointed_surface = nullptr;
struct zwp_relative_pointer_v1 *wp_relative_pointer = nullptr;
struct zwp_locked_pointer_v1 *wp_locked_pointer = nullptr;
struct zwp_confined_pointer_v1 *wp_confined_pointer = nullptr;
@ -421,6 +442,9 @@ public:
// Keyboard.
struct wl_keyboard *wl_keyboard = nullptr;
// For key events.
DisplayServer::WindowID focused_id = DisplayServer::INVALID_WINDOW_ID;
struct xkb_context *xkb_context = nullptr;
struct xkb_keymap *xkb_keymap = nullptr;
struct xkb_state *xkb_state = nullptr;
@ -449,6 +473,7 @@ public:
struct wl_data_device *wl_data_device = nullptr;
// Drag and drop.
DisplayServer::WindowID dnd_id = DisplayServer::INVALID_WINDOW_ID;
struct wl_data_offer *wl_data_offer_dnd = nullptr;
uint32_t dnd_enter_serial = 0;
@ -473,6 +498,7 @@ public:
// IME.
struct zwp_text_input_v3 *wp_text_input = nullptr;
DisplayServer::WindowID ime_window_id = DisplayServer::INVALID_WINDOW_ID;
bool ime_enabled = false;
bool ime_active = false;
String ime_text;
@ -503,7 +529,7 @@ private:
Thread events_thread;
ThreadData thread_data;
WindowState main_window;
HashMap<DisplayServer::WindowID, WindowState> windows;
List<Ref<Message>> messages;
@ -615,6 +641,10 @@ private:
static void _xdg_toplevel_on_configure_bounds(void *data, struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height);
static void _xdg_toplevel_on_wm_capabilities(void *data, struct xdg_toplevel *xdg_toplevel, struct wl_array *capabilities);
static void _xdg_popup_on_configure(void *data, struct xdg_popup *xdg_popup, int32_t x, int32_t y, int32_t width, int32_t height);
static void _xdg_popup_on_popup_done(void *data, struct xdg_popup *xdg_popup);
static void _xdg_popup_on_repositioned(void *data, struct xdg_popup *xdg_popup, uint32_t token);
// wayland-protocols event handlers.
static void _wp_fractional_scale_on_preferred_scale(void *data, struct wp_fractional_scale_v1 *wp_fractional_scale_v1, uint32_t scale);
@ -770,6 +800,12 @@ private:
.wm_capabilities = _xdg_toplevel_on_wm_capabilities,
};
static constexpr struct xdg_popup_listener xdg_popup_listener = {
.configure = _xdg_popup_on_configure,
.popup_done = _xdg_popup_on_popup_done,
.repositioned = _xdg_popup_on_repositioned,
};
// wayland-protocols event listeners.
static constexpr struct wp_fractional_scale_v1_listener wp_fractional_scale_listener = {
.preferred_scale = _wp_fractional_scale_on_preferred_scale,
@ -955,8 +991,13 @@ public:
void beep() const;
void window_create(DisplayServer::WindowID p_window_id, int p_width, int p_height);
void window_create_popup(DisplayServer::WindowID p_window_id, DisplayServer::WindowID p_parent_id, Rect2i p_rect);
void window_destroy(DisplayServer::WindowID p_window_Id);
void window_set_parent(DisplayServer::WindowID p_window_id, DisplayServer::WindowID p_parent_id);
struct wl_surface *window_get_wl_surface(DisplayServer::WindowID p_window_id) const;
WindowState *window_get_state(DisplayServer::WindowID p_window_id);
void window_start_resize(DisplayServer::WindowResizeEdge p_edge, DisplayServer::WindowID p_window);
@ -989,6 +1030,7 @@ public:
void pointer_set_hint(const Point2i &p_hint);
PointerConstraint pointer_get_constraint() const;
DisplayServer::WindowID pointer_get_pointed_window_id() const;
DisplayServer::WindowID pointer_get_last_pointed_window_id() const;
BitField<MouseButtonMask> pointer_get_button_mask() const;
void cursor_set_visible(bool p_visible);
@ -1027,6 +1069,8 @@ public:
bool get_reset_frame();
bool wait_frame_suspend_ms(int p_timeout);
uint64_t window_get_last_frame_time(DisplayServer::WindowID p_window_id) const;
bool window_is_suspended(DisplayServer::WindowID p_window_id) const;
bool is_suspended() const;
Error init();
@ -1034,5 +1078,3 @@ public:
};
#endif // WAYLAND_ENABLED
#endif // WAYLAND_THREAD_H