From b1530ab8e8a40063102aa9b45e563dab5cc0976e Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Fri, 25 Mar 2005 21:51:02 +0000 Subject: [PATCH] When sending native keydown/keyup events the delivery of the string was broken. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12009 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/RootLayer.cpp | 36 ++++++++++++++++++------------- src/servers/input/InputServer.cpp | 10 +++++---- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/servers/app/RootLayer.cpp b/src/servers/app/RootLayer.cpp index ce8b7a0730..748deadd8b 100644 --- a/src/servers/app/RootLayer.cpp +++ b/src/servers/app/RootLayer.cpp @@ -1246,6 +1246,7 @@ void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg) int8 keystates[16]; int32 raw_char; int32 repeatcount; + int8 strlength; *((int32*)utf)=0; @@ -1255,9 +1256,12 @@ void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg) msg.Read(&repeatcount); msg.Read(&modifiers); msg.Read(utf, sizeof(utf)); + msg.Read(&strlength); msg.ReadString(&string); msg.Read(keystates,sizeof(int8)*16); - + + STRACE(("Key Down: 0x%lx\n",scancode)); + if(DISPLAYDRIVER==HWDRIVER) { // Check for workspace change or safe video mode @@ -1275,19 +1279,19 @@ void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg) break; } } - } - - if(modifiers & B_CONTROL_KEY) - { - STRACE(("Set Workspace %ld\n",scancode-1)); - //TODO: SetWorkspace in KeyboardEventHandler - //SetWorkspace(scancode-2); - if (string) - free(string); - break; - } - + if(modifiers & B_CONTROL_KEY) + { + 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)) { @@ -1405,7 +1409,7 @@ void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg) { BMessage keymsg(B_KEY_DOWN); keymsg.AddInt64("when",time); -// keymsg.AddInt32("modifiers",modifiers); + keymsg.AddInt32("modifiers",modifiers); keymsg.AddInt32("key",scancode); if(repeatcount>1) keymsg.AddInt32("be:key_repeat",repeatcount); @@ -1416,7 +1420,7 @@ void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg) keymsg.AddInt8("byte",utf[i]); } keymsg.AddString("bytes",string); -// keymsg.AddInt32("raw_char",raw_char); + keymsg.AddInt32("raw_char",raw_char); win->SendMessageToClient(&keymsg, B_NULL_TOKEN, true); } @@ -1445,6 +1449,7 @@ void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg) char *string = NULL; int8 keystates[16]; int32 raw_char; + int8 strlength; *((int32*)utf)=0; @@ -1453,6 +1458,7 @@ void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg) msg.Read(&raw_char); msg.Read(&modifiers); msg.Read(utf, sizeof(utf)); + msg.Read(&strlength); msg.ReadString(&string); msg.Read(keystates,sizeof(int8)*16); diff --git a/src/servers/input/InputServer.cpp b/src/servers/input/InputServer.cpp index 05f8c97f10..57a54cda09 100644 --- a/src/servers/input/InputServer.cpp +++ b/src/servers/input/InputServer.cpp @@ -1285,8 +1285,9 @@ InputServer::DispatchEvent(BMessage *message) appsvrlink->Attach(repeatcount); appsvrlink->Attach(modifiers); appsvrlink->Attach(utf8data,sizeof(int8)*3); - appsvrlink->Attach(string.Length()+1); - appsvrlink->Attach(string.String()); + int8 strlength = string.Length()+1; + appsvrlink->Attach(strlength); + appsvrlink->AttachString(string.String()); appsvrlink->Attach(keyarray,sizeof(int8)*16); appsvrlink->Flush(); break; @@ -1314,8 +1315,9 @@ InputServer::DispatchEvent(BMessage *message) appsvrlink->Attach(asciicode); appsvrlink->Attach(modifiers); appsvrlink->Attach(utf8data,sizeof(int8)*3); - appsvrlink->Attach(string.Length()+1); - appsvrlink->Attach(string.String()); + int8 strlength = string.Length() + 1; + appsvrlink->Attach(strlength); + appsvrlink->AttachString(string.String()); appsvrlink->Attach(keyarray,sizeof(int8)*16); appsvrlink->Flush(); break;