* Allowed Go() to also work if it was not called from within a window - this

prevented ProcessController from showing its menus.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17587 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-05-25 13:20:15 +00:00
parent 20914efdcf
commit 6d27f962bd
+13 -22
View File
@@ -7,6 +7,7 @@
* Stefano Ceccherini ([email protected]) * Stefano Ceccherini ([email protected])
*/ */
#include <Application.h> #include <Application.h>
#include <Looper.h> #include <Looper.h>
#include <MenuItem.h> #include <MenuItem.h>
@@ -14,8 +15,7 @@
#include <Window.h> #include <Window.h>
struct popup_menu_data struct popup_menu_data {
{
BPopUpMenu *object; BPopUpMenu *object;
BWindow *window; BWindow *window;
BMenuItem *selected; BMenuItem *selected;
@@ -33,9 +33,8 @@ struct popup_menu_data
BPopUpMenu::BPopUpMenu(const char *title, bool radioMode, bool autoRename, BPopUpMenu::BPopUpMenu(const char *title, bool radioMode, bool autoRename,
menu_layout layout) menu_layout layout)
: : BMenu(title, layout),
BMenu(title, layout),
fUseWhere(false), fUseWhere(false),
fAutoDestruct(false), fAutoDestruct(false),
fTrackThread(-1) fTrackThread(-1)
@@ -49,8 +48,7 @@ BPopUpMenu::BPopUpMenu(const char *title, bool radioMode, bool autoRename,
BPopUpMenu::BPopUpMenu(BMessage *archive) BPopUpMenu::BPopUpMenu(BMessage *archive)
: : BMenu(archive),
BMenu(archive),
fUseWhere(false), fUseWhere(false),
fAutoDestruct(false), fAutoDestruct(false),
fTrackThread(-1) fTrackThread(-1)
@@ -86,9 +84,9 @@ BPopUpMenu::Instantiate(BMessage *data)
BMenuItem * BMenuItem *
BPopUpMenu::Go(BPoint where, bool delivers_message, bool open_anyway, bool async) BPopUpMenu::Go(BPoint where, bool deliversMessage, bool openAnyway, bool async)
{ {
return _go(where, delivers_message, open_anyway, NULL, async); return _go(where, deliversMessage, openAnyway, NULL, async);
} }
@@ -247,8 +245,7 @@ BPopUpMenu::ScreenLocation()
} }
// #pragma mark - // #pragma mark - private methods
// private methods
void BPopUpMenu::_ReservedPopUpMenu1() {} void BPopUpMenu::_ReservedPopUpMenu1() {}
@@ -281,9 +278,6 @@ BPopUpMenu::_go(BPoint where, bool autoInvoke, bool startOpened,
BLooper *looper = BLooper::LooperForThread(find_thread(NULL)); BLooper *looper = BLooper::LooperForThread(find_thread(NULL));
BWindow *window = dynamic_cast<BWindow *>(looper); BWindow *window = dynamic_cast<BWindow *>(looper);
if (window == NULL)
return NULL;
popup_menu_data *data = new popup_menu_data; popup_menu_data *data = new popup_menu_data;
sem_id sem = create_sem(0, "window close lock"); sem_id sem = create_sem(0, "window close lock");
@@ -291,7 +285,7 @@ BPopUpMenu::_go(BPoint where, bool autoInvoke, bool startOpened,
// Asynchronous menu: we set the BWindow menu's semaphore // Asynchronous menu: we set the BWindow menu's semaphore
// and let BWindow block when needed // and let BWindow block when needed
if (async) { if (async && window != NULL) {
_set_menu_sem_(window, sem); _set_menu_sem_(window, sem);
} }
@@ -314,7 +308,7 @@ BPopUpMenu::_go(BPoint where, bool autoInvoke, bool startOpened,
else { else {
// Something went wrong. Cleanup and return NULL // Something went wrong. Cleanup and return NULL
delete_sem(sem); delete_sem(sem);
if (async) if (async && window != NULL)
_set_menu_sem_(window, B_BAD_SEM_ID); _set_menu_sem_(window, B_BAD_SEM_ID);
delete data; delete data;
return NULL; return NULL;
@@ -327,9 +321,9 @@ BPopUpMenu::_go(BPoint where, bool autoInvoke, bool startOpened,
// TODO: usually it's not a good idea to check for a particular error // TODO: usually it's not a good idea to check for a particular error
// code. Though here we just want to wait till the semaphore is deleted // code. Though here we just want to wait till the semaphore is deleted
// (it will return B_BAD_SEM_ID in that case), not provide locking or whatever. // (it will return B_BAD_SEM_ID in that case), not provide locking or whatever.
while (acquire_sem_etc(sem, 1, B_TIMEOUT, 50000) != B_BAD_SEM_ID) while (acquire_sem_etc(sem, 1, B_TIMEOUT, 50000) != B_BAD_SEM_ID) {
window->UpdateIfNeeded(); window->UpdateIfNeeded();
}
} }
status_t unused; status_t unused;
@@ -337,9 +331,7 @@ BPopUpMenu::_go(BPoint where, bool autoInvoke, bool startOpened,
; ;
selected = data->selected; selected = data->selected;
delete data; delete data;
} }
return selected; return selected;
@@ -380,7 +372,7 @@ BPopUpMenu::entry(void *arg)
BMenuItem * BMenuItem *
BPopUpMenu::start_track(BPoint where, bool autoInvoke, BPopUpMenu::start_track(BPoint where, bool autoInvoke,
bool startOpened, BRect *_specialRect) bool startOpened, BRect *_specialRect)
{ {
fWhere = where; fWhere = where;
@@ -401,7 +393,6 @@ BPopUpMenu::start_track(BPoint where, bool autoInvoke,
fUseWhere = false; fUseWhere = false;
Hide(); Hide();
be_app->ShowCursor(); be_app->ShowCursor();
fTrackThread = -1; fTrackThread = -1;