Ticket #4648: alternative_cspace_patch.diff

File alternative_cspace_patch.diff, 2.7 KB (added by stippi, 15 years ago)

Achieving the same, but without making FindString() slower.

  • src/kits/interface/Window.cpp

     
    11141114                    // different font encoding per view (it's supposed to be
    11151115                    // converted by _HandleKeyDown() one day)
    11161116                    const char* string;
    1117                     if (msg->FindString("bytes", &string) == B_OK)
    1118                         view->KeyDown(string, strlen(string));
     1117                    ssize_t bytes;
     1118                    if (msg->FindData("bytes", B_STRING_TYPE,
     1119                        (const void**)&string, &bytes) == B_OK) {
     1120                        view->KeyDown(string, bytes);
     1121                    }
    11191122                } else
    11201123                    target->MessageReceived(msg);
    11211124            }
     
    11241127
    11251128        case B_KEY_UP:
    11261129        {
    1127             const char* string = NULL;
    1128             msg->FindString("bytes", &string);
    1129 
    11301130            // TODO: same as above
    1131             if (BView* view = dynamic_cast<BView*>(target))
    1132                 view->KeyUp(string, strlen(string));
    1133             else
     1131            if (BView* view = dynamic_cast<BView*>(target)) {
     1132                const char* string;
     1133                ssize_t bytes;
     1134                if (msg->FindData("bytes", B_STRING_TYPE,
     1135                    (const void**)&string, &bytes) == B_OK) {
     1136                    view->KeyUp(string, bytes);
     1137                }
     1138            } else
    11341139                target->MessageReceived(msg);
    11351140            break;
    11361141        }
  • src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp

     
    11/*
    22 * Copyright 2004-2006, Jérôme Duval. All rights reserved.
    33 * Copyright 2005-2008, Axel Dörfler, axeld@pinc-software.de.
    4  * Copyright 2008, Stephan Aßmus, superstippi@gmx.de.
     4 * Copyright 2008-2009, Stephan Aßmus, superstippi@gmx.de.
    55 *
    66 * Distributed under the terms of the MIT License.
    77 */
     
    4343            fFunctionDepth++;
    4444            fPrepend.Append(' ', fFunctionDepth * 2);
    4545            fFunctionName << className << "::" << functionName << "()";
    46    
     46
    4747            debug_printf("%p -> %s%s {\n", fPointer, fPrepend.String(),
    4848                fFunctionName.String());
    4949        }
    50    
     50
    5151         ~FunctionTracer()
    5252        {
    5353            debug_printf("%p -> %s}\n", fPointer, fPrepend.String());
    5454            fFunctionDepth--;
    5555        }
    56    
     56
    5757    private:
    5858        BString fFunctionName;
    5959        BString fPrepend;
     
    733733            msg->AddInt32("modifiers", fModifiers);
    734734            msg->AddData("states", B_UINT8_TYPE, states, 16);
    735735            if (numBytes > 0) {
    736                 for (int i = 0; i < numBytes; i++) {
     736                for (int i = 0; i < numBytes; i++)
    737737                    msg->AddInt8("byte", (int8)string[i]);
    738                 }
    739                 msg->AddString("bytes", string);
     738                msg->AddData("bytes", B_STRING_TYPE, string, numBytes);
    740739
    741740                if (rawNumBytes <= 0) {
    742741                    rawNumBytes = 1;