Ensure that detached menus don't keep focus grab in wxGTK.

A widget being hidden must remove its focus grab with GTK+, otherwise GTK+
would continue sending all input messages to it but fail to process them
because the widget is not realized any more, resulting in a complete freeze of
the entire program.

Do it when detaching menus from menubar and menubar from the frame to fix just
such a problem in case SetMenuBar() was called while the previous menubar was
opened.

Closes #15221.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74056 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-05-26 13:14:43 +00:00
parent a7587bc4a2
commit 830c06655b

View File

@@ -152,6 +152,18 @@ wxMenuBar::wxMenuBar()
namespace
{
// This should be called when detaching menus to ensure that they don't keep
// focus grab, because if they do, they continue getting all GTK+ messages
// which they can't process any more in their (soon to be) unrealized state.
void
EnsureNoGrab(GtkWidget* widget)
{
#if !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
gtk_widget_hide(widget);
gtk_grab_remove(widget);
#endif // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
}
void
DetachFromFrame(wxMenu* menu, wxFrame* frame)
{
@@ -173,6 +185,8 @@ DetachFromFrame(wxMenu* menu, wxFrame* frame)
DetachFromFrame(menuitem->GetSubMenu(), frame);
node = node->GetNext();
}
EnsureNoGrab(menu->m_menu);
}
void
@@ -260,6 +274,8 @@ void wxMenuBar::Detach()
node = node->GetNext();
}
EnsureNoGrab(m_widget);
wxMenuBarBase::Detach();
}