The TEST_MODE and non-TEST_MODE code is now the same, only the modifiers/keys

are different. Therefore, workspace changes should work on real hardware as
well now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13387 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-07-01 11:22:58 +00:00
parent 0a7d4d9991
commit 1b36d9d743

View File

@ -1474,9 +1474,7 @@ fprintf(stderr, "mouse position changed in B_MOUSE_UP (%.1f, %.1f) from last B_M
void
RootLayer::KeyboardEventHandler(int32 code, BPrivate::PortLink& msg)
{
switch(code)
{
switch (code) {
case B_KEY_DOWN:
{
// Attached Data:
@ -1488,7 +1486,7 @@ RootLayer::KeyboardEventHandler(int32 code, BPrivate::PortLink& msg)
// 6) int8[3] UTF-8 data generated
// 7) Character string generated by the keystroke
// 8) int8[16] state of all keys
bigtime_t time;
int32 scancode, modifiers;
int8 utf[3] = { 0, 0, 0 };
@ -1496,7 +1494,7 @@ RootLayer::KeyboardEventHandler(int32 code, BPrivate::PortLink& msg)
int8 keystates[16];
int32 raw_char;
int32 repeatcount;
msg.Read<bigtime_t>(&time);
msg.Read<int32>(&scancode);
msg.Read<int32>(&raw_char);
@ -1504,201 +1502,131 @@ RootLayer::KeyboardEventHandler(int32 code, BPrivate::PortLink& msg)
msg.Read<int32>(&modifiers);
msg.Read(utf, sizeof(utf));
msg.ReadString(&string);
msg.Read(keystates,sizeof(int8)*16);
msg.Read(keystates, sizeof(keystates));
STRACE(("Key Down: 0x%lx\n",scancode));
// F1-F12
if (scancode > 0x01 && scancode < 0x0e) {
// Check for workspace change or safe video mode
#if !TEST_MODE
// Check for workspace change or safe video mode
if(scancode>0x01 && scancode<0x0e)
{
if(scancode==0x0d)
if (scancode == 0x0d && (modifiers & (B_LEFT_COMMAND_KEY
| B_LEFT_CONTROL_KEY | B_LEFT_SHIFT_KEY)) != 0)
#else
if (scancode == 0x0d && (modifiers & (B_LEFT_CONTROL_KEY
| B_LEFT_SHIFT_KEY | B_LEFT_OPTION_KEY)) != 0)
#endif
{
if(modifiers & (B_LEFT_COMMAND_KEY |
B_LEFT_CONTROL_KEY | B_LEFT_SHIFT_KEY))
{
// TODO: Set to Safe Mode in KeyboardEventHandler:B_KEY_DOWN. (DisplayDriver API change)
STRACE(("Safe Video Mode invoked - code unimplemented\n"));
if (string)
free(string);
break;
}
// TODO: Set to Safe Mode in KeyboardEventHandler:B_KEY_DOWN. (DisplayDriver API change)
STRACE(("Safe Video Mode invoked - code unimplemented\n"));
free(string);
break;
}
if(modifiers & B_CONTROL_KEY)
#if !TEST_MODE
if (modifiers & B_CONTROL_KEY)
#else
if (modifiers & (B_LEFT_SHIFT_KEY | B_LEFT_CONTROL_KEY))
#endif
{
STRACE(("Set Workspace %ld\n",scancode-1));
//TODO: SetWorkspace in KeyboardEventHandler
//SetWorkspace(scancode-2);
if (string)
free(string);
break;
}
}
// Tab key
if(scancode==0x26 && (modifiers & B_CONTROL_KEY))
{
//ServerApp *deskbar=app_server->FindApp("application/x-vnd.Be-TSKB");
//if(deskbar)
//{
WinBorder *exActive = ActiveWinBorder();
WinBorder *exFocus = FocusWinBorder();
if (ActiveWorkspace()->MoveToBack(exActive))
WinBorder* exFocus = FocusWinBorder();
WinBorder* exActive = ActiveWinBorder();
if (SetActiveWorkspace(scancode - 2))
show_final_scene(exFocus, exActive);
//printf("Send Twitcher message key to Deskbar - unimplmemented\n");
if (string)
free(string);
break;
//}
}
// PrintScreen
if(scancode==0xe)
{
if(GetDisplayDriver())
{
char filename[128];
BEntry entry;
sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex);
entry.SetTo(filename);
while(entry.Exists())
{
fScreenShotIndex++;
sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex);
entry.SetTo(filename);
}
fScreenShotIndex++;
GetDisplayDriver()->DumpToFile(filename);
if (string)
free(string);
break;
}
}
#else // TEST_MODE
// F12
if(scancode>0x1 && scancode<0xe)
{
if(scancode==0xd)
{
if(modifiers & (B_LEFT_CONTROL_KEY | B_LEFT_SHIFT_KEY | B_LEFT_OPTION_KEY))
{
// TODO: Set to Safe Mode in KeyboardEventHandler:B_KEY_DOWN. (DisplayDriver API change)
STRACE(("Safe Video Mode invoked - code unimplemented\n"));
if (string)
free(string);
break;
}
}
if(modifiers & (B_LEFT_SHIFT_KEY | B_LEFT_CONTROL_KEY))
{
STRACE(("Set Workspace %ld\n",scancode-1));
WinBorder *exFocus = FocusWinBorder();
WinBorder *exActive = ActiveWinBorder();
if (SetActiveWorkspace(scancode-2))
show_final_scene(exFocus, exActive);
if (string)
free(string);
#ifdef APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER
{
// to draw the current Workspace index on screen.
#ifdef APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER
// to draw the current Workspace index on screen.
#ifndef NEW_CLIPPING
BRegion reg(fVisible);
fDriver->ConstrainClippingRegion(&reg);
Draw(reg.Frame());
fDriver->ConstrainClippingRegion(NULL);
#endif
}
#endif
#endif
free(string);
break;
}
}
//Tab
if(scancode==0x26 && (modifiers & B_SHIFT_KEY))
// Tab key
#if !TEST_MODE
if (scancode == 0x26 && (modifiers & B_CONTROL_KEY))
#else
if (scancode == 0x26 && (modifiers & B_SHIFT_KEY))
#endif
{
STRACE(("Twitcher\n"));
//ServerApp *deskbar=app_server->FindApp("application/x-vnd.Be-TSKB");
//ServerApp *deskbar = app_server->FindApp("application/x-vnd.Be-TSKB");
//if(deskbar)
//{
WinBorder *exActive = ActiveWinBorder();
WinBorder *exFocus = FocusWinBorder();
if (ActiveWorkspace()->MoveToBack(exActive))
show_final_scene(exFocus, exActive);
printf("Send Twitcher message key to Deskbar - unimplmemented\n");
if (string)
free(string);
free(string);
break;
//}
}
#if !TEST_MODE
// PrintScreen
if (scancode == 0xe)
#else
// Pause/Break
if(scancode==0x7f)
if (scancode == 0x7f)
#endif
{
if(GetDisplayDriver())
{
if (GetDisplayDriver()) {
char filename[128];
BEntry entry;
sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex);
entry.SetTo(filename);
while(entry.Exists())
{
fScreenShotIndex++;
sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex);
int32 index = 1;
do {
sprintf(filename, "/boot/home/screen%ld.png", index);
entry.SetTo(filename);
}
fScreenShotIndex++;
} while(entry.Exists());
GetDisplayDriver()->DumpToFile(filename);
if (string)
free(string);
free(string);
break;
}
}
#endif // !TEST_MODE
// We got this far, so apparently it's safe to pass to the active
// window.
if(FocusWinBorder())
{
if (FocusWinBorder()) {
ServerWindow *win = FocusWinBorder()->Window();
if(win)
{
if (win) {
BMessage keymsg(B_KEY_DOWN);
keymsg.AddInt64("when", time);
keymsg.AddInt32("key", scancode);
if(repeatcount > 1)
if (repeatcount > 1)
keymsg.AddInt32("be:key_repeat", repeatcount);
keymsg.AddInt32("modifiers", modifiers);
keymsg.AddData("states", B_UINT8_TYPE, keystates, sizeof(int8) * 16);
for (uint8 i = 0; i < 3; i++)
keymsg.AddInt8("byte", utf[i]);
keymsg.AddString("bytes", string);
keymsg.AddInt32("raw_char", raw_char);
win->SendMessageToClient(&keymsg, B_NULL_TOKEN, true);
}
}
if (string)
free(string);
free(string);
break;
}
case B_KEY_UP:
{
// Attached Data:
@ -1709,24 +1637,24 @@ RootLayer::KeyboardEventHandler(int32 code, BPrivate::PortLink& msg)
// 5) int8[3] UTF-8 data generated
// 6) Character string generated by the keystroke
// 7) int8[16] state of all keys
bigtime_t time;
int32 scancode, modifiers;
int8 utf[3] = { 0, 0, 0 };
char *string = NULL;
int8 keystates[16];
int32 raw_char;
msg.Read<bigtime_t>(&time);
msg.Read<int32>(&scancode);
msg.Read<int32>(&raw_char);
msg.Read<int32>(&modifiers);
msg.Read(utf, sizeof(utf));
msg.ReadString(&string);
msg.Read(keystates,sizeof(int8)*16);
STRACE(("Key Up: 0x%lx\n",scancode));
msg.Read(keystates, sizeof(keystates));
STRACE(("Key Up: 0x%lx\n", scancode));
#if !TEST_MODE
// Tab key
if(scancode==0x26 && (modifiers & B_CONTROL_KEY))
@ -1752,33 +1680,31 @@ RootLayer::KeyboardEventHandler(int32 code, BPrivate::PortLink& msg)
// We got this far, so apparently it's safe to pass to the active
// window.
if(FocusWinBorder())
{
if (FocusWinBorder()) {
ServerWindow *win = FocusWinBorder()->Window();
if(win)
{
if (win) {
BMessage keymsg(B_KEY_UP);
keymsg.AddInt64("when", time);
keymsg.AddInt32("key", scancode);
keymsg.AddInt32("modifiers", modifiers);
keymsg.AddData("states", B_UINT8_TYPE, keystates, sizeof(int8) * 16);
for(uint8 i = 0; i < 3; i++) {
for (uint8 i = 0; i < 3; i++) {
keymsg.AddInt8("byte", utf[i]);
}
keymsg.AddString("bytes", string);
keymsg.AddInt32("raw_char", raw_char);
win->SendMessageToClient(&keymsg, B_NULL_TOKEN, true);
}
}
if (string)
free(string);
free(string);
break;
}
case B_UNMAPPED_KEY_DOWN:
{
// Attached Data: