Skip to content

Commit

Permalink
Suppress size event when IsMaximized is called on OSX
Browse files Browse the repository at this point in the history
IsMaximized internally calls [NSWindow isZoomed] which triggers a
windowWillResize call. Resize events will be ignored while calling
isZoomed.

Closes wxWidgets#17407.

See wxWidgets#740
  • Loading branch information
TcT2k authored and vadz committed Feb 21, 2018
1 parent 4e5904a commit dd2d62c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/wx/osx/nonownedwnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class WXDLLIMPEXP_CORE wxNonOwnedWindow : public wxNonOwnedWindowBase

void OSXHandleMiniaturize(double WXUNUSED(timestampsec), bool miniaturized);

void OSXSetIgnoreResizing(bool value) { m_ignoreResizing = value; }

void WindowWasPainted();

virtual bool Destroy();
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/osx/cocoa/nonownedwnd.mm
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,12 @@ - (void)windowWillEnterFullScreen:(NSNotification *)notification
{
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
{
Expand Down
4 changes: 4 additions & 0 deletions src/osx/nonownedwnd_osx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ void wxNonOwnedWindow::Init()
{
m_nowpeer = NULL;
m_isNativeWindowWrapper = false;
m_ignoreResizing = false;
}

bool wxNonOwnedWindow::Create(wxWindow *parent,
Expand Down Expand Up @@ -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 !
Expand Down

0 comments on commit dd2d62c

Please sign in to comment.