X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0ecd03525b34edba886ca83ff724265cd912dbbd..ad653fa23069c5d9378247084f03c9a718c3ad62:/src/gtk/menu.cpp diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 51e23212bc..686761a6be 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -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(); } @@ -537,6 +553,14 @@ static void menuitem_activate(GtkWidget*, wxMenuItem* item) wxMenu* menu = item->GetMenu(); menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1); + + // A lot of existing code, including any program that closes its main + // window from a menu handler and expects the program to exit -- as our own + // minimal sample -- relies on getting an idle event after a menu event. + // But when using Ubuntu Unity detached menus, we get called from a DBUS + // handler called from g_timeout_dispatch() and Glib doesn't send us any + // idle events after it. So ask explicitly for an idle event to get one. + wxWakeUpIdle(); } }