From 0625889c619cb5dd73fee1ee32c37ef96cd54775 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 10 Jan 2008 16:04:57 +0000 Subject: [PATCH] IsModal() now includes also the kMenuWindowLook. Fixes bug #1269. Please review. Added a compile time option to switch off the use of the cached menu windows. Looks like there is a problem with the focus system, if I keep the cached menu window around, it "steals" keyboard events from the main app window after the menu has been opened and closed once. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23343 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 13 +++++++++---- src/kits/interface/Window.cpp | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index b150781200..15245cc32e 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -34,6 +34,7 @@ #include "utf8_functions.h" +#define USE_CACHED_MENUWINDOW 0 using std::nothrow; using BPrivate::BMenuWindow; @@ -1367,12 +1368,14 @@ BMenu::_Hide() window->DetachMenu(); // we don't want to be deleted when the window is removed +#if USE_CACHED_MENUWINDOW if (fSuper != NULL) window->Unlock(); - else { - // it's our window, quit it + else +#endif window->Quit(); - } + // it's our window, quit it + // Delete the menu window used by our submenus _DeleteMenuWindow(); @@ -2022,12 +2025,13 @@ BMenu::_OverSubmenu(BMenuItem *item, BPoint loc) BMenuWindow * BMenu::_MenuWindow() { +#if USE_CACHED_MENUWINDOW if (fCachedMenuWindow == NULL) { char windowName[64]; snprintf(windowName, 64, "%s cached menu", Name()); fCachedMenuWindow = new (nothrow) BMenuWindow(windowName); } - +#endif return fCachedMenuWindow; } @@ -2385,6 +2389,7 @@ BMenu::QuitTracking() menuBar->_RestoreFocus(); fChosenItem = NULL; + fState = MENU_STATE_CLOSED; _Hide(); } diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 6ae9e73aa1..5feee246b9 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -1912,7 +1913,8 @@ BWindow::IsModal() const { return fFeel == B_MODAL_SUBSET_WINDOW_FEEL || fFeel == B_MODAL_APP_WINDOW_FEEL - || fFeel == B_MODAL_ALL_WINDOW_FEEL; + || fFeel == B_MODAL_ALL_WINDOW_FEEL + || fFeel == kMenuWindowFeel; }