@@ -211,7 +211,7 @@ void MCStack::view_set_content_scale(MCGFloat p_scale)
211211 m_view_content_scale = p_scale;
212212
213213 // IM-2014-01-16: [[ StackScale ]] Update view transform after changing view property
214- view_update_transform ();
214+ view_update_transform (true );
215215 // IM-2014-10-22: [[ Bug 13746 ]] Update window mask when stack scale changes
216216 loadwindowshape ();
217217}
@@ -422,7 +422,7 @@ void MCStack::view_calculate_viewports(const MCRectangle &p_stack_rect, MCRectan
422422 r_transform = MCGAffineTransformConcat (view_get_stack_transform (t_mode, MCGRectangleGetIntegerBounds (t_scaled_rect), t_view_rect), t_transform);
423423}
424424
425- void MCStack::view_update_transform (void )
425+ void MCStack::view_update_transform (bool p_ensure_onscreen )
426426{
427427 MCRectangle t_view_rect;
428428 MCGAffineTransform t_transform;
@@ -447,20 +447,30 @@ void MCStack::view_update_transform(void)
447447 }
448448
449449 // PM-2015-07-17: [[ Bug 13754 ]] Make sure stack does not disappear off screen when changing the scalefactor
450- MCRectangle t_bounded_rect, t_screen_rect;
451-
452- const MCDisplay* t_nearest_display = MCscreen -> getnearestdisplay (t_view_rect);
453- if (t_nearest_display != NULL )
450+ MCRectangle t_bounded_rect;
451+ if (p_ensure_onscreen)
454452 {
455- t_screen_rect = t_nearest_display -> viewport;
456- t_bounded_rect = MCU_bound_rect (t_view_rect, t_screen_rect . x, t_screen_rect . y, t_screen_rect . width, t_screen_rect . height);
453+ // AL-2015-10-01: [[ Bug 16017 ]] Remember location of stacks on a second monitor
454+ const MCDisplay* t_nearest_display;
455+ t_nearest_display = MCscreen -> getnearestdisplay (t_view_rect);
456+
457+ if (t_nearest_display != nil)
458+ {
459+ MCRectangle t_screen_rect;
460+ t_screen_rect = t_nearest_display -> viewport;
461+ t_bounded_rect = MCU_bound_rect (t_view_rect, t_screen_rect . x, t_screen_rect . y, t_screen_rect . width, t_screen_rect . height);
462+ }
463+ else
464+ {
465+ // In noUI mode, we don't have a nearest display.
466+ t_bounded_rect = MCU_bound_rect (t_view_rect, 0 , 0 , MCscreen -> getwidth (), MCscreen -> getheight ());
467+ }
457468 }
458469 else
459470 {
460- // In noUI mode, we don't have a nearest display.
461- t_bounded_rect = MCU_bound_rect (t_view_rect, 0 , 0 , MCscreen -> getwidth (), MCscreen -> getheight ());
471+ t_bounded_rect = t_view_rect;
462472 }
463-
473+
464474 // IM-2014-01-16: [[ StackScale ]] Update view rect if needed
465475 view_setrect (t_bounded_rect);
466476}
0 commit comments