Skip to content

Commit c76edc0

Browse files
committed
Merge branch 'bugfix-12080' into develop
2 parents 66bd836 + 9448cdf commit c76edc0

11 files changed

Lines changed: 99 additions & 40 deletions

engine/src/desktop-dc.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,30 @@ void MCScreenDC::controllostfocus(MCStack *p_stack, uint32_t p_id)
13681368

13691369
////////////////////////////////////////////////////////////////////////////////
13701370

1371+
// MW-2014-04-23: [[ Bug 12080 ]] Make sure the HideOnSuspend property of all
1372+
// palettes is in sync with hidePalettes.
1373+
void MCStacklist::hidepaletteschanged(void)
1374+
{
1375+
if (stacks != NULL)
1376+
{
1377+
MCStacknode *tptr = stacks;
1378+
do
1379+
{
1380+
MCStack *t_stack;
1381+
t_stack = tptr -> getstack();
1382+
1383+
if (t_stack->getwindow() != nil)
1384+
MCPlatformSetWindowBoolProperty(t_stack -> getwindow(), kMCPlatformWindowPropertyHideOnSuspend, MChidepalettes && t_stack -> getrealmode() == WM_PALETTE);
1385+
1386+
tptr = tptr->next();
1387+
}
1388+
while (tptr != stacks);
1389+
}
1390+
1391+
}
1392+
1393+
////////////////////////////////////////////////////////////////////////////////
1394+
13711395
double MCMacGetAnimationStartTime(void)
13721396
{
13731397
return s_animation_start_time;

engine/src/desktop-stack.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ void MCStack::realize(void)
198198
MCPlatformSetWindowBoolProperty(t_window, kMCPlatformWindowPropertyHasSizeWidget, t_has_sizebox);
199199
MCPlatformSetWindowBoolProperty(t_window, kMCPlatformWindowPropertyHasShadow, (decorations & WD_NOSHADOW) == 0);
200200
MCPlatformSetWindowBoolProperty(t_window, kMCPlatformWindowPropertyUseLiveResizing, (decorations & WD_LIVERESIZING) != 0);
201+
202+
// MW-2014-04-23: [[ Bug 12080 ]] If the window is a palette and hidePalettes is true then HideOnSuspend.
203+
MCPlatformSetWindowBoolProperty(t_window, kMCPlatformWindowPropertyHideOnSuspend, MChidepalettes && t_window_style == kMCPlatformWindowStylePalette);
201204

202205
setopacity(blendlevel * 255 / 100);
203206

engine/src/desktop.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -96,49 +96,14 @@ void MCPlatformHandleApplicationShutdownRequest(bool& r_terminate)
9696
}
9797
}
9898

99-
// MW-2014-04-08: [[ Bug 12080 ]] Show or hide palette windows as required.
100-
static void show_or_hide_palettes(bool p_show)
101-
{
102-
if (MCstacks -> isempty())
103-
return;
104-
105-
MCStacknode *t_stack_node;
106-
t_stack_node = MCstacks -> bottomnode();
107-
do
108-
{
109-
MCStack *t_stack;
110-
t_stack = t_stack_node -> getstack();
111-
112-
if (t_stack -> getrealmode() == WM_PALETTE && t_stack -> getflag(F_VISIBLE))
113-
{
114-
if (MChidepalettes)
115-
{
116-
if (p_show)
117-
MCPlatformShowWindow(t_stack -> getwindow());
118-
else
119-
MCPlatformHideWindow(t_stack -> getwindow());
120-
}
121-
}
122-
123-
t_stack_node = t_stack_node -> next();
124-
}
125-
while(t_stack_node != MCstacks -> bottomnode());
126-
}
127-
12899
void MCPlatformHandleApplicationSuspend(void)
129100
{
130101
MCdefaultstackptr -> getcard() -> message(MCM_suspend);
131102
MCappisactive = False;
132-
133-
// MW-2014-04-08: [[ Bug 12080 ]] Hide any palettes based on MChidepalettes.
134-
//show_or_hide_palettes(false);
135103
}
136104

137105
void MCPlatformHandleApplicationResume(void)
138106
{
139-
// MW-2014-04-08: [[ Bug 12080 ]] Show any palettes based on MChidepalettes.
140-
//show_or_hide_palettes(true);
141-
142107
MCappisactive = True;
143108
MCdefaultstackptr -> getcard() -> message(MCM_resume);
144109
}

