From 803a472c5f1d1943b534a7899b2bf162eacd0f6c Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Thu, 19 Dec 2019 18:25:09 +0100 Subject: Fix support of screen scaling under macOS --- src/Fl_cocoa.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 9a66a3479..03691956a 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -1879,7 +1879,7 @@ int Fl_Cocoa_Screen_Driver::get_mouse(int &x, int &y) NSPoint pt = [NSEvent mouseLocation]; x = int(pt.x); y = int(main_screen_height - pt.y); - return screen_num(x, y); + return screen_num(x/scale(0), y/scale(0)); } -- cgit v1.2.3 From f68dee3288202259fb2b417a590c462e3f4ff658 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 20 Dec 2019 10:59:19 +0100 Subject: Fix problems after closing full-screen window macOS strangely sends NSViewFrameDidChangeNotification and a drawRect: message to its content view after having sent to the window the close message. That is apparently new in 10.15.2 --- src/Fl_cocoa.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 03691956a..b0a13d714 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -1250,7 +1250,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil; if (![[notif object] isKindOfClass:[FLView class]]) return; FLView *view = (FLView*)[notif object]; FLWindow *nsw = (FLWindow*)[view window]; - if (!nsw) return; + if (!nsw || ![nsw getFl_Window]) return; fl_lock_function(); Fl_Window *window = [nsw getFl_Window]; int X, Y; @@ -2234,9 +2234,10 @@ static FLTextInputContext* fltextinputcontext_instance = nil; */ - (void)drawRect:(NSRect)rect { - fl_lock_function(); FLWindow *cw = (FLWindow*)[self window]; Fl_Window *window = [cw getFl_Window]; + if (!window) return; // may happen after closing full-screen window + fl_lock_function(); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 CGContextRef gc = views_use_CA ? [[NSGraphicsContext currentContext] CGContext] : NULL; #endif -- cgit v1.2.3