summaryrefslogtreecommitdiffstats
path: root/platform/linuxbsd/wayland/display_server_wayland.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/linuxbsd/wayland/display_server_wayland.cpp')
-rw-r--r--platform/linuxbsd/wayland/display_server_wayland.cpp112
1 files changed, 85 insertions, 27 deletions
diff --git a/platform/linuxbsd/wayland/display_server_wayland.cpp b/platform/linuxbsd/wayland/display_server_wayland.cpp
index e22eddd08e..b8a10ea6b9 100644
--- a/platform/linuxbsd/wayland/display_server_wayland.cpp
+++ b/platform/linuxbsd/wayland/display_server_wayland.cpp
@@ -100,8 +100,8 @@ void DisplayServerWayland::_resize_window(const Size2i &p_size) {
wd.rect.size = p_size;
#ifdef RD_ENABLED
- if (wd.visible && context_rd) {
- context_rd->window_resize(MAIN_WINDOW_ID, wd.rect.size.width, wd.rect.size.height);
+ if (wd.visible && rendering_context) {
+ rendering_context->window_set_size(MAIN_WINDOW_ID, wd.rect.size.width, wd.rect.size.height);
}
#endif
@@ -140,10 +140,10 @@ void DisplayServerWayland::_show_window() {
// the only acceptable way of implementing window showing is to move the
// graphics context window creation logic here.
#ifdef RD_ENABLED
- if (context_rd) {
+ if (rendering_context) {
union {
#ifdef VULKAN_ENABLED
- VulkanContextWayland::WindowPlatformData vulkan;
+ RenderingContextDriverVulkanWayland::WindowPlatformData vulkan;
#endif
} wpd;
#ifdef VULKAN_ENABLED
@@ -152,14 +152,17 @@ void DisplayServerWayland::_show_window() {
wpd.vulkan.display = wayland_thread.get_wl_display();
}
#endif
- Error err = context_rd->window_create(wd.id, wd.vsync_mode, wd.rect.size.width, wd.rect.size.height, &wpd);
- ERR_FAIL_COND_MSG(err != OK, vformat("Can't create a %s window", context_rd->get_api_name()));
+ Error err = rendering_context->window_create(wd.id, &wpd);
+ ERR_FAIL_COND_MSG(err != OK, vformat("Can't create a %s window", rendering_driver));
- emulate_vsync = (context_rd->get_vsync_mode(wd.id) == DisplayServer::VSYNC_ENABLED);
+ rendering_context->window_set_size(wd.id, wd.rect.size.width, wd.rect.size.height);
+ rendering_context->window_set_vsync_mode(wd.id, wd.vsync_mode);
+
+ emulate_vsync = (rendering_context->window_get_vsync_mode(wd.id) == DisplayServer::VSYNC_ENABLED);
if (emulate_vsync) {
print_verbose("VSYNC: manually throttling frames using MAILBOX.");
- context_rd->set_vsync_mode(wd.id, DisplayServer::VSYNC_MAILBOX);
+ rendering_context->window_set_vsync_mode(wd.id, DisplayServer::VSYNC_MAILBOX);
}
}
#endif
@@ -196,6 +199,9 @@ bool DisplayServerWayland::has_feature(Feature p_feature) const {
case FEATURE_SWAP_BUFFERS:
case FEATURE_KEEP_SCREEN_ON:
case FEATURE_CLIPBOARD_PRIMARY:
+#ifdef DBUS_ENABLED
+ case FEATURE_NATIVE_DIALOG:
+#endif
case FEATURE_HIDPI: {
return true;
} break;
@@ -269,6 +275,22 @@ bool DisplayServerWayland::is_dark_mode() const {
}
}
+Error DisplayServerWayland::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 window_id = MAIN_WINDOW_ID;
+ // TODO: Use window IDs for multiwindow support.
+
+ WaylandThread::WindowState *ws = wayland_thread.wl_surface_get_window_state(wayland_thread.window_get_wl_surface(window_id));
+ return portal_desktop->file_dialog_show(window_id, (ws ? ws->exported_handle : String()), p_title, p_current_directory, String(), p_filename, p_mode, p_filters, TypedArray<Dictionary>(), p_callback, false);
+}
+
+Error DisplayServerWayland::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 window_id = MAIN_WINDOW_ID;
+ // TODO: Use window IDs for multiwindow support.
+
+ WaylandThread::WindowState *ws = wayland_thread.wl_surface_get_window_state(wayland_thread.window_get_wl_surface(window_id));
+ return portal_desktop->file_dialog_show(window_id, (ws ? ws->exported_handle : String()), p_title, p_current_directory, p_root, p_filename, p_mode, p_filters, p_options, p_callback, true);
+}
+
#endif
void DisplayServerWayland::mouse_set_mode(MouseMode p_mode) {
@@ -557,6 +579,37 @@ Vector<DisplayServer::WindowID> DisplayServerWayland::get_window_list() const {
return ret;
}
+int64_t DisplayServerWayland::window_get_native_handle(HandleType p_handle_type, WindowID p_window) const {
+ MutexLock mutex_lock(wayland_thread.mutex);
+
+ switch (p_handle_type) {
+ case DISPLAY_HANDLE: {
+ return (int64_t)wayland_thread.get_wl_display();
+ } break;
+
+ case WINDOW_HANDLE: {
+ return (int64_t)wayland_thread.window_get_wl_surface(p_window);
+ } break;
+
+ case WINDOW_VIEW: {
+ return 0; // Not supported.
+ } break;
+
+#ifdef GLES3_ENABLED
+ case OPENGL_CONTEXT: {
+ if (egl_manager) {
+ return (int64_t)egl_manager->get_context(p_window);
+ }
+ return 0;
+ } break;
+#endif // GLES3_ENABLED
+
+ default: {
+ return 0;
+ } break;
+ }
+}
+
DisplayServer::WindowID DisplayServerWayland::get_window_at_screen_position(const Point2i &p_position) const {
// Standard Wayland APIs don't support this.
return MAIN_WINDOW_ID;
@@ -835,14 +888,14 @@ void DisplayServerWayland::window_set_vsync_mode(DisplayServer::VSyncMode p_vsyn
MutexLock mutex_lock(wayland_thread.mutex);
#ifdef RD_ENABLED
- if (context_rd) {
- context_rd->set_vsync_mode(p_window_id, p_vsync_mode);
+ if (rendering_context) {
+ rendering_context->window_set_vsync_mode(p_window_id, p_vsync_mode);
- emulate_vsync = (context_rd->get_vsync_mode(p_window_id) == DisplayServer::VSYNC_ENABLED);
+ emulate_vsync = (rendering_context->window_get_vsync_mode(p_window_id) == DisplayServer::VSYNC_ENABLED);
if (emulate_vsync) {
print_verbose("VSYNC: manually throttling frames using MAILBOX.");
- context_rd->set_vsync_mode(p_window_id, DisplayServer::VSYNC_MAILBOX);
+ rendering_context->window_set_vsync_mode(p_window_id, DisplayServer::VSYNC_MAILBOX);
}
}
#endif // VULKAN_ENABLED
@@ -867,8 +920,8 @@ DisplayServer::VSyncMode DisplayServerWayland::window_get_vsync_mode(DisplayServ
}
#ifdef VULKAN_ENABLED
- if (context_rd) {
- return context_rd->get_vsync_mode(p_window_id);
+ if (rendering_context) {
+ return rendering_context->window_get_vsync_mode(p_window_id);
}
#endif // VULKAN_ENABLED
@@ -1186,16 +1239,17 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win
#ifdef RD_ENABLED
#ifdef VULKAN_ENABLED
if (p_rendering_driver == "vulkan") {
- context_rd = memnew(VulkanContextWayland);
+ rendering_context = memnew(RenderingContextDriverVulkanWayland);
}
#endif
- if (context_rd) {
- if (context_rd->initialize() != OK) {
- memdelete(context_rd);
- context_rd = nullptr;
+ if (rendering_context) {
+ if (rendering_context->initialize() != OK) {
+ ERR_PRINT(vformat("Could not initialize %s", p_rendering_driver));
+ memdelete(rendering_context);
+ rendering_context = nullptr;
r_error = ERR_CANT_CREATE;
- ERR_FAIL_MSG(vformat("Could not initialize %s", context_rd->get_api_name()));
+ return;
}
}
#endif
@@ -1278,9 +1332,10 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win
_show_window();
#ifdef RD_ENABLED
- if (context_rd) {
+ if (rendering_context) {
rendering_device = memnew(RenderingDevice);
- rendering_device->initialize(context_rd);
+ rendering_device->initialize(rendering_context, MAIN_WINDOW_ID);
+ rendering_device->screen_create(MAIN_WINDOW_ID);
RendererCompositorRD::make_current();
}
@@ -1300,8 +1355,12 @@ DisplayServerWayland::~DisplayServerWayland() {
// TODO: Multiwindow support.
if (main_window.visible) {
#ifdef VULKAN_ENABLED
- if (context_rd) {
- context_rd->window_destroy(MAIN_WINDOW_ID);
+ if (rendering_device) {
+ rendering_device->screen_free(MAIN_WINDOW_ID);
+ }
+
+ if (rendering_context) {
+ rendering_context->window_destroy(MAIN_WINDOW_ID);
}
#endif
@@ -1323,12 +1382,11 @@ DisplayServerWayland::~DisplayServerWayland() {
// Destroy all drivers.
#ifdef RD_ENABLED
if (rendering_device) {
- rendering_device->finalize();
memdelete(rendering_device);
}
- if (context_rd) {
- memdelete(context_rd);
+ if (rendering_context) {
+ memdelete(rendering_context);
}
#endif