engine/src/mac-core.mm

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification
124124
NSAutoreleasePool *t_pool;
125125
t_pool = [[NSAutoreleasePool alloc] init];
126126

127+
// MW-2014-04-23: [[ Bug 12080 ]] Always create a dummy window which should
128+
// always sit at the bottom of our window list so that palettes have something
129+
// to float above.
130+
NSWindow *t_dummy_window;
131+
t_dummy_window = [[NSWindow alloc] initWithContentRect: NSZeroRect styleMask: NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
132+
[t_dummy_window orderFront: nil];
133+
127134
// Dispatch the startup callback.
128135
int t_error_code;
129136
char *t_error_message;
@@ -224,6 +231,20 @@ - (void)applicationDidUnhide:(NSNotification *)notification
224231

225232
- (void)applicationWillBecomeActive:(NSNotification *)notification
226233
{
234+
// MW-2014-04-23: [[ Bug 12080 ]] Loop through all our windows and any MCPanels
235+
// get set to not be floating. This is so that they sit behind the windows
236+
// of other applications (like we did before).
237+
for(NSNumber *t_window_id in [[NSWindow windowNumbersWithOptions: 0] reverseObjectEnumerator])
238+
{
239+
NSWindow *t_window;
240+
t_window = [NSApp windowWithWindowNumber: [t_window_id longValue]];
241+
if (![t_window isKindOfClass: [com_runrev_livecode_MCPanel class]])
242+
{
243+
continue;
244+
}
245+
246+
[t_window setFloatingPanel: YES];
247+
}
227248
}
228249

229250
- (void)applicationDidBecomeActive:(NSNotification *)notification
@@ -233,11 +254,28 @@ - (void)applicationDidBecomeActive:(NSNotification *)notification
233254

234255
- (void)applicationWillResignActive:(NSNotification *)notification
235256
{
236-
MCPlatformCallbackSendApplicationSuspend();
257+
// MW-2014-04-23: [[ Bug 12080 ]] Loop through all our windows and move any
258+
// MCPanels to be above the top-most non-panel.
259+
NSInteger t_above_window_id;
260+
for(NSNumber *t_window_id in [[NSWindow windowNumbersWithOptions: 0] reverseObjectEnumerator])
261+
{
262+
NSWindow *t_window;
263+
t_window = [NSApp windowWithWindowNumber: [t_window_id longValue]];
264+
if (![t_window isKindOfClass: [com_runrev_livecode_MCPanel class]])
265+
{
266+
t_above_window_id = [t_window_id longValue];
267+
continue;
268+
}
269+
270+
[t_window setFloatingPanel: NO];
271+
[t_window orderWindow: NSWindowAbove relativeTo: t_above_window_id];
272+
t_above_window_id = [t_window_id longValue];
273+
}
237274
}
238275

239276
- (void)applicationDidResignActive:(NSNotification *)notification
240277
{
278+
MCPlatformCallbackSendApplicationSuspend();
241279
}
242280

243281
//////////

engine/src/mac-window.mm

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,12 @@ - (void)setFrameSize: (NSSize)size
17691769

17701770
[m_window_handle setContentView: m_container_view];
17711771

1772-
[m_window_handle setLevel: t_window_level];
1772+
// MW-2014-04-23: [[ Bug 12080 ]] If the window is a palette and the app is active
1773+
// then make sure its floating (if app is not active it gets made floating on resume).
1774+
if (t_window_level == kCGFloatingWindowLevelKey)
1775+
[m_panel_handle setFloatingPanel: [NSApp isActive]];
1776+
else
1777+
[m_window_handle setLevel: t_window_level];
17731778
[m_window_handle setOpaque: m_mask == nil];
17741779
[m_window_handle setHasShadow: m_has_shadow];
17751780
if (!m_has_zoom_widget)
@@ -1782,7 +1787,7 @@ - (void)setFrameSize: (NSSize)size
17821787

17831788
// MW-2014-04-08: [[ Bug 12080 ]] Make sure we turn off automatic 'hiding on deactivate'.
17841789
// The engine handles this itself.
1785-
[m_window_handle setHidesOnDeactivate: NO];
1790+
[m_window_handle setHidesOnDeactivate: m_hides_on_suspend];
17861791
}
17871792

17881793
void MCMacPlatformWindow::DoSynchronize(void)
@@ -1837,6 +1842,10 @@ - (void)setFrameSize: (NSSize)size
18371842
if (m_changes . cursor_changed)
18381843
MCMacPlatformHandleMouseCursorChange(this);
18391844

