diff options
| author | Manolo Gouy <Manolo> | 2014-12-17 09:04:01 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2014-12-17 09:04:01 +0000 |
| commit | 15d497ebdf00537678226679503303a4f7c77800 (patch) | |
| tree | 1f229e16443963a6233535777405a5b281cf4baa | |
| parent | 00dd28afa4fbee63cc907d57f60b2c7d75355cfc (diff) | |
Apple-only changes to restore a layout of the Fl_X class identical to that in FLTK 1.3.3.
With true subwindows, several members of Fl_X became useless.
This change recycle two of them for new uses:
- Fl_Region subRegion is used as a pointer to a CGRect
- Fl_X *xidChildren is used to indicate the resolution of the display
containing a window
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10486 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | FL/mac.H | 30 | ||||
| -rw-r--r-- | src/Fl.cxx | 1 | ||||
| -rw-r--r-- | src/Fl_cocoa.mm | 58 |
3 files changed, 67 insertions, 22 deletions
@@ -125,11 +125,27 @@ public: Fl_Offscreen other_xid; // pointer for offscreen bitmaps (overlay window) Fl_Window *w; // FLTK window for Fl_Region region; - CGRect* subRect; // make sure subwindow remains inside its parent window - Fl_X *next; // linked tree to support subwindows +#if FLTK_ABI_VERSION >= 10304 + CGRect* subRect_; // make sure subwindow remains inside its parent window + CGRect* subRect() { return subRect_; } // getter + void subRect(CGRect *r) { subRect_ = r; } // setter +#else + Fl_Region subRegion; // for ABI compatibility, recycled to replace subRect_ + CGRect* subRect() { return (CGRect*)subRegion; } // getter + void subRect(CGRect *r) { subRegion = (Fl_Region)r; } // setter +#endif + Fl_X *next; // chain of mapped windows +#if FLTK_ABI_VERSION < 10304 + Fl_X *xidChildren; // useless with true subwindows, recycled to replace mapped_to_retina_ + Fl_X *xidNext; // useless with true subwindows +#endif +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + bool mapped_to_retina(); // is window mapped to retina display? + void mapped_to_retina(bool); // sets whether window is mapped to retina display +#endif + static void set_high_resolution(bool); int wait_for_expose; NSCursor *cursor; - bool mapped_to_retina; // true when window is mapped to a retina display static Fl_X* first; static Fl_X* i(const Fl_Window* w) {return w->i;} static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&); @@ -164,7 +180,13 @@ public: static int insertion_point_location(int *px, int *py, int *pheight); // computes window coordinates & height of insertion point static const int CoreText_threshold; // Mac OS version from which the Core Text API is used to display text static Fl_Fontdesc* calc_fl_fonts(void); // computes the fl_fonts global variable - static void set_high_resolution(bool); +private: +#if FLTK_ABI_VERSION >= 10304 + // stores whether window is mapped to retina display + unsigned mapped_to_retina_; +#else + bool subwindow; // for ABI compatibility, useless with true subwindows +#endif }; extern Window fl_window; diff --git a/src/Fl.cxx b/src/Fl.cxx index 36b0e54ed..b49033716 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1576,7 +1576,6 @@ void Fl_Window::hide() { if (count) delete[] doit; #elif defined(__APPLE_QUARTZ__) ip->destroy(); - delete ip->subRect; #else # error unsupported platform #endif diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 06ba767ff..e04d2fcfa 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -1106,7 +1106,11 @@ static void position_subwindows(Fl_Window *parent, BOOL is_a_move) while ((child = [enumerator nextObject]) != nil) { NSRect rchild; Fl_Window *sub = [child getFl_Window]; - Fl_X::i(sub)->mapped_to_retina = Fl_X::i(parent)->mapped_to_retina; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + Fl_X *subx = Fl_X::i(sub); + bool previous = subx->mapped_to_retina(); + subx->mapped_to_retina( Fl_X::i(parent)->mapped_to_retina() ); +#endif rchild.origin = NSMakePoint(pframe.origin.x + sub->x(), pframe.origin.y + parent->h() - (sub->h() + sub->y())); rchild.size = NSMakeSize(sub->w(), sub->h()); [child setFrame:rchild display:YES]; @@ -1134,21 +1138,40 @@ static void orderfront_subwindows(FLWindow *xid) } } -//determines whether the window is mapped to a retina display +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +//determines whether the (top-level) window is mapped to a retina display static void compute_mapped_to_retina(Fl_Window *window) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if (fl_mac_os_version >= 100700) { // determine whether window is now mapped to a retina display - bool *mapped = &(Fl_X::i(window)->mapped_to_retina); - bool previous = *mapped; + Fl_X *flx = Fl_X::i(window); + bool previous = flx->mapped_to_retina(); NSSize s = [[fl_xid(window) contentView] convertSizeToBacking:NSMakeSize(10, 10)]; - *mapped = (int(s.width + 0.5) > 10); + flx->mapped_to_retina( int(s.width + 0.5) > 10 ); // window needs redrawn when moving from low res to retina - if ((!previous) && *mapped) window->redraw(); + if ((!previous) && flx->mapped_to_retina()) { + window->redraw(); + } } +} + +bool Fl_X::mapped_to_retina() { +#if FLTK_ABI_VERSION >= 10304 + return (bool)mapped_to_retina_; +#else + return xidChildren != NULL; +#endif +} + +void Fl_X::mapped_to_retina(bool b) { +#if FLTK_ABI_VERSION >= 10304 + mapped_to_retina_ = b; +#else + xidChildren = (b ? (Fl_X*)1 : NULL); #endif } +#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + @interface FLWindowDelegateBefore10_6 : FLWindowDelegate - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)client; @end @@ -2685,11 +2708,11 @@ void Fl_X::make(Fl_Window* w) Fl_X* x = new Fl_X; x->other_xid = 0; // room for doublebuffering image map. On OS X this is only used by overlay windows x->region = 0; - x->subRect = 0; + x->subRect(0); x->cursor = NULL; x->gc = 0; - if (w->parent()) x->mapped_to_retina = w->top_window()->i->mapped_to_retina; - else x->mapped_to_retina = false; + if (w->parent()) x->mapped_to_retina( w->top_window()->i->mapped_to_retina() ); + else x->mapped_to_retina(false); NSRect crect; if (w->fullscreen_active()) { @@ -2800,7 +2823,7 @@ void Fl_X::make(Fl_Window* w) CGRect clip = CGRectIntersection(prect, srect); clip = CGRectOffset(clip, -w->x(), -w->y()); clip = fl_cgrectmake_cocoa(clip.origin.x, clip.origin.y, clip.size.width, clip.size.height); - x->subRect = new CGRect(clip); + x->subRect(new CGRect(clip)); } set_subwindow_frame(w); // needed if top window was first displayed miniaturized @@ -2960,15 +2983,15 @@ void Fl_Window::resize(int X,int Y,int W,int H) { Fl_Window *childw = [child getFl_Window]; CGRect prect = CGRectMake(0, 0, w(), h()); CGRect srect = CGRectMake(childw->x(), childw->y(), childw->w(), childw->h()); - CGRect **active = &(Fl_X::i(childw)->subRect); - delete *active; - *active = NULL; + delete Fl_X::i(childw)->subRect(); + CGRect *pclip = NULL; if (!CGRectContainsRect(prect, srect)) { // if subwindow extends outside its parent window CGRect clip = CGRectIntersection(prect, srect); clip = CGRectOffset(clip, -childw->x(), -childw->y()); clip = fl_cgrectmake_cocoa(clip.origin.x, clip.origin.y, clip.size.width, clip.size.height); - *active = new CGRect(clip); + pclip = new CGRect(clip); } + Fl_X::i(childw)->subRect(pclip); } } } @@ -3006,7 +3029,7 @@ void Fl_Window::make_current() if (make_current_counts) make_current_counts++; Fl_X::q_release_context(); fl_window = i->xid; - Fl_X::set_high_resolution( i->mapped_to_retina ); + Fl_X::set_high_resolution( i->mapped_to_retina() ); current_ = this; NSGraphicsContext *nsgc = through_drawRect ? [NSGraphicsContext currentContext] : @@ -3022,7 +3045,7 @@ void Fl_Window::make_current() CGContextTranslateCTM(fl_gc, 0.5, hgt-0.5f); CGContextScaleCTM(fl_gc, 1.0f, -1.0f); // now 0,0 is top-left point of the window // for subwindows, limit drawing to inside of parent window - if (i->subRect) CGContextClipToRect(fl_gc, *(i->subRect)); + if (i->subRect()) CGContextClipToRect(fl_gc, *(i->subRect())); // this is the context with origin at top left of (sub)window CGContextSaveGState(fl_gc); @@ -3367,6 +3390,7 @@ void Fl_X::destroy() { if (xid) { [xid close]; } + delete subRect(); } void Fl_X::map() { |
