Changeset 561 for trunk/src/gui/inputmethod/qmacinputcontext_mac.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/inputmethod/qmacinputcontext_mac.cpp
r2 r561 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 46 46 #include <qdebug.h> 47 47 #include <private/qapplication_p.h> 48 #include <private/qkeymapper_p.h> 48 49 49 50 QT_BEGIN_NAMESPACE … … 56 57 #endif 57 58 58 static QTextFormat qt_mac_compose_format()59 {60 QTextCharFormat ret;61 ret.setFontUnderline(true);62 return ret;63 }64 65 59 QMacInputContext::QMacInputContext(QObject *parent) 66 : QInputContext(parent), composing(false), recursionGuard(false), textDocument(0) 60 : QInputContext(parent), composing(false), recursionGuard(false), textDocument(0), 61 keydownEvent(0) 67 62 { 68 63 // createTextDocument(); … … 71 66 QMacInputContext::~QMacInputContext() 72 67 { 73 #if def Q_WS_MAC3268 #ifndef QT_MAC_USE_COCOA 74 69 if(textDocument) 75 70 DeleteTSMDocument(textDocument); … … 80 75 QMacInputContext::createTextDocument() 81 76 { 82 #if def Q_WS_MAC3277 #ifndef QT_MAC_USE_COCOA 83 78 if(!textDocument) { 84 79 InterfaceTypeList itl = { kUnicodeDocument }; … … 97 92 void QMacInputContext::mouseHandler(int pos, QMouseEvent *e) 98 93 { 99 #if def Q_WS_MAC3294 #ifndef QT_MAC_USE_COCOA 100 95 if(e->type() != QEvent::MouseButtonPress) 101 96 return; … … 106 101 reset(); 107 102 // ##### handle mouse position 103 #else 104 Q_UNUSED(pos); 105 Q_UNUSED(e); 108 106 #endif 109 107 } 110 108 111 109 #if !defined QT_MAC_USE_COCOA 110 111 static QTextFormat qt_mac_compose_format() 112 { 113 QTextCharFormat ret; 114 ret.setFontUnderline(true); 115 return ret; 116 } 112 117 113 118 void QMacInputContext::reset() … … 133 138 return composing; 134 139 } 135 #endif 140 #endif 136 141 137 142 void QMacInputContext::setFocusWidget(QWidget *w) 138 143 { 139 144 createTextDocument(); 140 #if def Q_WS_MAC32145 #ifndef QT_MAC_USE_COCOA 141 146 if(w) 142 147 ActivateTSMDocument(textDocument); … … 148 153 149 154 155 #ifndef QT_MAC_USE_COCOA 150 156 static EventTypeSpec input_events[] = { 151 157 { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent }, … … 155 161 static EventHandlerUPP input_proc_handlerUPP = 0; 156 162 static EventHandlerRef input_proc_handler = 0; 163 #endif 157 164 158 165 void 159 166 QMacInputContext::initialize() 160 167 { 161 #if def Q_WS_MAC32168 #ifndef QT_MAC_USE_COCOA 162 169 if(!input_proc_handler) { 163 170 input_proc_handlerUPP = NewEventHandlerUPP(QMacInputContext::globalEventProcessor); … … 172 179 QMacInputContext::cleanup() 173 180 { 174 #if def Q_WS_MAC32181 #ifndef QT_MAC_USE_COCOA 175 182 if(input_proc_handler) { 176 183 RemoveEventHandler(input_proc_handler); … … 184 191 } 185 192 193 void 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 186 203 OSStatus 187 204 QMacInputContext::globalEventProcessor(EventHandlerCallRef, EventRef event, void *) 188 205 { 189 #if def Q_WS_MAC32206 #ifndef QT_MAC_USE_COCOA 190 207 QScopedLoopLevelCounter loopLevelCounter(QApplicationPrivate::instance()->threadData); 191 208 … … 201 218 handled_event = false; 202 219 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) { 204 225 handled_event = false; 205 226 } else if(ekind == kEventTextInputOffsetToPos) { … … 336 357 if(!chr || chr >= 128 || (text.length() > 0 && (text.length() > 1 || text.at(0) != QLatin1Char(chr)))) 337 358 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 } 338 365 } 339 366 break; } … … 343 370 if(!handled_event) //let the event go through 344 371 return eventNotHandledErr; 372 #else 373 Q_UNUSED(event); 345 374 #endif 346 375 return noErr; //we eat the event
Note:
See TracChangeset
for help on using the changeset viewer.