Changeset 561 for trunk/src/gui/kernel/qapplication.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/kernel/qapplication.cpp
r428 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 ** 40 40 ****************************************************************************/ 41 41 42 #include "qplatformdefs.h" 42 43 #include "qabstracteventdispatcher.h" 43 44 #include "qaccessible.h" … … 75 76 #ifdef Q_WS_X11 76 77 #include <private/qt_x11_p.h> 78 #endif 79 80 #if defined(Q_WS_X11) || defined(Q_WS_S60) 77 81 #include "qinputcontextfactory.h" 78 82 #endif 83 84 #include "qguiplatformplugin_p.h" 79 85 80 86 #include <qthread.h> … … 86 92 87 93 #include "qapplication_p.h" 94 #include "qevent_p.h" 88 95 #include "qwidget_p.h" 89 96 90 97 #include "qapplication.h" 91 98 92 #ifdef Q_OS_WINCE 99 #include "qgesture.h" 100 #include "private/qgesturemanager_p.h" 101 102 #ifndef QT_NO_LIBRARY 103 #include "qlibrary.h" 104 #endif 105 106 #ifdef Q_WS_WINCE 93 107 #include "qdatetime.h" 94 108 #include "qguifunctions_wince.h" … … 98 112 #endif 99 113 114 #include "qdatetime.h" 115 116 #ifdef QT_MAC_USE_COCOA 117 #include <private/qt_cocoa_helpers_mac_p.h> 118 #endif 119 100 120 //#define ALIEN_DEBUG 101 121 102 122 static void initResources() 103 123 { 104 #ifdef Q_ OS_WINCE124 #ifdef Q_WS_WINCE 105 125 Q_INIT_RESOURCE(qstyle_wince); 106 126 #else … … 108 128 #endif 109 129 110 #if !defined(QT_NO_DIRECT3D) && defined(Q_WS_WIN)111 Q_INIT_RESOURCE(qpaintengine_d3d);112 #endif113 130 Q_INIT_RESOURCE(qmessagebox); 114 131 #if !defined(QT_NO_PRINTDIALOG) … … 128 145 129 146 #ifndef QT_NO_IM 130 QInputContext *QApplicationPrivate::inputContext ;147 QInputContext *QApplicationPrivate::inputContext = 0; 131 148 #endif 132 149 133 150 bool QApplicationPrivate::quitOnLastWindowClosed = true; 134 151 135 #ifdef Q_ OS_WINCE152 #ifdef Q_WS_WINCE 136 153 int QApplicationPrivate::autoMaximizeThreshold = -1; 137 154 bool QApplicationPrivate::autoSipEnabled = false; 155 #else 156 bool QApplicationPrivate::autoSipEnabled = true; 138 157 #endif 139 158 … … 161 180 #endif 162 181 182 gestureManager = 0; 183 gestureWidget = 0; 184 163 185 if (!self) 164 186 self = this; … … 176 198 flow and main settings. 177 199 178 \ingroup application179 \mainclass180 181 200 QApplication contains the main event loop, where all events from the window 182 201 system and other sources are processed and dispatched. It also handles the 183 application's initialization andfinalization, and provides session184 management. In addition, it handles most system-wide and application-wide185 settings.186 187 For any GUI application using Qt, there is precisely one QApplication202 application's initialization, finalization, and provides session 203 management. In addition, QApplication handles most of the system-wide and 204 application-wide settings. 205 206 For any GUI application using Qt, there is precisely \bold one QApplication 188 207 object, no matter whether the application has 0, 1, 2 or more windows at 189 208 any given time. For non-GUI Qt applications, use QCoreApplication instead, … … 241 260 \endlist 242 261 243 The QApplication object does so much initialization. Hence, it \e{must} be262 Since the QApplication object does so much initialization, it \e{must} be 244 263 created before any other objects related to the user interface are created. 245 Since QApplication also deals with common command line arguments, it is264 QApplication also deals with common command line arguments. Hence, it is 246 265 usually a good idea to create it \e before any interpretation or 247 266 modification of \c argv is done in the application itself. … … 397 416 398 417 QStyle *QApplicationPrivate::app_style = 0; // default application style 418 QString QApplicationPrivate::styleOverride; // style override 399 419 400 420 #ifndef QT_NO_STYLE_STYLESHEET … … 411 431 QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization 412 432 413 Q_GLOBAL_STATIC(QMutex, applicationFontMutex) ;433 Q_GLOBAL_STATIC(QMutex, applicationFontMutex) 414 434 QFont *QApplicationPrivate::app_font = 0; // default application font 415 435 QFont *QApplicationPrivate::sys_font = 0; // default system font … … 433 453 int qt_antialiasing_threshold = -1; 434 454 static int drag_time = 500; 455 #ifdef Q_OS_SYMBIAN 456 // The screens are a bit too small to for your thumb when using only 4 pixels drag distance. 457 static int drag_distance = 8; 458 #else 435 459 static int drag_distance = 4; 460 #endif 436 461 static Qt::LayoutDirection layout_direction = Qt::LeftToRight; 437 462 QSize QApplicationPrivate::app_strut = QSize(0,0); // no default application strut … … 444 469 bool QApplicationPrivate::animate_toolbox = false; 445 470 bool QApplicationPrivate::widgetCount = false; 446 QString* QApplicationPrivate::styleOverride = 0; 447 #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE) 448 bool QApplicationPrivate::inSizeMove = false; 449 #endif 471 bool QApplicationPrivate::load_testability = false; 450 472 #ifdef QT_KEYPAD_NAVIGATION 451 bool QApplicationPrivate::keypadNavigation = false; 473 # ifdef Q_OS_SYMBIAN 474 Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional; 475 # else 476 Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadTabOrder; 477 # endif 452 478 QWidget *QApplicationPrivate::oldEditFocus = 0; 453 479 #endif … … 456 482 static bool force_reverse = false; 457 483 458 static inline boolisAlien(QWidget *widget)484 inline bool QApplicationPrivate::isAlien(QWidget *widget) 459 485 { 460 486 if (!widget) 461 487 return false; 462 #if def Q_WS_MAC// Fake alien behavior on the Mac :)488 #if defined(Q_WS_MAC) // Fake alien behavior on the Mac :) 463 489 return !widget->isWindow() && widget->window()->testAttribute(Qt::WA_DontShowOnScreen); 490 #elif defined(Q_WS_QWS) 491 return !widget->isWindow() 492 # ifdef Q_BACKINGSTORE_SUBSURFACES 493 && !(widget->d_func()->maybeTopData() && widget->d_func()->maybeTopData()->windowSurface) 494 # endif 495 ; 464 496 #else 465 497 return !widget->internalWinId(); … … 469 501 // ######## move to QApplicationPrivate 470 502 // Default application palettes and fonts (per widget type) 471 472 typedef QHash<QByteArray, QPalette> PaletteHash;473 503 Q_GLOBAL_STATIC(PaletteHash, app_palettes) 474 504 PaletteHash *qt_app_palettes_hash() … … 477 507 } 478 508 479 typedef QHash<QByteArray, QFont> FontHash;480 509 Q_GLOBAL_STATIC(FontHash, app_fonts) 481 510 FontHash *qt_app_fonts_hash() … … 497 526 void QApplicationPrivate::process_cmdline() 498 527 { 499 Q_Q(QApplication);500 Q_UNUSED(q);// only static members being used.501 528 // process platform-indep command line 502 529 if (!qt_is_gui_used || !argc) … … 543 570 } else if (qstrcmp(arg, "-reverse") == 0) { 544 571 force_reverse = true; 545 q->setLayoutDirection(Qt::RightToLeft);572 QApplication::setLayoutDirection(Qt::RightToLeft); 546 573 } else if (qstrcmp(arg, "-widgetcount") == 0) { 547 574 widgetCount = true; 575 } else if (qstrcmp(arg, "-testability") == 0) { 576 load_testability = true; 548 577 } else if (arg == "-graphicssystem" && i < argc-1) { 549 578 graphics_system_name = QString::fromLocal8Bit(argv[++i]); … … 556 585 app_style = 0; 557 586 } 558 if (!styleOverride) 559 styleOverride = new QString; 560 *styleOverride = s; 587 styleOverride = s; 561 588 } 562 589 } … … 621 648 \o -graphicssystem, sets the backend to be used for on-screen widgets 622 649 and QPixmaps. Available options are \c{raster} and \c{opengl}. 623 \endlist624 625 The Windows version of Qt supports an additional command line option, if626 Direct3D support has been compiled into Qt:627 \list628 \o -direct3d will make the Direct3D paint engine the default widget629 paint engine in Qt. \bold {This functionality is experimental.}630 650 \endlist 631 651 … … 689 709 On X11, the window system is initialized if \a GUIenabled is true. If 690 710 \a GUIenabled is false, the application does not connect to the X server. 691 On Windows and Mac intosh, currently the window system is always692 initialized, regardless of the value of GUIenabled. This may change in693 future versionsof Qt.711 On Windows and Mac OS, currently the window system is always initialized, 712 regardless of the value of GUIenabled. This may change in future versions 713 of Qt. 694 714 695 715 The following example shows how to create an application that uses a … … 756 776 extern void qt_gui_eval_init(uint); 757 777 qt_gui_eval_init(application_type); 778 #endif 779 780 #ifndef QT_NO_LIBRARY 781 if(load_testability) { 782 QLibrary testLib(QLatin1String("qttestability")); 783 if (testLib.load()) { 784 typedef void (*TasInitialize)(void); 785 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init"); 786 if (initFunction) { 787 initFunction(); 788 } else { 789 qCritical("Library qttestability resolve failed!"); 790 } 791 } else { 792 qCritical("Library qttestability load failed!"); 793 } 794 } 795 796 //make sure the plugin is loaded 797 if (qt_is_gui_used) 798 qt_guiPlatformPlugin(); 758 799 #endif 759 800 } … … 835 876 #endif // Q_WS_X11 836 877 837 838 /*! 878 extern void qInitDrawhelperAsm(); 879 extern int qRegisterGuiVariant(); 880 extern int qUnregisterGuiVariant(); 881 #ifndef QT_NO_STATEMACHINE 882 extern int qRegisterGuiStateMachine(); 883 extern int qUnregisterGuiStateMachine(); 884 #endif 885 886 /*! 887 \fn void QApplicationPrivate::initialize() 888 839 889 Initializes the QApplication object, called from the constructors. 840 890 */ 841 extern void qInitDrawhelperAsm();842 843 891 void QApplicationPrivate::initialize() 844 892 { 845 893 QWidgetPrivate::mapper = new QWidgetMapper; 846 QWidgetPrivate:: uncreatedWidgets = new QWidgetSet;894 QWidgetPrivate::allWidgets = new QWidgetSet; 847 895 if (qt_appType != QApplication::Tty) 848 896 (void) QApplication::style(); // trigger creation of application style 849 897 // trigger registering of QVariant's GUI types 850 extern int qRegisterGuiVariant();851 898 qRegisterGuiVariant(); 899 #ifndef QT_NO_STATEMACHINE 900 // trigger registering of QStateMachine's GUI types 901 qRegisterGuiStateMachine(); 902 #endif 852 903 853 904 is_app_running = true; // no longer starting up … … 862 913 q->setAttribute(Qt::AA_NativeWindows); 863 914 864 #if defined(Q_WS_WIN) 865 // Alien is not currently working on Windows 98 866 if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) 867 q->setAttribute(Qt::AA_NativeWindows); 868 #endif 869 870 #ifdef Q_OS_WINCE 915 #ifdef Q_WS_WINCE 871 916 #ifdef QT_AUTO_MAXIMIZE_THRESHOLD 872 917 autoMaximizeThreshold = QT_AUTO_MAXIMIZE_THRESHOLD; … … 877 922 autoMaximizeThreshold = -1; 878 923 #endif //QT_AUTO_MAXIMIZE_THRESHOLD 879 #endif //Q_ OS_WINCE924 #endif //Q_WS_WINCE 880 925 881 926 // Set up which span functions should be used in raster engine... … … 889 934 #endif 890 935 #ifndef QT_NO_WHEELEVENT 891 #ifdef QT_MAC_USE_COCOA892 QApplicationPrivate::wheel_scroll_lines = 1;893 #else894 936 QApplicationPrivate::wheel_scroll_lines = 3; 895 937 #endif 896 #endif 938 939 if (qt_is_gui_used) 940 initializeMultitouch(); 897 941 } 898 942 … … 978 1022 d->eventDispatcher->closingDown(); 979 1023 d->eventDispatcher = 0; 1024 QApplicationPrivate::is_app_closing = true; 1025 QApplicationPrivate::is_app_running = false; 980 1026 981 1027 delete qt_desktopWidget; 982 1028 qt_desktopWidget = 0; 983 QApplicationPrivate::is_app_closing = true;984 QApplicationPrivate::is_app_running = false;985 1029 986 1030 #ifndef QT_NO_CLIPBOARD … … 989 1033 #endif 990 1034 991 // delete widget mapper 992 if (QWidgetPrivate::mapper) { 993 QWidgetMapper * myMapper = QWidgetPrivate::mapper; 994 QWidgetPrivate::mapper = 0; 995 for (QWidgetMapper::Iterator it = myMapper->begin(); it != myMapper->end(); ++it) { 996 register QWidget *w = *it; 997 if (!w->parent()) // window 998 w->destroy(true, true); 999 } 1000 delete myMapper; 1001 } 1002 1003 // delete uncreated widgets 1004 if (QWidgetPrivate::uncreatedWidgets) { 1005 QWidgetSet *mySet = QWidgetPrivate::uncreatedWidgets; 1006 QWidgetPrivate::uncreatedWidgets = 0; 1007 for (QWidgetSet::Iterator it = mySet->begin(); it != mySet->end(); ++it) { 1035 delete QWidgetPrivate::mapper; 1036 QWidgetPrivate::mapper = 0; 1037 1038 // delete all widgets 1039 if (QWidgetPrivate::allWidgets) { 1040 QWidgetSet *mySet = QWidgetPrivate::allWidgets; 1041 QWidgetPrivate::allWidgets = 0; 1042 for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) { 1008 1043 register QWidget *w = *it; 1009 1044 if (!w->parent()) // window … … 1044 1079 delete QDragManager::self(); 1045 1080 #endif 1081 1082 d->cleanupMultitouch(); 1046 1083 1047 1084 qt_cleanup(); … … 1071 1108 QApplicationPrivate::widgetCount = false; 1072 1109 1110 #ifndef QT_NO_STATEMACHINE 1111 // trigger unregistering of QStateMachine's GUI types 1112 qUnregisterGuiStateMachine(); 1113 #endif 1073 1114 // trigger unregistering of QVariant's GUI types 1074 extern int qUnregisterGuiVariant();1075 1115 qUnregisterGuiVariant(); 1076 1116 } … … 1153 1193 || event->type() == QEvent::Move 1154 1194 || event->type() == QEvent::LanguageChange 1195 || event->type() == QEvent::UpdateSoftKeys 1155 1196 || event->type() == QEvent::InputMethod)) { 1156 1197 for (int i = 0; i < postedEvents->size(); ++i) { … … 1170 1211 } else if (cur.event->type() == QEvent::LanguageChange) { 1171 1212 ; 1213 } else if (cur.event->type() == QEvent::UpdateSoftKeys) { 1214 ; 1172 1215 } else if ( cur.event->type() == QEvent::InputMethod ) { 1173 1216 *(QInputMethodEvent *)(cur.event) = *(QInputMethodEvent *)event; … … 1199 1242 \brief defines a threshold for auto maximizing widgets 1200 1243 1201 The auto maximize threshold is only available as part of Qt for Windows CE. 1244 \bold{The auto maximize threshold is only available as part of Qt for 1245 Windows CE.} 1202 1246 1203 1247 This property defines a threshold for the size of a window as a percentage 1204 1248 of the screen size. If the minimum size hint of a window exceeds the 1205 threshold, calling show() will thencause the window to be maximized1249 threshold, calling show() will cause the window to be maximized 1206 1250 automatically. 1207 1251 1208 Setting the threshold to be 100 or greater means that it will cause it to1209 always be maximized. Setting it to be 50 means that the widget is maximized1210 if the vertical minimum size hint is at least 50% of the vertical screen1211 size.1212 1213 If -1 is specified then this will disablethe feature.1214 1215 On Windows CE the default is -1 (i.e. it is disabled).1252 Setting the threshold to 100 or greater means that the widget will always 1253 be maximized. Alternatively, setting the threshold to 50 means that the 1254 widget will be maximized only if the vertical minimum size hint is at least 1255 50% of the vertical screen size. 1256 1257 Setting the threshold to -1 disables the feature. 1258 1259 On Windows CE the default is -1 (i.e., it is disabled). 1216 1260 On Windows Mobile the default is 40. 1217 1261 */ … … 1222 1266 \brief toggles automatic SIP (software input panel) visibility 1223 1267 1224 The auto SIP property is only available as part of Qt for Windows CE. 1225 1226 Set this property to true to automatically display the SIP when entering 1268 Set this property to \c true to automatically display the SIP when entering 1227 1269 widgets that accept keyboard input. This property only affects widgets with 1228 the WA_InputMethodEnabled attribute set. 1229 */ 1230 1231 #ifdef Q_OS_WINCE 1270 the WA_InputMethodEnabled attribute set, and is typically used to launch 1271 a virtual keyboard on devices which have very few or no keys. 1272 1273 \bold{ The property only has an effect on platforms which use software input 1274 panels, such as Windows CE and Symbian.} 1275 1276 The default is platform dependent. 1277 */ 1278 1279 #ifdef Q_WS_WINCE 1232 1280 void QApplication::setAutoMaximizeThreshold(const int threshold) 1233 1281 { … … 1239 1287 return QApplicationPrivate::autoMaximizeThreshold; 1240 1288 } 1289 #endif 1241 1290 1242 1291 void QApplication::setAutoSipEnabled(const bool enabled) … … 1249 1298 return QApplicationPrivate::autoSipEnabled; 1250 1299 } 1251 #endif1252 1300 1253 1301 #ifndef QT_NO_STYLE_STYLESHEET … … 1291 1339 } 1292 1340 1293 #if defined(Q_WS_X11)1294 if(!QApplicationPrivate::styleOverride)1295 QApplicationPrivate::x11_initialize_style(); // run-time search for default style1296 #endif1297 1341 if (!QApplicationPrivate::app_style) { 1298 1342 // Compile-time search for default style 1299 1343 // 1300 1344 QString style; 1301 if (QApplicationPrivate::styleOverride) { 1302 style = *QApplicationPrivate::styleOverride; 1303 delete QApplicationPrivate::styleOverride; 1304 QApplicationPrivate::styleOverride = 0; 1305 } else { 1306 #if defined(Q_WS_WIN) && defined(Q_OS_WINCE) 1307 if (qt_wince_is_smartphone() || qt_wince_is_pocket_pc()) 1308 style = QLatin1String("WindowsMobile"); 1309 else 1310 style = QLatin1String("WindowsCE"); 1311 1312 #elif defined(Q_WS_WIN) 1313 if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA 1314 && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) 1315 style = QLatin1String("WindowsVista"); 1316 else if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP 1317 && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) 1318 style = QLatin1String("WindowsXP"); 1319 else 1320 style = QLatin1String("Windows"); // default styles for Windows 1321 #elif defined(Q_WS_X11) && defined(Q_OS_SOLARIS) 1322 style = QLatin1String("CDE"); // default style for X11 on Solaris 1323 #elif defined(Q_WS_X11) && defined(Q_OS_IRIX) 1324 style = QLatin1String("SGI"); // default style for X11 on IRIX 1325 #elif defined(Q_WS_X11) || defined(Q_WS_QWS) 1326 style = QLatin1String("Plastique"); // default style for X11 and small devices 1327 #elif defined(Q_WS_MAC) 1328 style = QLatin1String("Macintosh"); // default style for all Mac's 1329 #endif 1330 } 1345 if (!QApplicationPrivate::styleOverride.isEmpty()) 1346 style = QApplicationPrivate::styleOverride; 1347 else 1348 style = QApplicationPrivate::desktopStyleKey(); 1331 1349 1332 1350 QStyle *&app_style = QApplicationPrivate::app_style; … … 1416 1434 #endif // QT_NO_STYLE_STYLESHEET 1417 1435 QApplicationPrivate::app_style = style; 1418 1419 1436 QApplicationPrivate::app_style->setParent(qApp); // take ownership 1420 1437 … … 1553 1570 texts and pixmaps with few colors. With this option, the 1554 1571 application uses system global colors. This works fine for most 1555 applications under X11, but on Windows machinesit may cause1572 applications under X11, but on the Windows platform, it may cause 1556 1573 dithering of non-standard colors. 1557 1574 \o QApplication::CustomColor. Use this option if your application … … 1940 1957 } 1941 1958 1959 /*! \internal 1960 */ 1961 QString QApplicationPrivate::desktopStyleKey() 1962 { 1963 return qt_guiPlatformPlugin()->styleName(); 1964 } 1965 1942 1966 /*! 1943 1967 \property QApplication::windowIcon … … 2012 2036 QWidgetList QApplication::allWidgets() 2013 2037 { 2014 QWidgetList list; 2015 if (QWidgetPrivate::mapper) 2016 list += QWidgetPrivate::mapper->values(); 2017 if (QWidgetPrivate::uncreatedWidgets) 2018 list += QWidgetPrivate::uncreatedWidgets->toList(); 2019 return list; 2038 if (QWidgetPrivate::allWidgets) 2039 return QWidgetPrivate::allWidgets->toList(); 2040 return QWidgetList(); 2020 2041 } 2021 2042 … … 2034 2055 void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) 2035 2056 { 2036 if (focus && focus->window()2037 2057 #ifndef QT_NO_GRAPHICSVIEW 2038 && focus->window()->graphicsProxyWidget() 2039 #endif 2040 ) 2058 if (focus && focus->window()->graphicsProxyWidget()) 2041 2059 return; 2060 #endif 2042 2061 2043 2062 hidden_focus_widget = 0; … … 2057 2076 QWidget *prev = focus_widget; 2058 2077 focus_widget = focus; 2059 2060 2078 #ifndef QT_NO_IM 2061 2079 if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason … … 2071 2089 } 2072 2090 } 2073 #endif 2091 #endif //QT_NO_IM 2074 2092 2075 2093 if(focus_widget) … … 2082 2100 #ifdef QT_KEYPAD_NAVIGATION 2083 2101 if (QApplication::keypadNavigationEnabled()) { 2084 if (prev->hasEditFocus() && reason != Qt::PopupFocusReason) 2102 if (prev->hasEditFocus() && reason != Qt::PopupFocusReason 2103 #ifdef Q_OS_SYMBIAN 2104 && reason != Qt::ActiveWindowFocusReason 2105 #endif 2106 ) 2085 2107 prev->setEditFocus(false); 2108 } 2109 #endif 2110 #ifndef QT_NO_IM 2111 if (focus) { 2112 QInputContext *prevIc; 2113 prevIc = prev->inputContext(); 2114 if (prevIc && prevIc != focus->inputContext()) { 2115 QEvent closeSIPEvent(QEvent::CloseSoftwareInputPanel); 2116 QApplication::sendEvent(prev, &closeSIPEvent); 2117 } 2086 2118 } 2087 2119 #endif … … 2096 2128 if (focus->testAttribute(Qt::WA_InputMethodEnabled)) { 2097 2129 QInputContext *qic = focus->inputContext(); 2098 if (qic && focus_widget->testAttribute(Qt::WA_WState_Created)) 2099 qic->setFocusWidget( focus_widget ); 2130 if (qic && focus->testAttribute(Qt::WA_WState_Created) 2131 && focus->isEnabled()) 2132 qic->setFocusWidget(focus); 2100 2133 } 2101 #endif 2134 #endif //QT_NO_IM 2102 2135 QFocusEvent in(QEvent::FocusIn, reason); 2103 2136 QPointer<QWidget> that = focus; … … 2106 2139 QApplication::sendEvent(that->style(), &in); 2107 2140 } 2108 }2109 emit qApp->focusChanged(prev, focus_widget);2141 emit qApp->focusChanged(prev, focus_widget); 2142 } 2110 2143 } 2111 2144 } … … 2317 2350 d->toolTipFallAsleep.stop(); 2318 2351 } 2319 #ifdef QT_MAC_USE_COCOA2320 } else if (e->type() == QEvent::CocoaRequestModal) {2321 d->_q_runAppModalWindow();2322 #endif2323 2352 } 2324 2353 return QCoreApplication::event(e); … … 2464 2493 * Helper function that returns the new focus widget, but does not set the focus reason. 2465 2494 * Returns 0 if a new focus widget could not be found. 2495 * Shared with QGraphicsProxyWidgetPrivate::findFocusChild() 2466 2496 */ 2467 2497 QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool next) … … 2504 2534 widget \a leave is left. 2505 2535 */ 2506 #if defined(Q_WS_WIN)2507 extern void qt_win_set_cursor(QWidget *, bool);2508 #elif defined(Q_WS_PM)2509 extern void qt_pm_set_cursor(QWidget *, bool);2510 #elif defined(Q_WS_X11)2511 extern void qt_x11_enforce_cursor(QWidget *, bool);2512 #endif2513 2514 2536 void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { 2515 2537 #if 0 … … 2586 2608 for (int i = 0; i < leaveList.size(); ++i) { 2587 2609 w = leaveList.at(i); 2588 if (! qApp->activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {2610 if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { 2589 2611 #if defined(Q_WS_WIN) || defined(Q_WS_PM) || defined(Q_WS_X11) 2590 2612 if (leaveAfterRelease == w) … … 2593 2615 QApplication::sendEvent(w, &leaveEvent); 2594 2616 if (w->testAttribute(Qt::WA_Hover) && 2595 (! qApp->activePopupWidget() || qApp->activePopupWidget() == w->window())) {2617 (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { 2596 2618 Q_ASSERT(instance()); 2597 2619 QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos)); … … 2604 2626 for (int i = 0; i < enterList.size(); ++i) { 2605 2627 w = enterList.at(i); 2606 if (! qApp->activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {2628 if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { 2607 2629 QApplication::sendEvent(w, &enterEvent); 2608 2630 if (w->testAttribute(Qt::WA_Hover) && 2609 (! qApp->activePopupWidget() || qApp->activePopupWidget() == w->window())) {2631 (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { 2610 2632 QHoverEvent he(QEvent::HoverEnter, w->mapFromGlobal(posEnter), QPoint(-1, -1)); 2611 2633 qApp->d_func()->notify_helper(w, &he); … … 2627 2649 break; 2628 2650 if (w->testAttribute(Qt::WA_SetCursor)) { 2629 parentOfLeavingCursor = w->parentWidget(); 2651 QWidget *parent = w->parentWidget(); 2652 while (parent && parent->d_func()->data.in_destructor) 2653 parent = parent->parentWidget(); 2654 parentOfLeavingCursor = parent; 2630 2655 //continue looping, we need to find the downest alien widget with a cursor. 2631 2656 // (downest on the screen) … … 2659 2684 #if defined(Q_WS_WIN) 2660 2685 qt_win_set_cursor(cursorWidget, true); 2686 #elif defined(Q_WS_X11) 2687 qt_x11_enforce_cursor(cursorWidget, true); 2688 #elif defined(Q_WS_S60) 2689 qt_symbian_set_cursor(cursorWidget, true); 2661 2690 #elif defined(Q_WS_PM) 2662 2691 qt_pm_set_cursor(cursorWidget, true); 2663 #elif defined(Q_WS_X11)2664 qt_x11_enforce_cursor(cursorWidget, true);2665 2692 #endif 2666 2693 } … … 2683 2710 if (!modalState()) 2684 2711 return false; 2685 if ( qApp->activePopupWidget() == widget)2712 if (QApplication::activePopupWidget() == widget) 2686 2713 return false; 2687 2714 … … 2772 2799 { 2773 2800 QSet<QWidget*> blocked; 2774 QList<QWidget*> windows = qApp->topLevelWidgets();2801 QList<QWidget*> windows = QApplication::topLevelWidgets(); 2775 2802 for (int i = 0; i < windows.count(); ++i) { 2776 2803 QWidget *window = windows.at(i); … … 2781 2808 enterModal_sys(widget); 2782 2809 2783 windows = qApp->topLevelWidgets();2810 windows = QApplication::topLevelWidgets(); 2784 2811 QEvent e(QEvent::WindowBlocked); 2785 2812 for (int i = 0; i < windows.count(); ++i) { … … 2795 2822 { 2796 2823 QSet<QWidget*> blocked; 2797 QList<QWidget*> windows = qApp->topLevelWidgets();2824 QList<QWidget*> windows = QApplication::topLevelWidgets(); 2798 2825 for (int i = 0; i < windows.count(); ++i) { 2799 2826 QWidget *window = windows.at(i); … … 2804 2831 leaveModal_sys(widget); 2805 2832 2806 windows = qApp->topLevelWidgets();2833 windows = QApplication::topLevelWidgets(); 2807 2834 QEvent e(QEvent::WindowUnblocked); 2808 2835 for (int i = 0; i < windows.count(); ++i) { … … 2827 2854 2828 2855 // the active popup widget always gets the input event 2829 if ( qApp->activePopupWidget())2856 if (QApplication::activePopupWidget()) 2830 2857 return true; 2831 2858 … … 2861 2888 2862 2889 if (!mouseGrabber) 2863 mouseGrabber = buttonDown? buttonDown : alienWidget;2890 mouseGrabber = (buttonDown && !isBlockedByModal(buttonDown)) ? buttonDown : alienWidget; 2864 2891 2865 2892 if (mouseGrabber && mouseGrabber != candidate) { … … 2880 2907 bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, 2881 2908 QWidget *alienWidget, QWidget *nativeWidget, 2882 QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver) 2909 QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver, 2910 bool spontaneous) 2883 2911 { 2884 2912 Q_ASSERT(receiver); … … 2893 2921 QPointer<QWidget> nativeGuard = nativeWidget; 2894 2922 QPointer<QWidget> alienGuard = alienWidget; 2895 QPointer<QWidget> activePopupWidget = qApp->activePopupWidget();2923 QPointer<QWidget> activePopupWidget = QApplication::activePopupWidget(); 2896 2924 2897 2925 const bool graphicsWidget = nativeWidget->testAttribute(Qt::WA_DontShowOnScreen); … … 2933 2961 // leaveAfterRelease is set to null, but we shall not update lastMouseReceiver. 2934 2962 const bool wasLeaveAfterRelease = leaveAfterRelease != 0; 2935 bool result = QApplication::sendSpontaneousEvent(receiver, event); 2963 bool result; 2964 if (spontaneous) 2965 result = QApplication::sendSpontaneousEvent(receiver, event); 2966 else 2967 result = QApplication::sendEvent(receiver, event); 2936 2968 2937 2969 if (!graphicsWidget && leaveAfterRelease && event->type() == QEvent::MouseButtonRelease … … 2962 2994 } 2963 2995 2964 #if defined(Q_WS_WIN) || defined(Q_WS_ PM) || defined(Q_WS_X11)2996 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_PM) 2965 2997 /* 2966 2998 This function should only be called when the widget changes visibility, i.e. … … 2974 3006 { 2975 3007 #ifndef QT_NO_CURSOR 3008 #ifdef Q_WS_QWS 3009 if (!widget || widget->isWindow()) 3010 return; 3011 #else 2976 3012 if (!widget || widget->internalWinId() || widget->isWindow()) 2977 3013 return; 2978 3014 #endif 2979 3015 const bool widgetInShow = widget->isVisible() && !widget->data->in_destructor; 2980 3016 if (!widgetInShow && widget != qt_last_mouse_receiver) … … 3014 3050 3015 3051 // Send enter/leave events followed by a mouse move on the entered widget. 3016 QMouseEvent e(QEvent::MouseMove, pos, globalPos, Qt::NoButton, mouse_buttons, modifier_buttons);3052 QMouseEvent e(QEvent::MouseMove, pos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier); 3017 3053 sendMouseEvent(widgetUnderCursor, &e, widgetUnderCursor, tlw, &qt_button_down, qt_last_mouse_receiver); 3018 3054 #endif // QT_NO_CURSOR … … 3489 3525 return; 3490 3526 qApp->d_func()->cursor_list.removeFirst(); 3527 #ifdef QT_MAC_USE_COCOA 3528 // We use native NSCursor stacks in Cocoa. The currentCursor is the 3529 // top of this stack. So to avoid flickering of cursor, we have to 3530 // change the cusor instead of pop-ing the existing OverrideCursor 3531 // and pushing the new one. 3532 qApp->d_func()->cursor_list.prepend(cursor); 3533 qt_cocoaChangeOverrideCursor(cursor); 3534 return; 3535 #endif 3491 3536 setOverrideCursor(cursor); 3492 3537 } … … 3519 3564 We recommend that you connect clean-up code to the 3520 3565 \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your 3521 application's \c{main()} function becauseon some platforms the3522 QApplication::exec() call may not return. For example, on Windows when the3523 user logs off, the system terminates the process after Qt closes all3524 top-level windows. Hence, there is no guarantee that the application will3525 have time to exit its event loop and execute code at the end ofthe3526 \c{main()} functionafter the QApplication::exec() call.3566 application's \c{main()} function. This is because, on some platforms the 3567 QApplication::exec() call may not return. For example, on the Windows 3568 platform, when the user logs off, the system terminates the process after Qt 3569 closes all top-level windows. Hence, there is \e{no guarantee} that the 3570 application will have time to exit its event loop and execute code at the 3571 end of the \c{main()} function, after the QApplication::exec() call. 3527 3572 3528 3573 \sa quitOnLastWindowClosed, quit(), exit(), processEvents(), … … 3574 3619 else 3575 3620 QApplicationPrivate::mouse_buttons &= ~me->button(); 3576 }3621 } 3577 3622 #if !defined(QT_NO_WHEELEVENT) || !defined(QT_NO_TABLETEVENT) 3578 else if (3623 else if (false 3579 3624 # ifndef QT_NO_WHEELEVENT 3580 e->type() == QEvent::Wheel ||3625 || e->type() == QEvent::Wheel 3581 3626 # endif 3582 3627 # ifndef QT_NO_TABLETEVENT 3583 e->type() == QEvent::TabletMove3584 || e->type() == QEvent::TabletPress3585 || e->type() == QEvent::TabletRelease3628 || e->type() == QEvent::TabletMove 3629 || e->type() == QEvent::TabletPress 3630 || e->type() == QEvent::TabletRelease 3586 3631 # endif 3587 ) {3632 ) { 3588 3633 QInputEvent *ie = static_cast<QInputEvent*>(e); 3589 3634 QApplicationPrivate::modifier_buttons = ie->modifiers(); … … 3591 3636 #endif // !QT_NO_WHEELEVENT || !QT_NO_TABLETEVENT 3592 3637 } 3638 3639 // walk through parents and check for gestures 3640 if (d->gestureManager) { 3641 switch (e->type()) { 3642 case QEvent::Paint: 3643 case QEvent::MetaCall: 3644 case QEvent::DeferredDelete: 3645 case QEvent::DragEnter: case QEvent::DragMove: case QEvent::DragLeave: 3646 case QEvent::Drop: case QEvent::DragResponse: 3647 case QEvent::ChildAdded: case QEvent::ChildPolished: 3648 #ifdef QT3_SUPPORT 3649 case QEvent::ChildInsertedRequest: 3650 case QEvent::ChildInserted: 3651 case QEvent::LayoutHint: 3652 #endif 3653 case QEvent::ChildRemoved: 3654 case QEvent::UpdateRequest: 3655 case QEvent::UpdateLater: 3656 case QEvent::AccessibilityPrepare: 3657 case QEvent::LocaleChange: 3658 case QEvent::Style: 3659 case QEvent::IconDrag: 3660 case QEvent::StyleChange: 3661 case QEvent::AccessibilityHelp: 3662 case QEvent::AccessibilityDescription: 3663 case QEvent::GraphicsSceneDragEnter: 3664 case QEvent::GraphicsSceneDragMove: 3665 case QEvent::GraphicsSceneDragLeave: 3666 case QEvent::GraphicsSceneDrop: 3667 case QEvent::DynamicPropertyChange: 3668 case QEvent::NetworkReplyUpdated: 3669 break; 3670 default: 3671 if (receiver->isWidgetType()) { 3672 if (d->gestureManager->filterEvent(static_cast<QWidget *>(receiver), e)) 3673 return true; 3674 } else { 3675 // a special case for events that go to QGesture objects. 3676 // We pass the object to the gesture manager and it'll figure 3677 // out if it's QGesture or not. 3678 if (d->gestureManager->filterEvent(receiver, e)) 3679 return true; 3680 } 3681 } 3682 } 3683 3593 3684 3594 3685 // User input and window activation makes tooltips sleep … … 3604 3695 case QEvent::MouseButtonDblClick: 3605 3696 d->toolTipFallAsleep.stop(); 3697 // fall-through 3606 3698 case QEvent::Leave: 3607 3699 d->toolTipWakeUp.stop(); … … 3719 3811 3720 3812 if (e->spontaneous()) { 3813 #ifndef QT_NO_IM 3814 QInputContext *ic = w->inputContext(); 3815 if (ic 3816 && w->testAttribute(Qt::WA_InputMethodEnabled) 3817 && ic->filterEvent(mouse)) 3818 return true; 3819 #endif 3721 3820 3722 3821 if (e->type() == QEvent::MouseButtonPress) { 3723 QWidget *fw = w; 3724 while (fw) { 3725 if (fw->isEnabled() 3726 && QApplicationPrivate::shouldSetFocus(fw, Qt::ClickFocus)) { 3727 fw->setFocus(Qt::MouseFocusReason); 3728 break; 3729 } 3730 if (fw->isWindow()) 3731 break; 3732 fw = fw->parentWidget(); 3733 } 3822 QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, 3823 Qt::ClickFocus, 3824 Qt::MouseFocusReason); 3734 3825 } 3735 3826 3827 // ### Qt 5 These dynamic tool tips should be an OPT-IN feature. Some platforms 3828 // like Mac OS X (probably others too), can optimize their views by not 3829 // dispatching mouse move events. We have attributes to control hover, 3830 // and mouse tracking, but as long as we are deciding to implement this 3831 // feature without choice of opting-in or out, you ALWAYS have to have 3832 // tracking enabled. Therefore, the other properties give a false sense of 3833 // performance enhancement. 3736 3834 if (e->type() == QEvent::MouseMove && mouse->buttons() == 0) { 3737 3835 d->toolTipWidget = w; … … 3790 3888 while (w) { 3791 3889 if (w->testAttribute(Qt::WA_Hover) && 3792 (! qApp->activePopupWidget() || qApp->activePopupWidget() == w->window())) {3890 (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { 3793 3891 QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff); 3794 3892 d->notify_helper(w, &he); … … 3813 3911 3814 3912 if (e->spontaneous()) { 3815 QWidget *fw = w; 3816 while (fw) { 3817 if (fw->isEnabled() 3818 && QApplicationPrivate::shouldSetFocus(fw, Qt::WheelFocus)) { 3819 fw->setFocus(Qt::MouseFocusReason); 3820 break; 3821 } 3822 if (fw->isWindow()) 3823 break; 3824 fw = fw->parentWidget(); 3825 } 3913 QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, 3914 Qt::WheelFocus, 3915 Qt::MouseFocusReason); 3826 3916 } 3827 3917 … … 4028 4118 break; 4029 4119 #endif 4030 4120 case QEvent::TouchBegin: 4121 // Note: TouchUpdate and TouchEnd events are never propagated 4122 { 4123 QWidget *widget = static_cast<QWidget *>(receiver); 4124 QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e); 4125 bool eventAccepted = touchEvent->isAccepted(); 4126 if (widget->testAttribute(Qt::WA_AcceptTouchEvents) && e->spontaneous()) { 4127 // give the widget focus if the focus policy allows it 4128 QApplicationPrivate::giveFocusAccordingToFocusPolicy(widget, 4129 Qt::ClickFocus, 4130 Qt::MouseFocusReason); 4131 } 4132 4133 while (widget) { 4134 // first, try to deliver the touch event 4135 bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents); 4136 touchEvent->setWidget(widget); 4137 touchEvent->setAccepted(acceptTouchEvents); 4138 QWeakPointer<QWidget> p = widget; 4139 res = acceptTouchEvents && d->notify_helper(widget, touchEvent); 4140 eventAccepted = touchEvent->isAccepted(); 4141 if (p.isNull()) { 4142 // widget was deleted 4143 widget = 0; 4144 } else { 4145 widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted); 4146 } 4147 touchEvent->spont = false; 4148 if (res && eventAccepted) { 4149 // the first widget to accept the TouchBegin gets an implicit grab. 4150 for (int i = 0; i < touchEvent->touchPoints().count(); ++i) { 4151 const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i); 4152 d->widgetForTouchPointId[touchPoint.id()] = widget; 4153 } 4154 break; 4155 } else if (p.isNull() || widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) { 4156 break; 4157 } 4158 QPoint offset = widget->pos(); 4159 widget = widget->parentWidget(); 4160 touchEvent->setWidget(widget); 4161 for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) { 4162 QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i]; 4163 QRectF rect = pt.rect(); 4164 rect.moveCenter(offset); 4165 pt.d->rect = rect; 4166 pt.d->startPos = pt.startPos() + offset; 4167 pt.d->lastPos = pt.lastPos() + offset; 4168 } 4169 } 4170 4171 touchEvent->setAccepted(eventAccepted); 4172 break; 4173 } 4174 case QEvent::RequestSoftwareInputPanel: 4175 case QEvent::CloseSoftwareInputPanel: 4176 #ifndef QT_NO_IM 4177 if (receiver->isWidgetType()) { 4178 QWidget *w = static_cast<QWidget *>(receiver); 4179 QInputContext *ic = w->inputContext(); 4180 if (ic && ic->filterEvent(e)) { 4181 break; 4182 } 4183 } 4184 #endif 4185 res = d->notify_helper(receiver, e); 4186 break; 4187 4188 case QEvent::NativeGesture: 4189 { 4190 // only propagate the first gesture event (after the GID_BEGIN) 4191 QWidget *w = static_cast<QWidget *>(receiver); 4192 while (w) { 4193 e->ignore(); 4194 res = d->notify_helper(w, e); 4195 if ((res && e->isAccepted()) || w->isWindow()) 4196 break; 4197 w = w->parentWidget(); 4198 } 4199 break; 4200 } 4201 case QEvent::Gesture: 4202 case QEvent::GestureOverride: 4203 { 4204 if (receiver->isWidgetType()) { 4205 QWidget *w = static_cast<QWidget *>(receiver); 4206 QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(e); 4207 QList<QGesture *> allGestures = gestureEvent->gestures(); 4208 4209 bool eventAccepted = gestureEvent->isAccepted(); 4210 bool wasAccepted = eventAccepted; 4211 while (w) { 4212 // send only gestures the widget expects 4213 QList<QGesture *> gestures; 4214 QWidgetPrivate *wd = w->d_func(); 4215 for (int i = 0; i < allGestures.size();) { 4216 QGesture *g = allGestures.at(i); 4217 Qt::GestureType type = g->gestureType(); 4218 QMap<Qt::GestureType, Qt::GestureFlags>::iterator contextit = 4219 wd->gestureContext.find(type); 4220 bool deliver = contextit != wd->gestureContext.end() && 4221 (g->state() == Qt::GestureStarted || w == receiver || 4222 (contextit.value() & Qt::ReceivePartialGestures)); 4223 if (deliver) { 4224 allGestures.removeAt(i); 4225 gestures.append(g); 4226 } else { 4227 ++i; 4228 } 4229 } 4230 if (!gestures.isEmpty()) { // we have gestures for this w 4231 QGestureEvent ge(gestures); 4232 ge.t = gestureEvent->t; 4233 ge.spont = gestureEvent->spont; 4234 ge.m_accept = wasAccepted; 4235 ge.d_func()->accepted = gestureEvent->d_func()->accepted; 4236 res = d->notify_helper(w, &ge); 4237 gestureEvent->spont = false; 4238 eventAccepted = ge.isAccepted(); 4239 for (int i = 0; i < gestures.size(); ++i) { 4240 QGesture *g = gestures.at(i); 4241 if ((res && eventAccepted) || (!eventAccepted && ge.isAccepted(g))) { 4242 // if the gesture was accepted, mark the target widget for it 4243 gestureEvent->d_func()->targetWidgets[g->gestureType()] = w; 4244 gestureEvent->setAccepted(g, true); 4245 } else if (!eventAccepted && !ge.isAccepted(g)) { 4246 // if the gesture was explicitly ignored by the application, 4247 // put it back so a parent can get it 4248 allGestures.append(g); 4249 } 4250 } 4251 } 4252 if (allGestures.isEmpty()) // everything delivered 4253 break; 4254 if (w->isWindow()) 4255 break; 4256 w = w->parentWidget(); 4257 } 4258 foreach (QGesture *g, allGestures) 4259 gestureEvent->setAccepted(g, false); 4260 gestureEvent->m_accept = false; // to make sure we check individual gestures 4261 } else { 4262 res = d->notify_helper(receiver, e); 4263 } 4264 break; 4265 } 4031 4266 default: 4032 4267 res = d->notify_helper(receiver, e); … … 4046 4281 QWidget *widget = static_cast<QWidget *>(receiver); 4047 4282 4048 #if !defined(Q_ OS_WINCE) || (defined(GWES_ICONCURS) && !defined(QT_NO_CURSOR))4283 #if !defined(Q_WS_WINCE) || (defined(GWES_ICONCURS) && !defined(QT_NO_CURSOR)) 4049 4284 // toggle HasMouse widget state on enter and leave 4050 4285 if ((e->type() == QEvent::Enter || e->type() == QEvent::DragEnter) && 4051 (! qApp->activePopupWidget() || qApp->activePopupWidget() == widget->window()))4286 (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == widget->window())) 4052 4287 widget->setAttribute(Qt::WA_UnderMouse, true); 4053 4288 else if (e->type() == QEvent::Leave || e->type() == QEvent::DragLeave) … … 4074 4309 \class QSessionManager 4075 4310 \brief The QSessionManager class provides access to the session manager. 4076 4077 \ingroup application4078 \ingroup environment4079 4311 4080 4312 A session manager in a desktop environment (in which Qt GUI applications … … 4376 4608 // We will use the following information to create the GUID 4377 4609 // 1. absolute path to application 4378 wchar_t tempFilename[ 512];4379 if (!GetModuleFileName W(0, tempFilename, 512))4610 wchar_t tempFilename[MAX_PATH]; 4611 if (!GetModuleFileName(0, tempFilename, MAX_PATH)) 4380 4612 return S_FALSE; 4381 unsigned int hash = qHash(QString::from Utf16((const unsigned short *)tempFilename));4613 unsigned int hash = qHash(QString::fromWCharArray(tempFilename)); 4382 4614 guid->Data1 = hash; 4383 4615 // 2. creation time of file 4384 QFileInfo info(QString::from Utf16((const unsigned short *)tempFilename));4616 QFileInfo info(QString::fromWCharArray(tempFilename)); 4385 4617 guid->Data2 = qHash(info.created().toTime_t()); 4386 4618 // 3. current system time … … 4416 4648 CoCreateGuid(&guid); 4417 4649 StringFromGUID2(guid, guidstr, 40); 4418 id = QString::from Utf16((ushort*)guidstr);4650 id = QString::fromWCharArray(guidstr); 4419 4651 CoCreateGuid(&guid); 4420 4652 StringFromGUID2(guid, guidstr, 40); 4421 key = QString::from Utf16((ushort*)guidstr);4653 key = QString::fromWCharArray(guidstr); 4422 4654 #endif 4423 4655 d->sessionId = id; … … 4579 4811 app.setWinStyleHighlightColor(color); 4580 4812 \newcode 4581 QPalette palette( qApp->palette());4813 QPalette palette(QApplication::palette()); 4582 4814 palette.setColor(QPalette::Highlight, color); 4583 qApp->setPalette(palette);4815 QApplication::setPalette(palette); 4584 4816 \endcode 4585 4817 */ … … 4600 4832 \fn const QColor &QApplication::winStyleHighlightColor() 4601 4833 4602 Use qApp->palette().color(QPalette::Active, QPalette::Highlight) instead.4834 Use QApplication::palette().color(QPalette::Active, QPalette::Highlight) instead. 4603 4835 */ 4604 4836 … … 4685 4917 #ifdef QT_KEYPAD_NAVIGATION 4686 4918 /*! 4919 Sets the kind of focus navigation Qt should use to \a mode. 4920 4921 This feature is available in Qt for Embedded Linux, Symbian and Windows CE 4922 only. 4923 4924 \note On Windows CE this feature is disabled by default for touch device 4925 mkspecs. To enable keypad navigation, build Qt with 4926 QT_KEYPAD_NAVIGATION defined. 4927 4928 \note On Symbian, setting the mode to Qt::NavigationModeCursorAuto will enable a 4929 virtual mouse cursor on non touchscreen devices, which is controlled 4930 by the cursor keys if there is no analog pointer device. 4931 On other platforms and on touchscreen devices, it has the same 4932 meaning as Qt::NavigationModeNone. 4933 4934 \since 4.6 4935 4936 \sa keypadNavigationEnabled() 4937 */ 4938 void QApplication::setNavigationMode(Qt::NavigationMode mode) 4939 { 4940 #ifdef Q_OS_SYMBIAN 4941 QApplicationPrivate::setNavigationMode(mode); 4942 #else 4943 QApplicationPrivate::navigationMode = mode; 4944 #endif 4945 } 4946 4947 /*! 4948 Returns what kind of focus navigation Qt is using. 4949 4950 This feature is available in Qt for Embedded Linux, Symbian and Windows CE 4951 only. 4952 4953 \note On Windows CE this feature is disabled by default for touch device 4954 mkspecs. To enable keypad navigation, build Qt with 4955 QT_KEYPAD_NAVIGATION defined. 4956 4957 \note On Symbian, the default mode is Qt::NavigationModeNone for touch 4958 devices, and Qt::NavigationModeKeypadDirectional. 4959 4960 \since 4.6 4961 4962 \sa keypadNavigationEnabled() 4963 */ 4964 Qt::NavigationMode QApplication::navigationMode() 4965 { 4966 return QApplicationPrivate::navigationMode; 4967 } 4968 4969 /*! 4687 4970 Sets whether Qt should use focus navigation suitable for use with a 4688 4971 minimal keypad. 4689 4972 4690 If \a enable is true, Qt::Key_Up and Qt::Key_Down are used to change focus. 4691 4692 This feature is available in Qt for Embedded Linux only. 4693 4694 \sa keypadNavigationEnabled() 4973 This feature is available in Qt for Embedded Linux, Symbian and Windows CE 4974 only. 4975 4976 \note On Windows CE this feature is disabled by default for touch device 4977 mkspecs. To enable keypad navigation, build Qt with 4978 QT_KEYPAD_NAVIGATION defined. 4979 4980 \deprecated 4981 4982 \sa setNavigationMode() 4695 4983 */ 4696 4984 void QApplication::setKeypadNavigationEnabled(bool enable) 4697 4985 { 4698 QApplicationPrivate::keypadNavigation = enable; 4986 if (enable) { 4987 #ifdef Q_OS_SYMBIAN 4988 QApplication::setNavigationMode(Qt::NavigationModeKeypadDirectional); 4989 #else 4990 QApplication::setNavigationMode(Qt::NavigationModeKeypadTabOrder); 4991 #endif 4992 } 4993 else { 4994 QApplication::setNavigationMode(Qt::NavigationModeNone); 4995 } 4699 4996 } 4700 4997 4701 4998 /*! 4702 4999 Returns true if Qt is set to use keypad navigation; otherwise returns 4703 false. The default is false. 4704 4705 This feature is available in Qt for Embedded Linux only. 4706 4707 \sa setKeypadNavigationEnabled() 5000 false. The default value is true on Symbian, but false on other platforms. 5001 5002 This feature is available in Qt for Embedded Linux, Symbian and Windows CE 5003 only. 5004 5005 \note On Windows CE this feature is disabled by default for touch device 5006 mkspecs. To enable keypad navigation, build Qt with 5007 QT_KEYPAD_NAVIGATION defined. 5008 5009 \deprecated 5010 5011 \sa navigationMode() 4708 5012 */ 4709 5013 bool QApplication::keypadNavigationEnabled() 4710 5014 { 4711 return QApplicationPrivate::keypadNavigation; 5015 return QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadTabOrder || 5016 QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadDirectional; 4712 5017 } 4713 5018 #endif … … 4727 5032 application icon to bounce in the dock. 4728 5033 4729 On Windows this causes the window's taskbar entry to flash for a time. If5034 On Windows, this causes the window's taskbar entry to flash for a time. If 4730 5035 \a msec is zero, the flashing will stop and the taskbar entry will turn a 4731 5036 different color (currently orange). … … 4744 5049 flash time, then hidden for the same amount of time, but this may vary. 4745 5050 4746 The default value on X11 is 1000 milliseconds. On Windows, the control4747 panel value is used. Widgets should not cache this value since it may be4748 changed at any time by the user changing the global desktop settings.4749 4750 \note On Microsoft Windows, setting this property sets the cursor flash4751 time for all applications.5051 The default value on X11 is 1000 milliseconds. On Windows, the 5052 \gui{Control Panel} value is used and setting this property sets the cursor 5053 flash time for all applications. 5054 5055 We recommend that widgets do not cache this value as it may change at any 5056 time if the user changes the global desktop settings. 4752 5057 */ 4753 5058 4754 5059 /*! 4755 5060 \property QApplication::doubleClickInterval 4756 \brief the time limit in milliseconds that distinguishes a double click from two 4757 consecutive mouse clicks 4758 4759 The default value on X11 is 400 milliseconds. On Windows and Mac OS X, the 4760 operating system's value is used. 4761 4762 On Microsoft Windows, calling this function sets the double click interval 4763 for all applications. 5061 \brief the time limit in milliseconds that distinguishes a double click 5062 from two consecutive mouse clicks 5063 5064 The default value on X11 is 400 milliseconds. On Windows and Mac OS, the 5065 operating system's value is used. However, on Windows and Symbian OS, 5066 calling this function sets the double click interval for all applications. 4764 5067 */ 4765 5068 … … 4770 5073 \since 4.2 4771 5074 4772 The default value on X11 is 400 milliseconds. On Windows and Mac OS X, the5075 The default value on X11 is 400 milliseconds. On Windows and Mac OS, the 4773 5076 operating system's value is used. 4774 5077 */ … … 4835 5138 is an alternative. 4836 5139 4837 ForX11, this function also resizes and moves the main widget according5140 On X11, this function also resizes and moves the main widget according 4838 5141 to the \e -geometry command-line option, so you should set the default 4839 5142 geometry (using \l QWidget::setGeometry()) before calling setMainWidget(). … … 4864 5167 pushes the cursor onto the stack, and restoreOverrideCursor() pops the 4865 5168 active cursor off the stack. changeOverrideCursor() changes the curently 4866 active application override cursor. Every setOverrideCursor() must 4867 eventually be followed by a corresponding restoreOverrideCursor(), 4868 otherwise the stack will never be emptied. 5169 active application override cursor. 5170 5171 Every setOverrideCursor() must eventually be followed by a corresponding 5172 restoreOverrideCursor(), otherwise the stack will never be emptied. 4869 5173 4870 5174 Example: … … 4920 5224 return; 4921 5225 } 4922 if (d->inputContext) 4923 delete d->inputContext; 5226 delete d->inputContext; 4924 5227 d->inputContext = inputContext; 4925 5228 #endif … … 4936 5239 Q_D(const QApplication); 4937 5240 Q_UNUSED(d);// only static members being used. 5241 if (QApplicationPrivate::is_app_closing) 5242 return d->inputContext; 4938 5243 #ifdef Q_WS_X11 4939 5244 if (!X11) … … 4946 5251 qic = QInputContextFactory::create(QLatin1String("xim"), that); 4947 5252 that->d_func()->inputContext = qic; 5253 } 5254 #elif defined(Q_WS_S60) 5255 if (!d->inputContext) { 5256 QApplication *that = const_cast<QApplication *>(this); 5257 that->d_func()->inputContext = QInputContextFactory::create(QString::fromLatin1("coefep"), that); 4948 5258 } 4949 5259 #endif … … 4967 5277 if (X11->desktopEnvironment == DE_CDE) 4968 5278 platform |= KB_CDE; 5279 #elif defined(Q_OS_SYMBIAN) 5280 platform = KB_S60; 4969 5281 #endif 4970 5282 return platform; … … 4999 5311 return Qt::LeftToRight; 5000 5312 return qt_keymapper_private()->keyboardInputDirection; 5313 } 5314 5315 void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget, 5316 Qt::FocusPolicy focusPolicy, 5317 Qt::FocusReason focusReason) 5318 { 5319 QWidget *focusWidget = widget; 5320 while (focusWidget) { 5321 if (focusWidget->isEnabled() 5322 && QApplicationPrivate::shouldSetFocus(focusWidget, focusPolicy)) { 5323 focusWidget->setFocus(focusReason); 5324 break; 5325 } 5326 if (focusWidget->isWindow()) 5327 break; 5328 focusWidget = focusWidget->parentWidget(); 5329 } 5001 5330 } 5002 5331 … … 5014 5343 } 5015 5344 5345 /*! \fn QDecoration &QApplication::qwsDecoration() 5346 Return the QWSDecoration used for decorating windows. 5347 5348 \warning This method is non-portable. It is only available in 5349 Qt for Embedded Linux. 5350 5351 \sa QDecoration 5352 */ 5353 5354 /*! 5355 \fn void QApplication::qwsSetDecoration(QDecoration *decoration) 5356 5357 Sets the QDecoration derived class to use for decorating the 5358 windows used by Qt for Embedded Linux to the \a decoration 5359 specified. 5360 5361 This method is non-portable. It is only available in Qt for Embedded Linux. 5362 5363 \sa QDecoration 5364 */ 5365 5366 /*! \fn QDecoration* QApplication::qwsSetDecoration(const QString &decoration) 5367 \overload 5368 5369 Requests a QDecoration object for \a decoration from the 5370 QDecorationFactory. 5371 5372 The string must be one of the QDecorationFactory::keys(). Keys are case 5373 insensitive. 5374 5375 A later call to the QApplication constructor will override the requested 5376 style when a "-style" option is passed in as a commandline parameter. 5377 5378 Returns 0 if an unknown \a decoration is passed, otherwise the QStyle object 5379 returned is set as the application's GUI style. 5380 */ 5381 5382 /*! 5383 \fn bool QApplication::qwsEventFilter(QWSEvent *event) 5384 5385 This virtual function is only implemented under Qt for Embedded Linux. 5386 5387 If you create an application that inherits QApplication and 5388 reimplement this function, you get direct access to all QWS (Q 5389 Window System) events that the are received from the QWS master 5390 process. The events are passed in the \a event parameter. 5391 5392 Return true if you want to stop the event from being processed. 5393 Return false for normal event dispatching. The default 5394 implementation returns false. 5395 */ 5396 5397 /*! \fn void QApplication::qwsSetCustomColors(QRgb *colorTable, int start, int numColors) 5398 Set Qt for Embedded Linux custom color table. 5399 5400 Qt for Embedded Linux on 8-bpp displays allocates a standard 216 color cube. 5401 The remaining 40 colors may be used by setting a custom color 5402 table in the QWS master process before any clients connect. 5403 5404 \a colorTable is an array of up to 40 custom colors. \a start is 5405 the starting index (0-39) and \a numColors is the number of colors 5406 to be set (1-40). 5407 5408 This method is non-portable. It is available \e only in 5409 Qt for Embedded Linux. 5410 5411 \note The custom colors will not be used by the default screen 5412 driver. To make use of the new colors, implement a custom screen 5413 driver, or use QDirectPainter. 5414 */ 5415 5416 /*! \fn int QApplication::qwsProcessEvent(QWSEvent* event) 5417 \internal 5418 */ 5419 5420 /*! \fn int QApplication::x11ClientMessage(QWidget* w, XEvent* event, bool passive_only) 5421 \internal 5422 */ 5423 5424 /*! \fn int QApplication::x11ProcessEvent(XEvent* event) 5425 This function does the core processing of individual X 5426 \a{event}s, normally by dispatching Qt events to the right 5427 destination. 5428 5429 It returns 1 if the event was consumed by special handling, 0 if 5430 the \a event was consumed by normal handling, and -1 if the \a 5431 event was for an unrecognized widget. 5432 5433 \sa x11EventFilter() 5434 */ 5435 5436 /*! 5437 \fn bool QApplication::x11EventFilter(XEvent *event) 5438 5439 \warning This virtual function is only implemented under X11. 5440 5441 If you create an application that inherits QApplication and 5442 reimplement this function, you get direct access to all X events 5443 that the are received from the X server. The events are passed in 5444 the \a event parameter. 5445 5446 Return true if you want to stop the event from being processed. 5447 Return false for normal event dispatching. The default 5448 implementation returns false. 5449 5450 It is only the directly addressed messages that are filtered. 5451 You must install an event filter directly on the event 5452 dispatcher, which is returned by 5453 QAbstractEventDispatcher::instance(), to handle system wide 5454 messages. 5455 5456 \sa x11ProcessEvent() 5457 */ 5458 5459 /*! \fn void QApplication::winFocus(QWidget *widget, bool gotFocus) 5460 \internal 5461 \since 4.1 5462 5463 If \a gotFocus is true, \a widget will become the active window. 5464 Otherwise the active window is reset to 0. 5465 */ 5466 5467 /*! \fn void QApplication::winMouseButtonUp() 5468 \internal 5469 */ 5470 5471 /*! \fn void QApplication::syncX() 5472 Synchronizes with the X server in the X11 implementation. 5473 This normally takes some time. Does nothing on other platforms. 5474 */ 5475 5476 void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent) 5477 { 5478 for (int i = 0; i < touchEvent->touchPoints().count(); ++i) { 5479 QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i]; 5480 5481 // preserve the sub-pixel resolution 5482 QRectF rect = touchPoint.screenRect(); 5483 const QPointF screenPos = rect.center(); 5484 const QPointF delta = screenPos - screenPos.toPoint(); 5485 5486 rect.moveCenter(widget->mapFromGlobal(screenPos.toPoint()) + delta); 5487 touchPoint.d->rect = rect; 5488 if (touchPoint.state() == Qt::TouchPointPressed) { 5489 touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta; 5490 touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; 5491 } 5492 } 5493 } 5494 5495 void QApplicationPrivate::initializeMultitouch() 5496 { 5497 widgetForTouchPointId.clear(); 5498 appCurrentTouchPoints.clear(); 5499 5500 initializeMultitouch_sys(); 5501 } 5502 5503 void QApplicationPrivate::cleanupMultitouch() 5504 { 5505 cleanupMultitouch_sys(); 5506 5507 widgetForTouchPointId.clear(); 5508 appCurrentTouchPoints.clear(); 5509 } 5510 5511 int QApplicationPrivate::findClosestTouchPointId(const QPointF &screenPos) 5512 { 5513 int closestTouchPointId = -1; 5514 qreal closestDistance = qreal(0.); 5515 foreach (const QTouchEvent::TouchPoint &touchPoint, appCurrentTouchPoints) { 5516 qreal distance = QLineF(screenPos, touchPoint.screenPos()).length(); 5517 if (closestTouchPointId == -1 || distance < closestDistance) { 5518 closestTouchPointId = touchPoint.id(); 5519 closestDistance = distance; 5520 } 5521 } 5522 return closestTouchPointId; 5523 } 5524 5525 void QApplicationPrivate::translateRawTouchEvent(QWidget *window, 5526 QTouchEvent::DeviceType deviceType, 5527 const QList<QTouchEvent::TouchPoint> &touchPoints) 5528 { 5529 QApplicationPrivate *d = self; 5530 typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints; 5531 QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents; 5532 5533 for (int i = 0; i < touchPoints.count(); ++i) { 5534 QTouchEvent::TouchPoint touchPoint = touchPoints.at(i); 5535 // explicitly detach from the original touch point that we got, so even 5536 // if the touchpoint structs are reused, we will make a copy that we'll 5537 // deliver to the user (which might want to store the struct for later use). 5538 touchPoint.d = touchPoint.d->detach(); 5539 5540 // update state 5541 QWeakPointer<QWidget> widget; 5542 switch (touchPoint.state()) { 5543 case Qt::TouchPointPressed: 5544 { 5545 if (deviceType == QTouchEvent::TouchPad) { 5546 // on touch-pads, send all touch points to the same widget 5547 widget = d->widgetForTouchPointId.isEmpty() 5548 ? QWeakPointer<QWidget>() 5549 : d->widgetForTouchPointId.constBegin().value(); 5550 } 5551 5552 if (!widget) { 5553 // determine which widget this event will go to 5554 if (!window) 5555 window = QApplication::topLevelAt(touchPoint.screenPos().toPoint()); 5556 if (!window) 5557 continue; 5558 widget = window->childAt(window->mapFromGlobal(touchPoint.screenPos().toPoint())); 5559 if (!widget) 5560 widget = window; 5561 } 5562 5563 if (deviceType == QTouchEvent::TouchScreen) { 5564 int closestTouchPointId = d->findClosestTouchPointId(touchPoint.screenPos()); 5565 QWidget *closestWidget = d->widgetForTouchPointId.value(closestTouchPointId).data(); 5566 if (closestWidget 5567 && (widget.data()->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget.data()))) { 5568 widget = closestWidget; 5569 } 5570 } 5571 5572 d->widgetForTouchPointId[touchPoint.id()] = widget; 5573 touchPoint.d->startScreenPos = touchPoint.screenPos(); 5574 touchPoint.d->lastScreenPos = touchPoint.screenPos(); 5575 touchPoint.d->startNormalizedPos = touchPoint.normalizedPos(); 5576 touchPoint.d->lastNormalizedPos = touchPoint.normalizedPos(); 5577 if (touchPoint.pressure() < qreal(0.)) 5578 touchPoint.d->pressure = qreal(1.); 5579 5580 d->appCurrentTouchPoints.insert(touchPoint.id(), touchPoint); 5581 break; 5582 } 5583 case Qt::TouchPointReleased: 5584 { 5585 widget = d->widgetForTouchPointId.take(touchPoint.id()); 5586 if (!widget) 5587 continue; 5588 5589 QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.take(touchPoint.id()); 5590 touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); 5591 touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); 5592 touchPoint.d->startPos = previousTouchPoint.startPos(); 5593 touchPoint.d->lastPos = previousTouchPoint.pos(); 5594 touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); 5595 touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); 5596 if (touchPoint.pressure() < qreal(0.)) 5597 touchPoint.d->pressure = qreal(0.); 5598 break; 5599 } 5600 default: 5601 widget = d->widgetForTouchPointId.value(touchPoint.id()); 5602 if (!widget) 5603 continue; 5604 5605 Q_ASSERT(d->appCurrentTouchPoints.contains(touchPoint.id())); 5606 QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.value(touchPoint.id()); 5607 touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); 5608 touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); 5609 touchPoint.d->startPos = previousTouchPoint.startPos(); 5610 touchPoint.d->lastPos = previousTouchPoint.pos(); 5611 touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); 5612 touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); 5613 if (touchPoint.pressure() < qreal(0.)) 5614 touchPoint.d->pressure = qreal(1.); 5615 d->appCurrentTouchPoints[touchPoint.id()] = touchPoint; 5616 break; 5617 } 5618 Q_ASSERT(widget.data() != 0); 5619 5620 // make the *scene* functions return the same as the *screen* functions 5621 touchPoint.d->sceneRect = touchPoint.screenRect(); 5622 touchPoint.d->startScenePos = touchPoint.startScreenPos(); 5623 touchPoint.d->lastScenePos = touchPoint.lastScreenPos(); 5624 5625 StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[widget.data()]; 5626 maskAndPoints.first |= touchPoint.state(); 5627 if (touchPoint.isPrimary()) 5628 maskAndPoints.first |= Qt::TouchPointPrimary; 5629 maskAndPoints.second.append(touchPoint); 5630 } 5631 5632 if (widgetsNeedingEvents.isEmpty()) 5633 return; 5634 5635 QHash<QWidget *, StatesAndTouchPoints>::ConstIterator it = widgetsNeedingEvents.constBegin(); 5636 const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd(); 5637 for (; it != end; ++it) { 5638 QWidget *widget = it.key(); 5639 if (!QApplicationPrivate::tryModalHelper(widget, 0)) 5640 continue; 5641 5642 QEvent::Type eventType; 5643 switch (it.value().first & Qt::TouchPointStateMask) { 5644 case Qt::TouchPointPressed: 5645 eventType = QEvent::TouchBegin; 5646 break; 5647 case Qt::TouchPointReleased: 5648 eventType = QEvent::TouchEnd; 5649 break; 5650 case Qt::TouchPointStationary: 5651 // don't send the event if nothing changed 5652 continue; 5653 default: 5654 eventType = QEvent::TouchUpdate; 5655 break; 5656 } 5657 5658 QTouchEvent touchEvent(eventType, 5659 deviceType, 5660 QApplication::keyboardModifiers(), 5661 it.value().first, 5662 it.value().second); 5663 updateTouchPointsForWidget(widget, &touchEvent); 5664 5665 switch (touchEvent.type()) { 5666 case QEvent::TouchBegin: 5667 { 5668 // if the TouchBegin handler recurses, we assume that means the event 5669 // has been implicitly accepted and continue to send touch events 5670 widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent); 5671 (void ) QApplication::sendSpontaneousEvent(widget, &touchEvent); 5672 break; 5673 } 5674 default: 5675 if (widget->testAttribute(Qt::WA_WState_AcceptedTouchBeginEvent)) { 5676 if (touchEvent.type() == QEvent::TouchEnd) 5677 widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, false); 5678 (void) QApplication::sendSpontaneousEvent(widget, &touchEvent); 5679 } 5680 break; 5681 } 5682 } 5683 } 5684 5685 Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, 5686 QTouchEvent::DeviceType deviceType, 5687 const QList<QTouchEvent::TouchPoint> &touchPoints) 5688 { 5689 QApplicationPrivate::translateRawTouchEvent(window, deviceType, touchPoints); 5690 } 5691 5692 QGestureManager* QGestureManager::instance() 5693 { 5694 QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); 5695 if (!qAppPriv->gestureManager) 5696 qAppPriv->gestureManager = new QGestureManager(qApp); 5697 return qAppPriv->gestureManager; 5698 } 5699 5016 5700 QT_END_NAMESPACE 5017 5701
Note:
See TracChangeset
for help on using the changeset viewer.