* Shortcut messages now add a boolean "shutdown" field to the message - this
prevents Tracker from being quit by Command+Q. * Also, it's now possible (as on R5) to remove the Command+Q shortcut. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16411 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2006, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -325,6 +325,8 @@ private:
|
|||||||
bigtime_t fPulseRate;
|
bigtime_t fPulseRate;
|
||||||
bool fWaitingForMenu;
|
bool fWaitingForMenu;
|
||||||
bool fMinimized;
|
bool fMinimized;
|
||||||
|
bool fNoQuitShortcut;
|
||||||
|
bool _unused2;
|
||||||
sem_id fMenuSem;
|
sem_id fMenuSem;
|
||||||
float fMaxZoomHeight;
|
float fMaxZoomHeight;
|
||||||
float fMaxZoomWidth;
|
float fMaxZoomWidth;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2006, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -1397,6 +1397,9 @@ BWindow::RemoveShortcut(uint32 key, uint32 modifiers)
|
|||||||
if (shortcut != NULL) {
|
if (shortcut != NULL) {
|
||||||
fShortcuts.RemoveItem(shortcut);
|
fShortcuts.RemoveItem(shortcut);
|
||||||
delete shortcut;
|
delete shortcut;
|
||||||
|
} else if ((key == 'q' || key == 'Q') && modifiers == B_COMMAND_KEY) {
|
||||||
|
// the quit shortcut is a fake shortcut
|
||||||
|
fNoQuitShortcut = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2178,6 +2181,8 @@ BWindow::_InitData(BRect frame, const char* title, window_look look,
|
|||||||
|
|
||||||
// Shortcut 'Q' is handled in _HandleKeyDown() directly, as its message
|
// Shortcut 'Q' is handled in _HandleKeyDown() directly, as its message
|
||||||
// get sent to the application, and not one of our handlers
|
// get sent to the application, and not one of our handlers
|
||||||
|
fNoQuitShortcut = false;
|
||||||
|
|
||||||
if ((fFlags & B_NOT_CLOSABLE) == 0)
|
if ((fFlags & B_NOT_CLOSABLE) == 0)
|
||||||
AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
||||||
|
|
||||||
@@ -2823,9 +2828,11 @@ BWindow::_HandleKeyDown(char key, uint32 modifiers)
|
|||||||
if ((modifiers & B_COMMAND_KEY) != 0) {
|
if ((modifiers & B_COMMAND_KEY) != 0) {
|
||||||
// Command+q has been pressed, so, we will quit
|
// Command+q has been pressed, so, we will quit
|
||||||
// the shortcut mechanism doesn't allow handlers outside the window
|
// the shortcut mechanism doesn't allow handlers outside the window
|
||||||
// TODO: in BeOS, this shortcut can be removed!
|
if (!fNoQuitShortcut && (key == 'Q' || key == 'q')) {
|
||||||
if (key == 'Q' || key == 'q') {
|
BMessage message(B_QUIT_REQUESTED);
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
message.AddBool("shortcut", true);
|
||||||
|
|
||||||
|
be_app->PostMessage(&message);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2846,11 +2853,16 @@ BWindow::_HandleKeyDown(char key, uint32 modifiers)
|
|||||||
if (target == NULL)
|
if (target == NULL)
|
||||||
target = CurrentFocus();
|
target = CurrentFocus();
|
||||||
|
|
||||||
BMessage* message = shortcut->Message();
|
if (shortcut->Message() != NULL) {
|
||||||
if (message->ReplaceInt64("when", system_time()) != B_OK)
|
BMessage message(*shortcut->Message());
|
||||||
message->AddInt64("when", system_time());
|
|
||||||
|
|
||||||
PostMessage(message, target);
|
if (message.ReplaceInt64("when", system_time()) != B_OK)
|
||||||
|
message.AddInt64("when", system_time());
|
||||||
|
if (message.ReplaceBool("shortcut", true) != B_OK)
|
||||||
|
message.AddBool("shortcut", true);
|
||||||
|
|
||||||
|
PostMessage(&message, target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user