1845+
// MW-2014-04-23: [[ Bug 12080 ]] Sync hidesOnSuspend.
1846+
if (m_changes . hides_on_suspend_changed)
1847+
[m_window_handle setHidesOnDeactivate: m_hides_on_suspend];
1848+
18401849
m_synchronizing = false;
18411850
}
18421851

engine/src/platform-internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ class MCPlatformWindow
200200

201201
// MW-2014-04-08: [[ Bug 12073 ]] Changed flag for mouse cursor.
202202
bool cursor_changed : 1;
203+
204+
bool hides_on_suspend_changed : 1;
203205
} m_changes;
204206
MCPlatformWindowStyle m_style;
205207
char *m_title;
@@ -217,6 +219,7 @@ class MCPlatformWindow
217219
bool m_has_shadow : 1;
218220
bool m_has_modified_mark : 1;
219221
bool m_use_live_resizing : 1;
222+
bool m_hides_on_suspend : 1;
220223
};
221224

222225
// Universal state.

engine/src/platform-window.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ MCPlatformWindow::MCPlatformWindow(void)
4848
m_has_shadow = false;
4949
m_has_modified_mark = false;
5050
m_use_live_resizing = false;
51+
m_hides_on_suspend = false;
5152

5253
/* UNCHECKED */ MCRegionCreate(m_dirty_region);
5354
m_is_visible = false;
@@ -345,6 +346,11 @@ void MCPlatformWindow::SetProperty(MCPlatformWindowProperty p_property, MCPlatfo
345346
// MW-2014-04-08: [[ Bug 12073 ]] Mark the cursor as changed.
346347
m_changes . cursor_changed = true;
347348
break;
349+
case kMCPlatformWindowPropertyHideOnSuspend:
350+
assert(p_type == kMCPlatformPropertyTypeBool);
351+
m_hides_on_suspend = *(bool *)p_value;
352+
m_changes . hides_on_suspend_changed = true;
353+
break;
348354
default:
349355
assert(false);
350356
break;

engine/src/platform.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,21 @@ void MCPlatformCallbackSendApplicationRun(void)
9090

9191
void MCPlatformCallbackSendApplicationSuspend(void)
9292
{
93+
MCLog("Application -> Suspend()", 0);
9394
MCPlatformHandleApplicationSuspend();
9495
}
9596

9697
void MCPlatformCallbackSendApplicationResume(void)
9798
{
99+
MCLog("Application -> Resume()", 0);
98100
MCPlatformHandleApplicationResume();
99101
}
100102

101103
//////////
102104

103105
void MCPlatformCallbackSendScreenParametersChanged(void)
104106
{
105-
MCLog("ScreenParametersChanged()", 0);
107+
MCLog("Application -> ScreenParametersChanged()", 0);
106108
MCPlatformHandleScreenParametersChanged();
107109
}
108110

engine/src/platform.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,8 @@ enum MCPlatformWindowProperty
783783
kMCPlatformWindowPropertySystemId,
784784

785785
kMCPlatformWindowPropertyCursor,
786+
787+
kMCPlatformWindowPropertyHideOnSuspend,
786788
};
787789

788790
void MCPlatformSetWindowProperty(MCPlatformWindowRef window, MCPlatformWindowProperty property, MCPlatformPropertyType type, const void *value);

engine/src/property.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,12 @@ Exec_stat MCProperty::set(MCExecPoint &ep)
20952095
case P_ACTIVATE_PALETTES:
20962096
return ep.getboolean(MCactivatepalettes, line, pos, EE_PROPERTY_NAB);
20972097
case P_HIDE_PALETTES:
2098-
return ep.getboolean(MChidepalettes, line, pos, EE_PROPERTY_NAB);
2098+
stat = ep.getboolean(MChidepalettes, line, pos, EE_PROPERTY_NAB);
2099+
#ifdef _MACOSX
2100+
// MW-2014-04-23: [[ Bug 12080 ]] Make sure we update the hidesOnSuspend of all palettes.
2101+
MCstacks -> hidepaletteschanged();
2102+
#endif
2103+
return stat;
20992104
case P_RAISE_PALETTES:
21002105
// MW-2004-11-17: On Linux, effect a restack if 'raisepalettes' is changed
21012106
// MW-2004-11-24: Altered MCStacklst::restack to find right stack if passed NULL

0 commit comments

Comments
 (0)