diff options
Diffstat (limited to 'platform/x11')
-rw-r--r-- | platform/x11/context_gl_x11.h | 2 | ||||
-rw-r--r-- | platform/x11/crash_handler_x11.cpp | 4 | ||||
-rw-r--r-- | platform/x11/joypad_linux.h | 4 | ||||
-rw-r--r-- | platform/x11/key_mapping_x11.h | 2 | ||||
-rw-r--r-- | platform/x11/os_x11.cpp | 46 | ||||
-rw-r--r-- | platform/x11/os_x11.h | 3 | ||||
-rw-r--r-- | platform/x11/power_x11.h | 6 |
7 files changed, 55 insertions, 12 deletions
diff --git a/platform/x11/context_gl_x11.h b/platform/x11/context_gl_x11.h index b8f3eb95d4..ab0379a2fe 100644 --- a/platform/x11/context_gl_x11.h +++ b/platform/x11/context_gl_x11.h @@ -38,8 +38,8 @@ #if defined(OPENGL_ENABLED) +#include "core/os/os.h" #include "drivers/gl_context/context_gl.h" -#include "os/os.h" #include <X11/Xlib.h> #include <X11/extensions/Xrender.h> diff --git a/platform/x11/crash_handler_x11.cpp b/platform/x11/crash_handler_x11.cpp index 960105271b..ab9275e49f 100644 --- a/platform/x11/crash_handler_x11.cpp +++ b/platform/x11/crash_handler_x11.cpp @@ -33,9 +33,9 @@ #endif #include "crash_handler_x11.h" +#include "core/os/os.h" +#include "core/project_settings.h" #include "main/main.h" -#include "os/os.h" -#include "project_settings.h" #ifdef CRASH_HANDLER_ENABLED #include <cxxabi.h> diff --git a/platform/x11/joypad_linux.h b/platform/x11/joypad_linux.h index 1187acac23..34b240abf1 100644 --- a/platform/x11/joypad_linux.h +++ b/platform/x11/joypad_linux.h @@ -33,9 +33,9 @@ #define JOYPAD_LINUX_H #ifdef JOYDEV_ENABLED +#include "core/os/mutex.h" +#include "core/os/thread.h" #include "main/input_default.h" -#include "os/mutex.h" -#include "os/thread.h" struct input_absinfo; diff --git a/platform/x11/key_mapping_x11.h b/platform/x11/key_mapping_x11.h index 62dfcf3a4d..6f05941c19 100644 --- a/platform/x11/key_mapping_x11.h +++ b/platform/x11/key_mapping_x11.h @@ -41,7 +41,7 @@ #define XK_XKB_KEYS #include <X11/keysymdef.h> -#include "os/keyboard.h" +#include "core/os/keyboard.h" class KeyMappingX11 { KeyMappingX11(){}; diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 56eddb5ca4..b80a20ce40 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -29,12 +29,12 @@ /*************************************************************************/ #include "os_x11.h" +#include "core/os/dir_access.h" +#include "core/print_string.h" #include "drivers/gles2/rasterizer_gles2.h" #include "drivers/gles3/rasterizer_gles3.h" #include "errno.h" #include "key_mapping_x11.h" -#include "os/dir_access.h" -#include "print_string.h" #include "servers/visual/visual_server_raster.h" #include "servers/visual/visual_server_wrap_mt.h" @@ -581,6 +581,8 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a } } + update_real_mouse_position(); + return OK; } @@ -1053,6 +1055,7 @@ Point2 OS_X11::get_window_position() const { void OS_X11::set_window_position(const Point2 &p_position) { XMoveWindow(x11_display, x11_window, p_position.x, p_position.y); + update_real_mouse_position(); } Size2 OS_X11::get_window_size() const { @@ -1082,6 +1085,16 @@ Size2 OS_X11::get_real_window_size() const { } void OS_X11::set_window_size(const Size2 p_size) { + + if (current_videomode.width == p_size.width && current_videomode.height == p_size.height) + return; + + XWindowAttributes xwa; + XSync(x11_display, False); + XGetWindowAttributes(x11_display, x11_window, &xwa); + int old_w = xwa.width; + int old_h = xwa.height; + // If window resizable is disabled we need to update the attributes first if (is_window_resizable() == false) { XSizeHints *xsh; @@ -1101,6 +1114,16 @@ void OS_X11::set_window_size(const Size2 p_size) { // Update our videomode width and height current_videomode.width = p_size.x; current_videomode.height = p_size.y; + + for (int timeout = 0; timeout < 50; ++timeout) { + XSync(x11_display, False); + XGetWindowAttributes(x11_display, x11_window, &xwa); + + if (old_w != xwa.width || old_h != xwa.height) + break; + + usleep(10000); + } } void OS_X11::set_window_fullscreen(bool p_enabled) { @@ -2979,6 +3002,25 @@ OS::LatinKeyboardVariant OS_X11::get_latin_keyboard_variant() const { return LATIN_KEYBOARD_QWERTY; } +void OS_X11::update_real_mouse_position() { + Window root_return, child_return; + int root_x, root_y, win_x, win_y; + unsigned int mask_return; + + Bool xquerypointer_result = XQueryPointer(x11_display, x11_window, &root_return, &child_return, &root_x, &root_y, + &win_x, &win_y, &mask_return); + + if (xquerypointer_result) { + if (win_x > 0 && win_y > 0 && win_x <= current_videomode.width && win_y <= current_videomode.height) { + + last_mouse_pos.x = win_x; + last_mouse_pos.y = win_y; + last_mouse_pos_valid = true; + input->set_mouse_position(last_mouse_pos); + } + } +} + OS_X11::OS_X11() { #ifdef PULSEAUDIO_ENABLED diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 44455a2d8d..47ff257455 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -32,9 +32,9 @@ #define OS_X11_H #include "context_gl_x11.h" +#include "core/os/input.h" #include "crash_handler_x11.h" #include "drivers/unix/os_unix.h" -#include "os/input.h" #include "servers/visual_server.h" //#include "servers/visual/visual_server_wrap_mt.h" #include "drivers/alsa/audio_driver_alsa.h" @@ -313,6 +313,7 @@ public: virtual LatinKeyboardVariant get_latin_keyboard_variant() const; + void update_real_mouse_position(); OS_X11(); }; diff --git a/platform/x11/power_x11.h b/platform/x11/power_x11.h index 4077887998..d0805b6f8a 100644 --- a/platform/x11/power_x11.h +++ b/platform/x11/power_x11.h @@ -31,9 +31,9 @@ #ifndef X11_POWER_H_ #define X11_POWER_H_ -#include "os/dir_access.h" -#include "os/file_access.h" -#include "os/os.h" +#include "core/os/dir_access.h" +#include "core/os/file_access.h" +#include "core/os/os.h" class PowerX11 { |