Skip to content

Commit 5a9eacc

Browse files
committed
[[ Bug 12495 ]] Fix windowshape rendering and update issues.
1 parent b182e5e commit 5a9eacc

File tree

5 files changed

+37
-10
lines changed

5 files changed

+37
-10
lines changed

docs/notes/bugfix-12495.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[[ Bug 12495 ]] Animating windowShape does not work properly on Mac.

engine/src/desktop-stack.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,15 @@ void MCStack::view_platform_updatewindowwithcallback(MCRegionRef p_region, MCSta
323323

324324
////////////////////////////////////////////////////////////////////////////////
325325

326+
// MW-2014-06-11: [[ Bug 12495 ]] Update windowshape by setting window property.
327+
void MCStack::updatewindowshape(MCWindowShape *p_shape)
328+
{
329+
destroywindowshape();
330+
m_window_shape = p_shape;
331+
MCPlatformSetWindowProperty(window, kMCPlatformWindowPropertyMask, kMCPlatformPropertyTypeWindowMask, (MCPlatformWindowMaskRef *)&m_window_shape -> handle);
332+
dirtyall();
333+
}
334+
326335
void MCStack::destroywindowshape(void)
327336
{
328337
if (m_window_shape == nil)

engine/src/mac-window.mm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,9 @@ - (void)setFrameSize: (NSSize)size
17921792
if (m_changes . opacity_changed)
17931793
[m_window_handle setAlphaValue: m_opacity];
17941794

1795+
if (m_changes . has_shadow_changed)
1796+
[m_window_handle setHasShadow: m_has_shadow];
1797+
17951798
if (m_changes . mask_changed)
17961799
{
17971800
[m_window_handle setOpaque: m_mask == nil];
@@ -1931,7 +1934,7 @@ - (void)setFrameSize: (NSSize)size
19311934
{
19321935
// If the shadow has changed (due to the mask changing) we must disable
19331936
// screen updates otherwise we get a flicker.
1934-
if (m_shadow_changed)
1937+
if (m_shadow_changed && m_has_shadow)
19351938
NSDisableScreenUpdates();
19361939

19371940
// Mark the bounding box of the dirty region for needing display.
@@ -1943,8 +1946,13 @@ - (void)setFrameSize: (NSSize)size
19431946
[m_view displayIfNeeded];
19441947

19451948
// Re-enable screen updates if needed.
1946-
if (m_shadow_changed)
1949+
if (m_shadow_changed && m_has_shadow)
1950+
{
1951+
// MW-2014-06-11: [[ Bug 12495 ]] Turn the shadow off and on to force recaching.
1952+
[m_window_handle setHasShadow: NO];
1953+
[m_window_handle setHasShadow: YES];
19471954
NSEnableScreenUpdates();
1955+
}
19481956
}
19491957

19501958
void MCMacPlatformWindow::DoIconify(void)

engine/src/stack.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,14 +2493,10 @@ Exec_stat MCStack::setprop(uint4 parid, Properties which, MCExecPoint &ep, Boole
24932493
t_image -> open();
24942494
t_new_mask = t_image -> makewindowshape();
24952495
t_image -> close();
2496+
// MW-2014-06-11: [[ Bug 12495 ]] Refactored action as different whether using platform API or not.
24962497
if (t_new_mask != NULL)
2497-
{
2498-
destroywindowshape();
2499-
m_window_shape = t_new_mask;
2500-
// MW-2011-08-17: [[ Redraw ]] Tell the stack to dirty all of itself.
2501-
dirtyall();
2502-
break;
2503-
}
2498+
updatewindowshape(t_new_mask);
2499+
break;
25042500
}
25052501
}
25062502
#endif
@@ -3086,6 +3082,17 @@ bool MCStack::getuseideallayout(void)
30863082
#endif
30873083
}
30883084

3085+
#ifndef _MAC_DESKTOP
3086+
// MW-2014-06-11: [[ Bug 12495 ]] Non-platform API version of updating windowshape.
3087+
void MCStack::updatewindowshape(MCWindowShape *p_shape)
3088+
{
3089+
destroywindowshape();
3090+
m_window_shape = p_shape;
3091+
// MW-2011-08-17: [[ Redraw ]] Tell the stack to dirty all of itself.
3092+
dirtyall();
3093+
}
3094+
#endif
3095+
30893096
//////////
30903097

30913098
MCRectangle MCStack::getwindowrect(void) const

engine/src/stack.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ class MCStack : public MCObject
495495
MCRectangle getcardrect() const;
496496
// IM-2014-01-07: [[ StackScale ]] Update the rect of the current card to fit the stack
497497
void updatecardsize();
498-
498+
499499
//////////
500500

501501
void setgeom();
@@ -759,7 +759,9 @@ class MCStack : public MCObject
759759
void sethints();
760760
// IM-2013-10-08: [[ FullscreenMode ]] Separate out window sizing hints
761761
void setsizehints();
762+
762763
void destroywindowshape();
764+
void updatewindowshape(MCWindowShape *shape);
763765

764766
// MW-2011-08-17: [[ Redraw ]] Mark the whole content area as needing redrawn.
765767
void dirtyall(void);

0 commit comments

Comments
 (0)