Changeset 170


Ignore:
Timestamp:
Apr 10, 2007, 11:12:37 PM (18 years ago)
Author:
dmik
Message:

Kernel: Fixed DBCS input/output support (thanks again to Ko Myung-Hun).

Location:
trunk/src/kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel/qapplication_pm.cpp

    r169 r170  
    29802980        // don't have KC_CHAR set) because processing Alt+Letter shortcuts
    29812981        // for non-ASCII letters in widgets (e.g. QPushButton) depends on that.
    2982         if ( !(chm.fs & KC_KEYUP) && (chm.chr & 0xFF) && (chm.chr & 0xFF00) &&
    2983              qt_os2UconvFirstByteTable()[ (chm.chr & 0xFF) ] == 2 ) {
    2984             // We assime we get a DBCS char if both hi and lo bytes of chr are
    2985             // non-zero. Note that this check is performed only for key press
    2986             // events, because key release events (at least for SBCS) often
    2987             // contain a scancode in the hi byte of chr, which is of course
    2988             // doesn't mean DBCS. We also perform a DBCS lead byte check to
    2989             // ensure keys like ESC (that always gives chm=0x011B) are not
    2990             // mistakenly recognized as DBCS.
     2982        if ( (chm.fs & (KC_VIRTUALKEY | KC_CHAR)) == KC_CHAR && (chm.chr & 0xFF00) ) {
     2983            // We assime we get a DBCS char if the above condition is met.
     2984            // DBCS chars seem to have KC_CHAR set but not KC_VIRTUALKEY; we
     2985            // use this to prevent keys like ESC (chm=0x011B) with the non-zero
     2986            // high byte to be mistakenly recognized as DBCS.
    29912987            text = QString::fromLocal8Bit( (char *) &chm.chr, 2 );
    29922988        }
     
    30123008{
    30133009    KeyRec *result = 0;
     3010    if( scan == 0 ) // DBCS chars or user-injected keys
     3011        return result;
     3012
    30143013    for (int i=0; i<nrecs; i++) {
    30153014        if (key_rec[i].scan == scan) {
     
    30353034{
    30363035    KeyRec *result = 0;
     3036    if( code == 0 ) // DBCS chars or user-injected keys
     3037        return result;
     3038
    30373039    for (int i=0; i<nrecs; i++) {
    30383040        if (key_rec[i].code == code) {
     
    30583060                           const QString& text )
    30593061{
     3062    if( scan == 0 && code == 0 ) // DBCS chars or user-injected keys
     3063        return;
     3064
    30603065    if ( nrecs == maxrecs ) {
    30613066#if defined(QT_CHECK_RANGE)
     
    30863091    translateKeyCode( chm, code, ascii, state, text );
    30873092
    3088     // code will be zero for all non-ASCII letters, but I'm not sure when
    3089     // scancode is oficially allowed to be zero and what it means. Anyway,
    3090     // ignore key events when both are zero, because it will not make sense
    3091     // (we will not be able to properly report key releases for such events
    3092     // since all of them will be indexed by the same zero number in key_rec).
    3093     if ( !code && !chm.scancode ) return FALSE;
     3093    // Note: code and/or chm.scancode may be zero here. We cannot ignore such
     3094    // events because, for example, all non-ASCII letters have zero virtual
     3095    // codes, and DBCS characters entered via IME have both zero virtual codes
     3096    // and zero scancodes. However, if both code and chm.scancode are zero
     3097    // (as for DBCS), store_key_rec()/find_key_rec() will do nothing which
     3098    // means that:
     3099    //   1) QKeyEvents will not have the auto-repeat flag set when a key is
     3100    //      being auto-repeated by the system;
     3101    //   2) there will be no QEvent::KeyRelease event corresponding to the
     3102    //      QEvent::KeyPress event.
    30943103
    30953104    // Invert state logic
  • trunk/src/kernel/qfontengine_pm.cpp

    r169 r170  
    232232    int realLen = 0;
    233233    for( int i = 0; i < slen; i++ ) {
    234         bool isDBCSLeadByte = uconvFirstByteTable[ s[ i ] ] == 2;
     234        bool isDBCSLeadByte = uconvFirstByteTable[ (uchar) s[ i ] ] == 2;
    235235        if ( realLen < givenLen ) {
    236236            // enough space, store the glyph
Note: See TracChangeset for help on using the changeset viewer.