* 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:
@@ -7,6 +7,7 @@
|
||||
* Stefano Ceccherini ([email protected])
|
||||
*/
|
||||
|
||||
|
||||
#include <Application.h>
|
||||
#include <Looper.h>
|
||||
#include <MenuItem.h>
|
||||
@@ -14,8 +15,7 @@
|
||||
#include <Window.h>
|
||||
|
||||
|
||||
struct popup_menu_data
|
||||
{
|
||||
struct popup_menu_data {
|
||||
BPopUpMenu *object;
|
||||
BWindow *window;
|
||||
BMenuItem *selected;
|
||||
@@ -34,8 +34,7 @@ struct popup_menu_data
|
||||
|
||||
BPopUpMenu::BPopUpMenu(const char *title, bool radioMode, bool autoRename,
|
||||
menu_layout layout)
|
||||
:
|
||||
BMenu(title, layout),
|
||||
: BMenu(title, layout),
|
||||
fUseWhere(false),
|
||||
fAutoDestruct(false),
|
||||
fTrackThread(-1)
|
||||
@@ -49,8 +48,7 @@ BPopUpMenu::BPopUpMenu(const char *title, bool radioMode, bool autoRename,
|
||||
|
||||
|
||||
BPopUpMenu::BPopUpMenu(BMessage *archive)
|
||||
:
|
||||
BMenu(archive),
|
||||
: BMenu(archive),
|
||||
fUseWhere(false),
|
||||
fAutoDestruct(false),
|
||||
fTrackThread(-1)
|
||||
@@ -86,9 +84,9 @@ BPopUpMenu::Instantiate(BMessage *data)
|
||||
|
||||
|
||||
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 -
|
||||
// private methods
|
||||
// #pragma mark - private methods
|
||||
|
||||
|
||||
void BPopUpMenu::_ReservedPopUpMenu1() {}
|
||||
@@ -281,9 +278,6 @@ BPopUpMenu::_go(BPoint where, bool autoInvoke, bool startOpened,
|
||||
BLooper *looper = BLooper::LooperForThread(find_thread(NULL));
|
||||
BWindow *window = dynamic_cast<BWindow *>(looper);
|
||||
|
||||
if (window == NULL)
|
||||
return NULL;
|
||||
|
||||
popup_menu_data *data = new popup_menu_data;
|
||||
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
|
||||
// and let BWindow block when needed
|
||||
if (async) {
|
||||
if (async && window != NULL) {
|
||||
_set_menu_sem_(window, sem);
|
||||
}
|
||||
|
||||
@@ -314,7 +308,7 @@ BPopUpMenu::_go(BPoint where, bool autoInvoke, bool startOpened,
|
||||
else {
|
||||
// Something went wrong. Cleanup and return NULL
|
||||
delete_sem(sem);
|
||||
if (async)
|
||||
if (async && window != NULL)
|
||||
_set_menu_sem_(window, B_BAD_SEM_ID);
|
||||
delete data;
|
||||
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
|
||||
// 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.
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
status_t unused;
|
||||
@@ -337,9 +331,7 @@ BPopUpMenu::_go(BPoint where, bool autoInvoke, bool startOpened,
|
||||
;
|
||||
|
||||
selected = data->selected;
|
||||
|
||||
delete data;
|
||||
|
||||
}
|
||||
|
||||
return selected;
|
||||
@@ -401,7 +393,6 @@ BPopUpMenu::start_track(BPoint where, bool autoInvoke,
|
||||
fUseWhere = false;
|
||||
|
||||
Hide();
|
||||
|
||||
be_app->ShowCursor();
|
||||
|
||||
fTrackThread = -1;
|
||||
|
||||
Reference in New Issue
Block a user