@@ -214,7 +214,7 @@ void MCStack::view_set_content_scale(MCGFloat p_scale)
214214 m_view_content_scale = p_scale;
215215
216216 // IM-2014-01-16: [[ StackScale ]] Update view transform after changing view property
217- view_update_transform ();
217+ view_update_transform (true );
218218 // IM-2014-10-22: [[ Bug 13746 ]] Update window mask when stack scale changes
219219 loadwindowshape ();
220220}
@@ -427,7 +427,7 @@ void MCStack::view_calculate_viewports(const MCRectangle &p_stack_rect, MCRectan
427427 r_transform = MCGAffineTransformConcat (view_get_stack_transform (t_mode, MCGRectangleGetIntegerBounds (t_scaled_rect), t_view_rect), t_transform);
428428}
429429
430- void MCStack::view_update_transform (void )
430+ void MCStack::view_update_transform (bool p_ensure_onscreen )
431431{
432432 MCRectangle t_view_rect;
433433 MCGAffineTransform t_transform;
@@ -452,21 +452,30 @@ void MCStack::view_update_transform(void)
452452 }
453453
454454 // PM-2015-07-17: [[ Bug 13754 ]] Make sure stack does not disappear off screen when changing the scalefactor
455- MCRectangle t_bounded_rect, t_screen_rect;
456-
457- // AL-2015-10-01: [[ Bug 16017 ]] Remember location of stacks on a second monitor
458- const MCDisplay* t_nearest_display = MCscreen -> getnearestdisplay (t_view_rect);
459- if (t_nearest_display != NULL )
455+ MCRectangle t_bounded_rect;
456+ if (p_ensure_onscreen)
460457 {
461- t_screen_rect = t_nearest_display -> viewport;
462- 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);
458+ // AL-2015-10-01: [[ Bug 16017 ]] Remember location of stacks on a second monitor
459+ const MCDisplay* t_nearest_display;
460+ t_nearest_display = MCscreen -> getnearestdisplay (t_view_rect);
461+
462+ if (t_nearest_display != nil)
463+ {
464+ MCRectangle t_screen_rect;
465+ t_screen_rect = t_nearest_display -> viewport;
466+ 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);
467+ }
468+ else
469+ {
470+ // In noUI mode, we don't have a nearest display.
471+ t_bounded_rect = MCU_bound_rect (t_view_rect, 0 , 0 , MCscreen -> getwidth (), MCscreen -> getheight ());
472+ }
463473 }
464474 else
465475 {
466- // In noUI mode, we don't have a nearest display.
467- t_bounded_rect = MCU_bound_rect (t_view_rect, 0 , 0 , MCscreen -> getwidth (), MCscreen -> getheight ());
476+ t_bounded_rect = t_view_rect;
468477 }
469-
478+
470479 // IM-2014-01-16: [[ StackScale ]] Update view rect if needed
471480 view_setrect (t_bounded_rect);
472481}
0 commit comments