One step closer to the Switcher - still doesn't work, though, but at least the

BWindow code looks okay now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19849 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-01-17 19:38:58 +00:00
parent f212f3bad2
commit 2a720453e1
2 changed files with 27 additions and 20 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2001-2006, Haiku.
* Copyright 2001-2007, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -343,7 +343,7 @@ private:
BView* _FindNextNavigable(BView *focus, uint32 flags);
BView* _FindPreviousNavigable(BView *focus,
uint32 flags);
bool _HandleKeyDown(char key, uint32 modifiers);
bool _HandleKeyDown(BMessage* event);
void _KeyboardNavigation();
// Debug (TODO: to be removed)

View File

@ -962,20 +962,15 @@ FrameMoved(origin);
case B_KEY_DOWN:
{
uint32 modifiers;
int32 rawChar;
const char *string = NULL;
msg->FindInt32("modifiers", (int32*)&modifiers);
msg->FindInt32("raw_char", &rawChar);
msg->FindString("bytes", &string);
// TODO: cannot use "string" here if we support having different
// font encoding per view (it's supposed to be converted by
// _HandleKeyDown() one day)
if (!_HandleKeyDown(string[0], (uint32)modifiers)) {
if (BView* view = dynamic_cast<BView*>(target))
view->KeyDown(string, strlen(string));
else
if (!_HandleKeyDown(msg)) {
if (BView* view = dynamic_cast<BView*>(target)) {
// TODO: cannot use "string" here if we support having different
// font encoding per view (it's supposed to be converted by
// _HandleKeyDown() one day)
const char *string = NULL;
if (msg->FindString("bytes", &string) == B_OK)
view->KeyDown(string, strlen(string));
} else
target->MessageReceived(msg);
}
break;
@ -3092,9 +3087,17 @@ BWindow::_StealMouseMessage(BMessage* message, bool& deleteMessage)
TODO: must also convert the incoming key to the font encoding of the target
*/
bool
BWindow::_HandleKeyDown(char key, uint32 modifiers)
BWindow::_HandleKeyDown(BMessage* event)
{
// TODO: ask people if using 'raw_char' is OK ?
const char *string = NULL;
if (event->FindString("bytes", &string) != B_OK)
return false;
char key = string[0];
uint32 modifiers;
if (event->FindInt32("modifiers", (int32*)&modifiers) != B_OK)
modifiers = 0;
// handle BMenuBar key
if (key == B_ESCAPE && (modifiers & B_COMMAND_KEY) != 0
@ -3116,9 +3119,13 @@ BWindow::_HandleKeyDown(char key, uint32 modifiers)
// Deskbar's Switcher
if (key == B_TAB && (modifiers & B_CONTROL_KEY) != 0) {
BMessenger deskbar(kDeskbarSignature);
if (deskbar.IsValid()) {
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", B_TAB);
message.AddInt32("key", rawKey);
message.AddInt32("modifiers", modifiers);
message.AddInt64("when", system_time());
message.AddInt32("team", Team());