Work based on a patch by Joshua R. Elsasser:

* Some key-sequences cause \0 chars in the "bytes" data which is supposed to
  be passed to BView::KeyDown() and BView::KeyUp(). Therefor, one cannot use
  string methods for adding/extracting the data to/from the events. For
  example, Control-Space now works in the Terminal.

Thanks a lot for the original patch, Joshua!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33338 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-09-28 17:13:31 +00:00
parent 1973e58137
commit 8a5e590d5e
2 changed files with 19 additions and 15 deletions
@@ -1,7 +1,7 @@
/* /*
* Copyright 2004-2006, Jérôme Duval. All rights reserved. * Copyright 2004-2006, Jérôme Duval. All rights reserved.
* Copyright 2005-2008, Axel Dörfler, [email protected]. * Copyright 2005-2008, Axel Dörfler, [email protected].
* Copyright 2008, Stephan Aßmus, [email protected]. * Copyright 2008-2009, Stephan Aßmus, [email protected].
* *
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -733,10 +733,9 @@ KeyboardDevice::_ControlThread()
msg->AddInt32("modifiers", fModifiers); msg->AddInt32("modifiers", fModifiers);
msg->AddData("states", B_UINT8_TYPE, states, 16); msg->AddData("states", B_UINT8_TYPE, states, 16);
if (numBytes > 0) { if (numBytes > 0) {
for (int i = 0; i < numBytes; i++) { for (int i = 0; i < numBytes; i++)
msg->AddInt8("byte", (int8)string[i]); msg->AddInt8("byte", (int8)string[i]);
} msg->AddData("bytes", B_STRING_TYPE, string, numBytes);
msg->AddString("bytes", string);
if (rawNumBytes <= 0) { if (rawNumBytes <= 0) {
rawNumBytes = 1; rawNumBytes = 1;
+13 -8
View File
@@ -1114,8 +1114,11 @@ FrameMoved(origin);
// different font encoding per view (it's supposed to be // different font encoding per view (it's supposed to be
// converted by _HandleKeyDown() one day) // converted by _HandleKeyDown() one day)
const char* string; const char* string;
if (msg->FindString("bytes", &string) == B_OK) ssize_t bytes;
view->KeyDown(string, strlen(string)); if (msg->FindData("bytes", B_STRING_TYPE,
(const void**)&string, &bytes) == B_OK) {
view->KeyDown(string, bytes);
}
} else } else
target->MessageReceived(msg); target->MessageReceived(msg);
} }
@@ -1124,13 +1127,15 @@ FrameMoved(origin);
case B_KEY_UP: case B_KEY_UP:
{ {
const char* string = NULL;
msg->FindString("bytes", &string);
// TODO: same as above // TODO: same as above
if (BView* view = dynamic_cast<BView*>(target)) if (BView* view = dynamic_cast<BView*>(target)) {
view->KeyUp(string, strlen(string)); const char* string;
else ssize_t bytes;
if (msg->FindData("bytes", B_STRING_TYPE,
(const void**)&string, &bytes) == B_OK) {
view->KeyUp(string, bytes);
}
} else
target->MessageReceived(msg); target->MessageReceived(msg);
break; break;
} }