diff options
| author | Manolo Gouy <Manolo> | 2018-08-29 16:42:41 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2018-08-29 16:42:41 +0000 |
| commit | f50e9170dc2234fbc69524ead0a88214ff417d34 (patch) | |
| tree | f5dfa3db7352fcacae821e5ab808960153e43fd1 | |
| parent | d0739e8712834a81fe4eba41cc23f97652560968 (diff) | |
MacOS: slightly simplify [FLAppDelegate applicationDidChangeScreenParameters:]
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@13033 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/Fl_cocoa.mm | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index f20fb227f..2e3adab39 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -1159,7 +1159,8 @@ static FLWindowDelegate *flwindowdelegate_instance = nil; NSPoint pt2; pt2 = [nsw convertBaseToScreen:NSMakePoint(0, [[nsw contentView] frame].size.height)]; update_e_xy_and_e_xy_root(nsw); - pt2.y = main_screen_height - pt2.y; + // we don't use 'main_screen_height' here because it's wrong just after screen config changes + pt2.y = CGDisplayBounds(CGMainDisplayID()).size.height - pt2.y; float s = Fl::screen_driver()->scale(0); pt2.x = int(pt2.x / s + 0.5); pt2.y = int(pt2.y / s + 0.5); @@ -1389,18 +1390,8 @@ static FLWindowDelegate *flwindowdelegate_instance = nil; - (void)applicationDidChangeScreenParameters:(NSNotification *)unused { // react to changes in screen numbers and positions fl_lock_function(); - main_screen_height = [[[NSScreen screens] objectAtIndex:0] frame].size.height; + main_screen_height = CGDisplayBounds(CGMainDisplayID()).size.height; Fl::call_screen_init(); - // FLTK windows have already been notified they were moved, - // but they had the old main_screen_height, so they must be notified again. - NSArray *windows = [NSApp windows]; - int count = [windows count]; - for (int i = 0; i < count; i++) { - NSWindow *win = [windows objectAtIndex:i]; - if ([win isKindOfClass:[FLWindow class]] && ![win parentWindow] && [win isVisible]) { - [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidMoveNotification object:win]; - } - } Fl::handle(FL_SCREEN_CONFIGURATION_CHANGED, NULL); fl_unlock_function(); } @@ -1660,7 +1651,7 @@ void Fl_Cocoa_Screen_Driver::open_display_platform() { foreground_and_activate_if_needed(); if (![NSApp servicesMenu]) createAppleMenu(); - main_screen_height = [[[NSScreen screens] objectAtIndex:0] frame].size.height; + main_screen_height = CGDisplayBounds(CGMainDisplayID()).size.height; [[NSNotificationCenter defaultCenter] addObserver:[FLWindowDelegate singleInstance] selector:@selector(anyWindowWillClose:) name:NSWindowWillCloseNotification |
