diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/osx/os_osx.mm | 2 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 50 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 2 | ||||
-rw-r--r-- | platform/x11/detect.py | 12 |
4 files changed, 40 insertions, 26 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 985811e166..81dc861f3f 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -326,7 +326,6 @@ static Vector2 get_mouse_pos(NSPoint locationInWindow, CGFloat backingScaleFacto - (void)windowDidBecomeKey:(NSNotification *)notification { //_GodotInputWindowFocus(window, GL_TRUE); //_GodotPlatformSetCursorMode(window, window->cursorMode); - [OS_OSX::singleton->context update]; if (OS_OSX::singleton->get_main_loop()) { get_mouse_pos( @@ -1238,6 +1237,7 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a ERR_FAIL_COND_V(window_object == nil, ERR_UNAVAILABLE); window_view = [[GodotContentView alloc] init]; + [window_view setWantsLayer:TRUE]; float displayScale = 1.0; if (is_hidpi_allowed()) { diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 5e9f9bc59b..bdf459fd83 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -300,19 +300,17 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { case WM_SETFOCUS: { window_has_focus = true; - // Re-capture cursor if we're in one of the capture modes - if (mouse_mode == MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED) { - SetCapture(hWnd); - } + + // Restore mouse mode + _set_mouse_mode_impl(mouse_mode); + break; } case WM_KILLFOCUS: { window_has_focus = false; - // Release capture if we're in one of the capture modes - if (mouse_mode == MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED) { - ReleaseCapture(); - } + // Release capture unconditionally because it can be set due to dragging, in addition to captured mode + ReleaseCapture(); // Release every touch to avoid sticky points for (Map<int, Vector2>::Element *E = touch_state.front(); E; E = E->next()) { @@ -334,15 +332,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) alt_mem = false; control_mem = false; shift_mem = false; - if (mouse_mode == MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED) { - RECT clipRect; - GetClientRect(hWnd, &clipRect); - ClientToScreen(hWnd, (POINT *)&clipRect.left); - ClientToScreen(hWnd, (POINT *)&clipRect.right); - ClipCursor(&clipRect); - SetCapture(hWnd); - } - } else { + } else { // WM_INACTIVE main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT); alt_mem = false; }; @@ -702,12 +692,14 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (uMsg != WM_MOUSEWHEEL && uMsg != WM_MOUSEHWHEEL) { if (mb->is_pressed()) { - if (++pressrc > 0) + if (++pressrc > 0 && mouse_mode != MOUSE_MODE_CAPTURED) SetCapture(hWnd); } else { if (--pressrc <= 0) { - ReleaseCapture(); + if (mouse_mode != MOUSE_MODE_CAPTURED) { + ReleaseCapture(); + } pressrc = 0; } } @@ -1516,18 +1508,27 @@ void OS_Windows::set_mouse_mode(MouseMode p_mode) { if (mouse_mode == p_mode) return; + + _set_mouse_mode_impl(p_mode); + mouse_mode = p_mode; - if (mouse_mode == MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED) { +} + +void OS_Windows::_set_mouse_mode_impl(MouseMode p_mode) { + + if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_CONFINED) { RECT clipRect; GetClientRect(hWnd, &clipRect); ClientToScreen(hWnd, (POINT *)&clipRect.left); ClientToScreen(hWnd, (POINT *)&clipRect.right); ClipCursor(&clipRect); - center = Point2i(video_mode.width / 2, video_mode.height / 2); - POINT pos = { (int)center.x, (int)center.y }; - ClientToScreen(hWnd, &pos); - if (mouse_mode == MOUSE_MODE_CAPTURED) + if (p_mode == MOUSE_MODE_CAPTURED) { + center = Point2i(video_mode.width / 2, video_mode.height / 2); + POINT pos = { (int)center.x, (int)center.y }; + ClientToScreen(hWnd, &pos); SetCursorPos(pos.x, pos.y); + SetCapture(hWnd); + } } else { ReleaseCapture(); ClipCursor(NULL); @@ -1541,7 +1542,6 @@ void OS_Windows::set_mouse_mode(MouseMode p_mode) { set_cursor_shape(c); } } - OS_Windows::MouseMode OS_Windows::get_mouse_mode() const { return mouse_mode; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 01e1c51ca5..6aadd6994c 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -157,6 +157,8 @@ class OS_Windows : public OS { void _update_window_style(bool repaint = true); + void _set_mouse_mode_impl(MouseMode p_mode); + // functions used by main to initialize/deinitialize the OS protected: virtual int get_current_video_driver() const; diff --git a/platform/x11/detect.py b/platform/x11/detect.py index ee59e9b5a1..dc5c22b4b3 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -149,6 +149,18 @@ def configure(env): env.Append(CCFLAGS=['-pipe']) env.Append(LINKFLAGS=['-pipe']) + # Check for gcc version > 4 before adding -no-pie + import re + import subprocess + proc = subprocess.Popen([env['CXX'], '--version'], stdout=subprocess.PIPE) + (stdout, _) = proc.communicate() + match = re.search('[0-9][0-9.]*', stdout) + if match is not None: + version = match.group().split('.') + if (version[0] > '4'): + env.Append(CCFLAGS=['-fpie']) + env.Append(LINKFLAGS=['-no-pie']) + ## Dependencies env.ParseConfig('pkg-config x11 --cflags --libs') |