From ae94f4da9cb8d845d1dcf7c42cf24fc38fa75771 Mon Sep 17 00:00:00 2001 From: Matthew Griffin <45285214+matthew-griffin@users.noreply.github.com> Date: Fri, 25 Jan 2019 11:51:20 +0000 Subject: [PATCH] Ensure that top level window is active when it's shown in wxQt Under some (not totally clear) circumstances, a TLW can remain inactive after being shown, which is undesirable, as it prevents setting focus to its children from working. Work around this by calling activateWindow() explicitly if necessary. Closes https://github.com/wxWidgets/wxWidgets/pull/1179 --- include/wx/qt/toplevel.h | 1 + src/qt/toplevel.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/wx/qt/toplevel.h b/include/wx/qt/toplevel.h index 2e7bd198ec..5bc66da183 100644 --- a/include/wx/qt/toplevel.h +++ b/include/wx/qt/toplevel.h @@ -29,6 +29,7 @@ public: long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr); + virtual bool Show(bool show = true) wxOVERRIDE; virtual void Maximize(bool maximize = true); virtual void Restore(); virtual void Iconize(bool iconize = true); diff --git a/src/qt/toplevel.cpp b/src/qt/toplevel.cpp index 4ab7344dbb..c9b21a8ca1 100644 --- a/src/qt/toplevel.cpp +++ b/src/qt/toplevel.cpp @@ -62,6 +62,17 @@ bool wxTopLevelWindowQt::Create( wxWindow *parent, wxWindowID winId, return true; } +bool wxTopLevelWindowQt::Show(bool show) +{ + if ( !wxTopLevelWindowBase::Show(show) ) + return false; + + if ( show && !m_qtWindow->isActiveWindow() ) + m_qtWindow->activateWindow(); + + return true; +} + void wxTopLevelWindowQt::Maximize(bool maximize) { QWidget *widget = GetHandle();