summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2017-07-26 16:16:10 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2017-07-27 10:05:33 +0300
commit3220fee6b296991cecc46a2c44288ca1cb7b507c (patch)
tree6785a8901ae10d10603d022c4a9f28776cd7f7b5
parentf98a20337799d0dffe1f4f4d106ea034f855a29f (diff)
Fix is_window_fullscreen() and set_window_fullscreen() behaviour after window has entered/left full-screen mode via green zoom button.
Fix get/set_current_screen & set_window_maximized.
-rw-r--r--platform/osx/os_osx.h1
-rw-r--r--platform/osx/os_osx.mm30
2 files changed, 23 insertions, 8 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 44f4334786..fc80088846 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -105,7 +105,6 @@ public:
Vector<int> screen_dpi;
Size2 window_size;
- int current_screen;
Rect2 restore_rect;
power_osx *power_manager;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 646eae943e..7538d6a45c 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -152,6 +152,16 @@ static bool mouse_down_control = false;
return NO;
}
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+- (void)windowDidEnterFullScreen:(NSNotification *)notification {
+ OS_OSX::singleton->zoomed = true;
+}
+
+- (void)windowDidExitFullScreen:(NSNotification *)notification {
+ OS_OSX::singleton->zoomed = false;
+}
+#endif // MAC_OS_X_VERSION_MAX_ALLOWED
+
- (void)windowDidResize:(NSNotification *)notification {
[OS_OSX::singleton->context update];
@@ -1233,13 +1243,21 @@ int OS_OSX::get_screen_count() const {
};
int OS_OSX::get_current_screen() const {
-
- return current_screen;
+ Vector2 wpos = get_window_position();
+
+ int count = get_screen_count();
+ for (int i = 0; i < count; i++) {
+ Point2 pos = get_screen_position(i);
+ Size2 size = get_screen_size(i);
+ if ((wpos.x >= pos.x && wpos.x < pos.x + size.width) && (wpos.y >= pos.y && wpos.y < pos.y + size.height))
+ return i;
+ }
+ return 0;
};
void OS_OSX::set_current_screen(int p_screen) {
-
- current_screen = p_screen;
+ Vector2 wpos = get_window_position() - get_screen_position(get_current_screen());
+ set_window_position(wpos + get_screen_position(p_screen));
};
Point2 OS_OSX::get_screen_position(int p_screen) const {
@@ -1383,7 +1401,7 @@ void OS_OSX::set_window_maximized(bool p_enabled) {
if (p_enabled) {
restore_rect = Rect2(get_window_position(), get_window_size());
- [window_object setFrame:[[[NSScreen screens] objectAtIndex:current_screen] visibleFrame] display:YES];
+ [window_object setFrame:[[[NSScreen screens] objectAtIndex:get_current_screen()] visibleFrame] display:YES];
} else {
set_window_size(restore_rect.size);
set_window_position(restore_rect.position);
@@ -1716,8 +1734,6 @@ OS_OSX::OS_OSX() {
cursor_shape = CURSOR_ARROW;
- current_screen = 0;
-
maximized = false;
minimized = false;
window_size = Vector2(1024, 600);