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
This commit is contained in:
Manolo Gouy
2014-12-05 17:18:19 +00:00
parent 596fd2784a
commit f1c7d674d2
2 changed files with 18 additions and 3 deletions
+1
View File
@@ -142,6 +142,7 @@ public:
static void q_begin_image(CGRect&, int x, int y, int w, int h); static void q_begin_image(CGRect&, int x, int y, int w, int h);
static void q_end_image(); static void q_end_image();
// Cocoa additions // Cocoa additions
static CGSize window_pixel_size(Fl_Window* win);
void destroy(void); void destroy(void);
void map(void); void map(void);
void unmap(void); void unmap(void);
+17 -3
View File
@@ -2545,6 +2545,22 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
} }
@end @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() { void Fl_Window::fullscreen_x() {
_set_fullscreen(); _set_fullscreen();
@@ -2985,9 +3001,7 @@ void Fl_Window::make_current()
if (make_current_counts) make_current_counts++; if (make_current_counts) make_current_counts++;
Fl_X::q_release_context(); Fl_X::q_release_context();
fl_window = i->xid; fl_window = i->xid;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 Fl_X::set_high_resolution( Fl_X::window_pixel_size(this).width > w() + 0.5 );
Fl_X::set_high_resolution(fl_mac_os_version >= 100700 && [fl_window backingScaleFactor] > 1.0);
#endif
current_ = this; current_ = this;
NSGraphicsContext *nsgc = through_drawRect ? [NSGraphicsContext currentContext] : NSGraphicsContext *nsgc = through_drawRect ? [NSGraphicsContext currentContext] :