mirror of https://github.com/fltk/fltk
Fix for [fltk.coredev] reentrant calls with Fl_Window::resize
This commit is contained in:
parent
1ce3a84e9f
commit
7e484c614c
|
@ -1221,7 +1221,12 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
|||
main_screen_height = CGDisplayBounds(CGMainDisplayID()).size.height;
|
||||
int X, Y;
|
||||
CocoatoFLTK(window, X, Y);
|
||||
if (window->x() != X || window->y() != Y) window->position(X, Y);
|
||||
if (window->x() != X || window->y() != Y) {
|
||||
if (!Fl_Cocoa_Window_Driver::driver(window)->through_resize())
|
||||
window->position(X, Y);
|
||||
else
|
||||
window->Fl_Widget::resize(X,Y,window->w(),window->h());
|
||||
}
|
||||
update_e_xy_and_e_xy_root(nsw);
|
||||
// at least since MacOS 10.9: OS moves subwindows contained in a moved window
|
||||
// setSubwindowFrame is no longer necessary.
|
||||
|
@ -1244,6 +1249,9 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
|||
float s = Fl::screen_driver()->scale(window->screen_num());
|
||||
NSRect r = [view frame];
|
||||
Fl_Cocoa_Window_Driver::driver(window)->view_resized(1);
|
||||
if (Fl_Cocoa_Window_Driver::driver(window)->through_resize())
|
||||
Fl_Cocoa_Window_Driver::driver(window)->resize(X, Y, lround(r.size.width/s), lround(r.size.height/s));
|
||||
else
|
||||
window->resize(X, Y, lround(r.size.width/s), lround(r.size.height/s));
|
||||
Fl_Cocoa_Window_Driver::driver(window)->view_resized(0);
|
||||
update_e_xy_and_e_xy_root(nsw);
|
||||
|
@ -3327,9 +3335,10 @@ void Fl_Cocoa_Window_Driver::resize(int X, int Y, int W, int H) {
|
|||
if (view_resized() || !visible_r()) {
|
||||
pWindow->Fl_Group::resize(X, Y, W, H);
|
||||
if (!pWindow->shown()) pWindow->init_sizes();
|
||||
} else {
|
||||
} else if (!through_resize()) {
|
||||
NSPoint pt = FLTKtoCocoa(pWindow, X, Y, H);
|
||||
FLWindow *xid = fl_xid(pWindow);
|
||||
through_resize(1);
|
||||
if (W != w() || H != h() || Fl_Window::is_a_rescale()) {
|
||||
NSRect r;
|
||||
float s = Fl::screen_driver()->scale(screen_num());
|
||||
|
@ -3347,10 +3356,14 @@ void Fl_Cocoa_Window_Driver::resize(int X, int Y, int W, int H) {
|
|||
}
|
||||
else {
|
||||
if (pWindow->parent()) starting_moved_window = pWindow;
|
||||
if (!NSEqualPoints([xid frame].origin, pt))
|
||||
[xid setFrameOrigin:pt]; // set cocoa coords to FLTK position
|
||||
x(X); y(Y); // useful when frame did not move but X or Y changed
|
||||
else {
|
||||
x(X); y(Y);
|
||||
}
|
||||
if (pWindow->parent()) starting_moved_window = NULL;
|
||||
}
|
||||
through_resize(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,8 @@ public:
|
|||
void changed_resolution(bool);// sets whether window just moved to display with another resolution
|
||||
bool view_resized(); // did window's view receive [FLView view_did_resize] message?
|
||||
void view_resized(bool b); // sets whether window's view received [FLView view_did_resize] message
|
||||
bool through_resize(); // did Fl_Window::resize() run already
|
||||
void through_resize(bool b); // set whether Fl_Window::resize() run already
|
||||
CGRect* subRect() { return subRect_; } // getter
|
||||
void subRect(CGRect *r) { subRect_ = r; } // setter
|
||||
static void destroy(FLWindow*);
|
||||
|
|
|
@ -262,6 +262,7 @@ int Fl_Cocoa_Window_Driver::scroll(int src_x, int src_y, int src_w, int src_h, i
|
|||
static const unsigned mapped_mask = 1;
|
||||
static const unsigned changed_mask = 2;
|
||||
static const unsigned view_resized_mask = 4;
|
||||
static const unsigned through_resize_mask = 8;
|
||||
|
||||
bool Fl_Cocoa_Window_Driver::mapped_to_retina() {
|
||||
return window_flags_ & mapped_mask;
|
||||
|
@ -290,6 +291,15 @@ void Fl_Cocoa_Window_Driver::view_resized(bool b) {
|
|||
else window_flags_ &= ~view_resized_mask;
|
||||
}
|
||||
|
||||
bool Fl_Cocoa_Window_Driver::through_resize() {
|
||||
return window_flags_ & through_resize_mask;
|
||||
}
|
||||
|
||||
void Fl_Cocoa_Window_Driver::through_resize(bool b) {
|
||||
if (b) window_flags_ |= through_resize_mask;
|
||||
else window_flags_ &= ~through_resize_mask;
|
||||
}
|
||||
|
||||
|
||||
// clip the graphics context to rounded corners
|
||||
void Fl_Cocoa_Window_Driver::clip_to_rounded_corners(CGContextRef gc, int w, int h) {
|
||||
|
|
Loading…
Reference in New Issue