src/osx/native_window.mm in reflexion-0.1.56 vs src/osx/native_window.mm in reflexion-0.1.57
- old
+ new
@@ -40,11 +40,22 @@
painter->canvas(window->frame().dup().move_to(0, 0), pd);
window->redraw();
}
}
+static void
+move_to_main_screen_origin (NativeWindow* window)
+{
+ NSRect frame = window.frame;
+ NSRect screen = NSScreen.mainScreen.visibleFrame;
+ frame.origin.x = screen.origin.x;
+ frame.origin.y = screen.origin.y + screen.size.height;
+ [window setFrame: frame display: NO animate: NO];
+}
+
+
@implementation NativeWindow
{
Reflex::Window *pwindow, *ptr_for_rebind;
OpenGLView* view;
@@ -86,10 +97,12 @@
[super dealloc];
}
- (void) bind: (Reflex::Window*) window
{
+ move_to_main_screen_origin(self);
+
if (!window)
Reflex::argument_error(__FILE__, __LINE__);
Reflex::WindowData& data = Window_get_data(window);
if (data.native)
@@ -219,10 +232,15 @@
Reflex::DrawEvent e(dt, fps);
Window_call_draw_event(win, &e);
}
+ - (BOOL) hasFullScreenFlag
+ {
+ return self.styleMask & NSWindowStyleMaskFullScreen;
+ }
+
- (BOOL) windowShouldClose: (id) sender
{
Reflex::Window* win = self.window;
if (!win) return YES;
@@ -295,9 +313,44 @@
View_set_frame(win->root(), b);
win->on_resize(&e);
}
}
+ }
+
+ - (void) windowWillEnterFullScreen: (NSNotification*) notification
+ {
+ [self updateFullScreenFlag];
+ }
+
+ - (void) windowDidEnterFullScreen: (NSNotification*) notification
+ {
+ [self updateFullScreenFlag];
+ }
+
+ - (void) windowWillExitFullScreen: (NSNotification*) notification
+ {
+ [self updateFullScreenFlag];
+ }
+
+ - (void) windowDidExitFullScreen: (NSNotification*) notification
+ {
+ [self updateFullScreenFlag];
+ }
+
+ - (void) updateFullScreenFlag
+ {
+ Reflex::Window* win = self.window;
+ if (!win) return;
+
+ bool fullscreen = self.hasFullScreenFlag;
+ if (fullscreen == win->has_flag(Reflex::Window::FLAG_FULLSCREEN))
+ return;
+
+ if (fullscreen)
+ win->add_flag(Reflex::Window::FLAG_FULLSCREEN);
+ else
+ win->remove_flag(Reflex::Window::FLAG_FULLSCREEN);
}
- (void) windowDidBecomeKey: (NSNotification*) notification
{
Window_call_activate_event(self.window);