diff options
Diffstat (limited to 'platform/x11/os_x11.cpp')
-rw-r--r-- | platform/x11/os_x11.cpp | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index ade3a0a0c5..2d33d25773 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -116,24 +116,22 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au /** XLIB INITIALIZATION **/ x11_display = XOpenDisplay(NULL); + char *modifiers = NULL; Bool xkb_dar = False; if (x11_display) { XAutoRepeatOn(x11_display); xkb_dar = XkbSetDetectableAutoRepeat(x11_display, True, NULL); - } - - char *modifiers = 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) { // Xutf8LookupString will be used later instead of XmbLookupString before // the multibyte sequences can be converted to unicode string. #ifdef X_HAVE_UTF8_STRING - modifiers = XSetLocaleModifiers(""); + modifiers = XSetLocaleModifiers(""); #endif + } } if (modifiers == NULL) { @@ -141,8 +139,6 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au WARN_PRINT("IME is disabled"); } modifiers = XSetLocaleModifiers("@im=none"); - } - if (modifiers == NULL) { WARN_PRINT("Error setting locale modifiers"); } @@ -191,8 +187,7 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au ::XIMStyles *xim_styles = NULL; xim_style = 0L; - char *imvalret = NULL; - imvalret = XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL); + char *imvalret = XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL); if (imvalret != NULL || xim_styles == NULL) { fprintf(stderr, "Input method doesn't support any styles\n"); } @@ -351,20 +346,9 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au XChangeWindowAttributes(x11_display, x11_window, CWEventMask, &new_attr); - XClassHint *classHint; - /* set the titlebar name */ XStoreName(x11_display, x11_window, "Godot"); - /* set the name and class hints for the window manager to use */ - classHint = XAllocClassHint(); - if (classHint) { - classHint->res_name = (char *)"Godot_Engine"; - classHint->res_class = (char *)"Godot"; - } - XSetClassHint(x11_display, x11_window, classHint); - XFree(classHint); - wm_delete = XInternAtom(x11_display, "WM_DELETE_WINDOW", true); XSetWMProtocols(x11_display, x11_window, &wm_delete, 1); @@ -550,6 +534,8 @@ void OS_X11::finalize() { physics_2d_server->finish(); memdelete(physics_2d_server); + memdelete(power_manager); + if (xrandr_handle) dlclose(xrandr_handle); @@ -773,6 +759,10 @@ void OS_X11::set_current_screen(int p_screen) { } Point2 OS_X11::get_screen_position(int p_screen) const { + if (p_screen == -1) { + p_screen = get_current_screen(); + } + // Using Xinerama Extension int event_base, error_base; const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); @@ -794,6 +784,10 @@ Point2 OS_X11::get_screen_position(int p_screen) const { } Size2 OS_X11::get_screen_size(int p_screen) const { + if (p_screen == -1) { + p_screen = get_current_screen(); + } + // Using Xinerama Extension int event_base, error_base; const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); @@ -809,6 +803,9 @@ Size2 OS_X11::get_screen_size(int p_screen) const { } int OS_X11::get_screen_dpi(int p_screen) const { + if (p_screen == -1) { + p_screen = get_current_screen(); + } //invalid screen? ERR_FAIL_INDEX_V(p_screen, get_screen_count(), 0); @@ -1604,8 +1601,7 @@ void OS_X11::process_xevents() { Point2i pos(event.xmotion.x, event.xmotion.y); if (mouse_mode == MOUSE_MODE_CAPTURED) { -#if 1 - //Vector2 c = Point2i(current_videomode.width/2,current_videomode.height/2); + if (pos == Point2i(current_videomode.width / 2, current_videomode.height / 2)) { //this sucks, it's a hack, etc and is a little inaccurate, etc. //but nothing I can do, X11 sucks. @@ -1618,17 +1614,6 @@ void OS_X11::process_xevents() { pos = last_mouse_pos + (pos - center); center = new_center; do_mouse_warp = window_has_focus; // warp the cursor if we're focused in -#else - //Dear X11, thanks for making my life miserable - - center.x = current_videomode.width / 2; - center.y = current_videomode.height / 2; - pos = last_mouse_pos + (pos - center); - if (pos == last_mouse_pos) - break; - XWarpPointer(x11_display, None, x11_window, - 0, 0, 0, 0, (int)center.x, (int)center.y); -#endif } if (!last_mouse_pos_valid) { @@ -2151,8 +2136,7 @@ bool OS_X11::is_vsync_enabled() const { void OS_X11::set_context(int p_context) { - XClassHint *classHint = NULL; - classHint = XAllocClassHint(); + XClassHint *classHint = XAllocClassHint(); if (classHint) { if (p_context == CONTEXT_EDITOR) |