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
+2 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2006, Haiku. * Copyright 2001-2007, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -343,7 +343,7 @@ private:
BView* _FindNextNavigable(BView *focus, uint32 flags); BView* _FindNextNavigable(BView *focus, uint32 flags);
BView* _FindPreviousNavigable(BView *focus, BView* _FindPreviousNavigable(BView *focus,
uint32 flags); uint32 flags);
bool _HandleKeyDown(char key, uint32 modifiers); bool _HandleKeyDown(BMessage* event);
void _KeyboardNavigation(); void _KeyboardNavigation();
// Debug (TODO: to be removed) // Debug (TODO: to be removed)
+25 -18
View File
@@ -962,20 +962,15 @@ FrameMoved(origin);
case B_KEY_DOWN: case B_KEY_DOWN:
{ {
uint32 modifiers; if (!_HandleKeyDown(msg)) {
int32 rawChar; if (BView* view = dynamic_cast<BView*>(target)) {
const char *string = NULL; // TODO: cannot use "string" here if we support having different
msg->FindInt32("modifiers", (int32*)&modifiers); // font encoding per view (it's supposed to be converted by
msg->FindInt32("raw_char", &rawChar); // _HandleKeyDown() one day)
msg->FindString("bytes", &string); const char *string = NULL;
if (msg->FindString("bytes", &string) == B_OK)
// TODO: cannot use "string" here if we support having different view->KeyDown(string, strlen(string));
// font encoding per view (it's supposed to be converted by } else
// _HandleKeyDown() one day)
if (!_HandleKeyDown(string[0], (uint32)modifiers)) {
if (BView* view = dynamic_cast<BView*>(target))
view->KeyDown(string, strlen(string));
else
target->MessageReceived(msg); target->MessageReceived(msg);
} }
break; 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 TODO: must also convert the incoming key to the font encoding of the target
*/ */
bool 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 // handle BMenuBar key
if (key == B_ESCAPE && (modifiers & B_COMMAND_KEY) != 0 if (key == B_ESCAPE && (modifiers & B_COMMAND_KEY) != 0
@@ -3116,9 +3119,13 @@ BWindow::_HandleKeyDown(char key, uint32 modifiers)
// Deskbar's Switcher // Deskbar's Switcher
if (key == B_TAB && (modifiers & B_CONTROL_KEY) != 0) { if (key == B_TAB && (modifiers & B_CONTROL_KEY) != 0) {
BMessenger deskbar(kDeskbarSignature); 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'); BMessage message('TASK');
message.AddInt32("key", B_TAB); message.AddInt32("key", rawKey);
message.AddInt32("modifiers", modifiers); message.AddInt32("modifiers", modifiers);
message.AddInt64("when", system_time()); message.AddInt64("when", system_time());
message.AddInt32("team", Team()); message.AddInt32("team", Team());