summaryrefslogtreecommitdiffstats
path: root/platform/linuxbsd
diff options
context:
space:
mode:
Diffstat (limited to 'platform/linuxbsd')
-rw-r--r--platform/linuxbsd/export/export.cpp3
-rw-r--r--platform/linuxbsd/export/export_plugin.cpp5
-rw-r--r--platform/linuxbsd/freedesktop_portal_desktop.cpp3
-rw-r--r--platform/linuxbsd/godot_linuxbsd.cpp7
-rw-r--r--platform/linuxbsd/joypad_linux.h1
-rw-r--r--platform/linuxbsd/os_linuxbsd.cpp20
-rw-r--r--platform/linuxbsd/os_linuxbsd.h5
-rw-r--r--platform/linuxbsd/tts_linux.cpp57
-rw-r--r--platform/linuxbsd/tts_linux.h8
-rw-r--r--platform/linuxbsd/x11/detect_prime_x11.cpp14
-rw-r--r--platform/linuxbsd/x11/display_server_x11.cpp32
-rw-r--r--platform/linuxbsd/x11/display_server_x11.h33
-rw-r--r--platform/linuxbsd/x11/gl_manager_x11.cpp10
-rw-r--r--platform/linuxbsd/x11/gl_manager_x11.h10
-rw-r--r--platform/linuxbsd/x11/key_mapping_x11.h7
-rw-r--r--platform/linuxbsd/x11/vulkan_context_x11.h1
16 files changed, 125 insertions, 91 deletions
diff --git a/platform/linuxbsd/export/export.cpp b/platform/linuxbsd/export/export.cpp
index 09f354246d..f72c079d1d 100644
--- a/platform/linuxbsd/export/export.cpp
+++ b/platform/linuxbsd/export/export.cpp
@@ -30,9 +30,10 @@
#include "export.h"
-#include "editor/export/editor_export.h"
#include "export_plugin.h"
+#include "editor/export/editor_export.h"
+
void register_linuxbsd_exporter_types() {
GDREGISTER_VIRTUAL_CLASS(EditorExportPlatformLinuxBSD);
}
diff --git a/platform/linuxbsd/export/export_plugin.cpp b/platform/linuxbsd/export/export_plugin.cpp
index 9544cc761d..daa2664b09 100644
--- a/platform/linuxbsd/export/export_plugin.cpp
+++ b/platform/linuxbsd/export/export_plugin.cpp
@@ -30,13 +30,14 @@
#include "export_plugin.h"
+#include "../logo_svg.gen.h"
+#include "../run_icon_svg.gen.h"
+
#include "core/config/project_settings.h"
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
#include "editor/editor_scale.h"
#include "editor/export/editor_export.h"
-#include "platform/linuxbsd/logo_svg.gen.h"
-#include "platform/linuxbsd/run_icon_svg.gen.h"
#include "modules/modules_enabled.gen.h" // For svg.
#ifdef MODULE_SVG_ENABLED
diff --git a/platform/linuxbsd/freedesktop_portal_desktop.cpp b/platform/linuxbsd/freedesktop_portal_desktop.cpp
index 6dfa8ed93c..c3cb0f411d 100644
--- a/platform/linuxbsd/freedesktop_portal_desktop.cpp
+++ b/platform/linuxbsd/freedesktop_portal_desktop.cpp
@@ -35,6 +35,7 @@
#include "core/error/error_macros.h"
#include "core/os/os.h"
#include "core/string/ustring.h"
+#include "core/variant/variant.h"
#ifdef SOWRAP_ENABLED
#include "dbus-so_wrap.h"
@@ -42,8 +43,6 @@
#include <dbus/dbus.h>
#endif
-#include "core/variant/variant.h"
-
#define BUS_OBJECT_NAME "org.freedesktop.portal.Desktop"
#define BUS_OBJECT_PATH "/org/freedesktop/portal/desktop"
diff --git a/platform/linuxbsd/godot_linuxbsd.cpp b/platform/linuxbsd/godot_linuxbsd.cpp
index 76d579dd53..d059d60b72 100644
--- a/platform/linuxbsd/godot_linuxbsd.cpp
+++ b/platform/linuxbsd/godot_linuxbsd.cpp
@@ -28,6 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
+#include "os_linuxbsd.h"
+
+#include "main/main.h"
+
#include <limits.h>
#include <locale.h>
#include <stdlib.h>
@@ -37,9 +41,6 @@
#include <sys/resource.h>
#endif
-#include "main/main.h"
-#include "os_linuxbsd.h"
-
int main(int argc, char *argv[]) {
#if defined(SANITIZERS_ENABLED)
// Note: Set stack size to be at least 30 MB (vs 8 MB default) to avoid overflow, address sanitizer can increase stack usage up to 3 times.
diff --git a/platform/linuxbsd/joypad_linux.h b/platform/linuxbsd/joypad_linux.h
index 6661abdb37..26a9908d4e 100644
--- a/platform/linuxbsd/joypad_linux.h
+++ b/platform/linuxbsd/joypad_linux.h
@@ -32,6 +32,7 @@
#define JOYPAD_LINUX_H
#ifdef JOYDEV_ENABLED
+
#include "core/input/input.h"
#include "core/os/mutex.h"
#include "core/os/thread.h"
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp
index 2c093b00e7..ebdbd061d1 100644
--- a/platform/linuxbsd/os_linuxbsd.cpp
+++ b/platform/linuxbsd/os_linuxbsd.cpp
@@ -35,17 +35,13 @@
#include "main/main.h"
#include "servers/display_server.h"
-#include "modules/modules_enabled.gen.h" // For regex.
-#ifdef MODULE_REGEX_ENABLED
-#include "modules/regex/regex.h"
-#endif
-
#ifdef X11_ENABLED
#include "x11/display_server_x11.h"
#endif
-#ifdef HAVE_MNTENT
-#include <mntent.h>
+#include "modules/modules_enabled.gen.h" // For regex.
+#ifdef MODULE_REGEX_ENABLED
+#include "modules/regex/regex.h"
#endif
#include <dlfcn.h>
@@ -57,6 +53,10 @@
#include <sys/utsname.h>
#include <unistd.h>
+#ifdef HAVE_MNTENT
+#include <mntent.h>
+#endif
+
void OS_LinuxBSD::alert(const String &p_alert, const String &p_title) {
const char *message_programs[] = { "zenity", "kdialog", "Xdialog", "xmessage" };
@@ -252,7 +252,7 @@ String OS_LinuxBSD::get_version() const {
}
Vector<String> OS_LinuxBSD::get_video_adapter_driver_info() const {
- if (RenderingServer::get_singleton()->get_rendering_device() == nullptr) {
+ if (RenderingServer::get_singleton() == nullptr) {
return Vector<String>();
}
@@ -261,8 +261,8 @@ Vector<String> OS_LinuxBSD::get_video_adapter_driver_info() const {
return info;
}
- const String rendering_device_name = RenderingServer::get_singleton()->get_rendering_device()->get_device_name(); // e.g. `NVIDIA GeForce GTX 970`
- const String rendering_device_vendor = RenderingServer::get_singleton()->get_rendering_device()->get_device_vendor_name(); // e.g. `NVIDIA`
+ const String rendering_device_name = RenderingServer::get_singleton()->get_video_adapter_name(); // e.g. `NVIDIA GeForce GTX 970`
+ const String rendering_device_vendor = RenderingServer::get_singleton()->get_video_adapter_vendor(); // e.g. `NVIDIA`
const String card_name = rendering_device_name.trim_prefix(rendering_device_vendor).strip_edges(); // -> `GeForce GTX 970`
String vendor_device_id_mappings;
diff --git a/platform/linuxbsd/os_linuxbsd.h b/platform/linuxbsd/os_linuxbsd.h
index c1e735b0d4..007b90b82b 100644
--- a/platform/linuxbsd/os_linuxbsd.h
+++ b/platform/linuxbsd/os_linuxbsd.h
@@ -31,13 +31,14 @@
#ifndef OS_LINUXBSD_H
#define OS_LINUXBSD_H
-#include "core/input/input.h"
#include "crash_handler_linuxbsd.h"
+#include "joypad_linux.h"
+
+#include "core/input/input.h"
#include "drivers/alsa/audio_driver_alsa.h"
#include "drivers/alsamidi/midi_driver_alsamidi.h"
#include "drivers/pulseaudio/audio_driver_pulseaudio.h"
#include "drivers/unix/os_unix.h"
-#include "joypad_linux.h"
#include "servers/audio_server.h"
#ifdef FONTCONFIG_ENABLED
diff --git a/platform/linuxbsd/tts_linux.cpp b/platform/linuxbsd/tts_linux.cpp
index a0cb4f5c6c..8bc83f5b9c 100644
--- a/platform/linuxbsd/tts_linux.cpp
+++ b/platform/linuxbsd/tts_linux.cpp
@@ -101,6 +101,24 @@ void TTS_Linux::speech_event_callback(size_t p_msg_id, size_t p_client_id, SPDNo
}
}
+void TTS_Linux::_load_voices() {
+ if (!voices_loaded) {
+ SPDVoice **spd_voices = spd_list_synthesis_voices(synth);
+ if (spd_voices != nullptr) {
+ SPDVoice **voices_ptr = spd_voices;
+ while (*voices_ptr != nullptr) {
+ VoiceInfo vi;
+ vi.language = String::utf8((*voices_ptr)->language);
+ vi.variant = String::utf8((*voices_ptr)->variant);
+ voices[String::utf8((*voices_ptr)->name)] = vi;
+ voices_ptr++;
+ }
+ free_spd_voices(spd_voices);
+ }
+ voices_loaded = true;
+ }
+}
+
void TTS_Linux::_speech_event(size_t p_msg_id, size_t p_client_id, int p_type) {
_THREAD_SAFE_METHOD_
@@ -123,18 +141,13 @@ void TTS_Linux::_speech_event(size_t p_msg_id, size_t p_client_id, int p_type) {
// Inject index mark after each word.
String text;
String language;
- SPDVoice **voices = spd_list_synthesis_voices(synth);
- if (voices != nullptr) {
- SPDVoice **voices_ptr = voices;
- while (*voices_ptr != nullptr) {
- if (String::utf8((*voices_ptr)->name) == message.voice) {
- language = String::utf8((*voices_ptr)->language);
- break;
- }
- voices_ptr++;
- }
- free_spd_voices(voices);
+
+ _load_voices();
+ const VoiceInfo *voice = voices.getptr(message.voice);
+ if (voice) {
+ language = voice->language;
}
+
PackedInt32Array breaks = TS->string_get_word_breaks(message.text, language);
for (int i = 0; i < breaks.size(); i += 2) {
const int start = breaks[i];
@@ -174,21 +187,17 @@ Array TTS_Linux::get_voices() const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!synth, Array());
+ const_cast<TTS_Linux *>(this)->_load_voices();
+
Array list;
- SPDVoice **voices = spd_list_synthesis_voices(synth);
- if (voices != nullptr) {
- SPDVoice **voices_ptr = voices;
- while (*voices_ptr != nullptr) {
- Dictionary voice_d;
- voice_d["name"] = String::utf8((*voices_ptr)->name);
- voice_d["id"] = String::utf8((*voices_ptr)->name);
- voice_d["language"] = String::utf8((*voices_ptr)->language) + "_" + String::utf8((*voices_ptr)->variant);
- list.push_back(voice_d);
-
- voices_ptr++;
- }
- free_spd_voices(voices);
+ for (const KeyValue<String, VoiceInfo> &E : voices) {
+ Dictionary voice_d;
+ voice_d["name"] = E.key;
+ voice_d["id"] = E.key;
+ voice_d["language"] = E.value.language + "_" + E.value.variant;
+ list.push_back(voice_d);
}
+
return list;
}
diff --git a/platform/linuxbsd/tts_linux.h b/platform/linuxbsd/tts_linux.h
index 651a64d9d6..ec68219689 100644
--- a/platform/linuxbsd/tts_linux.h
+++ b/platform/linuxbsd/tts_linux.h
@@ -55,6 +55,13 @@ class TTS_Linux : public Object {
int last_msg_id = -1;
HashMap<int, int> ids;
+ struct VoiceInfo {
+ String language;
+ String variant;
+ };
+ bool voices_loaded = false;
+ HashMap<String, VoiceInfo> voices;
+
Thread init_thread;
static void speech_init_thread_func(void *p_userdata);
@@ -64,6 +71,7 @@ class TTS_Linux : public Object {
static TTS_Linux *singleton;
protected:
+ void _load_voices();
void _speech_event(size_t p_msg_id, size_t p_client_id, int p_type);
void _speech_index_mark(size_t p_msg_id, size_t p_client_id, int p_type, const String &p_index_mark);
diff --git a/platform/linuxbsd/x11/detect_prime_x11.cpp b/platform/linuxbsd/x11/detect_prime_x11.cpp
index 78778a8b56..2b5776ce54 100644
--- a/platform/linuxbsd/x11/detect_prime_x11.cpp
+++ b/platform/linuxbsd/x11/detect_prime_x11.cpp
@@ -28,29 +28,26 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
-#ifdef X11_ENABLED
-#if defined(GLES3_ENABLED)
+#if defined(X11_ENABLED) && defined(GLES3_ENABLED)
#include "detect_prime_x11.h"
#include "core/string/print_string.h"
#include "core/string/ustring.h"
-#include <stdlib.h>
-
#include "thirdparty/glad/glad/gl.h"
#include "thirdparty/glad/glad/glx.h"
#ifdef SOWRAP_ENABLED
-#include "dynwrappers/xlib-so_wrap.h"
+#include "x11/dynwrappers/xlib-so_wrap.h"
#else
#include <X11/XKBlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#endif
-#include <cstring>
-
+#include <stdlib.h>
+#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
@@ -265,5 +262,4 @@ int detect_prime() {
return preferred;
}
-#endif
-#endif
+#endif // X11_ENABLED && GLES3_ENABLED
diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp
index 507acfcf34..83b6fb7628 100644
--- a/platform/linuxbsd/x11/display_server_x11.cpp
+++ b/platform/linuxbsd/x11/display_server_x11.cpp
@@ -32,12 +32,13 @@
#ifdef X11_ENABLED
+#include "x11/detect_prime_x11.h"
+#include "x11/key_mapping_x11.h"
+
#include "core/config/project_settings.h"
#include "core/math/math_funcs.h"
#include "core/string/print_string.h"
#include "core/string/ustring.h"
-#include "detect_prime_x11.h"
-#include "key_mapping_x11.h"
#include "main/main.h"
#include "scene/resources/texture.h"
@@ -58,6 +59,9 @@
#include <sys/types.h>
#include <unistd.h>
+#undef CursorShape
+#include <X11/XKBlib.h>
+
// ICCCM
#define WM_NormalState 1L // window normal state
#define WM_IconicState 3L // window minimized
@@ -65,9 +69,6 @@
#define _NET_WM_STATE_REMOVE 0L // remove/unset property
#define _NET_WM_STATE_ADD 1L // add/set property
-#undef CursorShape
-#include <X11/XKBlib.h>
-
// 2.2 is the first release with multitouch
#define XINPUT_CLIENT_VERSION_MAJOR 2
#define XINPUT_CLIENT_VERSION_MINOR 2
@@ -855,12 +856,30 @@ Size2i DisplayServerX11::screen_get_size(int p_screen) const {
return _screen_get_rect(p_screen).size;
}
+// A Handler to avoid crashing on non-fatal X errors by default.
+//
+// The original X11 error formatter `_XPrintDefaultError` is defined here:
+// https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/e45ca7b41dcd3ace7681d6897505f85d374640f2/src/XlibInt.c#L1322
+// It is not exposed through the API, accesses X11 internals,
+// and is much more complex, so this is a less complete simplified error X11 printer.
+int default_window_error_handler(Display *display, XErrorEvent *error) {
+ static char message[1024];
+ XGetErrorText(display, error->error_code, message, sizeof(message));
+
+ ERR_PRINT(vformat("Unhandled XServer error: %s"
+ "\n Major opcode of failed request: %d"
+ "\n Serial number of failed request: %d"
+ "\n Current serial number in output stream: %d",
+ String::utf8(message), (uint64_t)error->request_code, (uint64_t)error->minor_code, (uint64_t)error->serial));
+ return 0;
+}
+
bool g_bad_window = false;
int bad_window_error_handler(Display *display, XErrorEvent *error) {
if (error->error_code == BadWindow) {
g_bad_window = true;
} else {
- ERR_PRINT("Unhandled XServer error code: " + itos(error->error_code));
+ return default_window_error_handler(display, error);
}
return 0;
}
@@ -5930,6 +5949,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
portal_desktop = memnew(FreeDesktopPortalDesktop);
#endif
+ XSetErrorHandler(&default_window_error_handler);
r_error = OK;
}
diff --git a/platform/linuxbsd/x11/display_server_x11.h b/platform/linuxbsd/x11/display_server_x11.h
index fd3a5dccfa..176a1ffb9a 100644
--- a/platform/linuxbsd/x11/display_server_x11.h
+++ b/platform/linuxbsd/x11/display_server_x11.h
@@ -33,7 +33,7 @@
#ifdef X11_ENABLED
-#include "servers/display_server.h"
+#include "joypad_linux.h"
#include "core/input/input.h"
#include "core/os/mutex.h"
@@ -43,27 +43,28 @@
#include "drivers/alsamidi/midi_driver_alsamidi.h"
#include "drivers/pulseaudio/audio_driver_pulseaudio.h"
#include "drivers/unix/os_unix.h"
-#include "joypad_linux.h"
#include "servers/audio_server.h"
+#include "servers/display_server.h"
#include "servers/rendering/renderer_compositor.h"
#include "servers/rendering_server.h"
#if defined(SPEECHD_ENABLED)
-#include "../tts_linux.h"
+#include "tts_linux.h"
#endif
#if defined(GLES3_ENABLED)
-#include "gl_manager_x11.h"
+#include "x11/gl_manager_x11.h"
#endif
#if defined(VULKAN_ENABLED)
+#include "x11/vulkan_context_x11.h"
+
#include "drivers/vulkan/rendering_device_vulkan.h"
-#include "vulkan_context_x11.h"
#endif
#if defined(DBUS_ENABLED)
-#include "../freedesktop_portal_desktop.h"
-#include "../freedesktop_screensaver.h"
+#include "freedesktop_portal_desktop.h"
+#include "freedesktop_screensaver.h"
#endif
#include <X11/Xatom.h>
@@ -72,16 +73,16 @@
#include <X11/keysym.h>
#ifdef SOWRAP_ENABLED
-#include "dynwrappers/xlib-so_wrap.h"
+#include "x11/dynwrappers/xlib-so_wrap.h"
-#include "dynwrappers/xcursor-so_wrap.h"
-#include "dynwrappers/xext-so_wrap.h"
-#include "dynwrappers/xinerama-so_wrap.h"
-#include "dynwrappers/xinput2-so_wrap.h"
-#include "dynwrappers/xrandr-so_wrap.h"
-#include "dynwrappers/xrender-so_wrap.h"
+#include "x11/dynwrappers/xcursor-so_wrap.h"
+#include "x11/dynwrappers/xext-so_wrap.h"
+#include "x11/dynwrappers/xinerama-so_wrap.h"
+#include "x11/dynwrappers/xinput2-so_wrap.h"
+#include "x11/dynwrappers/xrandr-so_wrap.h"
+#include "x11/dynwrappers/xrender-so_wrap.h"
-#include "../xkbcommon-so_wrap.h"
+#include "xkbcommon-so_wrap.h"
#else
#include <X11/XKBlib.h>
#include <X11/Xlib.h>
@@ -521,6 +522,6 @@ public:
~DisplayServerX11();
};
-#endif // X11 enabled
+#endif // X11_ENABLED
#endif // DISPLAY_SERVER_X11_H
diff --git a/platform/linuxbsd/x11/gl_manager_x11.cpp b/platform/linuxbsd/x11/gl_manager_x11.cpp
index 1e579c9f01..f24bac5e19 100644
--- a/platform/linuxbsd/x11/gl_manager_x11.cpp
+++ b/platform/linuxbsd/x11/gl_manager_x11.cpp
@@ -30,15 +30,14 @@
#include "gl_manager_x11.h"
-#ifdef X11_ENABLED
-#if defined(GLES3_ENABLED)
+#if defined(X11_ENABLED) && defined(GLES3_ENABLED)
+
+#include "thirdparty/glad/glad/glx.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include "thirdparty/glad/glad/glx.h"
-
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
@@ -403,5 +402,4 @@ GLManager_X11::~GLManager_X11() {
release_current();
}
-#endif
-#endif
+#endif // X11_ENABLED && GLES3_ENABLED
diff --git a/platform/linuxbsd/x11/gl_manager_x11.h b/platform/linuxbsd/x11/gl_manager_x11.h
index 0203dff679..59e20fec45 100644
--- a/platform/linuxbsd/x11/gl_manager_x11.h
+++ b/platform/linuxbsd/x11/gl_manager_x11.h
@@ -31,12 +31,11 @@
#ifndef GL_MANAGER_X11_H
#define GL_MANAGER_X11_H
-#ifdef X11_ENABLED
-
-#ifdef GLES3_ENABLED
+#if defined(X11_ENABLED) && defined(GLES3_ENABLED)
#include "core/os/os.h"
#include "core/templates/local_vector.h"
+#include "servers/display_server.h"
#ifdef SOWRAP_ENABLED
#include "dynwrappers/xlib-so_wrap.h"
@@ -53,8 +52,6 @@
#include <X11/extensions/shape.h>
#endif
-#include "servers/display_server.h"
-
struct GLManager_X11_Private;
class GLManager_X11 {
@@ -136,7 +133,6 @@ public:
~GLManager_X11();
};
-#endif // GLES3_ENABLED
-#endif // X11_ENABLED
+#endif // X11_ENABLED && GLES3_ENABLED
#endif // GL_MANAGER_X11_H
diff --git a/platform/linuxbsd/x11/key_mapping_x11.h b/platform/linuxbsd/x11/key_mapping_x11.h
index 48beefff4c..ae8fd67f27 100644
--- a/platform/linuxbsd/x11/key_mapping_x11.h
+++ b/platform/linuxbsd/x11/key_mapping_x11.h
@@ -31,16 +31,17 @@
#ifndef KEY_MAPPING_X11_H
#define KEY_MAPPING_X11_H
+#include "core/os/keyboard.h"
+#include "core/templates/hash_map.h"
+
#include <X11/XF86keysym.h>
#include <X11/Xlib.h>
+
#define XK_MISCELLANY
#define XK_LATIN1
#define XK_XKB_KEYS
#include <X11/keysymdef.h>
-#include "core/os/keyboard.h"
-#include "core/templates/hash_map.h"
-
class KeyMappingX11 {
struct HashMapHasherKeys {
static _FORCE_INLINE_ uint32_t hash(const Key p_key) { return hash_fmix32(static_cast<uint32_t>(p_key)); }
diff --git a/platform/linuxbsd/x11/vulkan_context_x11.h b/platform/linuxbsd/x11/vulkan_context_x11.h
index d093bca853..294fdc710e 100644
--- a/platform/linuxbsd/x11/vulkan_context_x11.h
+++ b/platform/linuxbsd/x11/vulkan_context_x11.h
@@ -34,6 +34,7 @@
#ifdef VULKAN_ENABLED
#include "drivers/vulkan/vulkan_context.h"
+
#include <X11/Xlib.h>
class VulkanContextX11 : public VulkanContext {