summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/osx/os_osx.h2
-rw-r--r--platform/osx/os_osx.mm18
-rwxr-xr-xplatform/windows/os_windows.cpp8
-rw-r--r--platform/windows/os_windows.h2
-rw-r--r--platform/x11/os_x11.cpp8
-rw-r--r--platform/x11/os_x11.h2
6 files changed, 35 insertions, 5 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 53b44af867..44c5412a39 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -121,6 +121,7 @@ public:
bool maximized;
bool zoomed;
bool resizable;
+ bool window_focused;
Size2 window_size;
Rect2 restore_rect;
@@ -274,6 +275,7 @@ public:
virtual bool is_window_maximized() const;
virtual void set_window_always_on_top(bool p_enabled);
virtual bool is_window_always_on_top() const;
+ virtual bool is_window_focused() const;
virtual void request_attention();
virtual String get_joy_guid(int p_device) const;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 7225fbf43d..95c103bd28 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -393,9 +393,6 @@ static Vector2 get_mouse_pos(NSPoint locationInWindow, CGFloat backingScaleFacto
}
- (void)windowDidBecomeKey:(NSNotification *)notification {
- //_GodotInputWindowFocus(window, GL_TRUE);
- //_GodotPlatformSetCursorMode(window, window->cursorMode);
-
if (OS_OSX::singleton->get_main_loop()) {
get_mouse_pos(
[OS_OSX::singleton->window_object mouseLocationOutsideOfEventStream],
@@ -404,25 +401,31 @@ static Vector2 get_mouse_pos(NSPoint locationInWindow, CGFloat backingScaleFacto
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
}
+
+ OS_OSX::singleton->window_focused = true;
}
- (void)windowDidResignKey:(NSNotification *)notification {
- //_GodotInputWindowFocus(window, GL_FALSE);
- //_GodotPlatformSetCursorMode(window, Godot_CURSOR_NORMAL);
if (OS_OSX::singleton->get_main_loop())
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
+
+ OS_OSX::singleton->window_focused = false;
}
- (void)windowDidMiniaturize:(NSNotification *)notification {
OS_OSX::singleton->wm_minimized(true);
if (OS_OSX::singleton->get_main_loop())
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
+
+ OS_OSX::singleton->window_focused = false;
};
- (void)windowDidDeminiaturize:(NSNotification *)notification {
OS_OSX::singleton->wm_minimized(false);
if (OS_OSX::singleton->get_main_loop())
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
+
+ OS_OSX::singleton->window_focused = true;
};
@end
@@ -2607,6 +2610,10 @@ bool OS_OSX::is_window_always_on_top() const {
return [window_object level] == NSFloatingWindowLevel;
}
+bool OS_OSX::is_window_focused() const {
+ return window_focused;
+}
+
void OS_OSX::request_attention() {
[NSApp requestUserAttention:NSCriticalRequest];
@@ -3059,6 +3066,7 @@ OS_OSX::OS_OSX() {
window_size = Vector2(1024, 600);
zoomed = false;
resizable = false;
+ window_focused = true;
Vector<Logger *> loggers;
loggers.push_back(memnew(OSXTerminalLogger));
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index cee848f270..3868d0bc63 100755
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -352,12 +352,14 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) {
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
+ window_focused = true;
alt_mem = false;
control_mem = false;
shift_mem = false;
} else { // WM_INACTIVE
input->release_pressed_events();
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
+ window_focused = false;
alt_mem = false;
};
@@ -2095,6 +2097,11 @@ bool OS_Windows::is_window_always_on_top() const {
return video_mode.always_on_top;
}
+bool OS_Windows::is_window_focused() const {
+
+ return window_focused;
+}
+
void OS_Windows::set_console_visible(bool p_enabled) {
if (console_visible == p_enabled)
return;
@@ -3372,6 +3379,7 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) {
meta_mem = false;
minimized = false;
was_maximized = false;
+ window_focused = true;
console_visible = IsWindowVisible(GetConsoleWindow());
//Note: Functions for pen input, available on Windows 8+
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 20b61e3dbe..65d08f5d36 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -274,6 +274,7 @@ protected:
bool maximized;
bool minimized;
bool borderless;
+ bool window_focused;
bool console_visible;
bool was_maximized;
@@ -322,6 +323,7 @@ public:
virtual bool is_window_maximized() const;
virtual void set_window_always_on_top(bool p_enabled);
virtual bool is_window_always_on_top() const;
+ virtual bool is_window_focused() const;
virtual void set_console_visible(bool p_enabled);
virtual bool is_console_visible() const;
virtual void request_attention();
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index b9cfd6f386..2f0d49e6dd 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -1684,6 +1684,10 @@ bool OS_X11::is_window_always_on_top() const {
return current_videomode.always_on_top;
}
+bool OS_X11::is_window_focused() const {
+ return window_focused;
+}
+
void OS_X11::set_borderless_window(bool p_borderless) {
if (get_borderless_window() == p_borderless)
@@ -2276,6 +2280,8 @@ void OS_X11::process_xevents() {
minimized = false;
window_has_focus = true;
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
+ window_focused = true;
+
if (mouse_mode_grab) {
// Show and update the cursor if confined and the window regained focus.
if (mouse_mode == MOUSE_MODE_CONFINED)
@@ -2303,6 +2309,7 @@ void OS_X11::process_xevents() {
window_has_focus = false;
input->release_pressed_events();
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
+ window_focused = false;
if (mouse_mode_grab) {
//dear X11, I try, I really try, but you never work, you do whathever you want.
@@ -3497,6 +3504,7 @@ OS_X11::OS_X11() {
xi.last_relative_time = 0;
layered_window = false;
minimized = false;
+ window_focused = true;
xim_style = 0L;
mouse_mode = MOUSE_MODE_VISIBLE;
}
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 35c55aab54..01e5aac3df 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -195,6 +195,7 @@ class OS_X11 : public OS_Unix {
int video_driver_index;
bool maximized;
+ bool window_focused;
//void set_wm_border(bool p_enabled);
void set_wm_fullscreen(bool p_enabled);
void set_wm_above(bool p_enabled);
@@ -284,6 +285,7 @@ public:
virtual bool is_window_maximized() const;
virtual void set_window_always_on_top(bool p_enabled);
virtual bool is_window_always_on_top() const;
+ virtual bool is_window_focused() const;
virtual void request_attention();
virtual void set_borderless_window(bool p_borderless);