diff options
Diffstat (limited to 'platform/x11')
-rw-r--r-- | platform/x11/crash_handler_x11.cpp | 9 | ||||
-rw-r--r-- | platform/x11/crash_handler_x11.h | 2 | ||||
-rw-r--r-- | platform/x11/detect.py | 19 | ||||
-rw-r--r-- | platform/x11/joypad_linux.cpp | 2 | ||||
-rw-r--r-- | platform/x11/os_x11.cpp | 46 | ||||
-rw-r--r-- | platform/x11/os_x11.h | 2 | ||||
-rw-r--r-- | platform/x11/power_x11.h | 6 |
7 files changed, 59 insertions, 27 deletions
diff --git a/platform/x11/crash_handler_x11.cpp b/platform/x11/crash_handler_x11.cpp index 8737a2b92b..1e7f393bdd 100644 --- a/platform/x11/crash_handler_x11.cpp +++ b/platform/x11/crash_handler_x11.cpp @@ -28,15 +28,16 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifdef DEBUG_ENABLED -#define CRASH_HANDLER_ENABLED 1 -#endif - #include "crash_handler_x11.h" + #include "core/os/os.h" #include "core/project_settings.h" #include "main/main.h" +#ifdef DEBUG_ENABLED +#define CRASH_HANDLER_ENABLED 1 +#endif + #ifdef CRASH_HANDLER_ENABLED #include <cxxabi.h> #include <dlfcn.h> diff --git a/platform/x11/crash_handler_x11.h b/platform/x11/crash_handler_x11.h index 6efdd33d9d..d0664aef85 100644 --- a/platform/x11/crash_handler_x11.h +++ b/platform/x11/crash_handler_x11.h @@ -45,4 +45,4 @@ public: ~CrashHandler(); }; -#endif +#endif // CRASH_HANDLER_X11_H diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 72139538b7..16760f9407 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -2,7 +2,7 @@ import os import platform import sys from compat import decode_utf8 - +from methods import get_compiler_version def is_active(): return True @@ -161,18 +161,11 @@ def configure(env): env.Append(CCFLAGS=['-pipe']) env.Append(LINKFLAGS=['-pipe']) - # Check for gcc version > 5 before adding -no-pie - import re - import subprocess - proc = subprocess.Popen([env['CXX'], '--version'], stdout=subprocess.PIPE) - (stdout, _) = proc.communicate() - stdout = decode_utf8(stdout) - match = re.search('[0-9][0-9.]*', stdout) - if match is not None: - version = match.group().split('.') - if (version[0] > '5'): - env.Append(CCFLAGS=['-fpie']) - env.Append(LINKFLAGS=['-no-pie']) + # Check for gcc version >= 6 before adding -no-pie + version = get_compiler_version(env) + if version != None and version[0] > '6': + env.Append(CCFLAGS=['-fpie']) + env.Append(LINKFLAGS=['-no-pie']) ## Dependencies diff --git a/platform/x11/joypad_linux.cpp b/platform/x11/joypad_linux.cpp index 907c652ab4..7cf0a1ef1e 100644 --- a/platform/x11/joypad_linux.cpp +++ b/platform/x11/joypad_linux.cpp @@ -476,7 +476,7 @@ void JoypadLinux::process_joypads() { // ev may be tainted and out of MAX_KEY range, which will cause // joy->key_map[ev.code] to crash - if (ev.code < 0 || ev.code >= MAX_KEY) + if (ev.code >= MAX_KEY) return; switch (ev.type) { diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index e0924fc982..879642d8f9 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -243,8 +243,37 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a // maybe contextgl wants to be in charge of creating the window #if defined(OPENGL_ENABLED) if (getenv("DRI_PRIME") == NULL) { - print_verbose("Detecting GPUs, set DRI_PRIME in the environment to override GPU detection logic."); - int use_prime = detect_prime(); + int use_prime = -1; + + if (getenv("PRIMUS_DISPLAY") || + getenv("PRIMUS_libGLd") || + getenv("PRIMUS_libGLa") || + getenv("PRIMUS_libGL") || + getenv("PRIMUS_LOAD_GLOBAL") || + getenv("BUMBLEBEE_SOCKET")) { + + print_verbose("Optirun/primusrun detected. Skipping GPU detection"); + use_prime = 0; + } + + if (getenv("LD_LIBRARY_PATH")) { + String ld_library_path(getenv("LD_LIBRARY_PATH")); + Vector<String> libraries = ld_library_path.split(":"); + + for (int i = 0; i < libraries.size(); ++i) { + if (FileAccess::exists(libraries[i] + "/libGL.so.1") || + FileAccess::exists(libraries[i] + "/libGL.so")) { + + print_verbose("Custom libGL override detected. Skipping GPU detection"); + use_prime = 0; + } + } + } + + if (use_prime == -1) { + print_verbose("Detecting GPUs, set DRI_PRIME in the environment to override GPU detection logic."); + use_prime = detect_prime(); + } if (use_prime) { print_line("Found discrete GPU, setting DRI_PRIME=1 to use it."); @@ -1714,7 +1743,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) { // is correct, but the xorg developers are // not very helpful today. - ::Time tresh = ABS(peek_event.xkey.time - xkeyevent->time); + ::Time tresh = ABSDIFF(peek_event.xkey.time, xkeyevent->time); if (peek_event.type == KeyPress && tresh < 5) { KeySym rk; XLookupString((XKeyEvent *)&peek_event, str, 256, &rk, NULL); @@ -3004,7 +3033,9 @@ bool OS_X11::is_vsync_enabled() const { */ void OS_X11::set_context(int p_context) { + char *config_name = NULL; XClassHint *classHint = XAllocClassHint(); + if (classHint) { char *wm_class = (char *)"Godot"; @@ -3015,13 +3046,20 @@ void OS_X11::set_context(int p_context) { if (p_context == CONTEXT_ENGINE) { classHint->res_name = (char *)"Godot_Engine"; - wm_class = (char *)((String)GLOBAL_GET("application/config/name")).utf8().ptrw(); + char *config_name_tmp = (char *)((String)GLOBAL_GET("application/config/name")).utf8().ptrw(); + if (config_name_tmp) + config_name = strdup(config_name_tmp); + else + config_name = strdup("Godot Engine"); + + wm_class = config_name; } classHint->res_class = wm_class; XSetClassHint(x11_display, x11_window, classHint); XFree(classHint); + free(config_name); } } diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index cf1619bae2..6d1a66af84 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -35,7 +35,7 @@ #include "core/os/input.h" #include "crash_handler_x11.h" #include "drivers/alsa/audio_driver_alsa.h" -#include "drivers/alsamidi/alsa_midi.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" diff --git a/platform/x11/power_x11.h b/platform/x11/power_x11.h index 56fbd602f4..469e3910f4 100644 --- a/platform/x11/power_x11.h +++ b/platform/x11/power_x11.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef X11_POWER_H_ -#define X11_POWER_H_ +#ifndef POWER_X11_H +#define POWER_X11_H #include "core/os/dir_access.h" #include "core/os/file_access.h" @@ -63,4 +63,4 @@ public: int get_power_percent_left(); }; -#endif /* X11_POWER_H_ */ +#endif // POWER_X11_H |