summaryrefslogtreecommitdiff
path: root/src/Fl_cocoa.mm
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2014-11-19 16:23:36 +0000
committerManolo Gouy <Manolo>2014-11-19 16:23:36 +0000
commitf52b457cc24c4c66d5d370d1529c5438ec4416df (patch)
tree7b9cc573abde7b8ee6ce458575ade1aab3a2fa55 /src/Fl_cocoa.mm
parent659480f28beb44a7a805682563183698a279cd96 (diff)
Added full support of retina displays on the mac platform.
On such displays, one drawing unit equals two pixels. The fl_xyline() and fl_yxline() functions are modified to perform extra operations when drawing to a window on a retina display. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10463 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_cocoa.mm')
-rw-r--r--src/Fl_cocoa.mm21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 09d42bdd2..433add3a9 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -792,9 +792,8 @@ double fl_mac_flush_and_wait(double time_to_wait) {
time_to_wait = 0.0;
double retval = fl_wait(time_to_wait);
if (fl_gc) {
- CGContextFlush(fl_gc);
- fl_gc = 0;
- }
+ Fl_X::q_release_context();
+ }
[pool release];
return retval;
}
@@ -2989,6 +2988,9 @@ 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
current_ = this;
NSGraphicsContext *nsgc = through_drawRect ? [NSGraphicsContext currentContext] :
@@ -3048,6 +3050,9 @@ void Fl_X::q_release_context(Fl_X *x) {
if (x && x->gc!=fl_gc) return;
if (!fl_gc) return;
CGContextRestoreGState(fl_gc); // KEEP IT: matches the CGContextSaveGState of make_current
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+ Fl_X::set_high_resolution(false);
+#endif
CGContextFlush(fl_gc);
fl_gc = 0;
#if defined(FLTK_USE_CAIRO)
@@ -3073,6 +3078,11 @@ void Fl_X::q_end_image() {
CGContextRestoreGState(fl_gc);
}
+void Fl_X::set_high_resolution(bool new_val)
+{
+ Fl_Display_Device::high_res_window_ = new_val;
+}
+
void Fl_Copy_Surface::complete_copy_pdf_and_tiff()
{
CGContextRestoreGState(gc);
@@ -3583,6 +3593,7 @@ int Fl_X::set_cursor(const Fl_RGB_Image *image, int hotx, int hoty) {
printer.origin(w/2, h/2);
#endif
printer.print_window(win, -ww/2, -wh/2);
+ //printer.print_window_part(win,0,0,win->w(),win->h(), -ww/2, -wh/2);
printer.end_page();
printer.end_job();
fl_unlock_function();
@@ -3933,9 +3944,7 @@ static NSBitmapImageRep* rect_to_NSBitmapImageRep(Fl_Window *win, int x, int y,
} else {
NSView *winview = nil;
if ( through_drawRect && Fl_Window::current() == win ) {
- CGFloat epsilon = 0;
- if (fl_mac_os_version >= 100600) epsilon = 0.5; // STR #2887
- rect = NSMakeRect(x - epsilon, y - epsilon, w, h);
+ rect = NSMakeRect(x - 0.5, y - 0.5, w, h);
}
else {
rect = NSMakeRect(x, win->h()-(y+h), w, h);