From e230a34cfdab9515fa3041a4947cc5b22afdf7e6 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Thu, 11 Dec 2014 22:25:31 +0000 Subject: [PATCH] It is necessary to compute Fl_X::mapped_to_retina after the window is mapped because the windowDidMove notification is not always sent. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10484 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_cocoa.mm | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index dcbee5d27..eca0cbf70 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -1134,6 +1134,21 @@ static void orderfront_subwindows(FLWindow *xid) } } +//determines whether the window is mapped to a retina display +static void compute_mapped_to_retina(Fl_Window *window) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + if (fl_mac_os_version >= 100700) { // determine whether window is now mapped to a retina display + bool *mapped = &(Fl_X::i(window)->mapped_to_retina); + bool previous = *mapped; + NSSize s = [[fl_xid(window) contentView] convertSizeToBacking:NSMakeSize(10, 10)]; + *mapped = (int(s.width + 0.5) > 10); + // window needs redrawn when moving from low res to retina + if ((!previous) && *mapped) window->redraw(); + } +#endif +} + @interface FLWindowDelegateBefore10_6 : FLWindowDelegate - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)client; @end @@ -1191,16 +1206,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil; update_e_xy_and_e_xy_root(nsw); resize_from_system = NULL; window->position((int)pt2.x, (int)(main_screen_height - pt2.y)); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - if (fl_mac_os_version >= 100700) { // determine whether window is now mapped to a retina display - bool *mapped = &(Fl_X::i(window)->mapped_to_retina); - bool previous = *mapped; - NSSize s = [[nsw contentView] convertSizeToBacking:NSMakeSize(10, 10)]; - *mapped = (int(s.width + 0.5) > 10); - // window needs redrawn when moving from low res to retina - if ((!previous) && *mapped) window->redraw(); - } -#endif + compute_mapped_to_retina(window); position_subwindows(window, YES); } fl_unlock_function(); @@ -2811,6 +2817,7 @@ void Fl_X::make(Fl_Window* w) crect = [cw frame]; w->x(int(crect.origin.x)); w->y(int(main_screen_height - (crect.origin.y + w->h()))); + compute_mapped_to_retina(w); } int old_event = Fl::e_number;