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