diff options
| author | Emmanuel Leblond | 2018-01-03 18:26:44 +0100 |
|---|---|---|
| committer | Rémi Verschelde | 2018-01-04 15:15:55 +0100 |
| commit | e315c94900be47e61152a2958011e14b7e635a3e (patch) | |
| tree | 9fbe974664cd253d3fdd0792db0b7b5f91cfcde6 /platform/x11 | |
| parent | 99eb394a5f5f164a562e315980cb730a704a0a1c (diff) | |
| download | godot-e315c94900be47e61152a2958011e14b7e635a3e.tar.gz godot-e315c94900be47e61152a2958011e14b7e635a3e.tar.zst godot-e315c94900be47e61152a2958011e14b7e635a3e.zip | |
Diffstat (limited to 'platform/x11')
| -rw-r--r-- | platform/x11/os_x11.cpp | 27 | ||||
| -rw-r--r-- | platform/x11/os_x11.h | 2 |
2 files changed, 16 insertions, 13 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index e9920b18a..5ca3ad45b 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -100,7 +100,7 @@ void OS_X11::initialize_core() { OS_Unix::initialize_core(); } -void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { +Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { long im_event_mask = 0; last_button_state = 0; @@ -123,21 +123,24 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au /** XLIB INITIALIZATION **/ x11_display = XOpenDisplay(NULL); + if (!x11_display) { + ERR_PRINT("X11 Display is not available"); + return ERR_UNAVAILABLE; + } + char *modifiers = NULL; Bool xkb_dar = False; - if (x11_display) { - XAutoRepeatOn(x11_display); - xkb_dar = XkbSetDetectableAutoRepeat(x11_display, True, NULL); + XAutoRepeatOn(x11_display); + xkb_dar = XkbSetDetectableAutoRepeat(x11_display, True, NULL); - // Try to support IME if detectable auto-repeat is supported - if (xkb_dar == True) { + // Try to support IME if detectable auto-repeat is supported + if (xkb_dar == True) { #ifdef X_HAVE_UTF8_STRING - // Xutf8LookupString will be used later instead of XmbLookupString before - // the multibyte sequences can be converted to unicode string. - modifiers = XSetLocaleModifiers(""); + // Xutf8LookupString will be used later instead of XmbLookupString before + // the multibyte sequences can be converted to unicode string. + modifiers = XSetLocaleModifiers(""); #endif - } } if (modifiers == NULL) { @@ -331,8 +334,8 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au AudioDriverManager::initialize(p_audio_driver); - ERR_FAIL_COND(!visual_server); - ERR_FAIL_COND(x11_window == 0); + ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE); + ERR_FAIL_COND_V(x11_window == 0, ERR_UNAVAILABLE); XSetWindowAttributes new_attr; diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 04243a9b3..2bf2f3cf2 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -193,7 +193,7 @@ protected: virtual const char *get_audio_driver_name(int p_driver) const; virtual void initialize_core(); - virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); + virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); virtual void finalize(); virtual void set_main_loop(MainLoop *p_main_loop); |
