summaryrefslogtreecommitdiff
path: root/platform/osx/os_osx.mm
diff options
context:
space:
mode:
authorAnton Yabchinskiy <arn@bestmx.ru>2015-04-04 09:31:21 +0300
committerAnton Yabchinskiy <arn@bestmx.ru>2015-04-04 09:31:21 +0300
commit16746f157f83d666079ba3266acec13d35b84c3f (patch)
tree8c872d18ccdef90a15e72622cd0139e0e64801a6 /platform/osx/os_osx.mm
parent43713810deaadfec6a1656767cf5520073e58a06 (diff)
parent5d99e15e43d5a446b35d48e8a3b08a478f1998a9 (diff)
Merge branch 'master' of github.com:okamstudio/godot
Diffstat (limited to 'platform/osx/os_osx.mm')
-rw-r--r--platform/osx/os_osx.mm158
1 files changed, 144 insertions, 14 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 1c0d1f9991..a20263f9b2 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -227,19 +227,6 @@ static int button_mask=0;
// centerCursor(window);
}
-- (void)windowDidMiniaturize:(NSNotification *)notification
-{
- // _GodotInputWindowIconify(window, GL_TRUE);
-}
-
-- (void)windowDidDeminiaturize:(NSNotification *)notification
-{
- //if (window->monitor)
-// enterFullscreenMode(window);
-
- // _GodotInputWindowIconify(window, GL_FALSE);
-}
-
- (void)windowDidBecomeKey:(NSNotification *)notification
{
// _GodotInputWindowFocus(window, GL_TRUE);
@@ -256,6 +243,21 @@ static int button_mask=0;
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
}
+- (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);
+};
+
+- (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);
+};
+
@end
@interface GodotContentView : NSView
@@ -903,7 +905,7 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
unsigned int attributeCount = 0;
// OS X needs non-zero color size, so set resonable values
- int colorBits = 24;
+ int colorBits = 32;
// Fail if a robustness strategy was requested
@@ -1018,7 +1020,15 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
_ensure_data_dir();
+ NSArray *screenArray = [NSScreen screens];
+ printf("nscreen count %i\n", (int)[screenArray count]);
+ for (int i=0; i<[screenArray count]; i++) {
+ NSRect nsrect = [[screenArray objectAtIndex: i] visibleFrame];
+ screens.push_back(Rect2(nsrect.origin.x, nsrect.origin.y, nsrect.size.width, nsrect.size.height));
+ printf("added screen %i\n", screens.size());
+ };
+ restore_rect = Rect2(get_window_position(), get_window_size());
}
void OS_OSX::finalize() {
@@ -1231,7 +1241,10 @@ void OS_OSX::swap_buffers() {
}
+void OS_OSX::wm_minimized(bool p_minimized) {
+ minimized = p_minimized;
+};
void OS_OSX::set_video_mode(const VideoMode& p_video_mode,int p_screen) {
@@ -1245,6 +1258,119 @@ void OS_OSX::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) cons
}
+
+int OS_OSX::get_screen_count() const {
+
+ return screens.size();
+};
+
+int OS_OSX::get_current_screen() const {
+
+ return current_screen;
+};
+
+void OS_OSX::set_current_screen(int p_screen) {
+
+ current_screen = p_screen;
+};
+
+Point2 OS_OSX::get_screen_position(int p_screen) {
+
+ ERR_FAIL_INDEX_V(p_screen, screens.size(), Point2());
+ return screens[p_screen].pos;
+};
+
+Size2 OS_OSX::get_screen_size(int p_screen) {
+
+ ERR_FAIL_INDEX_V(p_screen, screens.size(), Point2());
+ return screens[p_screen].size;
+};
+
+Point2 OS_OSX::get_window_position() const {
+
+ return Size2([window_object frame].origin.x, [window_object frame].origin.y);
+};
+
+
+void OS_OSX::set_window_position(const Point2& p_position) {
+
+ [window_object setFrame:NSMakeRect(p_position.x, p_position.y, [window_object frame].size.width, [window_object frame].size.height) display:YES];
+};
+
+Size2 OS_OSX::get_window_size() const {
+
+ return Size2([window_object frame].size.width, [window_object frame].size.height);
+};
+
+void OS_OSX::set_window_size(const Size2 p_size) {
+
+ NSRect frame = [window_object frame];
+ [window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, p_size.x, p_size.y) display:YES];
+};
+
+void OS_OSX::set_window_fullscreen(bool p_enabled) {
+
+ [window_object performZoom:nil];
+ zoomed = p_enabled;
+};
+
+bool OS_OSX::is_window_fullscreen() const {
+
+ if ( [window_object respondsToSelector:@selector(isZoomed)] )
+ return [window_object isZoomed];
+
+ return zoomed;
+};
+
+void OS_OSX::set_window_resizable(bool p_enabled) {
+
+ if (p_enabled)
+ [window_object setStyleMask:[window_object styleMask] | NSResizableWindowMask ];
+ else
+ [window_object setStyleMask:[window_object styleMask] & ~NSResizableWindowMask ];
+};
+
+bool OS_OSX::is_window_resizable() const {
+
+ return [window_object styleMask] & NSResizableWindowMask;
+};
+
+void OS_OSX::set_window_minimized(bool p_enabled) {
+
+ if (p_enabled)
+ [window_object performMiniaturize:nil];
+ else
+ [window_object deminiaturize:nil];
+};
+
+bool OS_OSX::is_window_minimized() const {
+
+ if ( [window_object respondsToSelector:@selector(isMiniaturized)])
+ return [window_object isMiniaturized];
+
+ return minimized;
+};
+
+
+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];
+ } else {
+ set_window_size(restore_rect.size);
+ set_window_position(restore_rect.pos);
+ };
+ maximized = p_enabled;
+};
+
+bool OS_OSX::is_window_maximized() const {
+
+ // don't know
+ return maximized;
+};
+
+
void OS_OSX::move_window_to_foreground() {
[window_object orderFrontRegardless];
@@ -1473,5 +1599,9 @@ OS_OSX::OS_OSX() {
last_id=1;
cursor_shape=CURSOR_ARROW;
+ current_screen = 0;
+ maximized = false;
+ minimized = false;
+ zoomed = false;
}