Ticket #12187: wxWidgets-workswhenmodal.2.diff

File wxWidgets-workswhenmodal.2.diff, 1.7 KB (added by gmeeker, 11 years ago)

New patch that only calls worksWhenModal on floating frames

  • src/osx/cocoa/nonownedwnd.mm

     
    1414    #include "wx/nonownedwnd.h"
    1515    #include "wx/frame.h"
    1616    #include "wx/app.h"
     17    #include "wx/dialog.h"
    1718#endif
    1819
    1920#include "wx/osx/private.h"
     
    408409    }
    409410}
    410411
    411 void wxNonOwnedWindowCocoaImpl::Create( wxWindow* WXUNUSED(parent), const wxPoint& pos, const wxSize& size,
     412void wxNonOwnedWindowCocoaImpl::Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
    412413long style, long extraStyle, const wxString& WXUNUSED(name) )
    413414{
    414415    static wxNonOwnedWindowController* controller = NULL;
     
    516517        defer:NO
    517518        ];
    518519
     520    // If the parent is modal, wxFRAME_FLOAT_ON_PARENT
     521    // needs to be in kCGUtilityWindowLevel not kCGFloatingWindowLevel
     522    // to stay above the parent.
     523    wxDialog* parentDialog = wxDynamicCast(parent, wxDialog);
     524    if (parentDialog != NULL && parentDialog->IsModal())
     525    {
     526        if (level == kCGFloatingWindowLevel)
     527        {
     528            level = kCGUtilityWindowLevel;
     529        }
     530
     531        // Cocoa's modal loop does not process other windows by default,
     532        // but don't call this on normal window levels so
     533        // nested modal dialogs will still behave modally.
     534        if (level != kCGNormalWindowLevel)
     535        {
     536            if ([m_macWindow isKindOfClass:[NSPanel class]])
     537            {
     538                [(NSPanel*)m_macWindow setWorksWhenModal:YES];
     539            }
     540        }
     541    }
     542
    519543    [m_macWindow setLevel:level];
    520544
    521545    [m_macWindow setDelegate:controller];