Fix computation of Fl_Window::decorated_h() on macOS when screen is scaled.

This commit is contained in:
ManoloFLTK 2020-02-06 16:00:41 +01:00
parent c0b4fed619
commit 7cb0c2311c
4 changed files with 7 additions and 4 deletions

View File

@ -4352,7 +4352,8 @@ int Fl_Cocoa_Window_Driver::decorated_h()
return h();
int bx = 0, by = 0;
int bt = get_window_frame_sizes(pWindow, &bx, &by);
return h() + bt + by;
float s = Fl::screen_driver()->scale(0);
return h() + bt/s;
}
CALayer *Fl_Cocoa_Window_Driver::get_titlebar_layer()

View File

@ -372,7 +372,8 @@ void Fl_Cocoa_Printer_Driver::draw_decorated_window(Fl_Window *win, int x_offset
this->print_widget(win, x_offset, y_offset);
return;
}
int bt = win->decorated_h() - win->h();
int bt, hleft, hright, hbottom;
Fl_Cocoa_Window_Driver::driver(win)->decoration_sizes(&bt, &hleft, &hright, &hbottom);
float s = Fl::screen_scale(win->screen_num());
if (s < 1) y_offset += bt*(1/s-1);
CALayer *layer = Fl_Cocoa_Window_Driver::driver(win)->get_titlebar_layer();

View File

@ -314,7 +314,8 @@ const Fl_Image* Fl_Cocoa_Window_Driver::shape() {
void Fl_Cocoa_Window_Driver::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right)
{
left = bottom = right = NULL;
int htop = pWindow->decorated_h() - h();
int htop, hleft, hright, hbottom;
Fl_Cocoa_Window_Driver::decoration_sizes(&htop, &hleft, &hright, &hbottom);
CALayer *layer = get_titlebar_layer();
CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB();
float s = Fl::screen_driver()->scale(screen_num());

View File

@ -99,7 +99,7 @@ void Fl_Quartz_Copy_Surface_Driver::draw_decorated_window(Fl_Window *win, int x_
CGContextTranslateCTM(gc, x_offset - 0.5, y_offset + bt - 0.5);
float s = Fl::screen_scale(win->screen_num());
CGContextScaleCTM(gc, 1/s, s >= 1 ? -1/s : -1);
Fl_Cocoa_Window_Driver::draw_layer_to_context(layer, gc, win->w() * s, bt);
Fl_Cocoa_Window_Driver::draw_layer_to_context(layer, gc, win->w() * s, bt*s);
CGContextRestoreGState(gc);
draw(win, x_offset, y_offset + bt); // print the window inner part
}