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
+49 -123
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:
@@ -1504,109 +1502,41 @@ 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));
#if !TEST_MODE // F1-F12
if (scancode > 0x01 && scancode < 0x0e) {
// Check for workspace change or safe video mode // Check for workspace change or safe video mode
if(scancode>0x01 && scancode<0x0e) #if !TEST_MODE
{ if (scancode == 0x0d && (modifiers & (B_LEFT_COMMAND_KEY
if(scancode==0x0d) | B_LEFT_CONTROL_KEY | B_LEFT_SHIFT_KEY)) != 0)
{ #else
if(modifiers & (B_LEFT_COMMAND_KEY | if (scancode == 0x0d && (modifiers & (B_LEFT_CONTROL_KEY
B_LEFT_CONTROL_KEY | B_LEFT_SHIFT_KEY)) | B_LEFT_SHIFT_KEY | B_LEFT_OPTION_KEY)) != 0)
#endif
{ {
// TODO: Set to Safe Mode in KeyboardEventHandler:B_KEY_DOWN. (DisplayDriver API change) // TODO: Set to Safe Mode in KeyboardEventHandler:B_KEY_DOWN. (DisplayDriver API change)
STRACE(("Safe Video Mode invoked - code unimplemented\n")); STRACE(("Safe Video Mode invoked - code unimplemented\n"));
if (string)
free(string); free(string);
break; 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();
WinBorder* exActive = ActiveWinBorder();
//TODO: SetWorkspace in KeyboardEventHandler if (SetActiveWorkspace(scancode - 2))
//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))
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
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 #ifdef APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER
{
// to draw the current Workspace index on screen. // to draw the current Workspace index on screen.
#ifndef NEW_CLIPPING #ifndef NEW_CLIPPING
BRegion reg(fVisible); BRegion reg(fVisible);
@@ -1614,18 +1544,21 @@ RootLayer::KeyboardEventHandler(int32 code, BPrivate::PortLink& msg)
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();
@@ -1634,52 +1567,47 @@ RootLayer::KeyboardEventHandler(int32 code, BPrivate::PortLink& msg)
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;
do {
sprintf(filename, "/boot/home/screen%ld.png", index);
entry.SetTo(filename); entry.SetTo(filename);
} while(entry.Exists());
while(entry.Exists())
{
fScreenShotIndex++;
sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex);
entry.SetTo(filename);
}
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);
@@ -1695,10 +1623,10 @@ RootLayer::KeyboardEventHandler(int32 code, BPrivate::PortLink& msg)
} }
} }
if (string)
free(string); free(string);
break; break;
} }
case B_KEY_UP: case B_KEY_UP:
{ {
// Attached Data: // Attached Data:
@@ -1723,9 +1651,9 @@ 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 Up: 0x%lx\n",scancode)); STRACE(("Key Up: 0x%lx\n", scancode));
#if !TEST_MODE #if !TEST_MODE
// Tab key // Tab key
@@ -1753,18 +1681,16 @@ 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]);
} }
@@ -1775,10 +1701,10 @@ RootLayer::KeyboardEventHandler(int32 code, BPrivate::PortLink& msg)
} }
} }
if (string)
free(string); free(string);
break; break;
} }
case B_UNMAPPED_KEY_DOWN: case B_UNMAPPED_KEY_DOWN:
{ {
// Attached Data: // Attached Data: