Merge branch 'osx-fix-dialog-level-on-floating-frames-master' of https://github.com/lanurmi/wxWidgets

Closes #4355.
This commit is contained in:
Vadim Zeitlin
2017-02-20 17:54:46 +01:00
2 changed files with 23 additions and 13 deletions

View File

@@ -170,6 +170,7 @@ wxMSW:
wxOSX:
- Fix handling of non-BMP characters in GetPartialTextExtents() (ARATA Mizuki).
- Fix dialogs using wxFRAME_FLOAT_ON_PARENT frame as parent (Lauri Nurmi).
- Implement wxGetDisplaySizeMM() and fix printing DPI (David Vanderson).
- Remove extra borders around wxFilePickerCtrl (John Roberts).
- Set up extensions filter correctly in wxFileDialog (nick863).

View File

@@ -671,7 +671,7 @@ long style, long extraStyle, const wxString& WXUNUSED(name) )
[m_macWindow setAcceptsMouseMovedEvents:YES];
CGWindowLevel level = kCGNormalWindowLevel;
NSInteger level = NSNormalWindowLevel;
if ( style & wxFRAME_TOOL_WINDOW )
{
@@ -679,7 +679,7 @@ long style, long extraStyle, const wxString& WXUNUSED(name) )
}
else if ( ( style & wxPOPUP_WINDOW ) )
{
level = kCGPopUpMenuWindowLevel;
level = NSPopUpMenuWindowLevel;
}
else if ( ( style & wxFRAME_DRAWER ) )
{
@@ -709,10 +709,10 @@ long style, long extraStyle, const wxString& WXUNUSED(name) )
windowstyle |= NSTexturedBackgroundWindowMask;
if ( ( style & wxFRAME_FLOAT_ON_PARENT ) || ( style & wxFRAME_TOOL_WINDOW ) )
level = kCGFloatingWindowLevel;
level = NSFloatingWindowLevel;
if ( ( style & wxSTAY_ON_TOP ) )
level = kCGUtilityWindowLevel;
level = NSModalPanelWindowLevel;
NSRect r = wxToNSRect( NULL, wxRect( pos, size) );
@@ -734,20 +734,20 @@ long style, long extraStyle, const wxString& WXUNUSED(name) )
}
// If the parent is modal, windows with wxFRAME_FLOAT_ON_PARENT style need
// to be in kCGUtilityWindowLevel and not kCGFloatingWindowLevel to stay
// to be in NSModalPanelWindowLevel and not NSFloatingWindowLevel to stay
// above the parent.
wxDialog * const parentDialog = parent == NULL ? NULL : wxDynamicCast(parent->MacGetTopLevelWindow(), wxDialog);
if (parentDialog && parentDialog->IsModal())
{
if (level == kCGFloatingWindowLevel)
if (level == NSFloatingWindowLevel)
{
level = kCGUtilityWindowLevel;
level = NSModalPanelWindowLevel;
}
// Cocoa's modal loop does not process other windows by default, but
// don't call this on normal window levels so nested modal dialogs will
// still behave modally.
if (level != kCGNormalWindowLevel)
if (level != NSNormalWindowLevel)
{
if ([m_macWindow isKindOfClass:[NSPanel class]])
{
@@ -806,14 +806,23 @@ bool wxNonOwnedWindowCocoaImpl::Show(bool show)
{
// add to parent window before showing
wxDialog * const dialog = wxDynamicCast(wxpeer, wxDialog);
if ( wxpeer->GetParent() && dialog && dialog->IsModal())
if ( wxpeer->GetParent() && dialog )
{
NSView * parentView = wxpeer->GetParent()->GetPeer()->GetWXWidget();
if ( parentView )
{
NSWindow* parentNSWindow = [parentView window];
if ( parentNSWindow )
if ( parentNSWindow ) {
[parentNSWindow addChildWindow:m_macWindow ordered:NSWindowAbove];
// If the parent is modal, windows with wxFRAME_FLOAT_ON_PARENT style need
// to be in NSModalPanelWindowLevel and not NSFloatingWindowLevel to stay
// above the parent.
if ([m_macWindow level] == NSFloatingWindowLevel ||
[m_macWindow level] == NSModalPanelWindowLevel) {
m_macWindowLevel = NSModalPanelWindowLevel;
[m_macWindow setLevel:m_macWindowLevel];
}
}
}
}
@@ -881,12 +890,12 @@ void wxNonOwnedWindowCocoaImpl::SetWindowStyleFlag( long style )
// don't mess with native wrapped windows, they might throw an exception when their level is changed
if (!m_wxPeer->IsNativeWindowWrapper() && m_macWindow)
{
CGWindowLevel level = kCGNormalWindowLevel;
NSInteger level = NSNormalWindowLevel;
if (style & wxSTAY_ON_TOP)
level = kCGUtilityWindowLevel;
level = NSModalPanelWindowLevel;
else if (( style & wxFRAME_FLOAT_ON_PARENT ) || ( style & wxFRAME_TOOL_WINDOW ))
level = kCGFloatingWindowLevel;
level = NSFloatingWindowLevel;
[m_macWindow setLevel: level];
m_macWindowLevel = level;