Ignore:
Timestamp:
Mar 31, 2007, 6:22:28 PM (18 years ago)
Author:
dmik
Message:

Kernel: Added initial DBCS input/output support (thanks to Ko Myung-Hun for patches).

File:
1 edited

Legend:

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

    r154 r169  
    10151015    // some undocumented system values
    10161016   
    1017     SV_WORKAREA_YTOP = 51,           
    1018     SV_WORKAREA_YBOTTOM = 52,           
    1019     SV_WORKAREA_XRIGHT = 53,           
     1017    SV_WORKAREA_YTOP = 51,
     1018    SV_WORKAREA_YBOTTOM = 52,
     1019    SV_WORKAREA_XRIGHT = 53,
    10201020    SV_WORKAREA_XLEFT = 54,
    10211021};
     
    12521252#if 0
    12531253            qDebug( "WM_CHAR:  [%s]", widget->name() );
    1254 #endif           
     1254#endif
    12551255            QWidget *g = QWidget::keyboardGrabber();
    12561256            if ( g )
     
    12761276            }
    12771277            break;
     1278        }
     1279
     1280        case WM_QUERYCONVERTPOS :
     1281        {
     1282            // Ooops, how to get caret pos ?
     1283            /// @todo (r=dmik) we should make usage of the QIMEvent
     1284            //  to query widgets about IME data (see how/where this event
     1285            //  is used across the sources)
     1286
     1287            PRECTL pcp = ( PRECTL )mp1;
     1288            CURSORINFO ci;
     1289
     1290            WinQueryCursorInfo( HWND_DESKTOP, &ci );
     1291
     1292            memset( pcp, 0xFF, sizeof( RECTL ));
     1293
     1294            pcp->xLeft = ci.x;
     1295            pcp->yBottom = ci.y;
     1296            WinMapWindowPoints( ci.hwnd, hwnd, ( PPOINTL )pcp, 2 );
     1297
     1298            RETURN( QCP_CONVERT );
    12781299        }
    12791300
     
    17871808                    USHORT w = r.width();
    17881809                    USHORT h = r.height();
    1789                     // flip y coordinate 
     1810                    // flip y coordinate
    17901811                    y = QApplication::desktop()->height() - (y + h);
    17911812                    WinSetWindowUShort( hwnd, QWS_XRESTORE, x );
     
    18671888            // WM_MINMAXFRAME, because WM_MINMAXFRAME is a pre-process message
    18681889            // (i.e. no actual changes have been made) We need actual changes
    1869             // in order to update the frame strut and send WindowStateChange. 
     1890            // in order to update the frame strut and send WindowStateChange.
    18701891            result = TRUE;
    18711892            rc = QtOldFrameProc( hwnd, msg, mp1, mp2 );
     
    29542975    ascii = ch;
    29552976    if ( ascii > 0x7F ) ascii = 0;
    2956     if ( ch )
    2957         text = QString::fromLocal8Bit( (char*)&ch, 1 );
     2977    if ( ch ) {
     2978        // Note: Ignore the KC_CHAR flag when generating text for a key to get
     2979        // correct (non-null) text even for Alt+Letter combinations (that
     2980        // don't have KC_CHAR set) because processing Alt+Letter shortcuts
     2981        // 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.
     2991            text = QString::fromLocal8Bit( (char *) &chm.chr, 2 );
     2992        }
     2993        else
     2994            text = QString::fromLocal8Bit( (char*) &ch, 1 );
     2995    }
    29582996}
    29592997
     
    30223060    if ( nrecs == maxrecs ) {
    30233061#if defined(QT_CHECK_RANGE)
    3024         qWarning( "Qt: Internal keyboard buffer overflow" );
     3062        qWarning( "Qt: Internal keyboard buffer overflow" );
    30253063#endif
    3026         return;
     3064        return;
    30273065    }
    30283066
     
    30443082
    30453083    if ( sm_blockUserInput ) // block user interaction during session management
    3046         return TRUE;
     3084        return TRUE;
    30473085
    30483086    translateKeyCode( chm, code, ascii, state, text );
    3049 /// @todo (dmik) currently WM_CHARs chars with zero virtual code or zero
    3050 //  scancode are totally ignored. -- are they?
    3051 //    if ( !code || !chm.scancode ) return FALSE;
     3087
     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;
    30523094
    30533095    // Invert state logic
     
    30723114                        // "Alt depressed" event, that must preceed it, will be
    30733115                        // eaten by the system)
    3074                         find_key_rec( Qt::Key_Alt, TRUE ); 
     3116                        find_key_rec( Qt::Key_Alt, TRUE );
    30753117/// @todo (dmik) do the same for other global keys (ALT+TAB, ALT+ESC, CTRL+ESC)
    30763118//  by handling this situation when we obtain/loose focus)
     
    30803122//  that find_key_rec() above should also be removed to get identical behavior for
    30813123//  all stolen keys. This will allow to solve the problem on the Qt application
    3082 //  level if needed (and even in a platform-independent manner). 
     3124//  level if needed (and even in a platform-independent manner).
    30833125                    }
    30843126                    return TRUE;
     
    31273169    }
    31283170
    3129 #if 0   
     3171#if 0
    31303172    qDebug("WM_CHAR: RESULT = %d", (k0 || k1));
    3131 #endif   
     3173#endif
    31323174    return k0 || k1;
    31333175}
Note: See TracChangeset for help on using the changeset viewer.