Fix unresponsive frame after using wxHtmlHelpFrame from a dialog. See #17837

This commit is contained in:
Paul Cornett 2017-07-24 08:56:59 -07:00
parent 572ec50827
commit a533fb141d
2 changed files with 19 additions and 10 deletions

View File

@ -9,6 +9,8 @@
#ifndef _WX_GTK_TOPLEVEL_H_ #ifndef _WX_GTK_TOPLEVEL_H_
#define _WX_GTK_TOPLEVEL_H_ #define _WX_GTK_TOPLEVEL_H_
class WXDLLIMPEXP_CORE wxGUIEventLoop;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxTopLevelWindowGTK // wxTopLevelWindowGTK
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -80,7 +82,7 @@ public:
// viewable from within modal dialogs // viewable from within modal dialogs
virtual void AddGrab(); virtual void AddGrab();
virtual void RemoveGrab(); virtual void RemoveGrab();
virtual bool IsGrabbed() const { return m_grabbed; } virtual bool IsGrabbed() const;
virtual void Refresh( bool eraseBackground = true, virtual void Refresh( bool eraseBackground = true,
@ -158,7 +160,7 @@ private:
bool m_isIconized; bool m_isIconized;
// is the frame currently grabbed explicitly by the application? // is the frame currently grabbed explicitly by the application?
bool m_grabbed; wxGUIEventLoop* m_grabbedEventLoop;
bool m_updateDecorSize; bool m_updateDecorSize;
bool m_deferShowAllowed; bool m_deferShowAllowed;

View File

@ -552,7 +552,7 @@ void wxTopLevelWindowGTK::Init()
m_themeEnabled = true; m_themeEnabled = true;
m_gdkDecor = m_gdkDecor =
m_gdkFunc = 0; m_gdkFunc = 0;
m_grabbed = false; m_grabbedEventLoop = NULL;
m_deferShow = true; m_deferShow = true;
m_deferShowAllowed = true; m_deferShowAllowed = true;
m_updateDecorSize = true; m_updateDecorSize = true;
@ -808,7 +808,7 @@ wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
g_source_remove(m_netFrameExtentsTimerId); g_source_remove(m_netFrameExtentsTimerId);
} }
if (m_grabbed) if (m_grabbedEventLoop)
{ {
wxFAIL_MSG(wxT("Window still grabbed")); wxFAIL_MSG(wxT("Window still grabbed"));
RemoveGrab(); RemoveGrab();
@ -1478,24 +1478,31 @@ void wxTopLevelWindowGTK::SetIconizeState(bool iconize)
void wxTopLevelWindowGTK::AddGrab() void wxTopLevelWindowGTK::AddGrab()
{ {
if (!m_grabbed) if (!m_grabbedEventLoop)
{ {
m_grabbed = true; wxGUIEventLoop eventLoop;
m_grabbedEventLoop = &eventLoop;
gtk_grab_add( m_widget ); gtk_grab_add( m_widget );
wxGUIEventLoop().Run(); eventLoop.Run();
gtk_grab_remove( m_widget ); gtk_grab_remove( m_widget );
m_grabbedEventLoop = NULL;
} }
} }
void wxTopLevelWindowGTK::RemoveGrab() void wxTopLevelWindowGTK::RemoveGrab()
{ {
if (m_grabbed) if (m_grabbedEventLoop)
{ {
gtk_main_quit(); m_grabbedEventLoop->Exit();
m_grabbed = false; m_grabbedEventLoop = NULL;
} }
} }
bool wxTopLevelWindowGTK::IsGrabbed() const
{
return m_grabbedEventLoop != NULL;
}
bool wxTopLevelWindowGTK::IsActive() bool wxTopLevelWindowGTK::IsActive()
{ {
return (this == (wxTopLevelWindowGTK*)g_activeFrame); return (this == (wxTopLevelWindowGTK*)g_activeFrame);