* Contrl-~ now switches between application windows. This is handier than the

mechanism used in BeOS, that is to press Control+Option-Tab (which didn't
  work on Haiku, though).
* Did not change the window switch logic, though, so it's still not really
  nice.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32524 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-08-19 15:45:17 +00:00
parent 105f1c632e
commit 87da7984dc
3 changed files with 85 additions and 39 deletions
+3
View File
@@ -330,7 +330,10 @@ private:
BView* _FindNextNavigable(BView *focus, uint32 flags); BView* _FindNextNavigable(BView *focus, uint32 flags);
BView* _FindPreviousNavigable(BView *focus, uint32 flags); BView* _FindPreviousNavigable(BView *focus, uint32 flags);
void _Switcher(int32 rawKey, uint32 modifiers,
bool repeat);
bool _HandleKeyDown(BMessage* event); bool _HandleKeyDown(BMessage* event);
bool _HandleUnmappedKeyDown(BMessage* event);
void _KeyboardNavigation(); void _KeyboardNavigation();
void _GetDecoratorSize(float* _borderWidth, void _GetDecoratorSize(float* _borderWidth,
+9 -6
View File
@@ -598,10 +598,12 @@ TSwitchManager::MessageReceived(BMessage* message)
// Want to skip TASK msgs posted before the window // Want to skip TASK msgs posted before the window
// was made visible. Better UI feel if we do this. // was made visible. Better UI feel if we do this.
if (time > fSkipUntil) { if (time > fSkipUntil) {
uint32 modifiers; uint32 modifiers = 0;
message->FindInt32("modifiers", (int32*)&modifiers); message->FindInt32("modifiers", (int32*)&modifiers);
Process((modifiers & B_SHIFT_KEY) == 0, int32 key = 0;
(modifiers & B_OPTION_KEY) != 0); message->FindInt32("key", &key);
Process((modifiers & B_SHIFT_KEY) == 0, key == 0x11);
} }
} }
} else } else
@@ -702,8 +704,7 @@ TSwitchManager::MainEntry(BMessage* message)
// Must be a multiple of the delay used above // Must be a multiple of the delay used above
} }
Process((modifierKeys & B_SHIFT_KEY) == 0, Process((modifierKeys & B_SHIFT_KEY) == 0, key == 0x11);
(modifierKeys & B_OPTION_KEY) != 0);
} }
@@ -784,12 +785,14 @@ TSwitchManager::QuickSwitch(BMessage* message)
{ {
uint32 modifiers = 0; uint32 modifiers = 0;
message->FindInt32("modifiers", (int32*)&modifiers); message->FindInt32("modifiers", (int32*)&modifiers);
int32 key = 0;
message->FindInt32("key", &key);
team_id team; team_id team;
if (message->FindInt32("team", &team) == B_OK) { if (message->FindInt32("team", &team) == B_OK) {
bool forward = (modifiers & B_SHIFT_KEY) == 0; bool forward = (modifiers & B_SHIFT_KEY) == 0;
if ((modifiers & B_OPTION_KEY) != 0) { if (key == 0x11) {
// TODO: add the same switch logic we have for apps! // TODO: add the same switch logic we have for apps!
SwitchWindow(team, forward, true); SwitchWindow(team, forward, true);
} else { } else {
+73 -33
View File
@@ -1134,6 +1134,13 @@ FrameMoved(origin);
break; break;
} }
case B_UNMAPPED_KEY_DOWN:
{
if (!_HandleUnmappedKeyDown(msg))
target->MessageReceived(msg);
break;
}
case B_MOUSE_DOWN: case B_MOUSE_DOWN:
{ {
BView* view = dynamic_cast<BView*>(target); BView* view = dynamic_cast<BView*>(target);
@@ -3434,8 +3441,32 @@ BWindow::_TransitForMouseMoved(BView* view, BView* viewUnderMouse) const
} }
/*! /*! Forwards the key to the switcher
Handles keyboard input before it gets forwarded to the target handler. */
void
BWindow::_Switcher(int32 rawKey, uint32 modifiers, bool repeat)
{
// only send the first key press, no repeats
if (repeat)
return;
BMessenger deskbar(kDeskbarSignature);
if (!deskbar.IsValid()) {
// TODO: have some kind of fallback-handling in case the Deskbar is
// not available?
return;
}
BMessage message('TASK');
message.AddInt32("key", rawKey);
message.AddInt32("modifiers", modifiers);
message.AddInt64("when", system_time());
message.AddInt32("team", Team());
deskbar.SendMessage(&message);
}
/*! Handles keyboard input before it gets forwarded to the target handler.
This includes shortcut evaluation, keyboard navigation, etc. This includes shortcut evaluation, keyboard navigation, etc.
\return handled if true, the event was already handled, and will not \return handled if true, the event was already handled, and will not
@@ -3475,21 +3506,12 @@ BWindow::_HandleKeyDown(BMessage* event)
return true; return true;
} }
int32 rawKey;
event->FindInt32("key", &rawKey);
// Deskbar's Switcher // Deskbar's Switcher
if (key == B_TAB && (modifiers & B_CONTROL_KEY) != 0) { if ((key == B_TAB || rawKey == 0x11) && (modifiers & B_CONTROL_KEY) != 0) {
BMessenger deskbar(kDeskbarSignature); _Switcher(rawKey, modifiers, event->HasInt32("be:key_repeat"));
int32 rawKey;
if (event->FindInt32("key", &rawKey) == B_OK
&& !event->HasInt32("be:key_repeat")
&& deskbar.IsValid()) {
// only send the first key press, no repeats
BMessage message('TASK');
message.AddInt32("key", rawKey);
message.AddInt32("modifiers", modifiers);
message.AddInt64("when", system_time());
message.AddInt32("team", Team());
deskbar.SendMessage(&message);
}
return true; return true;
} }
@@ -3502,22 +3524,18 @@ BWindow::_HandleKeyDown(BMessage* event)
return true; return true;
} }
if (key == B_FUNCTION_KEY) { if (key == B_FUNCTION_KEY && rawKey == B_PRINT_KEY) {
// Check for Print Screen BMessage message(B_REFS_RECEIVED);
int32 rawKey; message.AddBool("silent", true);
if (event->FindInt32("key", &rawKey) == B_OK && rawKey == B_PRINT_KEY) {
BMessage message(B_REFS_RECEIVED);
message.AddBool("silent", true);
if ((modifiers & B_CONTROL_KEY) != 0) if ((modifiers & B_CONTROL_KEY) != 0)
message.AddBool("window", true); message.AddBool("window", true);
if ((modifiers & B_SHIFT_KEY) != 0 || (modifiers & B_OPTION_KEY) != 0) if ((modifiers & B_SHIFT_KEY) != 0 || (modifiers & B_OPTION_KEY) != 0)
message.ReplaceBool("silent", false); message.ReplaceBool("silent", false);
be_roster->Launch("application/x-vnd.haiku-screenshot", &message); be_roster->Launch("application/x-vnd.haiku-screenshot", &message);
return true; return true;
}
} }
// Handle shortcuts // Handle shortcuts
@@ -3544,10 +3562,8 @@ BWindow::_HandleKeyDown(BMessage* event)
// example) // example)
if (shortcut->MenuItem() != NULL) { if (shortcut->MenuItem() != NULL) {
BMenu* menu = shortcut->MenuItem()->Menu(); BMenu* menu = shortcut->MenuItem()->Menu();
if (menu != NULL) { if (menu != NULL)
MenuPrivate(menu).InvokeItem(shortcut->MenuItem(), MenuPrivate(menu).InvokeItem(shortcut->MenuItem(), true);
true);
}
} else { } else {
BHandler* target = shortcut->Target(); BHandler* target = shortcut->Target();
if (target == NULL) if (target == NULL)
@@ -3578,6 +3594,30 @@ BWindow::_HandleKeyDown(BMessage* event)
} }
bool
BWindow::_HandleUnmappedKeyDown(BMessage* event)
{
// Only handle special functions when the event targeted the active focus
// view
if (!_IsFocusMessage(event))
return false;
uint32 modifiers;
int32 rawKey;
if (event->FindInt32("modifiers", (int32*)&modifiers) != B_OK
|| event->FindInt32("key", &rawKey))
return false;
// Deskbar's Switcher
if (rawKey == 0x11 && (modifiers & B_CONTROL_KEY) != 0) {
_Switcher(rawKey, modifiers, event->HasInt32("be:key_repeat"));
return true;
}
return false;
}
void void
BWindow::_KeyboardNavigation() BWindow::_KeyboardNavigation()
{ {