From 8a5e590d5e01f1d3221dc5351f78f73268b9b568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 28 Sep 2009 17:13:31 +0000 Subject: [PATCH] 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 --- .../devices/keyboard/KeyboardInputDevice.cpp | 13 ++++++------ src/kits/interface/Window.cpp | 21 ++++++++++++------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp index abc9f53a32..41cb3430e2 100644 --- a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp +++ b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp @@ -1,7 +1,7 @@ /* * Copyright 2004-2006, Jérôme Duval. All rights reserved. * Copyright 2005-2008, Axel Dörfler, axeld@pinc-software.de. - * Copyright 2008, Stephan Aßmus, superstippi@gmx.de. + * Copyright 2008-2009, Stephan Aßmus, superstippi@gmx.de. * * Distributed under the terms of the MIT License. */ @@ -43,17 +43,17 @@ fFunctionDepth++; fPrepend.Append(' ', fFunctionDepth * 2); fFunctionName << className << "::" << functionName << "()"; - + debug_printf("%p -> %s%s {\n", fPointer, fPrepend.String(), fFunctionName.String()); } - + ~FunctionTracer() { debug_printf("%p -> %s}\n", fPointer, fPrepend.String()); fFunctionDepth--; } - + private: BString fFunctionName; BString fPrepend; @@ -733,10 +733,9 @@ KeyboardDevice::_ControlThread() msg->AddInt32("modifiers", fModifiers); msg->AddData("states", B_UINT8_TYPE, states, 16); if (numBytes > 0) { - for (int i = 0; i < numBytes; i++) { + for (int i = 0; i < numBytes; i++) msg->AddInt8("byte", (int8)string[i]); - } - msg->AddString("bytes", string); + msg->AddData("bytes", B_STRING_TYPE, string, numBytes); if (rawNumBytes <= 0) { rawNumBytes = 1; diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index e464fb252f..721efee296 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -1114,8 +1114,11 @@ FrameMoved(origin); // different font encoding per view (it's supposed to be // converted by _HandleKeyDown() one day) const char* string; - if (msg->FindString("bytes", &string) == B_OK) - view->KeyDown(string, strlen(string)); + ssize_t bytes; + if (msg->FindData("bytes", B_STRING_TYPE, + (const void**)&string, &bytes) == B_OK) { + view->KeyDown(string, bytes); + } } else target->MessageReceived(msg); } @@ -1124,13 +1127,15 @@ FrameMoved(origin); case B_KEY_UP: { - const char* string = NULL; - msg->FindString("bytes", &string); - // TODO: same as above - if (BView* view = dynamic_cast(target)) - view->KeyUp(string, strlen(string)); - else + if (BView* view = dynamic_cast(target)) { + const char* string; + ssize_t bytes; + if (msg->FindData("bytes", B_STRING_TYPE, + (const void**)&string, &bytes) == B_OK) { + view->KeyUp(string, bytes); + } + } else target->MessageReceived(msg); break; }