Improved Mac OS X Fl_Gl_Window resizing: the GL scene was drawn twice at each resize operation.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10545 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
22b4288c23
commit
8887600f5f
2
FL/mac.H
2
FL/mac.H
@ -156,6 +156,8 @@ public:
|
||||
bool changed_resolution(); // did window just moved to display with another resolution?
|
||||
void changed_resolution(bool);// sets whether window just moved to display with another resolution
|
||||
#endif
|
||||
bool in_windowDidResize(); // is window performing windowDidResize?
|
||||
void in_windowDidResize(bool); // sets whether window is performing windowDidResize
|
||||
// Quartz additions:
|
||||
CGContextRef gc; // graphics context (NULL when using QD)
|
||||
static void q_fill_context(); // fill a Quartz context with current FLTK state
|
||||
|
@ -435,6 +435,10 @@ void Fl_Gl_Window::resize(int X,int Y,int W,int H) {
|
||||
int is_a_resize = (W != Fl_Widget::w() || H != Fl_Widget::h());
|
||||
if (is_a_resize) valid(0);
|
||||
|
||||
#ifdef __APPLE__
|
||||
if (Fl_X::i(this)->in_windowDidResize()) gl_context_update(context_);
|
||||
#endif
|
||||
|
||||
#if ! ( defined(__APPLE__) || defined(WIN32) )
|
||||
if (is_a_resize && !resizable() && overlay && overlay != this) {
|
||||
((Fl_Gl_Window*)overlay)->resize(0,0,W,H);
|
||||
@ -442,12 +446,6 @@ void Fl_Gl_Window::resize(int X,int Y,int W,int H) {
|
||||
#endif
|
||||
|
||||
Fl_Window::resize(X,Y,W,H);
|
||||
#ifdef __APPLE__
|
||||
if (is_a_resize) {
|
||||
gl_context_update(context_);
|
||||
redraw();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1111,6 +1111,30 @@ static void orderfront_subwindows(FLWindow *xid)
|
||||
}
|
||||
}
|
||||
|
||||
#if FLTK_ABI_VERSION >= 10304
|
||||
static const unsigned windowDidResize_mask = 1;
|
||||
#else
|
||||
static const unsigned long windowDidResize_mask = 1;
|
||||
#endif
|
||||
|
||||
bool Fl_X::in_windowDidResize() {
|
||||
#if FLTK_ABI_VERSION >= 10304
|
||||
return mapped_to_retina_ & windowDidResize_mask;
|
||||
#else
|
||||
return (unsigned long)xidChildren & windowDidResize_mask;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Fl_X::in_windowDidResize(bool b) {
|
||||
#if FLTK_ABI_VERSION >= 10304
|
||||
if (b) mapped_to_retina_ |= windowDidResize_mask;
|
||||
else mapped_to_retina_ &= ~windowDidResize_mask;
|
||||
#else
|
||||
if (b) xidChildren = (Fl_X*)((unsigned long)xidChildren | windowDidResize_mask);
|
||||
else xidChildren = (Fl_X*)((unsigned long)xidChildren & ~windowDidResize_mask);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
//determines whether a window is mapped to a retina display
|
||||
static void compute_mapped_to_retina(Fl_Window *window)
|
||||
@ -1129,11 +1153,11 @@ static void compute_mapped_to_retina(Fl_Window *window)
|
||||
}
|
||||
|
||||
#if FLTK_ABI_VERSION >= 10304
|
||||
static const unsigned mapped_mask = 1;
|
||||
static const unsigned changed_mask = 2;
|
||||
static const unsigned mapped_mask = 2;
|
||||
static const unsigned changed_mask = 4;
|
||||
#else
|
||||
static const unsigned long mapped_mask = 1; // sizeof(unsigned long) = sizeof(Fl_X*)
|
||||
static const unsigned long changed_mask = 2;
|
||||
static const unsigned long mapped_mask = 2; // sizeof(unsigned long) = sizeof(Fl_X*)
|
||||
static const unsigned long changed_mask = 4;
|
||||
#endif
|
||||
|
||||
bool Fl_X::mapped_to_retina() {
|
||||
@ -1264,8 +1288,10 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
||||
parent = parent->window();
|
||||
}
|
||||
resize_from_system = window;
|
||||
if (window->as_gl_window()) Fl_X::i(window)->in_windowDidResize(true);
|
||||
update_e_xy_and_e_xy_root(nsw);
|
||||
window->resize((int)pt2.x, (int)pt2.y, (int)r.size.width, (int)r.size.height);
|
||||
if (window->as_gl_window()) Fl_X::i(window)->in_windowDidResize(false);
|
||||
fl_unlock_function();
|
||||
}
|
||||
- (void)windowDidResignKey:(NSNotification *)notif
|
||||
@ -2974,12 +3000,17 @@ void Fl_X::make(Fl_Window* w)
|
||||
// next 2 statements so a subwindow doesn't leak out of its parent window
|
||||
[cw setOpaque:NO];
|
||||
[cw setBackgroundColor:[NSColor clearColor]]; // transparent background color
|
||||
CGRect prect = CGRectMake(0, 0, w->window()->w(), w->window()->h());
|
||||
CGRect srect = CGRectMake(w->x(), w->y(), w->w(), w->h());
|
||||
if (!CGRectContainsRect(prect, srect)) { // if subwindow extends outside its parent window
|
||||
CGRect clip = CGRectIntersection(prect, srect);
|
||||
clip = CGRectOffset(clip, -w->x(), -w->y());
|
||||
x->subRect(new CGRect(clip));
|
||||
CGRect srect = CGRectMake(0, 0, w->w(), w->h());
|
||||
Fl_Window *parent, *from = w;
|
||||
int fromx = 0, fromy = 0;
|
||||
while ((parent = from->window()) != NULL) {
|
||||
fromx -= from->x(); // parent origin in w's coordinates
|
||||
fromy -= from->y();
|
||||
srect = CGRectIntersection(CGRectMake(fromx, fromy, parent->w(), parent->h()), srect);
|
||||
from = parent;
|
||||
}
|
||||
if (!CGRectEqualToRect(srect, CGRectMake(0, 0, w->w(), w->h()))) { // if subwindow extends outside its parent windows
|
||||
x->subRect(new CGRect(srect));
|
||||
}
|
||||
set_subwindow_frame(w);
|
||||
// needed if top window was first displayed miniaturized
|
||||
@ -3587,9 +3618,9 @@ void Fl_X::map() {
|
||||
set_subwindow_frame(w);
|
||||
}
|
||||
//+ link to window list
|
||||
if (w && w->parent()) {
|
||||
/*if (w && w->parent()) {
|
||||
w->redraw(); // possibly not necessary
|
||||
}
|
||||
}*/
|
||||
if (cursor) {
|
||||
[(NSCursor*)cursor release];
|
||||
cursor = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user