Qt 4.8
qapplication.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qplatformdefs.h"
44 #include "qaccessible.h"
45 #include "qapplication.h"
46 #include "qclipboard.h"
47 #include "qcursor.h"
48 #include "qdesktopwidget.h"
49 #include "qdir.h"
50 #include "qevent.h"
51 #include "qfile.h"
52 #include "qfileinfo.h"
53 #include "qgraphicsscene.h"
54 #include "qhash.h"
55 #include "qset.h"
56 #include "qlayout.h"
57 #include "qsessionmanager.h"
58 #include "qstyle.h"
59 #include "qstylefactory.h"
60 #include "qtextcodec.h"
61 #include "qtranslator.h"
62 #include "qvariant.h"
63 #include "qwidget.h"
64 #include "qdnd_p.h"
65 #include "qcolormap.h"
66 #include "qdebug.h"
67 #include "private/qgraphicssystemfactory_p.h"
68 #include "private/qgraphicssystem_p.h"
69 #include "private/qstylesheetstyle_p.h"
70 #include "private/qstyle_p.h"
71 #include "qmessagebox.h"
72 #include <QtGui/qgraphicsproxywidget.h>
73 
74 #ifdef QT_GRAPHICSSYSTEM_RUNTIME
75 #include "private/qgraphicssystem_runtime_p.h"
76 #endif
77 
78 #include "qinputcontext.h"
79 #include "qkeymapper_p.h"
80 
81 #ifdef Q_WS_X11
82 #include <private/qt_x11_p.h>
83 #endif
84 
85 #if defined(Q_WS_X11) || defined(Q_OS_SYMBIAN)
86 #include "qinputcontextfactory.h"
87 #endif
88 
89 #include "qguiplatformplugin_p.h"
90 
91 #include <qthread.h>
92 #include <private/qthread_p.h>
93 
94 #include <private/qfont_p.h>
95 
96 #include <stdlib.h>
97 
98 #if defined(Q_WS_X11) && !defined(QT_NO_EGL)
99 #include <link.h>
100 #endif
101 
102 #include "qapplication_p.h"
103 #include "qevent_p.h"
104 #include "qwidget_p.h"
105 
106 #include "qapplication.h"
107 
108 #include "qgesture.h"
109 #include "private/qgesturemanager_p.h"
110 
111 #ifndef QT_NO_LIBRARY
112 #include "qlibrary.h"
113 #endif
114 
115 #ifdef Q_WS_WINCE
116 #include "qdatetime.h"
117 #include "qguifunctions_wince.h"
118 extern bool qt_wince_is_smartphone(); //qguifunctions_wince.cpp
119 extern bool qt_wince_is_mobile(); //qguifunctions_wince.cpp
120 extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp
121 #endif
122 
123 #include "qdatetime.h"
124 
125 #ifdef QT_MAC_USE_COCOA
126 #include <private/qt_cocoa_helpers_mac_p.h>
127 #endif
128 
129 //#define ALIEN_DEBUG
130 
131 #if defined(Q_OS_SYMBIAN)
132 #include "qt_s60_p.h"
133 #endif
134 
135 static void initResources()
136 {
137 #if defined(Q_WS_WINCE)
138  Q_INIT_RESOURCE_EXTERN(qstyle_wince)
139  Q_INIT_RESOURCE(qstyle_wince);
140 #elif defined(Q_OS_SYMBIAN)
141  Q_INIT_RESOURCE_EXTERN(qstyle_s60)
142  Q_INIT_RESOURCE(qstyle_s60);
143 #else
144  Q_INIT_RESOURCE_EXTERN(qstyle)
145  Q_INIT_RESOURCE(qstyle);
146 #endif
147  Q_INIT_RESOURCE_EXTERN(qmessagebox)
148  Q_INIT_RESOURCE(qmessagebox);
149 #if !defined(QT_NO_PRINTDIALOG)
150  Q_INIT_RESOURCE_EXTERN(qprintdialog)
151  Q_INIT_RESOURCE(qprintdialog);
152 #endif
153 #ifdef Q_WS_MAC
154  Q_INIT_RESOURCE_EXTERN(macresources)
155  Q_INIT_RESOURCE(macresources);
156 #endif
157 }
158 
160 
162 
165 
167 
169 
170 #ifdef Q_OS_SYMBIAN
171 bool QApplicationPrivate::inputContextBeingCreated = false;
172 #endif
173 
174 #ifdef Q_WS_WINCE
177 #else
179 #endif
180 
182  : QCoreApplicationPrivate(argc, argv, flags)
183 {
185  qt_appType = type;
186 
187 #ifndef QT_NO_SESSIONMANAGER
188  is_session_restored = false;
189 #endif
190 
191  quitOnLastWindowClosed = true;
192 
193 #ifdef QT3_SUPPORT
194  qt_compat_used = 0;
195  qt_compat_resolved = 0;
196  qt_tryAccelEvent = 0;
197  qt_tryComposeUnicode = 0;
198  qt_dispatchAccelEvent = 0;
199 #endif
200 #if defined(Q_WS_QWS) && !defined(QT_NO_DIRECTPAINTER)
201  directPainters = 0;
202 #endif
203 
204 #ifndef QT_NO_GESTURES
205  gestureManager = 0;
206  gestureWidget = 0;
207 #endif // QT_NO_GESTURES
208 
209 #if defined(Q_WS_X11) || defined(Q_WS_WIN)
210  move_cursor = 0;
211  copy_cursor = 0;
212  link_cursor = 0;
213 #endif
214 #if defined(Q_WS_WIN)
215  ignore_cursor = 0;
216 #endif
217 
218  if (!self)
219  self = this;
220 }
221 
223 {
224  if (self == this)
225  self = 0;
226 }
227 
440 /*
441  The qt_init() and qt_cleanup() functions are implemented in the
442  qapplication_xyz.cpp file.
443 */
444 
446 #ifdef Q_WS_X11
447  , Display *display = 0, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0
448 #endif
449  );
450 void qt_cleanup();
451 
454 
455 QStyle *QApplicationPrivate::app_style = 0; // default application style
457 
458 #ifndef QT_NO_STYLE_STYLESHEET
459 QString QApplicationPrivate::styleSheet; // default application stylesheet
460 #endif
462 
464 QPalette *QApplicationPrivate::app_pal = 0; // default application palette
465 QPalette *QApplicationPrivate::sys_pal = 0; // default system palette
466 QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer
467 
468 QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system
469 #if defined(Q_WS_QPA)
470 QPlatformIntegration *QApplicationPrivate::platform_integration = 0;
471 #endif
472 QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization
474 
475 Q_GLOBAL_STATIC(QMutex, applicationFontMutex)
476 QFont *QApplicationPrivate::app_font = 0; // default application font
477 QFont *QApplicationPrivate::sys_font = 0; // default system font
478 QFont *QApplicationPrivate::set_font = 0; // default font set by programmer
479 
481 QWidget *QApplicationPrivate::main_widget = 0; // main application widget
482 QWidget *QApplicationPrivate::focus_widget = 0; // has keyboard input focus
483 QWidget *QApplicationPrivate::hidden_focus_widget = 0; // will get keyboard input focus after show()
484 QWidget *QApplicationPrivate::active_window = 0; // toplevel with keyboard focus
485 bool QApplicationPrivate::obey_desktop_settings = true; // use winsys resources
486 int QApplicationPrivate::cursor_flash_time = 1000; // text caret flash time
487 int QApplicationPrivate::mouse_double_click_time = 400; // mouse dbl click limit
488 int QApplicationPrivate::keyboard_input_time = 400; // keyboard input interval
489 #ifndef QT_NO_WHEELEVENT
490 int QApplicationPrivate::wheel_scroll_lines; // number of lines to scroll
491 #endif
494 bool qt_in_tab_key_event = false;
496 static int drag_time = 500;
497 #ifndef QT_GUI_DRAG_DISTANCE
498 #define QT_GUI_DRAG_DISTANCE 4
499 #endif
500 #ifdef Q_OS_SYMBIAN
501 // The screens are a bit too small to for your thumb when using only 4 pixels drag distance.
502 static int drag_distance = 12; //XXX move to qplatformdefs.h
503 #else
505 #endif
507 QSize QApplicationPrivate::app_strut = QSize(0,0); // no default application strut
510 bool QApplicationPrivate::fade_menu = false;
517 #ifdef QT_KEYPAD_NAVIGATION
518 # ifdef Q_OS_SYMBIAN
519 Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional;
520 # else
521 Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadTabOrder;
522 # endif
523 QWidget *QApplicationPrivate::oldEditFocus = 0;
524 #endif
525 
526 bool qt_tabletChokeMouse = false;
527 static bool force_reverse = false;
528 
530 {
531  if (!widget)
532  return false;
533 #if defined(Q_WS_QWS) || defined(Q_WS_QPA)
534  return !widget->isWindow()
535 # ifdef Q_BACKINGSTORE_SUBSURFACES
536  && !(widget->d_func()->maybeTopData() && widget->d_func()->maybeTopData()->windowSurface)
537 # endif
538  ;
539 #else
540  return !widget->internalWinId();
541 #endif
542 }
543 
544 // ######## move to QApplicationPrivate
545 // Default application palettes and fonts (per widget type)
546 Q_GLOBAL_STATIC(PaletteHash, app_palettes)
548 {
549  return app_palettes();
550 }
551 
552 Q_GLOBAL_STATIC(FontHash, app_fonts)
554 {
555  return app_fonts();
556 }
557 
558 QWidgetList *QApplicationPrivate::popupWidgets = 0; // has keyboard input focus
559 
560 QDesktopWidget *qt_desktopWidget = 0; // root window widgets
561 #ifndef QT_NO_CLIPBOARD
562 QClipboard *qt_clipboard = 0; // global clipboard object
563 #endif
564 QWidgetList * qt_modal_stack=0; // stack of modal widgets
565 
570 {
571  // process platform-indep command line
572  if (!qt_is_gui_used || !argc)
573  return;
574 
575  int i, j;
576 
577  j = 1;
578  for (i=1; i<argc; i++) { // if you add anything here, modify QCoreApplication::arguments()
579  if (argv[i] && *argv[i] != '-') {
580  argv[j++] = argv[i];
581  continue;
582  }
583  QByteArray arg = argv[i];
584  arg = arg;
585  QString s;
586  if (arg == "-qdevel" || arg == "-qdebug") {
587  // obsolete argument
588  } else if (arg.indexOf("-style=", 0) != -1) {
589  s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower());
590  } else if (arg == "-style" && i < argc-1) {
591  s = QString::fromLocal8Bit(argv[++i]).toLower();
592 #ifndef QT_NO_SESSIONMANAGER
593  } else if (arg == "-session" && i < argc-1) {
594  ++i;
595  if (argv[i] && *argv[i]) {
597  int p = session_id.indexOf(QLatin1Char('_'));
598  if (p >= 0) {
599  session_key = session_id.mid(p +1);
601  }
602  is_session_restored = true;
603  }
604 #endif
605 #ifndef QT_NO_STYLE_STYLESHEET
606  } else if (arg == "-stylesheet" && i < argc -1) {
607  styleSheet = QLatin1String("file:///");
609  } else if (arg.indexOf("-stylesheet=") != -1) {
610  styleSheet = QLatin1String("file:///");
612 #endif
613  } else if (qstrcmp(arg, "-reverse") == 0) {
614  force_reverse = true;
616  } else if (qstrcmp(arg, "-widgetcount") == 0) {
617  widgetCount = true;
618  } else if (qstrcmp(arg, "-testability") == 0) {
619  load_testability = true;
620  } else if (arg == "-graphicssystem" && i < argc-1) {
622  } else {
623  argv[j++] = argv[i];
624  }
625  if (!s.isEmpty()) {
626  if (app_style) {
627  delete app_style;
628  app_style = 0;
629  }
630  styleOverride = s;
631  }
632  }
633 
634  if(j < argc) {
635  argv[j] = 0;
636  argc = j;
637  }
638 }
639 
740  : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000))
741 { Q_D(QApplication); d->construct(); }
742 
743 QApplication::QApplication(int &argc, char **argv, int _internal)
745 { Q_D(QApplication); d->construct(); }
746 
747 
773 QApplication::QApplication(int &argc, char **argv, bool GUIenabled )
774  : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, 0x040000))
775 { Q_D(QApplication); d->construct(); }
776 
777 QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _internal)
778  : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, _internal))
779 { Q_D(QApplication); d->construct();}
780 
781 
782 
797  : QCoreApplication(*new QApplicationPrivate(argc, argv, type, 0x040000))
798 { Q_D(QApplication); d->construct(); }
799 
800 QApplication::QApplication(int &argc, char **argv, Type type , int _internal)
801  : QCoreApplication(*new QApplicationPrivate(argc, argv, type, _internal))
802 { Q_D(QApplication); d->construct(); }
803 
804 #if defined(Q_WS_X11) && !defined(QT_NO_EGL)
805 static int qt_matchLibraryName(dl_phdr_info *info, size_t, void *data)
806 {
807  const char *name = static_cast<const char *>(data);
808  return strstr(info->dlpi_name, name) != 0;
809 }
810 #endif
811 
816 #ifdef Q_WS_X11
817  Display *dpy, Qt::HANDLE visual, Qt::HANDLE cmap
818 #endif
819  )
820 {
821  initResources();
822 
824  process_cmdline();
825  // the environment variable has the lowest precedence of runtime graphicssystem switches
826  if (graphics_system_name.isEmpty())
827  graphics_system_name = QString::fromLocal8Bit(qgetenv("QT_GRAPHICSSYSTEM"));
828 
829 #if defined(Q_WS_X11) && !defined(QT_NO_EGL)
830  if (graphics_system_name.isEmpty()) {
831  bool linksWithMeeGoTouch = dl_iterate_phdr(qt_matchLibraryName, const_cast<char *>("libmeegotouchcore"));
832  bool linksWithMeeGoGraphicsSystemHelper = dl_iterate_phdr(qt_matchLibraryName, const_cast<char *>("libQtMeeGoGraphicsSystemHelper"));
833 
834  if (linksWithMeeGoTouch && !linksWithMeeGoGraphicsSystemHelper) {
835  qWarning("Running non-meego graphics system enabled MeeGo touch, forcing native graphicssystem\n");
836  graphics_system_name = QLatin1String("native");
837  }
838  }
839 #endif
840 
841  // Must be called before initialize()
842  qt_init(this, qt_appType
843 #ifdef Q_WS_X11
844  , dpy, visual, cmap
845 #endif
846  );
847  initialize();
848  eventDispatcher->startingUp();
849 
850 #ifdef QT_EVAL
851  extern void qt_gui_eval_init(uint);
852  qt_gui_eval_init(application_type);
853 #endif
854 
855 #if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE)
856  symbianInit();
857 #endif
858 
859 #ifndef QT_NO_LIBRARY
860  if(load_testability) {
861  QLibrary testLib(QLatin1String("qttestability"));
862  if (testLib.load()) {
863  typedef void (*TasInitialize)(void);
864  TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
865 #ifdef Q_OS_SYMBIAN
866  // resolving method by name does not work on Symbian OS so need to use ordinal
867  if(!initFunction) {
868  initFunction = (TasInitialize)testLib.resolve("1");
869  }
870 #endif
871  if (initFunction) {
872  initFunction();
873  } else {
874  qCritical("Library qttestability resolve failed!");
875  }
876  } else {
877  qCritical("Library qttestability load failed!");
878  }
879  }
880 
881  //make sure the plugin is loaded
882  if (qt_is_gui_used)
884 #endif
885 
886 #ifdef Q_OS_SYMBIAN
887  symbianHandleLiteModeStartup();
888 #endif
889 }
890 
891 #if defined(Q_WS_X11)
892 // ### a string literal is a cont char*
893 // ### using it as a char* is wrong and could lead to segfaults
894 // ### if aargv is modified someday
895 // ########## make it work with argc == argv == 0
896 static int aargc = 1;
897 static char *aargv[] = { (char*)"unknown", 0 };
898 
913 {
914  if (! dpy)
915  qWarning("QApplication: Invalid Display* argument");
916  Q_D(QApplication);
917  d->construct(dpy, visual, colormap);
918 }
919 
920 QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap, int _internal)
922 {
923  if (! dpy)
924  qWarning("QApplication: Invalid Display* argument");
925  Q_D(QApplication);
926  d->construct(dpy, visual, colormap);
928 }
929 
945  Qt::HANDLE visual, Qt::HANDLE colormap)
946  : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000))
947 {
948  if (! dpy)
949  qWarning("QApplication: Invalid Display* argument");
950  Q_D(QApplication);
951  d->construct(dpy, visual, colormap);
952 }
953 
954 QApplication::QApplication(Display *dpy, int &argc, char **argv,
955  Qt::HANDLE visual, Qt::HANDLE colormap, int _internal)
957 {
958  if (! dpy)
959  qWarning("QApplication: Invalid Display* argument");
960  Q_D(QApplication);
961  d->construct(dpy, visual, colormap);
963 }
964 
965 #endif // Q_WS_X11
966 
967 extern void qInitDrawhelperAsm();
968 extern void qInitImageConversions();
969 extern int qRegisterGuiVariant();
970 extern int qUnregisterGuiVariant();
971 #ifndef QT_NO_STATEMACHINE
972 extern int qRegisterGuiStateMachine();
973 extern int qUnregisterGuiStateMachine();
974 #endif
975 
985 {
988 
989 #if !defined(Q_WS_X11) && !defined(Q_WS_QWS) && !defined(Q_WS_QPA)
990  // initialize the graphics system - on X11 this is initialized inside
991  // qt_init() in qapplication_x11.cpp because of several reasons.
992  // On QWS, the graphics system is set by the QScreen plugin.
993  // We don't use graphics systems in Qt QPA
994  graphics_system = QGraphicsSystemFactory::create(graphics_system_name);
995 #endif
996 
998  (void) QApplication::style(); // trigger creation of application style
999  // trigger registering of QVariant's GUI types
1001 #ifndef QT_NO_STATEMACHINE
1002  // trigger registering of QStateMachine's GUI types
1004 #endif
1005 
1006  is_app_running = true; // no longer starting up
1007 
1008  Q_Q(QApplication);
1009 #ifndef QT_NO_SESSIONMANAGER
1010  // connect to the session manager
1011  session_manager = new QSessionManager(q, session_id, session_key);
1012 #endif
1013 
1014  if (qgetenv("QT_USE_NATIVE_WINDOWS").toInt() > 0)
1015  q->setAttribute(Qt::AA_NativeWindows);
1016 
1017 #ifdef Q_WS_WINCE
1018 #ifdef QT_AUTO_MAXIMIZE_THRESHOLD
1019  autoMaximizeThreshold = QT_AUTO_MAXIMIZE_THRESHOLD;
1020 #else
1021  if (qt_wince_is_mobile())
1022  autoMaximizeThreshold = 50;
1023  else
1024  autoMaximizeThreshold = -1;
1025 #endif //QT_AUTO_MAXIMIZE_THRESHOLD
1026 #endif //Q_WS_WINCE
1027 
1028  // Set up which span functions should be used in raster engine...
1030  // and QImage conversion functions
1032 
1033 #ifndef QT_NO_WHEELEVENT
1035 #endif
1036 
1037 #ifdef Q_WS_S60
1038  q->setAttribute(Qt::AA_S60DisablePartialScreenInputMode);
1039 #endif
1040 
1041  if (qt_is_gui_used)
1042  initializeMultitouch();
1043 }
1044 
1051 {
1052  return qt_appType;
1053 }
1054 
1055 /*****************************************************************************
1056  Functions returning the active popup and modal widgets.
1057  *****************************************************************************/
1058 
1075 {
1076  return QApplicationPrivate::popupWidgets && !QApplicationPrivate::popupWidgets->isEmpty() ?
1077  QApplicationPrivate::popupWidgets->last() : 0;
1078 }
1079 
1080 
1096 {
1097  return qt_modal_stack && !qt_modal_stack->isEmpty() ? qt_modal_stack->first() : 0;
1098 }
1099 
1106 {
1107  Q_D(QApplication);
1108 
1109 #ifndef QT_NO_CLIPBOARD
1110  // flush clipboard contents
1111  if (qt_clipboard) {
1113  QApplication::sendEvent(qt_clipboard, &event);
1114  }
1115 #endif
1116 
1117  //### this should probable be done even later
1119 
1120  // kill timers before closing down the dispatcher
1121  d->toolTipWakeUp.stop();
1122  d->toolTipFallAsleep.stop();
1123 
1124  d->eventDispatcher->closingDown();
1125  d->eventDispatcher = 0;
1128 
1129  delete QWidgetPrivate::mapper;
1131 
1132  // delete all widgets
1136  for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) {
1137  register QWidget *w = *it;
1138  if (!w->parent()) // window
1139  w->destroy(true, true);
1140  }
1141  delete mySet;
1142  }
1143 
1144  delete qt_desktopWidget;
1145  qt_desktopWidget = 0;
1146 
1147 #ifndef QT_NO_CLIPBOARD
1148  delete qt_clipboard;
1149  qt_clipboard = 0;
1150 #endif
1151 
1152 #if defined(Q_WS_X11) || defined(Q_WS_WIN)
1153  delete d->move_cursor; d->move_cursor = 0;
1154  delete d->copy_cursor; d->copy_cursor = 0;
1155  delete d->link_cursor; d->link_cursor = 0;
1156 #endif
1157 #if defined(Q_WS_WIN)
1158  delete d->ignore_cursor; d->ignore_cursor = 0;
1159 #endif
1160 
1162  QApplicationPrivate::app_pal = 0;
1164  QApplicationPrivate::sys_pal = 0;
1166  QApplicationPrivate::set_pal = 0;
1167  app_palettes()->clear();
1168 
1169  {
1170  QMutexLocker locker(applicationFontMutex());
1172  QApplicationPrivate::app_font = 0;
1173  }
1175  QApplicationPrivate::sys_font = 0;
1177  QApplicationPrivate::set_font = 0;
1178  app_fonts()->clear();
1179 
1181  QApplicationPrivate::app_style = 0;
1183  QApplicationPrivate::app_icon = 0;
1185  QApplicationPrivate::graphics_system = 0;
1186 #ifndef QT_NO_CURSOR
1187  d->cursor_list.clear();
1188 #endif
1189 
1190 #ifndef QT_NO_DRAGANDDROP
1191  if (qt_is_gui_used)
1192  delete QDragManager::self();
1193 #endif
1194 
1195  d->cleanupMultitouch();
1196 
1197  qt_cleanup();
1198 
1200  qDebug("Widgets left: %i Max widgets: %i \n", QWidgetPrivate::instanceCounter, QWidgetPrivate::maxInstances);
1201 #ifndef QT_NO_SESSIONMANAGER
1202  delete d->session_manager;
1203  d->session_manager = 0;
1204 #endif //QT_NO_SESSIONMANAGER
1205 
1210 
1211  drag_time = 500;
1212  drag_distance = 4;
1214  QApplicationPrivate::app_strut = QSize(0, 0);
1222 
1223 #ifndef QT_NO_STATEMACHINE
1224  // trigger unregistering of QStateMachine's GUI types
1226 #endif
1227  // trigger unregistering of QVariant's GUI types
1229 }
1230 
1231 
1243 {
1245  if (!window)
1246  return 0;
1247 
1248  QWidget *child = 0;
1249 
1251  child = window->childAt(window->mapFromGlobal(p));
1252 
1253  if (child)
1254  return child;
1255 
1257  //shoot a hole in the widget and try once again,
1258  //suboptimal on Qt for Embedded Linux where we do
1259  //know the stacking order of the toplevels.
1260  int x = p.x();
1261  int y = p.y();
1262  QRegion oldmask = window->mask();
1263  QPoint wpoint = window->mapFromGlobal(QPoint(x, y));
1264  QRegion newmask = (oldmask.isEmpty() ? QRegion(window->rect()) : oldmask)
1265  - QRegion(wpoint.x(), wpoint.y(), 1, 1);
1266  window->setMask(newmask);
1267  QWidget *recurse = 0;
1268  if (QApplication::topLevelAt(p) != window) // verify recursion will terminate
1269  recurse = widgetAt(x, y);
1270  if (oldmask.isEmpty())
1271  window->clearMask();
1272  else
1273  window->setMask(oldmask);
1274  return recurse;
1275  }
1276  return window;
1277 }
1278 
1299 {
1300  if ((event->type() == QEvent::UpdateRequest
1301 #ifdef QT3_SUPPORT
1302  || event->type() == QEvent::LayoutHint
1303 #endif
1304  || event->type() == QEvent::LayoutRequest
1305  || event->type() == QEvent::Resize
1306  || event->type() == QEvent::Move
1307  || event->type() == QEvent::LanguageChange
1308  || event->type() == QEvent::UpdateSoftKeys
1309  || event->type() == QEvent::InputMethod)) {
1310  for (QPostEventList::const_iterator it = postedEvents->constBegin(); it != postedEvents->constEnd(); ++it) {
1311  const QPostEvent &cur = *it;
1312  if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type())
1313  continue;
1314  if (cur.event->type() == QEvent::LayoutRequest
1315 #ifdef QT3_SUPPORT
1316  || cur.event->type() == QEvent::LayoutHint
1317 #endif
1318  || cur.event->type() == QEvent::UpdateRequest) {
1319  ;
1320  } else if (cur.event->type() == QEvent::Resize) {
1321  ((QResizeEvent *)(cur.event))->s = ((QResizeEvent *)event)->s;
1322  } else if (cur.event->type() == QEvent::Move) {
1323  ((QMoveEvent *)(cur.event))->p = ((QMoveEvent *)event)->p;
1324  } else if (cur.event->type() == QEvent::LanguageChange) {
1325  ;
1326  } else if (cur.event->type() == QEvent::UpdateSoftKeys) {
1327  ;
1328  } else if ( cur.event->type() == QEvent::InputMethod ) {
1329  *(QInputMethodEvent *)(cur.event) = *(QInputMethodEvent *)event;
1330  } else {
1331  continue;
1332  }
1333  delete event;
1334  return true;
1335  }
1336  return false;
1337  }
1338  return QCoreApplication::compressEvent(event, receiver, postedEvents);
1339 }
1340 
1401 #ifdef Q_WS_WINCE
1403 {
1405 }
1406 
1408 {
1410 }
1411 #endif
1412 
1414 {
1416 }
1417 
1418 bool QApplication::autoSipEnabled() const
1419 {
1421 }
1422 
1423 #ifndef QT_NO_STYLE_STYLESHEET
1424 
1426 {
1428 }
1429 
1431 {
1432  QApplicationPrivate::styleSheet = styleSheet;
1434  if (styleSheet.isEmpty()) { // application style sheet removed
1435  if (!proxy)
1436  return; // there was no stylesheet before
1437  setStyle(proxy->base);
1438  } else if (proxy) { // style sheet update, just repolish
1439  proxy->repolish(qApp);
1440  } else { // stylesheet set the first time
1441  QStyleSheetStyle *newProxy = new QStyleSheetStyle(QApplicationPrivate::app_style);
1442  QApplicationPrivate::app_style->setParent(newProxy);
1443  setStyle(newProxy);
1444  }
1445 }
1446 
1447 #endif // QT_NO_STYLE_STYLESHEET
1448 
1455 {
1456  if (QApplicationPrivate::app_style)
1458  if (!qt_is_gui_used) {
1459  Q_ASSERT(!"No style available in non-gui applications!");
1460  return 0;
1461  }
1462 
1463  if (!QApplicationPrivate::app_style) {
1464  // Compile-time search for default style
1465  //
1466  QString style;
1467 #ifdef QT_BUILD_INTERNAL
1468  QString envStyle = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE"));
1469 #else
1470  QString envStyle;
1471 #endif
1472  if (!QApplicationPrivate::styleOverride.isEmpty()) {
1474  } else if (!envStyle.isEmpty()) {
1475  style = envStyle;
1476  } else {
1478  }
1479 
1480  QStyle *&app_style = QApplicationPrivate::app_style;
1481  app_style = QStyleFactory::create(style);
1482  if (!app_style) {
1483  QStringList styles = QStyleFactory::keys();
1484  for (int i = 0; i < styles.size(); ++i) {
1485  if ((app_style = QStyleFactory::create(styles.at(i))))
1486  break;
1487  }
1488  }
1489  if (!app_style) {
1490  Q_ASSERT(!"No styles available!");
1491  return 0;
1492  }
1493  }
1494  // take ownership of the style
1495  QApplicationPrivate::app_style->setParent(qApp);
1496 
1497  if (!QApplicationPrivate::sys_pal)
1498  QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette());
1499  if (QApplicationPrivate::set_pal) // repolish set palette with the new style
1500  QApplication::setPalette(*QApplicationPrivate::set_pal);
1501 
1502 #ifndef QT_NO_STYLE_STYLESHEET
1503  if (!QApplicationPrivate::styleSheet.isEmpty()) {
1504  qApp->setStyleSheet(QApplicationPrivate::styleSheet);
1505  } else
1506 #endif
1507  QApplicationPrivate::app_style->polish(qApp);
1508 
1510 }
1511 
1535 {
1536  if (!style || style == QApplicationPrivate::app_style)
1537  return;
1538 
1540 
1541  // clean up the old style
1542  if (QApplicationPrivate::app_style) {
1544  for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
1545  register QWidget *w = *it;
1546  if (!(w->windowType() == Qt::Desktop) && // except desktop
1547  w->testAttribute(Qt::WA_WState_Polished)) { // has been polished
1548  QApplicationPrivate::app_style->unpolish(w);
1549  }
1550  }
1551  }
1552  QApplicationPrivate::app_style->unpolish(qApp);
1553  }
1554 
1555  QStyle *old = QApplicationPrivate::app_style; // save
1556 
1557 #ifndef QT_NO_STYLE_STYLESHEET
1558  if (!QApplicationPrivate::styleSheet.isEmpty() && !qobject_cast<QStyleSheetStyle *>(style)) {
1559  // we have a stylesheet already and a new style is being set
1560  QStyleSheetStyle *newProxy = new QStyleSheetStyle(style);
1561  style->setParent(newProxy);
1562  QApplicationPrivate::app_style = newProxy;
1563  } else
1564 #endif // QT_NO_STYLE_STYLESHEET
1565  QApplicationPrivate::app_style = style;
1566  QApplicationPrivate::app_style->setParent(qApp); // take ownership
1567 
1568  // take care of possible palette requirements of certain gui
1569  // styles. Do it before polishing the application since the style
1570  // might call QApplication::setPalette() itself
1571  if (QApplicationPrivate::set_pal) {
1572  QApplication::setPalette(*QApplicationPrivate::set_pal);
1573  } else if (QApplicationPrivate::sys_pal) {
1575  QApplicationPrivate::setPalette_helper(*QApplicationPrivate::sys_pal, /*className=*/0, /*clearWidgetPaletteHash=*/false);
1576  } else if (!QApplicationPrivate::sys_pal) {
1577  // Initialize the sys_pal if it hasn't happened yet...
1578  QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette());
1579  }
1580 
1581  // initialize the application with the new style
1582  QApplicationPrivate::app_style->polish(qApp);
1583 
1584  // re-polish existing widgets if necessary
1586  for (QWidgetList::ConstIterator it1 = all.constBegin(); it1 != all.constEnd(); ++it1) {
1587  register QWidget *w = *it1;
1590  QApplicationPrivate::app_style->polish(w); // repolish
1591 #ifndef QT_NO_STYLE_STYLESHEET
1592  else
1593  w->setStyleSheet(w->styleSheet()); // touch
1594 #endif
1595  }
1596  }
1597 
1598  for (QWidgetList::ConstIterator it2 = all.constBegin(); it2 != all.constEnd(); ++it2) {
1599  register QWidget *w = *it2;
1600  if (w->windowType() != Qt::Desktop && !w->testAttribute(Qt::WA_SetStyle)) {
1602  QApplication::sendEvent(w, &e);
1603 #ifdef QT3_SUPPORT
1604  if (old)
1605  w->styleChange(*old);
1606 #endif
1607  w->update();
1608  }
1609  }
1610  }
1611 
1612 #ifndef QT_NO_STYLE_STYLESHEET
1613  if (QStyleSheetStyle *oldProxy = qobject_cast<QStyleSheetStyle *>(old)) {
1614  oldProxy->deref();
1615  } else
1616 #endif
1617  if (old && old->parent() == qApp) {
1618  delete old;
1619  }
1620 
1621  if (QApplicationPrivate::focus_widget) {
1623  QApplication::sendEvent(QApplicationPrivate::focus_widget->style(), &in);
1624  QApplicationPrivate::focus_widget->update();
1625  }
1626 }
1627 
1648 {
1649  QStyle *s = QStyleFactory::create(style);
1650  if (!s)
1651  return 0;
1652 
1653  setStyle(s);
1654  return s;
1655 }
1656 
1685 {
1686 #ifdef Q_WS_QPA
1687  Q_UNUSED(system);
1688 #else
1689 # ifdef QT_GRAPHICSSYSTEM_RUNTIME
1690  if (QApplicationPrivate::graphics_system_name == QLatin1String("runtime")) {
1693  r->setGraphicsSystem(system);
1694  } else
1695 # endif
1696  QApplicationPrivate::graphics_system_name = system;
1697 #endif
1698 }
1699 
1707 {
1709 }
1710 
1767 {
1768  if (qApp)
1769  qWarning("QApplication::setColorSpec: This function must be "
1770  "called before the QApplication object is created");
1772 }
1773 
1793 {
1795 }
1796 
1798 {
1799  QApplicationPrivate::app_strut = strut;
1800 }
1801 
1808 {
1809  if (!QApplicationPrivate::app_pal)
1810  QApplicationPrivate::app_pal = new QPalette(Qt::black);
1812 }
1813 
1827 {
1828  PaletteHash *hash = app_palettes();
1829  if (w && hash && hash->size()) {
1831  if (it != hash->constEnd())
1832  return *it;
1833  for (it = hash->constBegin(); it != hash->constEnd(); ++it) {
1834  if (w->inherits(it.key()))
1835  return it.value();
1836  }
1837  }
1838  return palette();
1839 }
1840 
1852 {
1853  if (!QApplicationPrivate::app_pal)
1854  palette();
1855  PaletteHash *hash = app_palettes();
1856  if (className && hash && hash->size()) {
1858  if (it != hash->constEnd())
1859  return *it;
1860  }
1862 }
1863 
1864 void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash)
1865 {
1866  QPalette pal = palette;
1867 
1868  if (QApplicationPrivate::app_style)
1869  QApplicationPrivate::app_style->polish(pal); // NB: non-const reference
1870 
1871  bool all = false;
1872  PaletteHash *hash = app_palettes();
1873  if (!className) {
1874  if (QApplicationPrivate::app_pal && pal.isCopyOf(*QApplicationPrivate::app_pal))
1875  return;
1876  if (!QApplicationPrivate::app_pal)
1877  QApplicationPrivate::app_pal = new QPalette(pal);
1878  else
1879  *QApplicationPrivate::app_pal = pal;
1880  if (hash && hash->size()) {
1881  all = true;
1882  if (clearWidgetPaletteHash)
1883  hash->clear();
1884  }
1885  } else if (hash) {
1886  hash->insert(className, pal);
1887  }
1888 
1890  // Send ApplicationPaletteChange to qApp itself, and to the widgets.
1893 
1895  for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) {
1896  register QWidget *w = *it;
1897  if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
1898  QApplication::sendEvent(w, &e);
1899  }
1900 
1901  // Send to all scenes as well.
1902 #ifndef QT_NO_GRAPHICSVIEW
1903  QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list;
1905  it != scenes.constEnd(); ++it) {
1907  }
1908 #endif //QT_NO_GRAPHICSVIEW
1909  }
1910  if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) {
1911  if (!QApplicationPrivate::set_pal)
1912  QApplicationPrivate::set_pal = new QPalette(palette);
1913  else
1914  *QApplicationPrivate::set_pal = palette;
1915  }
1916 }
1917 
1942 {
1943  QApplicationPrivate::setPalette_helper(palette, className, /*clearWidgetPaletteHash=*/ true);
1944 }
1945 
1946 
1947 
1949 {
1950  QPalette adjusted;
1951 
1952 #if 0
1953  // adjust the system palette to avoid dithering
1955  if (cmap.depths() > 4 && cmap.depths() < 24) {
1956  for (int g = 0; g < QPalette::NColorGroups; g++)
1957  for (int i = 0; i < QPalette::NColorRoles; i++) {
1959  color = cmap.colorAt(cmap.pixel(color));
1960  adjusted.setColor((QPalette::ColorGroup)g, (QPalette::ColorRole) i, color);
1961  }
1962  }
1963 #else
1964  adjusted = pal;
1965 #endif
1966 
1967  if (!sys_pal)
1968  sys_pal = new QPalette(adjusted);
1969  else
1970  *sys_pal = adjusted;
1971 
1972 
1973  if (!QApplicationPrivate::set_pal)
1974  QApplication::setPalette(*sys_pal);
1975 }
1976 
1983 {
1984  QMutexLocker locker(applicationFontMutex());
1985  if (!QApplicationPrivate::app_font) {
1986 #if defined(Q_OS_BLACKBERRY)
1987  // See http://docs.blackberry.com/en/developers/deliverables/41577/typography.jsp
1988  // which recommends using font family "Slate Pro" and normal font size of 8 points
1989  QApplicationPrivate::app_font = new QFont(QLatin1String("Slate Pro"));
1990  QApplicationPrivate::app_font->setPointSize(8);
1991 #else
1992  QApplicationPrivate::app_font = new QFont(QLatin1String("Helvetica"));
1993 #endif
1994  }
1996 }
1997 
2010 {
2011  FontHash *hash = app_fonts();
2012 
2013 #ifdef Q_WS_MAC
2014  // short circuit for small and mini controls
2015  if (widget->testAttribute(Qt::WA_MacSmallSize)) {
2016  return hash->value("QSmallFont");
2017  } else if (widget->testAttribute(Qt::WA_MacMiniSize)) {
2018  return hash->value("QMiniFont");
2019  }
2020 #endif
2021  if (widget && hash && hash->size()) {
2023  hash->constFind(widget->metaObject()->className());
2024  if (it != hash->constEnd())
2025  return it.value();
2026  for (it = hash->constBegin(); it != hash->constEnd(); ++it) {
2027  if (widget->inherits(it.key()))
2028  return it.value();
2029  }
2030  }
2031  return font();
2032 }
2033 
2045 {
2046  FontHash *hash = app_fonts();
2047  if (className && hash && hash->size()) {
2049  if (it != hash->constEnd())
2050  return *it;
2051  }
2052  return font();
2053 }
2054 
2055 
2075 void QApplication::setFont(const QFont &font, const char *className)
2076 {
2077  bool all = false;
2078  FontHash *hash = app_fonts();
2079  if (!className) {
2080  QMutexLocker locker(applicationFontMutex());
2081  if (!QApplicationPrivate::app_font)
2082  QApplicationPrivate::app_font = new QFont(font);
2083  else
2084  *QApplicationPrivate::app_font = font;
2085  if (hash && hash->size()) {
2086  all = true;
2087  hash->clear();
2088  }
2089  } else if (hash) {
2090  hash->insert(className, font);
2091  }
2093  // Send ApplicationFontChange to qApp itself, and to the widgets.
2096 
2098  for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) {
2099  register QWidget *w = *it;
2100  if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
2101  sendEvent(w, &e);
2102  }
2103 
2104 #ifndef QT_NO_GRAPHICSVIEW
2105  // Send to all scenes as well.
2106  QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list;
2108  it != scenes.constEnd(); ++it) {
2110  }
2111 #endif //QT_NO_GRAPHICSVIEW
2112  }
2113  if (!className && (!QApplicationPrivate::sys_font || !font.isCopyOf(*QApplicationPrivate::sys_font))) {
2114  if (!QApplicationPrivate::set_font)
2115  QApplicationPrivate::set_font = new QFont(font);
2116  else
2117  *QApplicationPrivate::set_font = font;
2118  }
2119 }
2120 
2124 {
2125  if (!sys_font)
2126  sys_font = new QFont(font);
2127  else
2128  *sys_font = font;
2129 
2130  if (!QApplicationPrivate::set_font)
2131  QApplication::setFont(*sys_font);
2132 }
2133 
2137 {
2138  return qt_guiPlatformPlugin()->styleName();
2139 }
2140 
2151 {
2152  return QApplicationPrivate::app_icon ? *QApplicationPrivate::app_icon : QIcon();
2153 }
2154 
2156 {
2157  if (!QApplicationPrivate::app_icon)
2158  QApplicationPrivate::app_icon = new QIcon();
2159  *QApplicationPrivate::app_icon = icon;
2161 #ifdef Q_WS_MAC
2162  void qt_mac_set_app_icon(const QPixmap &); //qapplication_mac.cpp
2163  QSize size = QApplicationPrivate::app_icon->actualSize(QSize(128, 128));
2164  qt_mac_set_app_icon(QApplicationPrivate::app_icon->pixmap(size));
2165 #endif
2168  for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
2169  register QWidget *w = *it;
2170  if (w->isWindow())
2171  sendEvent(w, &e);
2172  }
2173  }
2174 }
2175 
2189 {
2190  QWidgetList list;
2192 
2193  for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
2194  QWidget *w = *it;
2195  if (w->isWindow() && w->windowType() != Qt::Desktop)
2196  list.append(w);
2197  }
2198  return list;
2199 }
2200 
2215 {
2218  return QWidgetList();
2219 }
2220 
2229 {
2231 }
2232 
2234 {
2235 #ifndef QT_NO_GRAPHICSVIEW
2236  if (focus && focus->window()->graphicsProxyWidget())
2237  return;
2238 #endif
2239 
2240  hidden_focus_widget = 0;
2241 
2242  if (focus != focus_widget) {
2243  if (focus && focus->isHidden()) {
2244  hidden_focus_widget = focus;
2245  return;
2246  }
2247 
2248  if (focus && (reason == Qt::BacktabFocusReason || reason == Qt::TabFocusReason)
2251  else if (focus && reason == Qt::ShortcutFocusReason) {
2253  }
2254  QWidget *prev = focus_widget;
2255  focus_widget = focus;
2256 #ifndef QT_NO_IM
2257  if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
2259  // Do reset the input context, in case the new focus widget won't accept keyboard input
2260  // or it is not created fully yet.
2261  || (focus_widget && (!focus_widget->testAttribute(Qt::WA_InputMethodEnabled)
2262  || !focus_widget->testAttribute(Qt::WA_WState_Created))))) {
2263  QInputContext *qic = prev->inputContext();
2264  if(qic) {
2265  qic->reset();
2266  qic->setFocusWidget(0);
2267  }
2268  }
2269 #endif //QT_NO_IM
2270 
2271  if(focus_widget)
2272  focus_widget->d_func()->setFocus_sys();
2273 
2274  if (reason != Qt::NoFocusReason) {
2275 
2276  //send events
2277  if (prev) {
2278 #ifdef QT_KEYPAD_NAVIGATION
2279  if (QApplication::keypadNavigationEnabled()) {
2280  if (prev->hasEditFocus() && reason != Qt::PopupFocusReason
2281 #ifdef Q_OS_SYMBIAN
2282  && reason != Qt::ActiveWindowFocusReason
2283 #endif
2284  )
2285  prev->setEditFocus(false);
2286  }
2287 #endif
2288 #ifndef QT_NO_IM
2289  if (focus) {
2290  QInputContext *prevIc;
2291  prevIc = prev->inputContext();
2292  if (prevIc && prevIc != focus->inputContext()) {
2293  QEvent closeSIPEvent(QEvent::CloseSoftwareInputPanel);
2294  QApplication::sendEvent(prev, &closeSIPEvent);
2295  }
2296  }
2297 #endif
2298  QFocusEvent out(QEvent::FocusOut, reason);
2299  QPointer<QWidget> that = prev;
2300  QApplication::sendEvent(prev, &out);
2301  if (that)
2302  QApplication::sendEvent(that->style(), &out);
2303  }
2304  if(focus && QApplicationPrivate::focus_widget == focus) {
2305 #ifndef QT_NO_IM
2307  QInputContext *qic = focus->inputContext();
2308  if (qic && focus->testAttribute(Qt::WA_WState_Created)
2309  && focus->isEnabled())
2310  qic->setFocusWidget(focus);
2311  }
2312 #endif //QT_NO_IM
2313  QFocusEvent in(QEvent::FocusIn, reason);
2314  QPointer<QWidget> that = focus;
2315  QApplication::sendEvent(focus, &in);
2316  if (that)
2317  QApplication::sendEvent(that->style(), &in);
2318  }
2319  emit qApp->focusChanged(prev, focus_widget);
2320  }
2321  }
2322 }
2323 
2324 
2335 {
2337 }
2338 
2346 {
2347  return desktop()->fontMetrics();
2348 }
2349 
2350 
2370 {
2371  bool did_close = true;
2372  QWidget *w;
2373  while ((w = activeModalWidget()) && did_close) {
2374  if (!w->isVisible() || w->data->is_closing)
2375  break;
2376  did_close = w->close();
2377  }
2379  for (int i = 0; did_close && i < list.size(); ++i) {
2380  w = list.at(i);
2381  if (w->isVisible()
2382  && w->windowType() != Qt::Desktop
2383  && !w->data->is_closing) {
2384  did_close = w->close();
2386  i = -1;
2387  }
2388  }
2389 }
2390 
2401 {
2402 #ifndef QT_NO_MESSAGEBOX
2404 #ifdef Q_WS_MAC
2405  0
2406 #else
2407  activeWindow()
2408 #endif // Q_WS_MAC
2409  );
2410 #endif // QT_NO_MESSAGEBOX
2411 }
2412 
2413 
2469 #ifndef QT_NO_TRANSLATION
2471 {
2472  return force_reverse ^
2473  (QApplication::tr("QT_LAYOUT_DIRECTION",
2474  "Translate this string to the string 'LTR' in left-to-right"
2475  " languages or to 'RTL' in right-to-left languages (such as Hebrew"
2476  " and Arabic) to get proper widget layout.") == QLatin1String("RTL"));
2477 }
2478 #if defined(Q_WS_MAC)
2479 static const char *application_menu_strings[] = {
2480  QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"),
2481  QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"),
2482  QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"),
2483  QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All"),
2484  QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Preferences..."),
2485  QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Quit %1"),
2486  QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","About %1")
2487  };
2489 {
2491  QString translated = qApp->translate("QMenuBar", application_menu_strings[type]);
2492  if (translated != menuString)
2493  return translated;
2494  else
2495  return qApp->translate("MAC_APPLICATION_MENU",
2496  application_menu_strings[type]);
2497 }
2498 #endif
2499 #endif
2500 
2505 {
2506  Q_D(QApplication);
2507  if(e->type() == QEvent::Close) {
2508 #if defined(Q_OS_SYMBIAN)
2509  // In order to have proper application-exit effects on Symbian, certain
2510  // native APIs have to be called _before_ closing/destroying the widgets.
2511  bool effectStarted = qt_beginFullScreenEffect();
2512 #endif
2513  QCloseEvent *ce = static_cast<QCloseEvent*>(e);
2514  ce->accept();
2515  closeAllWindows();
2516 
2517  QWidgetList list = topLevelWidgets();
2518  for (int i = 0; i < list.size(); ++i) {
2519  QWidget *w = list.at(i);
2520  if (w->isVisible() && !(w->windowType() == Qt::Desktop) && !(w->windowType() == Qt::Popup) &&
2521  (!(w->windowType() == Qt::Dialog) || !w->parentWidget())) {
2522  ce->ignore();
2523  break;
2524  }
2525  }
2526  if (ce->isAccepted()) {
2527  return true;
2528  } else {
2529 #if defined(Q_OS_SYMBIAN)
2530  if (effectStarted)
2531  qt_abortFullScreenEffect();
2532 #endif
2533  }
2534  } else if(e->type() == QEvent::LanguageChange) {
2535 #ifndef QT_NO_TRANSLATION
2537 #endif
2538 #if defined(QT_MAC_USE_COCOA)
2540 #endif
2541  QWidgetList list = topLevelWidgets();
2542  for (int i = 0; i < list.size(); ++i) {
2543  QWidget *w = list.at(i);
2544  if (!(w->windowType() == Qt::Desktop))
2546  }
2547 #ifndef Q_OS_WIN
2548  } else if (e->type() == QEvent::LocaleChange) {
2549  // on Windows the event propagation is taken care by the
2550  // WM_SETTINGCHANGE event handler.
2551  QWidgetList list = topLevelWidgets();
2552  for (int i = 0; i < list.size(); ++i) {
2553  QWidget *w = list.at(i);
2554  if (!(w->windowType() == Qt::Desktop)) {
2556  w->d_func()->setLocale_helper(QLocale(), true);
2557  }
2558  }
2559 #endif
2560  } else if (e->type() == QEvent::Timer) {
2561  QTimerEvent *te = static_cast<QTimerEvent*>(e);
2562  Q_ASSERT(te != 0);
2563  if (te->timerId() == d->toolTipWakeUp.timerId()) {
2564  d->toolTipWakeUp.stop();
2565  if (d->toolTipWidget) {
2566  QWidget *w = d->toolTipWidget->window();
2567  // show tooltip if WA_AlwaysShowToolTips is set, or if
2568  // any ancestor of d->toolTipWidget is the active
2569  // window
2571  while (w && !showToolTip) {
2572  showToolTip = w->isActiveWindow();
2573  w = w->parentWidget();
2574  w = w ? w->window() : 0;
2575  }
2576  if (showToolTip) {
2577  QHelpEvent e(QEvent::ToolTip, d->toolTipPos, d->toolTipGlobalPos);
2578  QApplication::sendEvent(d->toolTipWidget, &e);
2579  if (e.isAccepted())
2580  d->toolTipFallAsleep.start(2000, this);
2581  }
2582  }
2583  } else if (te->timerId() == d->toolTipFallAsleep.timerId()) {
2584  d->toolTipFallAsleep.stop();
2585  }
2586  }
2587  return QCoreApplication::event(e);
2588 }
2589 #if !defined(Q_WS_X11)
2590 
2591 // The doc and X implementation of this function is in qapplication_x11.cpp
2592 
2593 void QApplication::syncX() {} // do nothing
2594 
2595 #endif
2596 
2623 {
2624  QWidget* window = act?act->window():0;
2625 
2626  if (QApplicationPrivate::active_window == window)
2627  return;
2628 
2629 #ifndef QT_NO_GRAPHICSVIEW
2630  if (window && window->graphicsProxyWidget()) {
2631  // Activate the proxy's view->viewport() ?
2632  return;
2633  }
2634 #endif
2635 
2636  QWidgetList toBeActivated;
2637  QWidgetList toBeDeactivated;
2638 
2639  if (QApplicationPrivate::active_window) {
2640  if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) {
2641  QWidgetList list = topLevelWidgets();
2642  for (int i = 0; i < list.size(); ++i) {
2643  QWidget *w = list.at(i);
2644  if (w->isVisible() && w->isActiveWindow())
2645  toBeDeactivated.append(w);
2646  }
2647  } else {
2648  toBeDeactivated.append(QApplicationPrivate::active_window);
2649  }
2650  }
2651 
2652 #if !defined(Q_WS_MAC)
2653  QWidget *previousActiveWindow = QApplicationPrivate::active_window;
2654 #endif
2655  QApplicationPrivate::active_window = window;
2656 
2657  if (QApplicationPrivate::active_window) {
2658  if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) {
2659  QWidgetList list = topLevelWidgets();
2660  for (int i = 0; i < list.size(); ++i) {
2661  QWidget *w = list.at(i);
2662  if (w->isVisible() && w->isActiveWindow())
2663  toBeActivated.append(w);
2664  }
2665  } else {
2666  toBeActivated.append(QApplicationPrivate::active_window);
2667  }
2668 
2669  }
2670 
2671  // first the activation/deactivation events
2672  QEvent activationChange(QEvent::ActivationChange);
2673  QEvent windowActivate(QEvent::WindowActivate);
2674  QEvent windowDeactivate(QEvent::WindowDeactivate);
2675 
2676 #if !defined(Q_WS_MAC)
2677  if (!previousActiveWindow) {
2678  QEvent appActivate(QEvent::ApplicationActivate);
2679  sendSpontaneousEvent(qApp, &appActivate);
2680  }
2681 #endif
2682 
2683  for (int i = 0; i < toBeActivated.size(); ++i) {
2684  QWidget *w = toBeActivated.at(i);
2685  sendSpontaneousEvent(w, &windowActivate);
2686  sendSpontaneousEvent(w, &activationChange);
2687  }
2688 
2689 #ifdef QT_MAC_USE_COCOA
2690  // In case the user clicked on a child window, we need to
2691  // reestablish the stacking order of the window so
2692  // it pops in front of other child windows in cocoa:
2693  qt_cocoaStackChildWindowOnTopOfOtherChildren(window);
2694 #endif
2695 
2696  for(int i = 0; i < toBeDeactivated.size(); ++i) {
2697  QWidget *w = toBeDeactivated.at(i);
2698  sendSpontaneousEvent(w, &windowDeactivate);
2699  sendSpontaneousEvent(w, &activationChange);
2700  }
2701 
2702 #if !defined(Q_WS_MAC)
2703  if (!QApplicationPrivate::active_window) {
2704  QEvent appDeactivate(QEvent::ApplicationDeactivate);
2705  sendSpontaneousEvent(qApp, &appDeactivate);
2706  }
2707 #endif
2708 
2709  if (QApplicationPrivate::popupWidgets == 0) { // !inPopupMode()
2710  // then focus events
2711  if (!QApplicationPrivate::active_window && QApplicationPrivate::focus_widget) {
2713  } else if (QApplicationPrivate::active_window) {
2714  QWidget *w = QApplicationPrivate::active_window->focusWidget();
2715  if (w && w->isVisible() /*&& w->focusPolicy() != QWidget::NoFocus*/)
2717  else {
2718  w = QApplicationPrivate::focusNextPrevChild_helper(QApplicationPrivate::active_window, true);
2719  if (w) {
2721  } else {
2722  // If the focus widget is not in the activate_window, clear the focus
2724  if (!w && QApplicationPrivate::active_window->focusPolicy() != Qt::NoFocus)
2725  QApplicationPrivate::setFocusWidget(QApplicationPrivate::active_window, Qt::ActiveWindowFocusReason);
2726  else if (!QApplicationPrivate::active_window->isAncestorOf(w))
2728  }
2729  }
2730  }
2731  }
2732 }
2733 
2740 {
2742 
2743  QWidget *f = toplevel->focusWidget();
2744  if (!f)
2745  f = toplevel;
2746 
2747  QWidget *w = f;
2748  QWidget *test = f->d_func()->focus_next;
2749  while (test && test != f) {
2750  if ((test->focusPolicy() & focus_flag) == focus_flag
2751  && !(test->d_func()->extra && test->d_func()->extra->focus_proxy)
2752  && test->isVisibleTo(toplevel) && test->isEnabled()
2753  && !(w->windowType() == Qt::SubWindow && !w->isAncestorOf(test))
2754  && (toplevel->windowType() != Qt::SubWindow || toplevel->isAncestorOf(test))) {
2755  w = test;
2756  if (next)
2757  break;
2758  }
2759  test = test->d_func()->focus_next;
2760  }
2761  if (w == f) {
2762  if (qt_in_tab_key_event) {
2764  w->update();
2765  }
2766  return 0;
2767  }
2768  return w;
2769 }
2770 
2779 #if 0
2780  if (leave) {
2781  QEvent e(QEvent::Leave);
2782  QApplication::sendEvent(leave, & e);
2783  }
2784  if (enter) {
2785  QEvent e(QEvent::Enter);
2786  QApplication::sendEvent(enter, & e);
2787  }
2788  return;
2789 #endif
2790 
2791  QWidget* w ;
2792  if ((!enter && !leave) || (enter == leave))
2793  return;
2794 #ifdef ALIEN_DEBUG
2795  qDebug() << "QApplicationPrivate::dispatchEnterLeave, ENTER:" << enter << "LEAVE:" << leave;
2796 #endif
2797  QWidgetList leaveList;
2798  QWidgetList enterList;
2799 
2800  bool sameWindow = leave && enter && leave->window() == enter->window();
2801  if (leave && !sameWindow) {
2802  w = leave;
2803  do {
2804  leaveList.append(w);
2805  } while (!w->isWindow() && (w = w->parentWidget()));
2806  }
2807  if (enter && !sameWindow) {
2808  w = enter;
2809  do {
2810  enterList.prepend(w);
2811  } while (!w->isWindow() && (w = w->parentWidget()));
2812  }
2813  if (sameWindow) {
2814  int enterDepth = 0;
2815  int leaveDepth = 0;
2816  w = enter;
2817  while (!w->isWindow() && (w = w->parentWidget()))
2818  enterDepth++;
2819  w = leave;
2820  while (!w->isWindow() && (w = w->parentWidget()))
2821  leaveDepth++;
2822  QWidget* wenter = enter;
2823  QWidget* wleave = leave;
2824  while (enterDepth > leaveDepth) {
2825  wenter = wenter->parentWidget();
2826  enterDepth--;
2827  }
2828  while (leaveDepth > enterDepth) {
2829  wleave = wleave->parentWidget();
2830  leaveDepth--;
2831  }
2832  while (!wenter->isWindow() && wenter != wleave) {
2833  wenter = wenter->parentWidget();
2834  wleave = wleave->parentWidget();
2835  }
2836 
2837  w = leave;
2838  while (w != wleave) {
2839  leaveList.append(w);
2840  w = w->parentWidget();
2841  }
2842  w = enter;
2843  while (w != wenter) {
2844  enterList.prepend(w);
2845  w = w->parentWidget();
2846  }
2847  }
2848 
2849  QEvent leaveEvent(QEvent::Leave);
2850  for (int i = 0; i < leaveList.size(); ++i) {
2851  w = leaveList.at(i);
2853 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC)
2854  if (leaveAfterRelease == w)
2855  leaveAfterRelease = 0;
2856 #endif
2857  QApplication::sendEvent(w, &leaveEvent);
2858  if (w->testAttribute(Qt::WA_Hover) &&
2860  Q_ASSERT(instance());
2862  qApp->d_func()->notify_helper(w, &he);
2863  }
2864  }
2865  }
2866  QPoint posEnter = QCursor::pos();
2867  QEvent enterEvent(QEvent::Enter);
2868  for (int i = 0; i < enterList.size(); ++i) {
2869  w = enterList.at(i);
2871  QApplication::sendEvent(w, &enterEvent);
2872  if (w->testAttribute(Qt::WA_Hover) &&
2874  QHoverEvent he(QEvent::HoverEnter, w->mapFromGlobal(posEnter), QPoint(-1, -1));
2875  qApp->d_func()->notify_helper(w, &he);
2876  }
2877  }
2878  }
2879 
2880 #ifndef QT_NO_CURSOR
2881  // Update cursor for alien/graphics widgets.
2882 
2883  const bool enterOnAlien = (enter && (isAlien(enter) || enter->testAttribute(Qt::WA_DontShowOnScreen)));
2884 #if defined(Q_WS_X11) || defined(Q_WS_QPA)
2885  //Whenever we leave an alien widget on X11, we need to reset its nativeParentWidget()'s cursor.
2886  // This is not required on Windows as the cursor is reset on every single mouse move.
2887  QWidget *parentOfLeavingCursor = 0;
2888  for (int i = 0; i < leaveList.size(); ++i) {
2889  w = leaveList.at(i);
2890  if (!isAlien(w))
2891  break;
2892  if (w->testAttribute(Qt::WA_SetCursor)) {
2893  QWidget *parent = w->parentWidget();
2894  while (parent && parent->d_func()->data.in_destructor)
2895  parent = parent->parentWidget();
2896  parentOfLeavingCursor = parent;
2897  //continue looping, we need to find the downest alien widget with a cursor.
2898  // (downest on the screen)
2899  }
2900  }
2901  //check that we will not call qt_x11_enforce_cursor twice with the same native widget
2902  if (parentOfLeavingCursor && (!enterOnAlien
2903  || parentOfLeavingCursor->effectiveWinId() != enter->effectiveWinId())) {
2904 #ifndef QT_NO_GRAPHICSVIEW
2905  if (!parentOfLeavingCursor->window()->graphicsProxyWidget())
2906 #endif
2907  {
2908 #if defined(Q_WS_X11)
2909  qt_x11_enforce_cursor(parentOfLeavingCursor,true);
2910 #elif defined(Q_WS_QPA)
2911  if (enter == QApplication::desktop()) {
2912  qt_qpa_set_cursor(enter, true);
2913  } else {
2914  qt_qpa_set_cursor(parentOfLeavingCursor, true);
2915  }
2916 #endif
2917  }
2918  }
2919 #endif
2920  if (enterOnAlien) {
2921  QWidget *cursorWidget = enter;
2922  while (!cursorWidget->isWindow() && !cursorWidget->isEnabled())
2923  cursorWidget = cursorWidget->parentWidget();
2924 
2925  if (!cursorWidget)
2926  return;
2927 
2928 #ifndef QT_NO_GRAPHICSVIEW
2929  if (cursorWidget->window()->graphicsProxyWidget()) {
2930  QWidgetPrivate::nearestGraphicsProxyWidget(cursorWidget)->setCursor(cursorWidget->cursor());
2931  } else
2932 #endif
2933  {
2934 #if defined(Q_WS_WIN)
2935  qt_win_set_cursor(cursorWidget, true);
2936 #elif defined(Q_WS_X11)
2937  qt_x11_enforce_cursor(cursorWidget, true);
2938 #elif defined(Q_OS_SYMBIAN)
2939  qt_symbian_set_cursor(cursorWidget, true);
2940 #elif defined(Q_WS_QPA)
2941  qt_qpa_set_cursor(cursorWidget, true);
2942 #endif
2943  }
2944  }
2945 #endif
2946 }
2947 
2948 /* exported for the benefit of testing tools */
2950 {
2951  return QApplicationPrivate::tryModalHelper(widget, rettop);
2952 }
2953 
2961 {
2962  widget = widget->window();
2963  if (!modalState())
2964  return false;
2965  if (QApplication::activePopupWidget() == widget)
2966  return false;
2967 
2968  for (int i = 0; i < qt_modal_stack->size(); ++i) {
2969  QWidget *modalWidget = qt_modal_stack->at(i);
2970 
2971  {
2972  // check if the active modal widget is our widget or a parent of our widget
2973  QWidget *w = widget;
2974  while (w) {
2975  if (w == modalWidget)
2976  return false;
2977  w = w->parentWidget();
2978  }
2979 #ifdef Q_WS_WIN
2980  if ((widget->testAttribute(Qt::WA_WState_Created) || widget->data->winid)
2981  && (modalWidget->testAttribute(Qt::WA_WState_Created) || modalWidget->data->winid)
2982  && IsChild(modalWidget->data->winid, widget->data->winid))
2983  return false;
2984 #endif
2985  }
2986 
2987  Qt::WindowModality windowModality = modalWidget->windowModality();
2988  if (windowModality == Qt::NonModal) {
2989  // determine the modality type if it hasn't been set on the
2990  // modalWidget, this normally happens when waiting for a
2991  // native dialog. use WindowModal if we are the child of a
2992  // group leader; otherwise use ApplicationModal.
2993  QWidget *m = modalWidget;
2994  while (m && !m->testAttribute(Qt::WA_GroupLeader)) {
2995  m = m->parentWidget();
2996  if (m)
2997  m = m->window();
2998  }
2999  windowModality = (m && m->testAttribute(Qt::WA_GroupLeader))
3000  ? Qt::WindowModal
3002  }
3003 
3004  switch (windowModality) {
3005  case Qt::ApplicationModal:
3006  {
3007  QWidget *groupLeaderForWidget = widget;
3008  while (groupLeaderForWidget && !groupLeaderForWidget->testAttribute(Qt::WA_GroupLeader))
3009  groupLeaderForWidget = groupLeaderForWidget->parentWidget();
3010 
3011  if (groupLeaderForWidget) {
3012  // if \a widget has WA_GroupLeader, it can only be blocked by ApplicationModal children
3013  QWidget *m = modalWidget;
3014  while (m && m != groupLeaderForWidget && !m->testAttribute(Qt::WA_GroupLeader))
3015  m = m->parentWidget();
3016  if (m == groupLeaderForWidget)
3017  return true;
3018  } else if (modalWidget != widget) {
3019  return true;
3020  }
3021  break;
3022  }
3023  case Qt::WindowModal:
3024  {
3025  QWidget *w = widget;
3026  do {
3027  QWidget *m = modalWidget;
3028  do {
3029  if (m == w)
3030  return true;
3031  m = m->parentWidget();
3032  if (m)
3033  m = m->window();
3034  } while (m);
3035  w = w->parentWidget();
3036  if (w)
3037  w = w->window();
3038  } while (w);
3039  break;
3040  }
3041  default:
3042  Q_ASSERT_X(false, "QApplication", "internal error, a modal widget cannot be modeless");
3043  break;
3044  }
3045  }
3046  return false;
3047 }
3048 
3052 {
3053  QSet<QWidget*> blocked;
3055  for (int i = 0; i < windows.count(); ++i) {
3056  QWidget *window = windows.at(i);
3057  if (window->windowType() != Qt::Tool && isBlockedByModal(window))
3058  blocked.insert(window);
3059  }
3060 
3061  enterModal_sys(widget);
3062 
3063  windows = QApplication::topLevelWidgets();
3065  for (int i = 0; i < windows.count(); ++i) {
3066  QWidget *window = windows.at(i);
3067  if (!blocked.contains(window) && window->windowType() != Qt::Tool && isBlockedByModal(window))
3068  QApplication::sendEvent(window, &e);
3069  }
3070 }
3071 
3075 {
3076  QSet<QWidget*> blocked;
3078  for (int i = 0; i < windows.count(); ++i) {
3079  QWidget *window = windows.at(i);
3080  if (window->windowType() != Qt::Tool && isBlockedByModal(window))
3081  blocked.insert(window);
3082  }
3083 
3084  leaveModal_sys(widget);
3085 
3086  windows = QApplication::topLevelWidgets();
3088  for (int i = 0; i < windows.count(); ++i) {
3089  QWidget *window = windows.at(i);
3090  if(blocked.contains(window) && window->windowType() != Qt::Tool && !isBlockedByModal(window))
3091  QApplication::sendEvent(window, &e);
3092  }
3093 }
3094 
3095 
3096 
3103 {
3105  if (rettop)
3106  *rettop = top;
3107 
3108  // the active popup widget always gets the input event
3110  return true;
3111 
3112 #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
3114  if (rettop)
3115  *rettop = top;
3116 #endif
3117 
3118  return !isBlockedByModal(widget->window());
3119 }
3120 
3121 /*
3122  \internal
3123 */
3125  QPoint &pos, QEvent::Type type,
3126  Qt::MouseButtons buttons, QWidget *buttonDown,
3127  QWidget *alienWidget)
3128 {
3129  Q_ASSERT(candidate);
3130 
3131  QWidget *mouseGrabber = QWidget::mouseGrabber();
3132  if (((type == QEvent::MouseMove && buttons) || (type == QEvent::MouseButtonRelease))
3133  && !buttonDown && !mouseGrabber) {
3134  return 0;
3135  }
3136 
3137  if (alienWidget && alienWidget->internalWinId())
3138  alienWidget = 0;
3139 
3140  QWidget *receiver = candidate;
3141 
3142  if (!mouseGrabber)
3143  mouseGrabber = (buttonDown && !isBlockedByModal(buttonDown)) ? buttonDown : alienWidget;
3144 
3145  if (mouseGrabber && mouseGrabber != candidate) {
3146  receiver = mouseGrabber;
3147  pos = receiver->mapFromGlobal(globalPos);
3148 #ifdef ALIEN_DEBUG
3149  qDebug() << " ** receiver adjusted to:" << receiver << "pos:" << pos;
3150 #endif
3151  }
3152 
3153  return receiver;
3154 
3155 }
3156 
3157 /*
3158  \internal
3159 */
3161  QWidget *alienWidget, QWidget *nativeWidget,
3162  QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver,
3163  bool spontaneous)
3164 {
3165  Q_ASSERT(receiver);
3166  Q_ASSERT(event);
3167  Q_ASSERT(nativeWidget);
3168  Q_ASSERT(buttonDown);
3169 
3170  if (alienWidget && !isAlien(alienWidget))
3171  alienWidget = 0;
3172 
3173  QPointer<QWidget> receiverGuard = receiver;
3174  QPointer<QWidget> nativeGuard = nativeWidget;
3175  QPointer<QWidget> alienGuard = alienWidget;
3177 
3178  const bool graphicsWidget = nativeWidget->testAttribute(Qt::WA_DontShowOnScreen);
3179 
3180  if (*buttonDown) {
3181  if (!graphicsWidget) {
3182  // Register the widget that shall receive a leave event
3183  // after the last button is released.
3184  if ((alienWidget || !receiver->internalWinId()) && !leaveAfterRelease && !QWidget::mouseGrabber())
3185  leaveAfterRelease = *buttonDown;
3186  if (event->type() == QEvent::MouseButtonRelease && !event->buttons())
3187  *buttonDown = 0;
3188  }
3189  } else if (lastMouseReceiver) {
3190  // Dispatch enter/leave if we move:
3191  // 1) from an alien widget to another alien widget or
3192  // from a native widget to an alien widget (first OR case)
3193  // 2) from an alien widget to a native widget (second OR case)
3194  if ((alienWidget && alienWidget != lastMouseReceiver)
3195  || (isAlien(lastMouseReceiver) && !alienWidget)) {
3196  if (activePopupWidget) {
3197  if (!QWidget::mouseGrabber())
3198  dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver);
3199  } else {
3200  dispatchEnterLeave(receiver, lastMouseReceiver);
3201  }
3202 
3203  }
3204  }
3205 
3206 #ifdef ALIEN_DEBUG
3207  qDebug() << "QApplicationPrivate::sendMouseEvent: receiver:" << receiver
3208  << "pos:" << event->pos() << "alien" << alienWidget << "button down"
3209  << *buttonDown << "last" << lastMouseReceiver << "leave after release"
3210  << leaveAfterRelease;
3211 #endif
3212 
3213  // We need this quard in case someone opens a modal dialog / popup. If that's the case
3214  // leaveAfterRelease is set to null, but we shall not update lastMouseReceiver.
3215  const bool wasLeaveAfterRelease = leaveAfterRelease != 0;
3216  bool result;
3217  if (spontaneous)
3218  result = QApplication::sendSpontaneousEvent(receiver, event);
3219  else
3220  result = QApplication::sendEvent(receiver, event);
3221 
3222  if (!graphicsWidget && leaveAfterRelease && event->type() == QEvent::MouseButtonRelease
3223  && !event->buttons() && QWidget::mouseGrabber() != leaveAfterRelease) {
3224  // Dispatch enter/leave if:
3225  // 1) the mouse grabber is an alien widget
3226  // 2) the button is released on an alien widget
3227  QWidget *enter = 0;
3228  if (nativeGuard)
3229  enter = alienGuard ? alienWidget : nativeWidget;
3230  else // The receiver is typically deleted on mouse release with drag'n'drop.
3231  enter = QApplication::widgetAt(event->globalPos());
3232  dispatchEnterLeave(enter, leaveAfterRelease);
3233  leaveAfterRelease = 0;
3234  lastMouseReceiver = enter;
3235  } else if (!wasLeaveAfterRelease) {
3236  if (activePopupWidget) {
3237  if (!QWidget::mouseGrabber())
3238  lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : 0);
3239  } else {
3240  lastMouseReceiver = receiverGuard ? receiver : QApplication::widgetAt(event->globalPos());
3241  }
3242  }
3243 
3244  return result;
3245 }
3246 
3247 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
3248 /*
3249  This function should only be called when the widget changes visibility, i.e.
3250  when the \a widget is shown, hidden or deleted. This function does nothing
3251  if the widget is a top-level or native, i.e. not an alien widget. In that
3252  case enter/leave events are genereated by the underlying windowing system.
3253 */
3255 extern QWidget *qt_button_down;
3257 {
3258 #ifndef QT_NO_CURSOR
3259 #if defined(Q_WS_QWS) || defined(Q_WS_QPA)
3260  if (!widget || widget->isWindow())
3261  return;
3262 #else
3263  if (!widget || widget->internalWinId() || widget->isWindow())
3264  return;
3265 #endif
3266  const bool widgetInShow = widget->isVisible() && !widget->data->in_destructor;
3267  if (!widgetInShow && widget != qt_last_mouse_receiver)
3268  return; // Widget was not under the cursor when it was hidden/deleted.
3269 
3270  if (widgetInShow && widget->parentWidget()->data->in_show)
3271  return; // Ingore recursive show.
3272 
3273  QWidget *mouseGrabber = QWidget::mouseGrabber();
3274  if (mouseGrabber && mouseGrabber != widget)
3275  return; // Someone else has the grab; enter/leave should not occur.
3276 
3277  QWidget *tlw = widget->window();
3278  if (tlw->data->in_destructor || tlw->data->is_closing)
3279  return; // Closing down the business.
3280 
3281  if (widgetInShow && (!qt_last_mouse_receiver || qt_last_mouse_receiver->window() != tlw))
3282  return; // Mouse cursor not inside the widget's top-level.
3283 
3284  const QPoint globalPos(QCursor::pos());
3285  QPoint pos = tlw->mapFromGlobal(globalPos);
3286 
3287  // Find the current widget under the mouse. If this function was called from
3288  // the widget's destructor, we have to make sure childAt() doesn't take into
3289  // account widgets that are about to be destructed.
3290  QWidget *widgetUnderCursor = tlw->d_func()->childAt_helper(pos, widget->data->in_destructor);
3291  if (!widgetUnderCursor)
3292  widgetUnderCursor = tlw;
3293  else
3294  pos = widgetUnderCursor->mapFrom(tlw, pos);
3295 
3296  if (widgetInShow && widgetUnderCursor != widget && !widget->isAncestorOf(widgetUnderCursor))
3297  return; // Mouse cursor not inside the widget or any of its children.
3298 
3299  if (widget->data->in_destructor && qt_button_down == widget)
3300  qt_button_down = 0;
3301 
3302  // Send enter/leave events followed by a mouse move on the entered widget.
3304  sendMouseEvent(widgetUnderCursor, &e, widgetUnderCursor, tlw, &qt_button_down, qt_last_mouse_receiver);
3305 #endif // QT_NO_CURSOR
3306 }
3307 #endif // Q_WS_WIN || Q_WS_X11 || Q_WS_MAC
3308 
3321 {
3322  if (!qt_desktopWidget || // not created yet
3323  !(qt_desktopWidget->windowType() == Qt::Desktop)) { // reparented away
3324  qt_desktopWidget = new QDesktopWidget();
3325  }
3326  return qt_desktopWidget;
3327 }
3328 
3329 #ifndef QT_NO_CLIPBOARD
3330 
3337 {
3338  if (qt_clipboard == 0) {
3339  if (!qApp) {
3340  qWarning("QApplication: Must construct a QApplication before accessing a QClipboard");
3341  return 0;
3342  }
3343  qt_clipboard = new QClipboard(0);
3344  }
3345  return qt_clipboard;
3346 }
3347 #endif // QT_NO_CLIPBOARD
3348 
3361 {
3363 }
3364 
3372 {
3374 }
3375 
3390 Qt::KeyboardModifiers QApplication::keyboardModifiers()
3391 {
3393 }
3394 
3431 Qt::MouseButtons QApplication::mouseButtons()
3432 {
3434 }
3435 
3480 #ifndef QT_NO_SESSIONMANAGER
3482 {
3483  Q_D(const QApplication);
3484  return d->is_session_restored;
3485 }
3486 
3488 {
3489  Q_D(const QApplication);
3490  return d->session_id;
3491 }
3492 
3494 {
3495  Q_D(const QApplication);
3496  return d->session_key;
3497 }
3498 #endif
3499 
3591 #ifndef QT_NO_SESSIONMANAGER
3593 {
3594  emit commitDataRequest(manager);
3595  if (manager.allowsInteraction()) {
3596  QWidgetList done;
3598  bool cancelled = false;
3599  for (int i = 0; !cancelled && i < list.size(); ++i) {
3600  QWidget* w = list.at(i);
3601  if (w->isVisible() && !done.contains(w)) {
3602  cancelled = !w->close();
3603  if (!cancelled)
3604  done.append(w);
3606  i = -1;
3607  }
3608  }
3609  if (cancelled)
3610  manager.cancel();
3611  }
3612 }
3613 
3669 {
3670  emit saveStateRequest(manager);
3671 }
3672 #endif //QT_NO_SESSIONMANAGER
3673 /*
3674  Sets the time after which a drag should start to \a ms ms.
3675 
3676  \sa startDragTime()
3677 */
3678 
3680 {
3681  drag_time = ms;
3682 }
3683 
3705 {
3706  return drag_time;
3707 }
3708 
3709 /*
3710  Sets the distance after which a drag should start to \a l pixels.
3711 
3712  \sa startDragDistance()
3713 */
3714 
3716 {
3717  drag_distance = l;
3718 }
3719 
3745 {
3746  return drag_distance;
3747 }
3748 
3805 {
3806  if (layout_direction == direction || direction == Qt::LayoutDirectionAuto)
3807  return;
3808 
3810 
3811  QWidgetList list = topLevelWidgets();
3812  for (int i = 0; i < list.size(); ++i) {
3813  QWidget *w = list.at(i);
3815  sendEvent(w, &ev);
3816  }
3817 }
3818 
3820 {
3821  return layout_direction;
3822 }
3823 
3824 
3836 #ifdef QT3_SUPPORT
3837 Qt::Alignment QApplication::horizontalAlignment(Qt::Alignment align)
3838 {
3839  return QStyle::visualAlignment(layoutDirection(), align);
3840 }
3841 #endif
3842 
3843 
3854 #ifndef QT_NO_CURSOR
3856 {
3857  return qApp->d_func()->cursor_list.isEmpty() ? 0 : &qApp->d_func()->cursor_list.first();
3858 }
3859 
3869 {
3870  if (qApp->d_func()->cursor_list.isEmpty())
3871  return;
3872  qApp->d_func()->cursor_list.removeFirst();
3873  setOverrideCursor(cursor);
3874 }
3875 #endif
3876 
3917 {
3918 #ifndef QT_NO_ACCESSIBILITY
3920 #endif
3921  return QCoreApplication::exec();
3922 }
3923 
3927 {
3928  Q_D(QApplication);
3929  // no events are delivered after ~QCoreApplication() has started
3931  return true;
3932 
3933  if (receiver == 0) { // serious error
3934  qWarning("QApplication::notify: Unexpected null receiver");
3935  return true;
3936  }
3937 
3938 #ifndef QT_NO_DEBUG
3939  d->checkReceiverThread(receiver);
3940 #endif
3941 
3942  // capture the current mouse/keyboard state
3943  if(e->spontaneous()) {
3944  if (e->type() == QEvent::KeyPress
3945  || e->type() == QEvent::KeyRelease) {
3946  QKeyEvent *ke = static_cast<QKeyEvent*>(e);
3948  } else if(e->type() == QEvent::MouseButtonPress
3949  || e->type() == QEvent::MouseButtonRelease) {
3950  QMouseEvent *me = static_cast<QMouseEvent*>(e);
3952  if(me->type() == QEvent::MouseButtonPress)
3954  else
3956  }
3957 #if !defined(QT_NO_WHEELEVENT) || !defined(QT_NO_TABLETEVENT)
3958  else if (false
3959 # ifndef QT_NO_WHEELEVENT
3960  || e->type() == QEvent::Wheel
3961 # endif
3962 # ifndef QT_NO_TABLETEVENT
3963  || e->type() == QEvent::TabletMove
3964  || e->type() == QEvent::TabletPress
3965  || e->type() == QEvent::TabletRelease
3966 # endif
3967  ) {
3968  QInputEvent *ie = static_cast<QInputEvent*>(e);
3970  }
3971 #endif // !QT_NO_WHEELEVENT || !QT_NO_TABLETEVENT
3972  }
3973 
3974 #ifndef QT_NO_GESTURES
3975  // walk through parents and check for gestures
3976  if (d->gestureManager) {
3977  switch (e->type()) {
3978  case QEvent::Paint:
3979  case QEvent::MetaCall:
3984 #ifdef QT3_SUPPORT
3985  case QEvent::ChildInsertedRequest:
3986  case QEvent::ChildInserted:
3987  case QEvent::LayoutHint:
3988 #endif
3989  case QEvent::ChildRemoved:
3990  case QEvent::UpdateRequest:
3991  case QEvent::UpdateLater:
3993  case QEvent::LocaleChange:
3994  case QEvent::Style:
3995  case QEvent::IconDrag:
3996  case QEvent::StyleChange:
4005  break;
4006  default:
4007  if (d->gestureManager->thread() == QThread::currentThread()) {
4008  if (receiver->isWidgetType()) {
4009  if (d->gestureManager->filterEvent(static_cast<QWidget *>(receiver), e))
4010  return true;
4011  } else {
4012  // a special case for events that go to QGesture objects.
4013  // We pass the object to the gesture manager and it'll figure
4014  // out if it's QGesture or not.
4015  if (d->gestureManager->filterEvent(receiver, e))
4016  return true;
4017  }
4018  }
4019  break;
4020  }
4021  }
4022 #endif // QT_NO_GESTURES
4023 
4024  // User input and window activation makes tooltips sleep
4025  switch (e->type()) {
4026  case QEvent::Wheel:
4028  case QEvent::KeyPress:
4029  case QEvent::KeyRelease:
4030  case QEvent::FocusOut:
4031  case QEvent::FocusIn:
4035  d->toolTipFallAsleep.stop();
4036  // fall-through
4037  case QEvent::Leave:
4038  d->toolTipWakeUp.stop();
4039  default:
4040  break;
4041  }
4042 
4043  bool res = false;
4044  if (!receiver->isWidgetType()) {
4045  res = d->notify_helper(receiver, e);
4046  } else switch (e->type()) {
4047 #if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT)
4048  case QEvent::Accel:
4049  {
4050  if (d->use_compat()) {
4051  QKeyEvent* key = static_cast<QKeyEvent*>(e);
4052  res = d->notify_helper(receiver, e);
4053 
4054  if (!res && !key->isAccepted())
4055  res = d->qt_dispatchAccelEvent(static_cast<QWidget *>(receiver), key);
4056 
4057  // next lines are for compatibility with Qt <= 3.0.x: old
4058  // QAccel was listening on toplevel widgets
4059  if (!res && !key->isAccepted() && !static_cast<QWidget *>(receiver)->isWindow())
4060  res = d->notify_helper(static_cast<QWidget *>(receiver)->window(), e);
4061  }
4062  break;
4063  }
4064 #endif //QT3_SUPPORT && !QT_NO_SHORTCUT
4066  case QEvent::KeyPress:
4067  case QEvent::KeyRelease:
4068  {
4069  bool isWidget = receiver->isWidgetType();
4070  bool isGraphicsWidget = false;
4071 #ifndef QT_NO_GRAPHICSVIEW
4072  isGraphicsWidget = !isWidget && qobject_cast<QGraphicsWidget *>(receiver);
4073 #endif
4074  if (!isWidget && !isGraphicsWidget) {
4075  res = d->notify_helper(receiver, e);
4076  break;
4077  }
4078 
4079  QKeyEvent* key = static_cast<QKeyEvent*>(e);
4080 #if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT)
4081  if (d->use_compat() && d->qt_tryComposeUnicode(static_cast<QWidget*>(receiver), key))
4082  break;
4083 #endif
4084  if (key->type()==QEvent::KeyPress) {
4085 #ifndef QT_NO_SHORTCUT
4086  // Try looking for a Shortcut before sending key events
4087  if ((res = qApp->d_func()->shortcutMap.tryShortcutEvent(receiver, key)))
4088  return res;
4089 #endif
4091  || key->key() == Qt::Key_Tab
4092  || key->key() == Qt::Key_Left
4093  || key->key() == Qt::Key_Up
4094  || key->key() == Qt::Key_Right
4095  || key->key() == Qt::Key_Down);
4096  }
4097  bool def = key->isAccepted();
4098  QPointer<QObject> pr = receiver;
4099  while (receiver) {
4100  if (def)
4101  key->accept();
4102  else
4103  key->ignore();
4104  res = d->notify_helper(receiver, e);
4105  QWidget *w = isWidget ? static_cast<QWidget *>(receiver) : 0;
4106 #ifndef QT_NO_GRAPHICSVIEW
4107  QGraphicsWidget *gw = isGraphicsWidget ? static_cast<QGraphicsWidget *>(receiver) : 0;
4108 #endif
4109 
4110  if ((res && key->isAccepted())
4111  /*
4112  QLineEdit will emit a signal on Key_Return, but
4113  ignore the event, and sometimes the connected
4114  slot deletes the QLineEdit (common in itemview
4115  delegates), so we have to check if the widget
4116  was destroyed even if the event was ignored (to
4117  prevent a crash)
4118 
4119  note that we don't have to reset pw while
4120  propagating (because the original receiver will
4121  be destroyed if one of its ancestors is)
4122  */
4123  || !pr
4124  || (isWidget && (w->isWindow() || !w->parentWidget()))
4125 #ifndef QT_NO_GRAPHICSVIEW
4126  || (isGraphicsWidget && (gw->isWindow() || !gw->parentWidget()))
4127 #endif
4128  ) {
4129  break;
4130  }
4131 
4132 #ifndef QT_NO_GRAPHICSVIEW
4133  receiver = w ? (QObject *)w->parentWidget() : (QObject *)gw->parentWidget();
4134 #else
4135  receiver = w->parentWidget();
4136 #endif
4137  }
4138  qt_in_tab_key_event = false;
4139  }
4140  break;
4144  case QEvent::MouseMove:
4145  {
4146  QWidget* w = static_cast<QWidget *>(receiver);
4147 
4148  QMouseEvent* mouse = static_cast<QMouseEvent*>(e);
4149  QPoint relpos = mouse->pos();
4150 
4151  if (e->spontaneous()) {
4152 #ifndef QT_NO_IM
4153  QInputContext *ic = w->inputContext();
4154  if (ic
4156  && ic->filterEvent(mouse))
4157  return true;
4158 #endif
4159 
4160  if (e->type() == QEvent::MouseButtonPress) {
4164  }
4165 
4166  // ### Qt 5 These dynamic tool tips should be an OPT-IN feature. Some platforms
4167  // like Mac OS X (probably others too), can optimize their views by not
4168  // dispatching mouse move events. We have attributes to control hover,
4169  // and mouse tracking, but as long as we are deciding to implement this
4170  // feature without choice of opting-in or out, you ALWAYS have to have
4171  // tracking enabled. Therefore, the other properties give a false sense of
4172  // performance enhancement.
4173  if (e->type() == QEvent::MouseMove && mouse->buttons() == 0) {
4174  d->toolTipWidget = w;
4175  d->toolTipPos = relpos;
4176  d->toolTipGlobalPos = mouse->globalPos();
4177  d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive()?20:700, this);
4178  }
4179  }
4180 
4181  bool eventAccepted = mouse->isAccepted();
4182 
4183  QPointer<QWidget> pw = w;
4184  while (w) {
4185  QMouseEvent me(mouse->type(), relpos, mouse->globalPos(), mouse->button(), mouse->buttons(),
4186  mouse->modifiers());
4187  me.spont = mouse->spontaneous();
4188  // throw away any mouse-tracking-only mouse events
4189  if (!w->hasMouseTracking()
4190  && mouse->type() == QEvent::MouseMove && mouse->buttons() == 0) {
4191  // but still send them through all application event filters (normally done by notify_helper)
4192  for (int i = 0; i < d->eventFilters.size(); ++i) {
4193  register QObject *obj = d->eventFilters.at(i);
4194  if (!obj)
4195  continue;
4196  if (obj->d_func()->threadData != w->d_func()->threadData) {
4197  qWarning("QApplication: Object event filter cannot be in a different thread.");
4198  continue;
4199  }
4200  if (obj->eventFilter(w, w == receiver ? mouse : &me))
4201  break;
4202  }
4203  res = true;
4204  } else {
4206  res = d->notify_helper(w, w == receiver ? mouse : &me);
4207  e->spont = false;
4208  }
4209  eventAccepted = (w == receiver ? mouse : &me)->isAccepted();
4210  if (res && eventAccepted)
4211  break;
4213  break;
4214  relpos += w->pos();
4215  w = w->parentWidget();
4216  }
4217 
4218  mouse->setAccepted(eventAccepted);
4219 
4220  if (e->type() == QEvent::MouseMove) {
4221  if (!pw)
4222  break;
4223 
4224  w = static_cast<QWidget *>(receiver);
4225  relpos = mouse->pos();
4226  QPoint diff = relpos - w->mapFromGlobal(d->hoverGlobalPos);
4227  while (w) {
4228  if (w->testAttribute(Qt::WA_Hover) &&
4230  QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff);
4231  d->notify_helper(w, &he);
4232  }
4234  break;
4235  relpos += w->pos();
4236  w = w->parentWidget();
4237  }
4238  }
4239 
4240  d->hoverGlobalPos = mouse->globalPos();
4241  }
4242  break;
4243 #ifndef QT_NO_WHEELEVENT
4244  case QEvent::Wheel:
4245  {
4246  QWidget* w = static_cast<QWidget *>(receiver);
4247  QWheelEvent* wheel = static_cast<QWheelEvent*>(e);
4248  QPoint relpos = wheel->pos();
4249  bool eventAccepted = wheel->isAccepted();
4250 
4251  if (e->spontaneous()) {
4255  }
4256 
4257  while (w) {
4258  QWheelEvent we(relpos, wheel->globalPos(), wheel->delta(), wheel->buttons(),
4259  wheel->modifiers(), wheel->orientation());
4260  we.spont = wheel->spontaneous();
4261  res = d->notify_helper(w, w == receiver ? wheel : &we);
4262  eventAccepted = ((w == receiver) ? wheel : &we)->isAccepted();
4263  e->spont = false;
4264  if ((res && eventAccepted)
4266  break;
4267 
4268  relpos += w->pos();
4269  w = w->parentWidget();
4270  }
4271  wheel->setAccepted(eventAccepted);
4272  }
4273  break;
4274 #endif
4275 #ifndef QT_NO_CONTEXTMENU
4276  case QEvent::ContextMenu:
4277  {
4278  QWidget* w = static_cast<QWidget *>(receiver);
4279  QContextMenuEvent *context = static_cast<QContextMenuEvent*>(e);
4280  QPoint relpos = context->pos();
4281  bool eventAccepted = context->isAccepted();
4282  while (w) {
4283  QContextMenuEvent ce(context->reason(), relpos, context->globalPos(), context->modifiers());
4284  ce.spont = e->spontaneous();
4285  res = d->notify_helper(w, w == receiver ? context : &ce);
4286  eventAccepted = ((w == receiver) ? context : &ce)->isAccepted();
4287  e->spont = false;
4288 
4289  if ((res && eventAccepted)
4291  break;
4292 
4293  relpos += w->pos();
4294  w = w->parentWidget();
4295  }
4296  context->setAccepted(eventAccepted);
4297  }
4298  break;
4299 #endif // QT_NO_CONTEXTMENU
4300 #ifndef QT_NO_TABLETEVENT
4301  case QEvent::TabletMove:
4302  case QEvent::TabletPress:
4303  case QEvent::TabletRelease:
4304  {
4305  QWidget *w = static_cast<QWidget *>(receiver);
4306  QTabletEvent *tablet = static_cast<QTabletEvent*>(e);
4307  QPoint relpos = tablet->pos();
4308  bool eventAccepted = tablet->isAccepted();
4309  while (w) {
4310  QTabletEvent te(tablet->type(), relpos, tablet->globalPos(),
4311  tablet->hiResGlobalPos(), tablet->device(), tablet->pointerType(),
4312  tablet->pressure(), tablet->xTilt(), tablet->yTilt(),
4313  tablet->tangentialPressure(), tablet->rotation(), tablet->z(),
4314  tablet->modifiers(), tablet->uniqueId());
4315  te.spont = e->spontaneous();
4316  res = d->notify_helper(w, w == receiver ? tablet : &te);
4317  eventAccepted = ((w == receiver) ? tablet : &te)->isAccepted();
4318  e->spont = false;
4319  if ((res && eventAccepted)
4320  || w->isWindow()
4322  break;
4323 
4324  relpos += w->pos();
4325  w = w->parentWidget();
4326  }
4327  tablet->setAccepted(eventAccepted);
4328  qt_tabletChokeMouse = tablet->isAccepted();
4329  }
4330  break;
4331 #endif // QT_NO_TABLETEVENT
4332 
4333 #if !defined(QT_NO_TOOLTIP) || !defined(QT_NO_WHATSTHIS)
4334  case QEvent::ToolTip:
4335  case QEvent::WhatsThis:
4337  {
4338  QWidget* w = static_cast<QWidget *>(receiver);
4339  QHelpEvent *help = static_cast<QHelpEvent*>(e);
4340  QPoint relpos = help->pos();
4341  bool eventAccepted = help->isAccepted();
4342  while (w) {
4343  QHelpEvent he(help->type(), relpos, help->globalPos());
4344  he.spont = e->spontaneous();
4345  res = d->notify_helper(w, w == receiver ? help : &he);
4346  e->spont = false;
4347  eventAccepted = (w == receiver ? help : &he)->isAccepted();
4348  if ((res && eventAccepted) || w->isWindow())
4349  break;
4350 
4351  relpos += w->pos();
4352  w = w->parentWidget();
4353  }
4354  help->setAccepted(eventAccepted);
4355  }
4356  break;
4357 #endif
4358 #if !defined(QT_NO_STATUSTIP) || !defined(QT_NO_WHATSTHIS)
4359  case QEvent::StatusTip:
4361  {
4362  QWidget *w = static_cast<QWidget *>(receiver);
4363  while (w) {
4364  res = d->notify_helper(w, e);
4365  if ((res && e->isAccepted()) || w->isWindow())
4366  break;
4367  w = w->parentWidget();
4368  }
4369  }
4370  break;
4371 #endif
4372 
4373 #ifndef QT_NO_DRAGANDDROP
4374  case QEvent::DragEnter: {
4375  QWidget* w = static_cast<QWidget *>(receiver);
4376  QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent *>(e);
4377 #ifdef Q_WS_MAC
4378  // HIView has a slight difference in how it delivers events to children and parents
4379  // It will not give a leave to a child's parent when it enters a child.
4380  QWidget *currentTarget = QDragManager::self()->currentTarget();
4381  if (currentTarget) {
4382  // Assume currentTarget did not get a leave
4384  QApplication::sendEvent(currentTarget, &event);
4385  }
4386 #endif
4387 #ifndef QT_NO_GRAPHICSVIEW
4388  // QGraphicsProxyWidget handles its own propagation,
4389  // and we must not change QDragManagers currentTarget.
4390  QWExtra *extra = w->window()->d_func()->extra;
4391  if (extra && extra->proxyWidget) {
4392  res = d->notify_helper(w, dragEvent);
4393  break;
4394  }
4395 #endif
4396  while (w) {
4397  if (w->isEnabled() && w->acceptDrops()) {
4398  res = d->notify_helper(w, dragEvent);
4399  if (res && dragEvent->isAccepted()) {
4401  break;
4402  }
4403  }
4404  if (w->isWindow())
4405  break;
4406  dragEvent->p = w->mapToParent(dragEvent->p);
4407  w = w->parentWidget();
4408  }
4409  }
4410  break;
4411  case QEvent::DragMove:
4412  case QEvent::Drop:
4413  case QEvent::DragLeave: {
4414  QWidget* w = static_cast<QWidget *>(receiver);
4415 #ifndef QT_NO_GRAPHICSVIEW
4416  // QGraphicsProxyWidget handles its own propagation,
4417  // and we must not change QDragManagers currentTarget.
4418  QWExtra *extra = w->window()->d_func()->extra;
4419  bool isProxyWidget = extra && extra->proxyWidget;
4420  if (!isProxyWidget)
4421 #endif
4423 
4424  if (!w) {
4425 #ifdef Q_WS_MAC
4426  // HIView has a slight difference in how it delivers events to children and parents
4427  // It will not give an enter to a child's parent when it leaves the child.
4428  if (e->type() == QEvent::DragLeave)
4429  break;
4430  // Assume that w did not get an enter.
4431  QDropEvent *dropEvent = static_cast<QDropEvent *>(e);
4432  QDragEnterEvent dragEnterEvent(dropEvent->pos(), dropEvent->possibleActions(),
4433  dropEvent->mimeData(), dropEvent->mouseButtons(),
4434  dropEvent->keyboardModifiers());
4435  QApplication::sendEvent(receiver, &dragEnterEvent);
4437  if (!w)
4438 #endif
4439  break;
4440  }
4441  if (e->type() == QEvent::DragMove || e->type() == QEvent::Drop) {
4442  QDropEvent *dragEvent = static_cast<QDropEvent *>(e);
4443  QWidget *origReciver = static_cast<QWidget *>(receiver);
4444  while (origReciver && w != origReciver) {
4445  dragEvent->p = origReciver->mapToParent(dragEvent->p);
4446  origReciver = origReciver->parentWidget();
4447  }
4448  }
4449  res = d->notify_helper(w, e);
4450  if (e->type() != QEvent::DragMove
4451 #ifndef QT_NO_GRAPHICSVIEW
4452  && !isProxyWidget
4453 #endif
4454  )
4456  }
4457  break;
4458 #endif
4459  case QEvent::TouchBegin:
4460  // Note: TouchUpdate and TouchEnd events are never propagated
4461  {
4462  QWidget *widget = static_cast<QWidget *>(receiver);
4463  QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
4464  bool eventAccepted = touchEvent->isAccepted();
4465  if (widget->testAttribute(Qt::WA_AcceptTouchEvents) && e->spontaneous()) {
4466  // give the widget focus if the focus policy allows it
4470  }
4471 
4472  while (widget) {
4473  // first, try to deliver the touch event
4474  bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents);
4475  touchEvent->setWidget(widget);
4476  touchEvent->setAccepted(acceptTouchEvents);
4478  res = acceptTouchEvents && d->notify_helper(widget, touchEvent);
4479  eventAccepted = touchEvent->isAccepted();
4480  if (p.isNull()) {
4481  // widget was deleted
4482  widget = 0;
4483  } else {
4484  widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted);
4485  }
4486  touchEvent->spont = false;
4487  if (res && eventAccepted) {
4488  // the first widget to accept the TouchBegin gets an implicit grab.
4489  for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
4490  const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i);
4491  d->widgetForTouchPointId[touchPoint.id()] = widget;
4492  }
4493  break;
4494  } else if (p.isNull() || widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) {
4495  break;
4496  }
4497  QPoint offset = widget->pos();
4498  widget = widget->parentWidget();
4499  touchEvent->setWidget(widget);
4500  for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) {
4501  QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i];
4502  QRectF rect = pt.rect();
4503  rect.moveCenter(offset);
4504  pt.d->rect = rect;
4505  pt.d->startPos = pt.startPos() + offset;
4506  pt.d->lastPos = pt.lastPos() + offset;
4507  }
4508  }
4509 
4510  touchEvent->setAccepted(eventAccepted);
4511  break;
4512  }
4515 #ifndef QT_NO_IM
4516  if (receiver->isWidgetType()) {
4517  QWidget *w = static_cast<QWidget *>(receiver);
4518  QInputContext *ic = w->inputContext();
4519  if (ic && ic->filterEvent(e)) {
4520  break;
4521  }
4522  }
4523 #endif
4524  res = d->notify_helper(receiver, e);
4525  break;
4526 
4527 #ifndef QT_NO_GESTURES
4528  case QEvent::NativeGesture:
4529  {
4530  // only propagate the first gesture event (after the GID_BEGIN)
4531  QWidget *w = static_cast<QWidget *>(receiver);
4532  while (w) {
4533  e->ignore();
4534  res = d->notify_helper(w, e);
4535  if ((res && e->isAccepted()) || w->isWindow())
4536  break;
4537  w = w->parentWidget();
4538  }
4539  break;
4540  }
4541  case QEvent::Gesture:
4543  {
4544  if (receiver->isWidgetType()) {
4545  QWidget *w = static_cast<QWidget *>(receiver);
4546  QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(e);
4547  QList<QGesture *> allGestures = gestureEvent->gestures();
4548 
4549  bool eventAccepted = gestureEvent->isAccepted();
4550  bool wasAccepted = eventAccepted;
4551  while (w) {
4552  // send only gestures the widget expects
4553  QList<QGesture *> gestures;
4554  QWidgetPrivate *wd = w->d_func();
4555  for (int i = 0; i < allGestures.size();) {
4556  QGesture *g = allGestures.at(i);
4559  wd->gestureContext.find(type);
4560  bool deliver = contextit != wd->gestureContext.end() &&
4561  (g->state() == Qt::GestureStarted || w == receiver ||
4562  (contextit.value() & Qt::ReceivePartialGestures));
4563  if (deliver) {
4564  allGestures.removeAt(i);
4565  gestures.append(g);
4566  } else {
4567  ++i;
4568  }
4569  }
4570  if (!gestures.isEmpty()) { // we have gestures for this w
4571  QGestureEvent ge(gestures);
4572  ge.t = gestureEvent->t;
4573  ge.spont = gestureEvent->spont;
4574  ge.m_accept = wasAccepted;
4575  ge.d_func()->accepted = gestureEvent->d_func()->accepted;
4576  res = d->notify_helper(w, &ge);
4577  gestureEvent->spont = false;
4578  eventAccepted = ge.isAccepted();
4579  for (int i = 0; i < gestures.size(); ++i) {
4580  QGesture *g = gestures.at(i);
4581  // Ignore res [event return value] because handling of multiple gestures
4582  // packed into a single QEvent depends on not consuming the event
4583  if (eventAccepted || ge.isAccepted(g)) {
4584  // if the gesture was accepted, mark the target widget for it
4585  gestureEvent->d_func()->targetWidgets[g->gestureType()] = w;
4586  gestureEvent->setAccepted(g, true);
4587  } else {
4588  // if the gesture was explicitly ignored by the application,
4589  // put it back so a parent can get it
4590  allGestures.append(g);
4591  }
4592  }
4593  }
4594  if (allGestures.isEmpty()) // everything delivered
4595  break;
4596  if (w->isWindow())
4597  break;
4598  w = w->parentWidget();
4599  }
4600  foreach (QGesture *g, allGestures)
4601  gestureEvent->setAccepted(g, false);
4602  gestureEvent->m_accept = false; // to make sure we check individual gestures
4603  } else {
4604  res = d->notify_helper(receiver, e);
4605  }
4606  break;
4607  }
4608 #endif // QT_NO_GESTURES
4609 #ifdef QT_MAC_USE_COCOA
4610  case QEvent::Enter:
4611  if (receiver->isWidgetType()) {
4612  QWidget *w = static_cast<QWidget *>(receiver);
4614  qt_widget_private(w)->registerTouchWindow(true);
4615  }
4616  res = d->notify_helper(receiver, e);
4617  break;
4618  case QEvent::Leave:
4619  if (receiver->isWidgetType()) {
4620  QWidget *w = static_cast<QWidget *>(receiver);
4622  qt_widget_private(w)->registerTouchWindow(false);
4623  }
4624  res = d->notify_helper(receiver, e);
4625  break;
4626 #endif
4627  default:
4628  res = d->notify_helper(receiver, e);
4629  break;
4630  }
4631 
4632  return res;
4633 }
4634 
4636 {
4637  // send to all application event filters
4638  if (sendThroughApplicationEventFilters(receiver, e))
4639  return true;
4640 
4641  if (receiver->isWidgetType()) {
4642  QWidget *widget = static_cast<QWidget *>(receiver);
4643 
4644 #if !defined(Q_WS_WINCE) || (defined(GWES_ICONCURS) && !defined(QT_NO_CURSOR))
4645  // toggle HasMouse widget state on enter and leave
4646  if ((e->type() == QEvent::Enter || e->type() == QEvent::DragEnter) &&
4648  widget->setAttribute(Qt::WA_UnderMouse, true);
4649  else if (e->type() == QEvent::Leave || e->type() == QEvent::DragLeave)
4650  widget->setAttribute(Qt::WA_UnderMouse, false);
4651 #endif
4652 
4653  if (QLayout *layout=widget->d_func()->layout) {
4654  layout->widgetEvent(e);
4655  }
4656  }
4657 
4658  // send to all receiver event filters
4659  if (sendThroughObjectEventFilters(receiver, e))
4660  return true;
4661 
4662  // deliver the event
4663  bool consumed = receiver->event(e);
4664  e->spont = false;
4665  return consumed;
4666 }
4667 
4668 
5014 /*****************************************************************************
5015  Stubbed session management support
5016  *****************************************************************************/
5017 #ifndef QT_NO_SESSIONMANAGER
5018 #if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
5019 
5020 #if defined(Q_OS_WINCE)
5022 {
5023  // We will use the following information to create the GUID
5024  // 1. absolute path to application
5025  wchar_t tempFilename[MAX_PATH];
5026  if (!GetModuleFileName(0, tempFilename, MAX_PATH))
5027  return S_FALSE;
5028  unsigned int hash = qHash(QString::fromWCharArray(tempFilename));
5029  guid->Data1 = hash;
5030  // 2. creation time of file
5031  QFileInfo info(QString::fromWCharArray(tempFilename));
5032  guid->Data2 = qHash(info.created().toTime_t());
5033  // 3. current system time
5034  guid->Data3 = qHash(QDateTime::currentDateTime().toTime_t());
5035  return S_OK;
5036 }
5037 #if !defined(OLE32_MCOMGUID) || defined(QT_WINCE_FORCE_CREATE_GUID)
5038 #define CoCreateGuid qt_CoCreateGuid
5039 #endif
5040 
5041 #endif
5042 
5044 {
5045 public:
5051 };
5052 
5055  : QObject(*new QSessionManagerPrivate, app)
5056 {
5058  setObjectName(QLatin1String("qt_sessionmanager"));
5059  qt_session_manager_self = this;
5060 #if defined(Q_WS_WIN)
5061  wchar_t guidstr[40];
5062  GUID guid;
5063  CoCreateGuid(&guid);
5064  StringFromGUID2(guid, guidstr, 40);
5065  id = QString::fromWCharArray(guidstr);
5066  CoCreateGuid(&guid);
5067  StringFromGUID2(guid, guidstr, 40);
5068  key = QString::fromWCharArray(guidstr);
5069 #endif
5070  d->sessionId = id;
5071  d->sessionKey = key;
5072  d->restartHint = RestartIfRunning;
5073 }
5074 
5076 {
5077  qt_session_manager_self = 0;
5078 }
5079 
5081 {
5082  Q_D(const QSessionManager);
5083  return d->sessionId;
5084 }
5085 
5087 {
5088  Q_D(const QSessionManager);
5089  return d->sessionKey;
5090 }
5091 
5092 
5093 #if defined(Q_WS_X11) || defined(Q_WS_MAC)
5095 {
5096  return 0;
5097 }
5098 #endif
5099 
5100 #if !defined(Q_WS_WIN)
5102 {
5103  return true;
5104 }
5105 
5107 {
5108  return true;
5109 }
5111 {
5112 }
5113 
5115 {
5116 }
5117 #endif
5118 
5119 
5121 {
5123  d->restartHint = hint;
5124 }
5125 
5127 {
5128  Q_D(const QSessionManager);
5129  return d->restartHint;
5130 }
5131 
5133 {
5135  d->restartCommand = command;
5136 }
5137 
5139 {
5140  Q_D(const QSessionManager);
5141  return d->restartCommand;
5142 }
5143 
5145 {
5147  d->discardCommand = command;
5148 }
5149 
5151 {
5152  Q_D(const QSessionManager);
5153  return d->discardCommand;
5154 }
5155 
5157 {
5158 }
5159 
5161 {
5162 }
5163 
5165 {
5166  return false;
5167 }
5168 
5170 {
5171 }
5172 
5173 #endif
5174 #endif // QT_NO_SESSIONMANAGER
5175 
5297 #ifdef QT3_SUPPORT
5298 QWidget *QApplication::mainWidget()
5299 {
5301 }
5302 #endif
5304 {
5305  return QApplicationPrivate::popupWidgets != 0;
5306 }
5307 
5329 {
5331 }
5332 
5334 {
5336 }
5337 
5339 {
5340  if (qApp && qApp->d_func()->in_exec) {
5342  // get ready to quit, this event might be removed if the
5343  // event loop is re-entered, however
5345  }
5346  emit qApp->lastWindowClosed();
5347  }
5348 }
5349 
5368 #ifdef QT_KEYPAD_NAVIGATION
5369 
5389 void QApplication::setNavigationMode(Qt::NavigationMode mode)
5390 {
5391 #ifdef Q_OS_SYMBIAN
5392  QApplicationPrivate::setNavigationMode(mode);
5393 #else
5394  QApplicationPrivate::navigationMode = mode;
5395 #endif
5396 }
5397 
5415 Qt::NavigationMode QApplication::navigationMode()
5416 {
5417  return QApplicationPrivate::navigationMode;
5418 }
5419 
5435 void QApplication::setKeypadNavigationEnabled(bool enable)
5436 {
5437  if (enable) {
5438 #ifdef Q_OS_SYMBIAN
5439  QApplication::setNavigationMode(Qt::NavigationModeKeypadDirectional);
5440 #else
5441  QApplication::setNavigationMode(Qt::NavigationModeKeypadTabOrder);
5442 #endif
5443  }
5444  else {
5445  QApplication::setNavigationMode(Qt::NavigationModeNone);
5446  }
5447 }
5448 
5464 bool QApplication::keypadNavigationEnabled()
5465 {
5466  return QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadTabOrder ||
5467  QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadDirectional;
5468 }
5469 #endif
5470 
5688 #ifndef QT_NO_IM
5689 // ************************************************************************
5690 // Input Method support
5691 // ************************************************************************
5692 
5702 {
5703  if (inputContext == QApplicationPrivate::inputContext)
5704  return;
5705  if (!inputContext) {
5706  qWarning("QApplication::setInputContext: called with 0 input context");
5707  return;
5708  }
5710  QApplicationPrivate::inputContext = inputContext;
5711  QApplicationPrivate::inputContext->setParent(this);
5712 }
5713 
5720 {
5721  Q_D(const QApplication);
5722  Q_UNUSED(d);// only static members being used.
5724  return d->inputContext;
5725 #ifdef Q_WS_X11
5726  if (!X11)
5727  return 0;
5728  if (!d->inputContext) {
5729  QApplication *that = const_cast<QApplication *>(this);
5730  QInputContext *qic = QInputContextFactory::create(X11->default_im, that);
5731  // fallback to default X Input Method.
5732  if (!qic)
5733  qic = QInputContextFactory::create(QLatin1String("xim"), that);
5734  that->d_func()->inputContext = qic;
5735  }
5736 #elif defined(Q_OS_SYMBIAN)
5737  if (!d->inputContext) {
5738  QApplication *that = const_cast<QApplication *>(this);
5740  // Try hbim and coefep first, then try others.
5741  if (keys.contains(QLatin1String("hbim"))) {
5742  that->d_func()->inputContext = QInputContextFactory::create(QLatin1String("hbim"), that);
5743  } else if (keys.contains(QLatin1String("coefep"))) {
5744  if (!that->d_func()->inputContextBeingCreated) {
5745  that->d_func()->inputContextBeingCreated = true;
5746  that->d_func()->inputContext = QInputContextFactory::create(QLatin1String("coefep"), that);
5747  that->d_func()->inputContextBeingCreated = false;
5748  }
5749  } else {
5750  for (int c = 0; c < keys.size() && !d->inputContext; ++c) {
5751  that->d_func()->inputContext = QInputContextFactory::create(keys[c], that);
5752  }
5753  }
5754  }
5755 #endif
5756  return d->inputContext;
5757 }
5758 #endif // QT_NO_IM
5759 
5760 //Returns the current platform used by keyBindings
5762  uint platform = KB_Win;
5763 #ifdef Q_WS_MAC
5764  platform = KB_Mac;
5765 #elif defined Q_WS_X11
5766  platform = KB_X11;
5767  if (X11->desktopEnvironment == DE_KDE)
5768  platform |= KB_KDE;
5769  if (X11->desktopEnvironment == DE_GNOME)
5770  platform |= KB_Gnome;
5771  if (X11->desktopEnvironment == DE_CDE)
5772  platform |= KB_CDE;
5773 #elif defined(Q_OS_SYMBIAN)
5774  platform = KB_S60;
5775 #endif
5776  return platform;
5777 }
5778 
5780 {
5781  return QCoreApplication::sendSpontaneousEvent(receiver, event);
5782 }
5783 
5784 
5794 {
5795  if (!QApplicationPrivate::checkInstance("keyboardInputLocale"))
5796  return QLocale::c();
5798 }
5799 
5809 {
5810  if (!QApplicationPrivate::checkInstance("keyboardInputDirection"))
5811  return Qt::LeftToRight;
5813 }
5814 
5816  Qt::FocusPolicy focusPolicy,
5817  Qt::FocusReason focusReason)
5818 {
5819  QWidget *focusWidget = widget;
5820  while (focusWidget) {
5821  if (focusWidget->isEnabled()
5822  && QApplicationPrivate::shouldSetFocus(focusWidget, focusPolicy)) {
5823  focusWidget->setFocus(focusReason);
5824  break;
5825  }
5826  if (focusWidget->isWindow())
5827  break;
5828  focusWidget = focusWidget->parentWidget();
5829  }
5830 }
5831 
5833 {
5834  QWidget *f = w;
5835  while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
5836  f = f->d_func()->extra->focus_proxy;
5837 
5838  if ((w->focusPolicy() & policy) != policy)
5839  return false;
5840  if (w != f && (f->focusPolicy() & policy) != policy)
5841  return false;
5842  return true;
5843 }
5844 
5983 {
5984  for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
5985  QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i];
5986 
5987  // preserve the sub-pixel resolution
5988  QRectF rect = touchPoint.screenRect();
5989  const QPointF screenPos = rect.center();
5990  const QPointF delta = screenPos - screenPos.toPoint();
5991 
5992  rect.moveCenter(widget->mapFromGlobal(screenPos.toPoint()) + delta);
5993  touchPoint.d->rect = rect;
5994  if (touchPoint.state() == Qt::TouchPointPressed) {
5995  touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta;
5996  touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta;
5997  }
5998  }
5999 }
6000 
6002 {
6003  widgetForTouchPointId.clear();
6004  appCurrentTouchPoints.clear();
6005 
6006  initializeMultitouch_sys();
6007 }
6008 
6010 {
6011  cleanupMultitouch_sys();
6012 
6013  widgetForTouchPointId.clear();
6014  appCurrentTouchPoints.clear();
6015 }
6016 
6018 {
6019  int closestTouchPointId = -1;
6020  qreal closestDistance = qreal(0.);
6021  foreach (const QTouchEvent::TouchPoint &touchPoint, appCurrentTouchPoints) {
6022  qreal distance = QLineF(screenPos, touchPoint.screenPos()).length();
6023  if (closestTouchPointId == -1 || distance < closestDistance) {
6024  closestTouchPointId = touchPoint.id();
6025  closestDistance = distance;
6026  }
6027  }
6028  return closestTouchPointId;
6029 }
6030 
6032  QTouchEvent::DeviceType deviceType,
6033  const QList<QTouchEvent::TouchPoint> &touchPoints)
6034 {
6035  QApplicationPrivate *d = self;
6036  typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
6037  QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents;
6038 
6039  for (int i = 0; i < touchPoints.count(); ++i) {
6040  QTouchEvent::TouchPoint touchPoint = touchPoints.at(i);
6041  // explicitly detach from the original touch point that we got, so even
6042  // if the touchpoint structs are reused, we will make a copy that we'll
6043  // deliver to the user (which might want to store the struct for later use).
6044  touchPoint.d = touchPoint.d->detach();
6045 
6046  // update state
6048  switch (touchPoint.state()) {
6049  case Qt::TouchPointPressed:
6050  {
6051  if (deviceType == QTouchEvent::TouchPad) {
6052  // on touch-pads, send all touch points to the same widget
6053  widget = d->widgetForTouchPointId.isEmpty()
6055  : d->widgetForTouchPointId.constBegin().value();
6056  }
6057 
6058  if (!widget) {
6059  // determine which widget this event will go to
6060  if (!window)
6061  window = QApplication::topLevelAt(touchPoint.screenPos().toPoint());
6062  if (!window)
6063  continue;
6064  widget = window->childAt(window->mapFromGlobal(touchPoint.screenPos().toPoint()));
6065  if (!widget)
6066  widget = window;
6067  }
6068 
6069  if (deviceType == QTouchEvent::TouchScreen) {
6070  int closestTouchPointId = d->findClosestTouchPointId(touchPoint.screenPos());
6071  QWidget *closestWidget = d->widgetForTouchPointId.value(closestTouchPointId).data();
6072  if (closestWidget
6073  && (widget.data()->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget.data()))) {
6074  widget = closestWidget;
6075  }
6076  }
6077 
6078  d->widgetForTouchPointId[touchPoint.id()] = widget;
6079  touchPoint.d->startScreenPos = touchPoint.screenPos();
6080  touchPoint.d->lastScreenPos = touchPoint.screenPos();
6081  touchPoint.d->startNormalizedPos = touchPoint.normalizedPos();
6082  touchPoint.d->lastNormalizedPos = touchPoint.normalizedPos();
6083  if (touchPoint.pressure() < qreal(0.))
6084  touchPoint.d->pressure = qreal(1.);
6085 
6086  d->appCurrentTouchPoints.insert(touchPoint.id(), touchPoint);
6087  break;
6088  }
6090  {
6091  widget = d->widgetForTouchPointId.take(touchPoint.id());
6092  if (!widget)
6093  continue;
6094 
6095  QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.take(touchPoint.id());
6096  touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos();
6097  touchPoint.d->lastScreenPos = previousTouchPoint.screenPos();
6098  touchPoint.d->startPos = previousTouchPoint.startPos();
6099  touchPoint.d->lastPos = previousTouchPoint.pos();
6100  touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos();
6101  touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos();
6102  if (touchPoint.pressure() < qreal(0.))
6103  touchPoint.d->pressure = qreal(0.);
6104  break;
6105  }
6106  default:
6107  widget = d->widgetForTouchPointId.value(touchPoint.id());
6108  if (!widget)
6109  continue;
6110 
6111  Q_ASSERT(d->appCurrentTouchPoints.contains(touchPoint.id()));
6112  QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.value(touchPoint.id());
6113  touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos();
6114  touchPoint.d->lastScreenPos = previousTouchPoint.screenPos();
6115  touchPoint.d->startPos = previousTouchPoint.startPos();
6116  touchPoint.d->lastPos = previousTouchPoint.pos();
6117  touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos();
6118  touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos();
6119  if (touchPoint.pressure() < qreal(0.))
6120  touchPoint.d->pressure = qreal(1.);
6121  d->appCurrentTouchPoints[touchPoint.id()] = touchPoint;
6122  break;
6123  }
6124  Q_ASSERT(widget.data() != 0);
6125 
6126  // make the *scene* functions return the same as the *screen* functions
6127  touchPoint.d->sceneRect = touchPoint.screenRect();
6128  touchPoint.d->startScenePos = touchPoint.startScreenPos();
6129  touchPoint.d->lastScenePos = touchPoint.lastScreenPos();
6130 
6131  StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[widget.data()];
6132  maskAndPoints.first |= touchPoint.state();
6133  if (touchPoint.isPrimary())
6134  maskAndPoints.first |= Qt::TouchPointPrimary;
6135  maskAndPoints.second.append(touchPoint);
6136  }
6137 
6138  if (widgetsNeedingEvents.isEmpty())
6139  return;
6140 
6143  for (; it != end; ++it) {
6144  QWidget *widget = it.key();
6145  if (!QApplicationPrivate::tryModalHelper(widget, 0))
6146  continue;
6147 
6148  QEvent::Type eventType;
6149  switch (it.value().first & Qt::TouchPointStateMask) {
6150  case Qt::TouchPointPressed:
6151  eventType = QEvent::TouchBegin;
6152  break;
6154  eventType = QEvent::TouchEnd;
6155  break;
6157  // don't send the event if nothing changed
6158  continue;
6159  default:
6160  eventType = QEvent::TouchUpdate;
6161  break;
6162  }
6163 
6164  QTouchEvent touchEvent(eventType,
6165  deviceType,
6167  it.value().first,
6168  it.value().second);
6169  updateTouchPointsForWidget(widget, &touchEvent);
6170 
6171  switch (touchEvent.type()) {
6172  case QEvent::TouchBegin:
6173  {
6174  // if the TouchBegin handler recurses, we assume that means the event
6175  // has been implicitly accepted and continue to send touch events
6178  break;
6179  }
6180  default:
6182  if (touchEvent.type() == QEvent::TouchEnd)
6185  }
6186  break;
6187  }
6188  }
6189 }
6190 
6192  QTouchEvent::DeviceType deviceType,
6193  const QList<QTouchEvent::TouchPoint> &touchPoints)
6194 {
6195  QApplicationPrivate::translateRawTouchEvent(window, deviceType, touchPoints);
6196 }
6197 
6198 #ifndef QT_NO_GESTURES
6200 {
6202  if (!qAppPriv)
6203  return 0;
6204  if (!qAppPriv->gestureManager)
6205  qAppPriv->gestureManager = new QGestureManager(qApp);
6206  return qAppPriv->gestureManager;
6207 }
6208 #endif // QT_NO_GESTURES
6209 
6210 // These pixmaps approximate the images in the Windows User Interface Guidelines.
6211 
6212 // XPM
6213 
6214 static const char * const move_xpm[] = {
6215 "11 20 3 1",
6216 ". c None",
6217 #if defined(Q_WS_WIN)
6218 "a c #000000",
6219 "X c #FFFFFF", // Windows cursor is traditionally white
6220 #else
6221 "a c #FFFFFF",
6222 "X c #000000", // X11 cursor is traditionally black
6223 #endif
6224 "aa.........",
6225 "aXa........",
6226 "aXXa.......",
6227 "aXXXa......",
6228 "aXXXXa.....",
6229 "aXXXXXa....",
6230 "aXXXXXXa...",
6231 "aXXXXXXXa..",
6232 "aXXXXXXXXa.",
6233 "aXXXXXXXXXa",
6234 "aXXXXXXaaaa",
6235 "aXXXaXXa...",
6236 "aXXaaXXa...",
6237 "aXa..aXXa..",
6238 "aa...aXXa..",
6239 "a.....aXXa.",
6240 "......aXXa.",
6241 ".......aXXa",
6242 ".......aXXa",
6243 "........aa."};
6244 
6245 #ifdef Q_WS_WIN
6246 /* XPM */
6247 static const char * const ignore_xpm[] = {
6248 "24 30 3 1",
6249 ". c None",
6250 "a c #000000",
6251 "X c #FFFFFF",
6252 "aa......................",
6253 "aXa.....................",
6254 "aXXa....................",
6255 "aXXXa...................",
6256 "aXXXXa..................",
6257 "aXXXXXa.................",
6258 "aXXXXXXa................",
6259 "aXXXXXXXa...............",
6260 "aXXXXXXXXa..............",
6261 "aXXXXXXXXXa.............",
6262 "aXXXXXXaaaa.............",
6263 "aXXXaXXa................",
6264 "aXXaaXXa................",
6265 "aXa..aXXa...............",
6266 "aa...aXXa...............",
6267 "a.....aXXa..............",
6268 "......aXXa.....XXXX.....",
6269 ".......aXXa..XXaaaaXX...",
6270 ".......aXXa.XaaaaaaaaX..",
6271 "........aa.XaaaXXXXaaaX.",
6272 "...........XaaaaX..XaaX.",
6273 "..........XaaXaaaX..XaaX",
6274 "..........XaaXXaaaX.XaaX",
6275 "..........XaaX.XaaaXXaaX",
6276 "..........XaaX..XaaaXaaX",
6277 "...........XaaX..XaaaaX.",
6278 "...........XaaaXXXXaaaX.",
6279 "............XaaaaaaaaX..",
6280 ".............XXaaaaXX...",
6281 "...............XXXX....."};
6282 #endif
6283 
6284 /* XPM */
6285 static const char * const copy_xpm[] = {
6286 "24 30 3 1",
6287 ". c None",
6288 "a c #000000",
6289 "X c #FFFFFF",
6290 #if defined(Q_WS_WIN) // Windows cursor is traditionally white
6291 "aa......................",
6292 "aXa.....................",
6293 "aXXa....................",
6294 "aXXXa...................",
6295 "aXXXXa..................",
6296 "aXXXXXa.................",
6297 "aXXXXXXa................",
6298 "aXXXXXXXa...............",
6299 "aXXXXXXXXa..............",
6300 "aXXXXXXXXXa.............",
6301 "aXXXXXXaaaa.............",
6302 "aXXXaXXa................",
6303 "aXXaaXXa................",
6304 "aXa..aXXa...............",
6305 "aa...aXXa...............",
6306 "a.....aXXa..............",
6307 "......aXXa..............",
6308 ".......aXXa.............",
6309 ".......aXXa.............",
6310 "........aa...aaaaaaaaaaa",
6311 #else
6312 "XX......................",
6313 "XaX.....................",
6314 "XaaX....................",
6315 "XaaaX...................",
6316 "XaaaaX..................",
6317 "XaaaaaX.................",
6318 "XaaaaaaX................",
6319 "XaaaaaaaX...............",
6320 "XaaaaaaaaX..............",
6321 "XaaaaaaaaaX.............",
6322 "XaaaaaaXXXX.............",
6323 "XaaaXaaX................",
6324 "XaaXXaaX................",
6325 "XaX..XaaX...............",
6326 "XX...XaaX...............",
6327 "X.....XaaX..............",
6328 "......XaaX..............",
6329 ".......XaaX.............",
6330 ".......XaaX.............",
6331 "........XX...aaaaaaaaaaa",
6332 #endif
6333 ".............aXXXXXXXXXa",
6334 ".............aXXXXXXXXXa",
6335 ".............aXXXXaXXXXa",
6336 ".............aXXXXaXXXXa",
6337 ".............aXXaaaaaXXa",
6338 ".............aXXXXaXXXXa",
6339 ".............aXXXXaXXXXa",
6340 ".............aXXXXXXXXXa",
6341 ".............aXXXXXXXXXa",
6342 ".............aaaaaaaaaaa"};
6343 
6344 /* XPM */
6345 static const char * const link_xpm[] = {
6346 "24 30 3 1",
6347 ". c None",
6348 "a c #000000",
6349 "X c #FFFFFF",
6350 #if defined(Q_WS_WIN) // Windows cursor is traditionally white
6351 "aa......................",
6352 "aXa.....................",
6353 "aXXa....................",
6354 "aXXXa...................",
6355 "aXXXXa..................",
6356 "aXXXXXa.................",
6357 "aXXXXXXa................",
6358 "aXXXXXXXa...............",
6359 "aXXXXXXXXa..............",
6360 "aXXXXXXXXXa.............",
6361 "aXXXXXXaaaa.............",
6362 "aXXXaXXa................",
6363 "aXXaaXXa................",
6364 "aXa..aXXa...............",
6365 "aa...aXXa...............",
6366 "a.....aXXa..............",
6367 "......aXXa..............",
6368 ".......aXXa.............",
6369 ".......aXXa.............",
6370 "........aa...aaaaaaaaaaa",
6371 #else
6372 "XX......................",
6373 "XaX.....................",
6374 "XaaX....................",
6375 "XaaaX...................",
6376 "XaaaaX..................",
6377 "XaaaaaX.................",
6378 "XaaaaaaX................",
6379 "XaaaaaaaX...............",
6380 "XaaaaaaaaX..............",
6381 "XaaaaaaaaaX.............",
6382 "XaaaaaaXXXX.............",
6383 "XaaaXaaX................",
6384 "XaaXXaaX................",
6385 "XaX..XaaX...............",
6386 "XX...XaaX...............",
6387 "X.....XaaX..............",
6388 "......XaaX..............",
6389 ".......XaaX.............",
6390 ".......XaaX.............",
6391 "........XX...aaaaaaaaaaa",
6392 #endif
6393 ".............aXXXXXXXXXa",
6394 ".............aXXXaaaaXXa",
6395 ".............aXXXXaaaXXa",
6396 ".............aXXXaaaaXXa",
6397 ".............aXXaaaXaXXa",
6398 ".............aXXaaXXXXXa",
6399 ".............aXXaXXXXXXa",
6400 ".............aXXXaXXXXXa",
6401 ".............aXXXXXXXXXa",
6402 ".............aaaaaaaaaaa"};
6403 
6405 {
6406 #if defined(Q_WS_X11) || defined(Q_WS_WIN)
6407  if (!move_cursor) {
6408  move_cursor = new QPixmap((const char **)move_xpm);
6409  copy_cursor = new QPixmap((const char **)copy_xpm);
6410  link_cursor = new QPixmap((const char **)link_xpm);
6411 #ifdef Q_WS_WIN
6412  ignore_cursor = new QPixmap((const char **)ignore_xpm);
6413 #endif
6414  }
6415 
6416  switch (cshape) {
6417  case Qt::DragMoveCursor:
6418  return *move_cursor;
6419  case Qt::DragCopyCursor:
6420  return *copy_cursor;
6421  case Qt::DragLinkCursor:
6422  return *link_cursor;
6423 #ifdef Q_WS_WIN
6424  case Qt::ForbiddenCursor:
6425  return *ignore_cursor;
6426 #endif
6427  default:
6428  break;
6429  }
6430 #else
6431  Q_UNUSED(cshape);
6432 #endif
6433  return QPixmap();
6434 }
6435 
6437 
6438 #include "moc_qapplication.cpp"
QSet< QWidget * > QWidgetSet
Definition: qwindowdefs.h:151
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
static QPointer< QWidget > leaveAfterRelease
static void aboutQt(QWidget *parent, const QString &title=QString())
Displays a simple message box about Qt, with the given title and centered over parent (if parent is n...
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
void setPointSize(int)
Sets the point size to pointSize.
Definition: qfont.cpp:1099
static QT_DEPRECATED int argc()
Use arguments().
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
virtual void unpolish(QWidget *)
Uninitialize the given {widget}&#39;s appearance.
Definition: qstyle.cpp:409
void setAccepted(QGesture *, bool)
Sets the accept flag of the given gesture object to the specified value.
Definition: qevent.cpp:4929
static QWidget * main_widget
static Qt::LayoutDirection layoutDirection()
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
bool allowsErrorInteraction()
Returns true if error interaction is permitted; otherwise returns false.
QApplicationPrivate(int &argc, char **argv, QApplication::Type type, int flags)
static QApplicationPrivate * self
int id() const
Returns the id number of this touch point.
Definition: qevent.cpp:4445
static QWidgetList allWidgets()
Returns a list of all the widgets in the application.
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
void qt_mac_post_retranslateAppMenu()
static QColormap instance(int screen=-1)
static bool qt_detectRTLLanguage()
static QInputContext * create(const QString &key, QObject *parent)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
The QKeyEvent class describes a key event.
Definition: qevent.h:224
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
int qUnregisterGuiVariant()
bool inPopupMode() const
static bool checkInstance(const char *method)
static void setPalette(const QPalette &, const char *className=0)
Changes the default application palette to palette.
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
void initialize()
Initializes the QApplication object, called from the constructors.
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
static mach_timebase_info_data_t info
unsigned char c[8]
Definition: qnumeric_p.h:62
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
void construct(Display *dpy=0, Qt::HANDLE visual=0, Qt::HANDLE cmap=0)
QPointer< QWidget > widget
ushort t
Definition: qcoreevent.h:316
static const char *const ignore_xpm[]
void clear()
Removes all items from the hash.
Definition: qhash.h:574
Qt::TouchPointState state() const
Returns the current state of this touch point.
Definition: qevent.cpp:4453
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
static void setStyle(QStyle *)
Sets the application&#39;s GUI style to style.
Definition: quuid.h:52
static QWidget * pickMouseReceiver(QWidget *candidate, const QPoint &globalPos, QPoint &pos, QEvent::Type type, Qt::MouseButtons buttons, QWidget *buttonDown, QWidget *alienWidget)
bool isActiveWindow
whether this widget&#39;s window is the active window
Definition: qwidget.h:186
bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
static bool fade_tooltip
QString sessionKey() const
Returns the session key in the current Session Management{session}.
ulong Data1
Definition: quuid.h:54
virtual void commitData(QSessionManager &sm)
This function deals with Session Management{session management}.
#define it(className, varName)
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
Qt::DropActions possibleActions() const
Returns an OR-combination of possible drop actions.
Definition: qevent.h:490
int xTilt() const
Returns the angle between the device (a pen, for example) and the perpendicular in the direction of t...
Definition: qevent.h:207
QList< QWidget * > QWidgetList
Definition: qwindowdefs.h:89
static QSize app_strut
The QWheelEvent class contains parameters that describe a wheel event.
Definition: qevent.h:139
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
static void updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent)
WId effectiveWinId() const
Returns the effective window system identifier of the widget, i.
Definition: qwidget.cpp:2654
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
static QPalette * set_pal
QDateTime created() const
Returns the date and time when the file was created.
Definition: qfileinfo.cpp:1278
bool isVisible() const
Definition: qwidget.h:1005
const QPoint & pos() const
Returns the position of the mouse pointer relative to the widget that received the event...
Definition: qevent.h:412
static void initializeWidgetPaletteHash()
bool notify(QObject *, QEvent *)
Reimplemented Function
bool isVisibleTo(QWidget *) const
Returns true if this widget would become visible if ancestor is shown; otherwise returns false...
Definition: qwidget.cpp:8371
QRectF rect() const
Returns the rect for this touch point, relative to the widget or QGraphicsItem that received the even...
Definition: qevent.cpp:4624
static QSize globalStrut()
virtual void styleChange(QStyle &)
Definition: qwidget.cpp:12000
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
const_iterator constEnd() const
Definition: qset.h:171
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static bool force_reverse
The QHoverEvent class contains parameters that describe a mouse event.
Definition: qevent.h:125
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or 0 if no application wi...
QSessionManager::RestartHint restartHint
static int colorSpec()
Returns the color specification.
void setAccepted(bool accepted)
Definition: qcoreevent.h:306
QMap< int, QTouchEvent::TouchPoint > appCurrentTouchPoints
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
ushort spont
Definition: qcoreevent.h:320
static Qt::MouseButtons buttons
static void setStartDragDistance(int l)
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:187
QPointF lastScreenPos() const
Returns the screen position of this touch point from the previous touch event.
Definition: qevent.cpp:4598
static int exec()
Enters the main event loop and waits until exit() is called.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setGraphicsSystem(const QString &name)
static QStyle * create(const QString &)
static QColor cmap[256]
Definition: qgl_mac.mm:760
static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOptionComplex &opt, QStyle::ComplexControl complexControl, QStyle::SubControl subControl)
static int wheel_scroll_lines
uint toTime_t() const
Returns the datetime as the number of seconds that have passed since 1970-01-01T00:00:00, Coordinated Universal Time (Qt::UTC).
Definition: qdatetime.cpp:2505
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
void qInitDrawhelperAsm()
bool qt_wince_is_mobile()
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
Definition: qglobal.h:2487
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
static QWidget * active_window
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
const QPointF & hiResGlobalPos() const
The high precision coordinates delivered from the tablet expressed.
Definition: qevent.h:193
static QApplicationPrivate * instance()
QGuiPlatformPlugin * qt_guiPlatformPlugin()
Return (an construct if necesseray) the Gui Platform plugin.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static QPalette palette()
Returns the application palette.
QGraphicsProxyWidget * graphicsProxyWidget() const
Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns ...
Definition: qwidget.cpp:12939
static QStyle * style()
Returns the application&#39;s style object.
static QLocale keyboardInputLocale()
Returns the current keyboard input locale.
iterator find(const Key &key)
Returns an iterator pointing to the item with key key in the map.
Definition: qmap.h:618
QLocale keyboardInputLocale
Definition: qkeymapper_p.h:155
static void setWindowIcon(const QIcon &icon)
void * resolve(const char *symbol)
Returns the address of the exported symbol symbol.
Definition: qlibrary.cpp:1155
void saveStateRequest(QSessionManager &sessionManager)
This signal deals with Session Management{session management}.
QStringList restartCommand() const
Returns the currently set restart command.
bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QClipboard * qt_clipboard
static bool animate_ui
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
bool isNull() const
Returns true if this object is holding a reference to a null pointer.
static QT_DEPRECATED char ** argv()
Use arguments() instead.
DeviceType
This enum represents the type of device that generated a QTouchEvent.
Definition: qevent.h:805
virtual bool compressEvent(QEvent *, QObject *receiver, QPostEventList *)
Returns true if event was compressed away (possibly deleted) and should not be added to the list...
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool isCopyOf(const QFont &) const
Returns true if this font and f are copies of each other, i.e.
Definition: qfont.cpp:1963
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QInputContext * inputContext() const
Returns the QInputContext instance used by the application.
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
#define X11
Definition: qt_x11_p.h:724
const QPoint & pos() const
Returns the position of the device, relative to the widget that received the event.
Definition: qevent.h:191
static const char *const copy_xpm[]
#define Q_D(Class)
Definition: qglobal.h:2482
bool qt_wince_is_smartphone()
Qt::KeyboardModifiers keyboardModifiers() const
Returns the modifier keys that are pressed.
Definition: qevent.h:488
QPointer< QWidget > qt_last_mouse_receiver
void qt_x11_enforce_cursor(QWidget *w, bool force)
Update the X11 cursor of the widget w.
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
QPointF normalizedPos() const
Returns the normalized position of this touch point.
Definition: qevent.cpp:4511
T * data() const
static QPalette * app_pal
int qRegisterGuiStateMachine()
static QFont * sys_font
void setDiscardCommand(const QStringList &)
Sets the discard command to the given list.
QStringList keys
static QGestureManager * instance()
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
const char * className
Definition: qwizard.cpp:137
QWidgetList * qt_modal_stack
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
bool allowsInteraction()
Asks the session manager for permission to interact with the user.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
QStyle * style() const
Definition: qwidget.cpp:2742
static bool autoSipEnabled
PointerType pointerType() const
Returns the type of point that generated the event.
Definition: qevent.h:201
static QWidget * focus_widget
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
QApplication(int &argc, char **argv)
Initializes the window system and constructs an application object with argc command line arguments i...
int qt_antialiasing_threshold
static QFont font()
Returns the default application font.
ColorGroup
Definition: qpalette.h:92
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
Q_CORE_EXPORT void qt_call_post_routines()
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
static void changeOverrideCursor(const QCursor &)
Changes the currently active application override cursor to cursor.
static uint currentPlatform()
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
QGraphicsProxyWidget * proxyWidget
Definition: qwidget_p.h:251
int qRegisterGuiVariant()
const Key & key() const
Returns the current item&#39;s key.
Definition: qhash.h:419
void release()
Releases the session manager&#39;s interaction semaphore after an interaction phase.
static int keyboard_input_time
Q_CORE_EXPORT void qDebug(const char *,...)
static QWidget * widgetAt(const QPoint &p)
Returns the widget at global screen position point, or 0 if there is no Qt widget there...
static QFontMetrics fontMetrics()
Returns display (screen) font metrics for the application font.
qreal pressure() const
Returns the pressure of this touch point.
Definition: qevent.cpp:4657
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
QByteArray right(int len) const
Returns a byte array that contains the rightmost len bytes of this byte array.
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
static void setLayoutDirection(Qt::LayoutDirection direction)
friend class const_iterator
Definition: qlist.h:264
void commitDataRequest(QSessionManager &sessionManager)
This signal deals with Session Management{session management}.
NSWindow * window
void setRestartCommand(const QStringList &)
If the session manager is capable of restoring sessions it will execute command in order to restore t...
static QIcon windowIcon()
static QWidget * activeModalWidget()
Returns the active modal widget.
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
void setCursor(const QCursor &cursor)
Sets the current cursor shape for the item to cursor.
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
Definition: qwidget_p.h:763
static void giveFocusAccordingToFocusPolicy(QWidget *w, Qt::FocusPolicy focusPolicy, Qt::FocusReason focusReason)
void setRestartHint(RestartHint)
Sets the application&#39;s restart hint to hint.
static void setSystemFont(const QFont &font)
The QSessionManager class provides access to the session manager.
void clearMask()
Removes any mask set by setMask().
Definition: qwidget.cpp:13324
QDesktopWidget * qt_desktopWidget
static QCursor * overrideCursor()
Strips out vertical alignment flags and transforms an alignment align of Qt::AlignLeft into Qt::Align...
static void setStartDragTime(int ms)
bool autoSipEnabled() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool load_testability
#define Q_INIT_RESOURCE(name)
Definition: qglobal.h:965
QList< QTouchEvent::TouchPoint > _touchPoints
Definition: qevent.h:832
The QGestureEvent class provides the description of triggered gestures.
Definition: qevent.h:841
The QMoveEvent class contains event parameters for move events.
Definition: qevent.h:334
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
static QGraphicsSystem * create(const QString &)
bool isCopyOf(const QPalette &p) const
Returns true if this palette and p are copies of each other, i.e.
Definition: qpalette.cpp:1233
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
void qt_qpa_set_cursor(QWidget *w, bool force)
static QStringList keys()
Returns the list of valid keys, i.e.
QSessionManager(QApplication *app, QString &id, QString &key)
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
bool isAccepted() const
Definition: qcoreevent.h:307
static bool isEmpty(const char *str)
void destroy(bool destroyWindow=true, bool destroySubWindows=true)
Frees up window system resources.
#define QT_GUI_DRAG_DISTANCE
const QColor colorAt(uint pixel) const
QString qt_mac_applicationmenu_string(int type)
em>Reimplemented Function
void setStyleSheet(const QString &sheet)
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
qint64 uniqueId() const
Returns a unique ID for the current device, making it possible to differentiate between multiple devi...
Definition: qevent.h:202
static QWidget * mouseGrabber()
Returns the widget that is currently grabbing the mouse input.
static void setFocusWidget(QWidget *focus, Qt::FocusReason reason)
static QClipboard * clipboard()
Returns a pointer to the application global clipboard.
bool contains(const T &value) const
Definition: qset.h:91
QList< T > toList() const
Definition: qset.h:296
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QPointF lastPos() const
Returns the position of this touch point from the previous touch event, relative to the widget or QGr...
Definition: qevent.cpp:4571
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static Qt::LayoutDirection layout_direction
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
#define qApp
static char * aargv[]
QCoreApplication(int &argc, char **argv)
Constructs a Qt kernel application.
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:90
const char * name
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget&#39;s coordinate system...
Definition: qwidget.h:934
static QWidgetList * popupWidgets
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Definition: qglobal.h:1968
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
const char * layout
#define CoCreateGuid
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
bool spontaneous() const
Returns true if the event originated outside the application (a system event); otherwise returns fals...
Definition: qcoreevent.h:304
static QIcon * app_icon
static int toInt(const QByteArray &str)
Definition: generator.cpp:167
LayoutDirection
Definition: qnamespace.h:1580
Qt::WindowModality windowModality
which windows are blocked by the modal widget
Definition: qwidget.h:156
static bool quitOnLastWindowClosed
QWidgetData * data
Definition: qwidget.h:815
static int startDragTime()
static bool sendSpontaneousEvent(QObject *receiver, QEvent *event)
static int mouse_double_click_time
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
Definition: qhash.h:297
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
const char * styleHint(const QFontDef &request)
const T & value() const
Returns the current item&#39;s value.
Definition: qhash.h:420
static QWidget * hidden_focus_widget
bool notify_helper(QObject *receiver, QEvent *e)
Q_CORE_EXPORT void qWarning(const char *,...)
const_iterator ConstIterator
Definition: qset.h:177
int delta() const
Returns the distance that the wheel is rotated, in eighths of a degree.
Definition: qevent.h:150
const_iterator insert(const T &value)
Definition: qset.h:179
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
static const char * data(const QByteArray &arr)
Qt::MouseButtons buttons() const
Returns the mouse state when the event occurred.
Definition: qevent.h:158
unsigned int uint
Definition: qglobal.h:996
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
QMap< Qt::GestureType, QWidget * > targetWidgets
Definition: qevent_p.h:170
static Bigint * diff(Bigint *a, Bigint *b)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:859
#define Q_INIT_RESOURCE_EXTERN(name)
Definition: qglobal.h:962
FontHash * qt_app_fonts_hash()
static int distance(QWidget *source, QWidget *target, QAccessible::RelationFlag relation)
static bool animate_combo
QWindowSurface * windowSurface() const
Returns the QWindowSurface this widget will be drawn into.
Definition: qwidget.cpp:12819
void qt_mac_set_app_icon(const QPixmap &pixmap)
static void setPalette_helper(const QPalette &palette, const char *className, bool clearWidgetPaletteHash)
static QStyle * app_style
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
QPointF screenPos() const
Returns the screen position of this touch point.
Definition: qevent.cpp:4498
QPointF startNormalizedPos() const
Returns the normalized starting position of this touch point.
Definition: qevent.cpp:4560
QList< QGesture * > gestures() const
Returns all gestures that are delivered in the event.
Definition: qevent.cpp:4873
The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leav...
Definition: qevent.h:577
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
static QPalette * sys_pal
QPointF startScreenPos() const
Returns the starting screen position of this touch point.
Definition: qevent.cpp:4547
void sendSyntheticEnterLeave(QWidget *widget)
The QClipboard class provides access to the window system clipboard.
Definition: qclipboard.h:62
void setInputContext(QInputContext *)
This function replaces the QInputContext instance used by the application with inputContext.
QCursor cursor
the cursor shape for this widget
Definition: qwidget.h:183
static int startDragDistance()
Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, QTouchEvent::DeviceType deviceType, const QList< QTouchEvent::TouchPoint > &touchPoints)
uint is_closing
Definition: qwidget.h:123
void * HANDLE
Definition: qnamespace.h:1671
bool isPhase2() const
Returns true if the session manager is currently performing a second session management phase; otherw...
static QStringList keys()
Returns the list of keys this factory can create input contexts for.
virtual void saveState(QSessionManager &sm)
This function deals with Session Management{session management}.
QTouchEventTouchPointPrivate * detach()
Definition: qevent_p.h:108
QString sessionId() const
Returns the current Session Management{session&#39;s} identifier.
static void setGraphicsSystem(const QString &)
Sets the default graphics backend to system, which will be used for on-screen widgets and QPixmaps...
static bool runtime_graphics_system
static void setActiveWindow(QWidget *act)
Sets the active window to the active widget in response to a system event.
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the map.
Definition: qmap.h:374
static const char *const move_xpm[]
Qt::Orientation orientation() const
Returns the wheel&#39;s orientation.
Definition: qevent.h:159
static QWidgetSet * allWidgets
Definition: qwidget_p.h:715
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
void setMask(const QBitmap &)
Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible...
Definition: qwidget.cpp:13309
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
static QString graphics_system_name
static QWidget * topLevelAt(const QPoint &p)
Returns the top-level widget at the given point; returns 0 if there is no such widget.
static int qt_matchLibraryName(dl_phdr_info *info, size_t, void *data)
GestureType
Definition: qnamespace.h:1759
bool acceptDrops
whether drop events are enabled for this widget
Definition: qwidget.h:197
uint pixel(const QColor &color) const
QRegion mask() const
Returns the mask currently set on a widget.
Definition: qwidget.cpp:10058
bool Q_GUI_EXPORT qt_tab_all_widgets
QInputContext * inputContext()
This function returns the QInputContext for this widget.
Definition: qwidget.cpp:474
void * handle() const
int findClosestTouchPointId(const QPointF &screenPos)
bool isEnabled() const
Definition: qwidget.h:948
The QTabletEvent class contains parameters that describe a Tablet event.
Definition: qevent.h:179
QString styleSheet
the widget&#39;s style sheet
Definition: qwidget.h:220
static QFont * app_font
void setManagerProperty(const QString &name, const QString &value)
Low-level write access to the application&#39;s identification and state records are kept in the session ...
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
Reason reason() const
Returns the reason for this context event.
Definition: qevent.h:415
NavigationMode
Definition: qnamespace.h:1781
QStringList discardCommand() const
Returns the currently set discard command.
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
The QPlatformIntegration class is the entry for WindowSystem specific functionality.
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
int length() const
Same as size().
Definition: qbytearray.h:356
QHash< WId, QWidget * > QWidgetMapper
Definition: qwindowdefs.h:148
RestartHint
This enum type defines the circumstances under which this application wants to be restarted by the se...
static QDragManager * self()
Definition: qdnd.cpp:163
const QPoint & pos() const
Returns the position of the mouse cursor relative to the widget that received the event...
Definition: qevent.h:151
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
bool qt_wince_is_pocket_pc()
static bool animate_tooltip
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
static void setColorSpec(int)
Sets the color specification for the application to spec.
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
#define QT_NO_WHEELEVENT
QEvent * event
Definition: qthread_p.h:78
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
qreal pressure() const
Returns the pressure for the device.
Definition: qevent.h:203
static bool tryModalHelper(QWidget *widget, QWidget **rettop=0)
static const char *const link_xpm[]
QString sessionId() const
Returns the identifier of the current session.
static QWidget * focusNextPrevChild_helper(QWidget *toplevel, bool next)
internal Helper function that returns the new focus widget, but does not set the focus reason...
struct _XDisplay Display
Definition: qwindowdefs.h:115
The QCoreApplication class provides an event loop for console Qt applications.
long HRESULT
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
Qt::MouseButtons mouseButtons() const
Returns the mouse buttons that are pressed.
Definition: qevent.h:487
void setCurrentTarget(QWidget *target, bool dropped=false)
Definition: qdnd.cpp:260
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLe...
Definition: qstyle.cpp:2149
static QLocale c()
Returns a QLocale object initialized to the "C" locale.
Definition: qlocale.h:773
void qt_init(QApplicationPrivate *priv, int type, Display *display=0, Qt::HANDLE visual=0, Qt::HANDLE colormap=0)
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
Definition: qevent.h:476
static bool obey_desktop_settings
virtual ~QApplication()
Cleans up any window system resources that were allocated by this application.
static Qt::KeyboardModifiers keyboardModifiers()
Returns the current state of the modifier keys on the keyboard.
static QWidget * activePopupWidget()
Returns the active popup widget.
int z() const
Returns the z position of the device.
Definition: qevent.h:204
void setAutoMaximizeThreshold(const int threshold)
static const char * application_menu_strings[]
QString & append(QChar c)
Definition: qstring.cpp:1777
bool load()
Loads the library and returns true if the library was loaded successfully; otherwise returns false...
Definition: qlibrary.cpp:909
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
int autoMaximizeThreshold() const
void setAutoSipEnabled(const bool enabled)
void qt_win_set_cursor(QWidget *, bool)
static Qt::KeyboardModifiers modifier_buttons
static void setRootObject(QObject *)
Sets the root accessible object of this application to object.
static void aboutQt()
Displays a simple message box about Qt.
int qUnregisterGuiStateMachine()
friend class QApplicationPrivate
QObject * receiver
Definition: qthread_p.h:77
#define Q_CORE_EXPORT
Definition: qglobal.h:1449
FocusReason
Definition: qnamespace.h:1521
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
QPoint pos
the position of the widget within its parent widget
Definition: qwidget.h:163
static bool isBlockedByModal(QWidget *widget)
Returns true if widget is blocked by a modal window.
static QWidget * tryModalHelper_sys(QWidget *top)
static QInputContext * inputContext
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
The QGesture class represents a gesture, containing properties that describe the corresponding user i...
Definition: qgesture.h:64
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.
static void closeAllWindows()
Closes all top-level windows.
bool hasMouseTracking() const
Definition: qwidget.h:993
static void setQuitOnLastWindowClosed(bool quit)
QPixmap getPixmapCursor(Qt::CursorShape cshape)
Qt::GestureType gestureType
the type of the gesture
Definition: qgesture.h:70
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
QWidget * currentTarget()
Definition: qdnd.cpp:273
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
QString sessionKey() const
Returns the session key in the current session.
QGestureEventPrivate * d_func()
Definition: qevent.cpp:5079
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
bool isSessionRestored() const
Returns true if the application has been restored from an earlier Session Management{session}; otherw...
static void syncX()
Synchronizes with the X server in the X11 implementation.
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
Definition: qicon.cpp:730
QPointF pos() const
Returns the position of this touch point, relative to the widget or QGraphicsItem that received the e...
Definition: qevent.cpp:4473
static QString styleSheet
const QPoint & globalPos() const
Returns the global position of the device at the time of the event.
Definition: qevent.h:192
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
static bool animate_toolbox
static int drag_distance
void qt_cleanup()
CursorShape
Definition: qnamespace.h:1262
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
Definition: qevent.h:555
bool qt_tabletChokeMouse
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
static QString desktopStyleKey()
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
QPoint mapToParent(const QPoint &) const
Translates the widget coordinate pos to a coordinate in the parent widget.
Definition: qwidget.cpp:4459
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
const QList< QTouchEvent::TouchPoint > & touchPoints() const
Returns the list of touch points contained in the touch event.
Definition: qevent.h:820
int yTilt() const
Returns the angle between the device (a pen, for example) and the perpendicular in the direction of t...
Definition: qevent.h:208
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
FocusPolicy
Definition: qnamespace.h:181
RestartHint restartHint() const
Returns the application&#39;s current restart hint.
bool isEmpty() const
Returns true if the map contains no items; otherwise returns false.
Definition: qmap.h:203
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
qreal tangentialPressure() const
Returns the tangential pressure for the device.
Definition: qevent.h:205
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
static const QMetaObjectPrivate * priv(const uint *data)
bool isAncestorOf(const QWidget *child) const
Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child...
Definition: qwidget.cpp:8573
QApplication::Type qt_appType
ushort Data3
Definition: quuid.h:56
const QPoint & globalPos() const
Returns the mouse cursor position when the event was generated in global coordinates.
Definition: qevent.h:598
QTouchEventTouchPointPrivate * d
Definition: qevent.h:800
QMap< int, QWeakPointer< QWidget > > widgetForTouchPointId
static QGraphicsSystem * graphics_system
static QDateTime currentDateTime()
Returns the current datetime, as reported by the system clock, in the local time zone.
Definition: qdatetime.cpp:3138
virtual void reset()=0
This function can be reimplemented in a subclass to reset the state of the input method.
QFactoryLoader * l
const_iterator constBegin() const
Definition: qset.h:168
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
Definition: qmap.h:553
const QPoint & globalPos() const
Returns the global position of the mouse pointer at the time of the event.
Definition: qevent.h:152
bool compressEvent(QEvent *, QObject *receiver, QPostEventList *)
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)
static void setSystemPalette(const QPalette &pal)
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
bool isPrimary() const
Returns true if this touch point is the primary touch point.
Definition: qevent.cpp:4462
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
QWidget * qt_button_down
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
virtual QString styleName()
static QString styleOverride
QMap< WId, QDirectPainter * > * directPainters
The TouchPoint class provides information about a touch point in a QTouchEvent.
Definition: qevent.h:744
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390
static void setOverrideCursor(const QCursor &)
Use changeOverrideCursor(cursor) (if replace is true) or setOverrideCursor(cursor) (if replace is fal...
static void emitLastWindowClosed()
bool isAccepted(QGesture *) const
Returns true if the gesture is accepted; otherwise returns false.
Definition: qevent.cpp:4968
static QWidgetMapper * mapper
Definition: qwidget_p.h:714
void qInitImageConversions()
Definition: qimage.cpp:3909
The QInputEvent class is the base class for events that describe user input.
Definition: qevent.h:74
QKeyMapperPrivate * qt_keymapper_private()
Definition: qkeymapper.cpp:113
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309
Qt::GestureState state
the current state of the gesture
Definition: qgesture.h:69
The QTouchEvent class contains parameters that describe a touch event.
Definition: qevent.h:741
uint in_destructor
Definition: qwidget.h:129
T take(const Key &key)
Removes the item with the key key from the map and returns the value associated with it...
Definition: qmap.h:692
QRectF screenRect() const
Returns the rect for this touch point in screen coordinates.
Definition: qevent.cpp:4648
static int aargc
const QMimeData * mimeData() const
Returns the data that was dropped on the widget and its associated MIME type information.
Definition: qevent.h:498
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setWidget(QWidget *awidget)
Definition: qevent.h:823
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
static Qt::MouseButtons mouseButtons()
Returns the current state of the buttons on the mouse.
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336
bool qt_is_gui_used
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin)
Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget an...
Definition: qwidget.cpp:6098
const QPoint & globalPos() const
Returns the global position of the mouse pointer at the time of the event.
Definition: qevent.h:413
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
qreal rotation() const
Returns the rotation of the current device in degress.
Definition: qevent.h:206
QTouchEventSequence touchEvent(QWidget *widget=0, QTouchEvent::DeviceType deviceType=QTouchEvent::TouchScreen)
Creates and returns a QTouchEventSequence for the device deviceType to simulate events for widget...
Definition: qtesttouch.h:141
static bool shouldSetFocus(QWidget *w, Qt::FocusPolicy policy)
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
HRESULT qt_CoCreateGuid(GUID *guid)
static QFont * set_font
static void translateRawTouchEvent(QWidget *widget, QTouchEvent::DeviceType deviceType, const QList< QTouchEvent::TouchPoint > &touchPoints)
static bool quitOnLastWindowClosed()
static Qt::LayoutDirection keyboardInputDirection()
Returns the current keyboard input direction.
QPoint mapFrom(QWidget *, const QPoint &) const
Translates the widget coordinate pos from the coordinate system of parent to this widget&#39;s coordinate...
Definition: qwidget.cpp:4433
static bool isAlien(QWidget *)
QPoint p
Definition: qevent.h:519
void setStyleSheet(const QString &styleSheet)
Definition: qwidget.cpp:2709
static bool widgetCount
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
bool qt_in_tab_key_event
static void setFont(const QFont &, const char *className=0)
Changes the default application font to font.
static const KeyPair *const end
void requestPhase2()
Requests a second session management phase for the application.
PaletteHash * qt_app_palettes_hash()
virtual void setFocusWidget(QWidget *w)
Sets the widget that has an input focus for this input context.
QGestureManager * gestureManager
void moveCenter(const QPointF &p)
Moves the rectangle, leaving the center point at the given position.
Definition: qrect.h:705
static int instanceCounter
Definition: qwidget_p.h:752
static bool sendMouseEvent(QWidget *receiver, QMouseEvent *event, QWidget *alienWidget, QWidget *native, QWidget **buttonDown, QPointer< QWidget > &lastMouseReceiver, bool spontaneous=true)
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
QMap< Qt::GestureType, bool > accepted
Definition: qevent_p.h:169
Qt::LayoutDirection keyboardInputDirection
Definition: qkeymapper_p.h:156
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
Definition: qevent.h:96
QPointF center() const
Returns the center point of the rectangle.
Definition: qrect.h:686
static int autoMaximizeThreshold
static Type type()
Returns the type of application (Tty , GuiClient, or GuiServer).
static void leaveModal(QWidget *)
static void initResources()
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
ushort Data2
Definition: quuid.h:55
void repolish(QWidget *widget)
void cancel()
Tells the session manager to cancel the shutdown process.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
WindowModality
Definition: qnamespace.h:1683
Q_GUI_EXPORT bool qt_tryModalHelper(QWidget *widget, QWidget **rettop)
The QCloseEvent class contains parameters that describe a close event.
Definition: qevent.h:364
static void setDesktopSettingsAware(bool)
Sets whether Qt should use the system&#39;s standard colors, fonts, etc., to on.
#define enabled
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
static void setGlobalStrut(const QSize &)
static void enterModal(QWidget *)
WId winid
Definition: qwidget.h:117
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
static int drag_time
TabletDevice device() const
Returns the type of device that generated the event.
Definition: qevent.h:200
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67
static Qt::MouseButtons mouse_buttons
static bool animate_menu
Q_CORE_EXPORT void qCritical(const char *,...)
const QPoint & pos() const
Returns the position where the drop was made.
Definition: qevent.h:486
virtual bool filterEvent(const QEvent *event)
This function can be reimplemented in a subclass to filter input events.
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310
QPointF startPos() const
Returns the starting position of this touch point, relative to the widget or QGraphicsItem that recei...
Definition: qevent.cpp:4522
QSessionManager * qt_session_manager_self
uint in_show
Definition: qwidget.h:124
The QLibrary class loads shared libraries at runtime.
Definition: qlibrary.h:62
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272
static int cursor_flash_time
Qt::LayoutDirection direction
QString styleSheet() const
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition: qevent.h:586
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
static int maxInstances
Definition: qwidget_p.h:753
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480
const QPoint & pos() const
Returns the mouse cursor position when the event was generated, relative to the widget to which the e...
Definition: qevent.h:597