diff options
Diffstat (limited to 'platform/linuxbsd/wayland/display_server_wayland.cpp')
-rw-r--r-- | platform/linuxbsd/wayland/display_server_wayland.cpp | 107 |
1 files changed, 78 insertions, 29 deletions
diff --git a/platform/linuxbsd/wayland/display_server_wayland.cpp b/platform/linuxbsd/wayland/display_server_wayland.cpp index 528c688a9c..1c3cae0435 100644 --- a/platform/linuxbsd/wayland/display_server_wayland.cpp +++ b/platform/linuxbsd/wayland/display_server_wayland.cpp @@ -46,6 +46,8 @@ #ifdef GLES3_ENABLED #include "detect_prime_egl.h" #include "drivers/gles3/rasterizer_gles3.h" +#include "wayland/egl_manager_wayland.h" +#include "wayland/egl_manager_wayland_gles.h" #endif String DisplayServerWayland::_get_app_id_from_context(Context p_context) { @@ -192,19 +194,37 @@ void DisplayServerWayland::_show_window() { bool DisplayServerWayland::has_feature(Feature p_feature) const { switch (p_feature) { +#ifndef DISABLE_DEPRECATED + case FEATURE_GLOBAL_MENU: { + return (native_menu && native_menu->has_feature(NativeMenu::FEATURE_GLOBAL_MENU)); + } break; +#endif case FEATURE_MOUSE: + case FEATURE_MOUSE_WARP: case FEATURE_CLIPBOARD: case FEATURE_CURSOR_SHAPE: + case FEATURE_CUSTOM_CURSOR_SHAPE: case FEATURE_WINDOW_TRANSPARENCY: + case FEATURE_HIDPI: case FEATURE_SWAP_BUFFERS: case FEATURE_KEEP_SCREEN_ON: - case FEATURE_CLIPBOARD_PRIMARY: + case FEATURE_CLIPBOARD_PRIMARY: { + return true; + } break; + + //case FEATURE_NATIVE_DIALOG: + //case FEATURE_NATIVE_DIALOG_INPUT: #ifdef DBUS_ENABLED - case FEATURE_NATIVE_DIALOG: + case FEATURE_NATIVE_DIALOG_FILE: { + return true; + } break; #endif - case FEATURE_HIDPI: { + +#ifdef SPEECHD_ENABLED + case FEATURE_TEXT_TO_SPEECH: { return true; } break; +#endif default: { return false; @@ -569,9 +589,9 @@ void DisplayServerWayland::screen_set_keep_on(bool p_enable) { bool DisplayServerWayland::screen_is_kept_on() const { #ifdef DBUS_ENABLED return wayland_thread.window_get_idle_inhibition(MAIN_WINDOW_ID) || screensaver_inhibited; -#endif - +#else return wayland_thread.window_get_idle_inhibition(MAIN_WINDOW_ID); +#endif } Vector<DisplayServer::WindowID> DisplayServerWayland::get_window_list() const { @@ -1143,6 +1163,12 @@ void DisplayServerWayland::process_events() { } } +#ifdef DBUS_ENABLED + if (portal_desktop) { + portal_desktop->process_file_dialog_callbacks(); + } +#endif + wayland_thread.mutex.unlock(); Input::get_singleton()->flush_buffered_events(); @@ -1156,14 +1182,6 @@ void DisplayServerWayland::release_rendering_thread() { #endif } -void DisplayServerWayland::make_rendering_thread() { -#ifdef GLES3_ENABLED - if (egl_manager) { - egl_manager->make_current(); - } -#endif -} - void DisplayServerWayland::swap_buffers() { #ifdef GLES3_ENABLED if (egl_manager) { @@ -1192,6 +1210,7 @@ Vector<String> DisplayServerWayland::get_rendering_drivers_func() { #ifdef GLES3_ENABLED drivers.push_back("opengl3"); + drivers.push_back("opengl3_es"); #endif return drivers; @@ -1231,6 +1250,8 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win // Input. Input::get_singleton()->set_event_dispatch_function(dispatch_input_events); + native_menu = memnew(NativeMenu); + #ifdef SPEECHD_ENABLED // Init TTS tts = memnew(TTS_Linux); @@ -1240,14 +1261,14 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win #ifdef RD_ENABLED #ifdef VULKAN_ENABLED - if (p_rendering_driver == "vulkan") { + if (rendering_driver == "vulkan") { rendering_context = memnew(RenderingContextDriverVulkanWayland); } #endif if (rendering_context) { if (rendering_context->initialize() != OK) { - ERR_PRINT(vformat("Could not initialize %s", p_rendering_driver)); + ERR_PRINT(vformat("Could not initialize %s", rendering_driver)); memdelete(rendering_context); rendering_context = nullptr; r_error = ERR_CANT_CREATE; @@ -1257,7 +1278,14 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win #endif #ifdef GLES3_ENABLED - if (p_rendering_driver == "opengl3") { + if (rendering_driver == "opengl3" || rendering_driver == "opengl3_es") { +#ifdef SOWRAP_ENABLED + if (initialize_wayland_egl(dylibloader_verbose) != 0) { + WARN_PRINT("Can't load the Wayland EGL library."); + return; + } +#endif // SOWRAP_ENABLED + if (getenv("DRI_PRIME") == nullptr) { int prime_idx = -1; @@ -1300,23 +1328,38 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win } } - egl_manager = memnew(EGLManagerWayland); + if (rendering_driver == "opengl3") { + egl_manager = memnew(EGLManagerWayland); -#ifdef SOWRAP_ENABLED - if (initialize_wayland_egl(dylibloader_verbose) != 0) { - WARN_PRINT("Can't load the Wayland EGL library."); - return; - } -#endif // SOWRAP_ENABLED + if (egl_manager->initialize() != OK || egl_manager->open_display(wayland_thread.get_wl_display()) != OK) { + memdelete(egl_manager); + egl_manager = nullptr; - if (egl_manager->initialize() != OK) { - memdelete(egl_manager); - egl_manager = nullptr; - r_error = ERR_CANT_CREATE; - ERR_FAIL_MSG("Could not initialize GLES3."); + bool fallback = GLOBAL_GET("rendering/gl_compatibility/fallback_to_gles"); + if (fallback) { + WARN_PRINT("Your video card drivers seem not to support the required OpenGL version, switching to OpenGLES."); + rendering_driver = "opengl3_es"; + } else { + r_error = ERR_UNAVAILABLE; + ERR_FAIL_MSG("Could not initialize OpenGL."); + } + } else { + RasterizerGLES3::make_current(true); + } } - RasterizerGLES3::make_current(true); + if (rendering_driver == "opengl3_es") { + egl_manager = memnew(EGLManagerWaylandGLES); + + if (egl_manager->initialize() != OK) { + memdelete(egl_manager); + egl_manager = nullptr; + r_error = ERR_CANT_CREATE; + ERR_FAIL_MSG("Could not initialize GLES3."); + } + + RasterizerGLES3::make_current(false); + } } #endif // GLES3_ENABLED @@ -1355,6 +1398,12 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win DisplayServerWayland::~DisplayServerWayland() { // TODO: Multiwindow support. + + if (native_menu) { + memdelete(native_menu); + native_menu = nullptr; + } + if (main_window.visible) { #ifdef VULKAN_ENABLED if (rendering_device) { |