Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/inputmethod/qmacinputcontext_mac.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4646#include <qdebug.h>
    4747#include <private/qapplication_p.h>
     48#include <private/qkeymapper_p.h>
    4849
    4950QT_BEGIN_NAMESPACE
     
    5657#endif
    5758
    58 static QTextFormat qt_mac_compose_format()
    59 {
    60     QTextCharFormat ret;
    61     ret.setFontUnderline(true);
    62     return ret;
    63 }
    64 
    6559QMacInputContext::QMacInputContext(QObject *parent)
    66     : QInputContext(parent), composing(false), recursionGuard(false), textDocument(0)
     60    : QInputContext(parent), composing(false), recursionGuard(false), textDocument(0),
     61      keydownEvent(0)
    6762{
    6863//    createTextDocument();
     
    7166QMacInputContext::~QMacInputContext()
    7267{
    73 #ifdef Q_WS_MAC32
     68#ifndef QT_MAC_USE_COCOA
    7469    if(textDocument)
    7570        DeleteTSMDocument(textDocument);
     
    8075QMacInputContext::createTextDocument()
    8176{
    82 #ifdef Q_WS_MAC32
     77#ifndef QT_MAC_USE_COCOA
    8378    if(!textDocument) {
    8479        InterfaceTypeList itl = { kUnicodeDocument };
     
    9792void QMacInputContext::mouseHandler(int pos, QMouseEvent *e)
    9893{
    99 #ifdef Q_WS_MAC32
     94#ifndef QT_MAC_USE_COCOA
    10095    if(e->type() != QEvent::MouseButtonPress)
    10196        return;
     
    106101        reset();
    107102    // ##### handle mouse position
     103#else
     104    Q_UNUSED(pos);
     105    Q_UNUSED(e);
    108106#endif
    109107}
    110108
    111109#if !defined QT_MAC_USE_COCOA
     110
     111static QTextFormat qt_mac_compose_format()
     112{
     113    QTextCharFormat ret;
     114    ret.setFontUnderline(true);
     115    return ret;
     116}
    112117
    113118void QMacInputContext::reset()
     
    133138    return composing;
    134139}
    135 #endif 
     140#endif
    136141
    137142void QMacInputContext::setFocusWidget(QWidget *w)
    138143{
    139144    createTextDocument();
    140 #ifdef Q_WS_MAC32
     145#ifndef QT_MAC_USE_COCOA
    141146    if(w)
    142147        ActivateTSMDocument(textDocument);
     
    148153
    149154
     155#ifndef QT_MAC_USE_COCOA
    150156static EventTypeSpec input_events[] = {
    151157    { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent },
     
    155161static EventHandlerUPP input_proc_handlerUPP = 0;
    156162static EventHandlerRef input_proc_handler = 0;
     163#endif
    157164
    158165void
    159166QMacInputContext::initialize()
    160167{
    161 #ifdef Q_WS_MAC32
     168#ifndef QT_MAC_USE_COCOA
    162169    if(!input_proc_handler) {
    163170        input_proc_handlerUPP = NewEventHandlerUPP(QMacInputContext::globalEventProcessor);
     
    172179QMacInputContext::cleanup()
    173180{
    174 #ifdef Q_WS_MAC32
     181#ifndef QT_MAC_USE_COCOA
    175182    if(input_proc_handler) {
    176183        RemoveEventHandler(input_proc_handler);
     
    184191}
    185192
     193void QMacInputContext::setLastKeydownEvent(EventRef event)
     194{
     195    EventRef tmpEvent = keydownEvent;
     196    keydownEvent = event;
     197    if (keydownEvent)
     198        RetainEvent(keydownEvent);
     199    if (tmpEvent)
     200        ReleaseEvent(tmpEvent);
     201}
     202
    186203OSStatus
    187204QMacInputContext::globalEventProcessor(EventHandlerCallRef, EventRef event, void *)
    188205{
    189 #ifdef Q_WS_MAC32
     206#ifndef QT_MAC_USE_COCOA
    190207    QScopedLoopLevelCounter loopLevelCounter(QApplicationPrivate::instance()->threadData);
    191208
     
    201218        handled_event = false;
    202219        QWidget *widget = QApplicationPrivate::focus_widget;
    203         if(!widget || (context && widget->inputContext() != context)) {
     220        bool canCompose = widget && (!context || widget->inputContext() == context)
     221                && !(widget->inputMethodHints() & Qt::ImhDigitsOnly
     222                || widget->inputMethodHints() & Qt::ImhFormattedNumbersOnly
     223                || widget->inputMethodHints() & Qt::ImhHiddenText);
     224        if(!canCompose) {
    204225            handled_event = false;
    205226        } else if(ekind == kEventTextInputOffsetToPos) {
     
    336357            if(!chr || chr >= 128 || (text.length() > 0 && (text.length() > 1 || text.at(0) != QLatin1Char(chr))))
    337358                handled_event = !widget->testAttribute(Qt::WA_InputMethodEnabled);
     359            QMacInputContext *context = qobject_cast<QMacInputContext*>(qApp->inputContext());
     360            if (context && context->lastKeydownEvent()) {
     361                qt_keymapper_private()->translateKeyEvent(widget, 0, context->lastKeydownEvent(),
     362                                                          0, false);
     363                context->setLastKeydownEvent(0);
     364            }
    338365        }
    339366        break; }
     
    343370    if(!handled_event) //let the event go through
    344371        return eventNotHandledErr;
     372#else
     373    Q_UNUSED(event);
    345374#endif
    346375    return noErr; //we eat the event
Note: See TracChangeset for help on using the changeset viewer.