diff options
| author | Manolo Gouy <Manolo> | 2014-12-05 17:18:19 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2014-12-05 17:18:19 +0000 |
| commit | f1c7d674d2d22cd14efb5e9a131c42bc5180cbcc (patch) | |
| tree | a3a0bc6622699a7be65c99c7b9a4a52d0ed60d63 /src | |
| parent | 596fd2784acfca5c6c9100b49853583d0b7057d6 (diff) | |
Improved processing of retina displays: replace [NSWindow backingScaleFactor] that is not recommended.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10477 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_cocoa.mm | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index af785d357..580310f1b 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -2545,6 +2545,22 @@ static FLTextInputContext* fltextinputcontext_instance = nil; } @end +// returns the window size in pixels. +// On retina display, values are double of w() x h() +CGSize Fl_X::window_pixel_size(Fl_Window* win) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + if (fl_mac_os_version >= 100700 && win->shown()) { + NSSize s = [[win->i->xid contentView] convertSizeToBacking:NSMakeSize(win->w(), win->h())]; +#if __LP64__ + return s; +#else + return CGSizeMake(s.width, s.height); +#endif + } +#endif + return CGSizeMake(win->w(), win->h()); +} void Fl_Window::fullscreen_x() { _set_fullscreen(); @@ -2985,9 +3001,7 @@ void Fl_Window::make_current() if (make_current_counts) make_current_counts++; Fl_X::q_release_context(); fl_window = i->xid; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - Fl_X::set_high_resolution(fl_mac_os_version >= 100700 && [fl_window backingScaleFactor] > 1.0); -#endif + Fl_X::set_high_resolution( Fl_X::window_pixel_size(this).width > w() + 0.5 ); current_ = this; NSGraphicsContext *nsgc = through_drawRect ? [NSGraphicsContext currentContext] : |
