Suppress size event when IsMaximized is called on OSX

IsMaximized internally calls [NSWindow isZoomed] which triggers a
windowWillResize call. Resize events will be ignored while calling
isZoomed.

Closes #17407.

See https://github.com/wxWidgets/wxWidgets/pull/740
This commit is contained in:
Tobias Taschner
2018-02-20 17:09:39 +01:00
committed by Vadim Zeitlin
parent 4e5904a4cc
commit dd2d62c703
3 changed files with 13 additions and 1 deletions

View File

@@ -116,6 +116,8 @@ public:
void OSXHandleMiniaturize(double WXUNUSED(timestampsec), bool miniaturized);
void OSXSetIgnoreResizing(bool value) { m_ignoreResizing = value; }
void WindowWasPainted();
virtual bool Destroy();
@@ -154,6 +156,7 @@ private :
#if wxUSE_GRAPHICS_CONTEXT
wxGraphicsPath m_shapePath;
#endif // wxUSE_GRAPHICS_CONTEXT
bool m_ignoreResizing;
};
// list of all frames and modeless dialogs

View File

@@ -998,7 +998,12 @@ bool wxNonOwnedWindowCocoaImpl::IsMaximized() const
{
if (([m_macWindow styleMask] & NSResizableWindowMask) != 0)
{
return [m_macWindow isZoomed];
// isZoomed internally calls windowWillResize which would trigger
// an wxEVT_SIZE. Setting ignore resizing supresses the event
m_wxPeer->OSXSetIgnoreResizing(true);
BOOL result = [m_macWindow isZoomed];
m_wxPeer->OSXSetIgnoreResizing(false);
return result;
}
else
{

View File

@@ -97,6 +97,7 @@ void wxNonOwnedWindow::Init()
{
m_nowpeer = NULL;
m_isNativeWindowWrapper = false;
m_ignoreResizing = false;
}
bool wxNonOwnedWindow::Create(wxWindow *parent,
@@ -306,6 +307,9 @@ void wxNonOwnedWindow::HandleResized( double WXUNUSED(timestampsec) )
void wxNonOwnedWindow::HandleResizing( double WXUNUSED(timestampsec), wxRect* rect )
{
if ( m_ignoreResizing )
return;
wxRect r = *rect ;
// this is a EVT_SIZING not a EVT_SIZE type !