Qt 4.8
qapplication_qpa.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 "qapplication_p.h"
43 #include "qcolormap.h"
44 #include "qpixmapcache.h"
45 #if defined(Q_OS_BLACKBERRY)
47 #else
48 #if !defined(QT_NO_GLIB)
50 #endif
51 #include "qeventdispatcher_qpa_p.h"
52 #endif
53 #ifndef QT_NO_CURSOR
54 #include "private/qcursor_p.h"
55 #endif
56 
57 #include "private/qwidget_p.h"
58 #include "private/qevent_p.h"
59 
62 #include <qdesktopwidget.h>
63 
64 #include <qinputcontext.h>
65 #include <QPlatformCursor>
66 #include <qdebug.h>
67 #include <QWindowSystemInterface>
69 #include <QPlatformIntegration>
70 
71 #include "qdesktopwidget_qpa_p.h"
72 
74 
77 
78 QWidget *qt_button_down = 0; // widget got last button-down
79 
80 static bool app_do_modal = false;
81 extern QWidgetList *qt_modal_stack; // stack of modal widgets
82 
83 int qt_last_x = 0;
84 int qt_last_y = 0;
86 
87 static Qt::MouseButtons buttons = Qt::NoButton;
90 static int mousePressX;
91 static int mousePressY;
93 
94 void QApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
95 {
96  switch(e->type) {
98  QApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e));
99  break;
101  QApplicationPrivate::processWheelEvent(static_cast<QWindowSystemInterfacePrivate::WheelEvent *>(e));
102  break;
104  QApplicationPrivate::processKeyEvent(static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e));
105  break;
107  QApplicationPrivate::processTouchEvent(static_cast<QWindowSystemInterfacePrivate::TouchEvent *>(e));
108  break;
110  QApplicationPrivate::processGeometryChangeEvent(static_cast<QWindowSystemInterfacePrivate::GeometryChangeEvent*>(e));
111  break;
113  QApplicationPrivate::processEnterEvent(static_cast<QWindowSystemInterfacePrivate::EnterEvent *>(e));
114  break;
116  QApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e));
117  break;
119  QApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e));
120  break;
122  QApplicationPrivate::processWindowStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowStateChangedEvent *>(e));
123  break;
125  QApplicationPrivate::processCloseEvent(
126  static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e));
127  break;
129  QApplicationPrivate::reportScreenCount(
130  static_cast<QWindowSystemInterfacePrivate::ScreenCountEvent *>(e));
131  break;
133  QApplicationPrivate::reportGeometryChange(
134  static_cast<QWindowSystemInterfacePrivate::ScreenGeometryEvent *>(e));
135  break;
137  QApplicationPrivate::reportAvailableGeometryChange(
138  static_cast<QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *>(e));
139  break;
141  QApplicationPrivate::reportLocaleChange();
142  break;
144  QApplicationPrivate::processPlatformPanelEvent(
145  static_cast<QWindowSystemInterfacePrivate::PlatformPanelEvent *>(e));
146  break;
147  default:
148  qWarning() << "Unknown user input event type:" << e->type;
149  break;
150  }
151 }
152 
153 void QApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse)
154 {
155  if (wse->tlw.isNull())
156  return;
157 
158  QWidget *tlw = wse->tlw.data();
159  if (!tlw->isWindow())
160  return;
161 
163  tlw->setWindowState(wse->newState);
165 }
166 
168 {
169  return QT_PREPEND_NAMESPACE(appName);
170 }
171 
173 {
174  Q_Q(QApplication);
175 #if defined(Q_OS_BLACKBERRY)
177 #else
178 #if !defined(QT_NO_GLIB)
179  if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported())
181  else
182 #endif
184 #endif
185 }
186 
188 {
189  QWidget * top = 0;
190 
191  if (QApplicationPrivate::tryModalHelper(widget, &top))
192  return true;
193 
194  bool block_event = false;
195  bool paint_event = false;
196 
197  switch (type) {
198 #if 0
199  case QEvent::Focus:
200  if (!static_cast<QWSFocusEvent*>(event)->simpleData.get_focus)
201  break;
202  // drop through
203 #endif
204  case QEvent::MouseButtonPress: // disallow mouse/key events
206  case QEvent::MouseMove:
207  case QEvent::KeyPress:
208  case QEvent::KeyRelease:
210  block_event = true;
211  break;
212  default:
213  break;
214  }
215 
216  if ((block_event || paint_event) && top->parentWidget() == 0)
217  top->raise();
218 
219  return !block_event;
220 }
221 
222 
223 
225 {
226  if (!qt_modal_stack)
227  qt_modal_stack = new QWidgetList;
228  qt_modal_stack->insert(0, widget);
229  app_do_modal = true;
230 }
231 
233 {
234  if (qt_modal_stack && qt_modal_stack->removeAll(widget)) {
235  if (qt_modal_stack->isEmpty()) {
236  delete qt_modal_stack;
237  qt_modal_stack = 0;
238  }
239  }
240  app_do_modal = qt_modal_stack != 0;
241 }
242 
244 {
245  return app_do_modal;
246 }
247 
249 {
250  Q_Q(QApplication);
251  if (!popupWidgets)
252  return;
253  popupWidgets->removeAll(popup);
254 
255 //###
256 // if (popup == qt_popup_down) {
257 // qt_button_down = 0;
258 // qt_popup_down = 0;
259 // }
260 
261  if (QApplicationPrivate::popupWidgets->count() == 0) { // this was the last popup
264 
265  //### replay mouse event?
266 
267  //### transfer/release mouse grab
268 
269  //### transfer/release keyboard grab
270 
271  //give back focus
272 
273  if (active_window) {
274  if (QWidget *fw = active_window->focusWidget()) {
275  if (fw != QApplication::focusWidget()) {
276  fw->setFocus(Qt::PopupFocusReason);
277  } else {
279  q->sendEvent(fw, &e);
280  }
281  }
282  }
283 
284  } else {
285  // A popup was closed, so the previous popup gets the focus.
286 
288  if (QWidget *fw = aw->focusWidget())
289  fw->setFocus(Qt::PopupFocusReason);
290 
291  //### regrab the keyboard and mouse in case 'popup' lost the grab
292 
293 
294  }
295 
296 }
297 
298 static int openPopupCount = 0;
300 {
301  openPopupCount++;
302  if (!popupWidgets) { // create list
304 
305  /* only grab if you are the first/parent popup */
306  //#### ->grabMouse(popup,true);
307  //#### ->grabKeyboard(popup,true);
308  //### popupGrabOk = true;
309  }
310  popupWidgets->append(popup); // add to end of list
311 
312  // popups are not focus-handled by the window system (the first
313  // popup grabbed the keyboard), so we have to do that manually: A
314  // new popup gets the focus
315  if (popup->focusWidget()) {
317  } else if (popupWidgets->count() == 1) { // this was the first popup
318  if (QWidget *fw = QApplication::focusWidget()) {
320  QApplication::sendEvent(fw, &e);
321  }
322  }
323 }
324 
326 {
327 }
328 
330 {
331 }
332 
334 {
335 }
336 
337 void QApplication::setCursorFlashTime(int msecs)
338 {
340 }
341 
343 {
345 }
346 
348 {
350 }
351 
353 {
355 }
356 
358 {
360 }
361 
363 {
365 }
366 
367 #ifndef QT_NO_WHEELEVENT
368 void QApplication::setWheelScrollLines(int lines)
369 {
371 }
372 
374 {
376 }
377 #endif
378 
379 void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
380 {
381  switch (effect) {
382  case Qt::UI_AnimateMenu:
384  break;
385  case Qt::UI_FadeMenu:
386  if (enable)
389  break;
390  case Qt::UI_AnimateCombo:
392  break;
395  break;
396  case Qt::UI_FadeTooltip:
397  if (enable)
400  break;
403  break;
404  default:
406  break;
407  }
408 }
409 
411 {
413  return false;
414 
415  switch(effect) {
416  case Qt::UI_AnimateMenu:
418  case Qt::UI_FadeMenu:
420  case Qt::UI_AnimateCombo:
424  case Qt::UI_FadeTooltip:
428  default:
430  }
431 }
432 
433 #ifndef QT_NO_CURSOR
434 void QApplication::setOverrideCursor(const QCursor &cursor)
435 {
436  qApp->d_func()->cursor_list.prepend(cursor);
437  qt_qpa_set_cursor(0, false);
438 }
439 
441 {
442  if (qApp->d_func()->cursor_list.isEmpty())
443  return;
444  qApp->d_func()->cursor_list.removeFirst();
445  qt_qpa_set_cursor(0, false);
446 }
447 
448 #endif// QT_NO_CURSOR
449 
451 {
452  QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
453 
454  QList<QPlatformScreen *> screens = pi->screens();
457 
458  // The first screen in a virtual environment should know about all top levels
459  if (pi->isVirtualDesktop()) {
460  QWidget *w = (*screen)->topLevelAt(pos);
461  return w;
462  }
463 
464  while (screen != end) {
465  if ((*screen)->geometry().contains(pos))
466  return (*screen)->topLevelAt(pos);
467  ++screen;
468  }
469  return 0;
470 }
471 
472 void QApplication::beep()
473 {
474 }
475 
476 void QApplication::alert(QWidget *, int)
477 {
478 }
479 
483 QPlatformNativeInterface *QApplication::platformNativeInterface()
484 {
485  QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
486  return pi ? pi->nativeInterface() : 0;
487 }
488 
489 static void init_platform(const QString &name, const QString &platformPluginPath)
490 {
491  QApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath);
492  if (!QApplicationPrivate::platform_integration) {
493  QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath);
494  QString fatalMessage =
495  QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name);
496  foreach(QString key, keys) {
497  fatalMessage.append(key + QString::fromLatin1("\n"));
498  }
499  qFatal("%s", fatalMessage.toLocal8Bit().constData());
500 
501  }
502 
503 }
504 
505 
506 static void cleanup_platform()
507 {
508  delete QApplicationPrivate::platform_integration;
509  QApplicationPrivate::platform_integration = 0;
510 }
511 
512 static void init_plugins(const QList<QByteArray> pluginList)
513 {
514  for (int i = 0; i < pluginList.count(); ++i) {
515  QByteArray pluginSpec = pluginList.at(i);
516  qDebug() << "init_plugins" << i << pluginSpec;
517  int colonPos = pluginSpec.indexOf(':');
518  QObject *plugin;
519  if (colonPos < 0)
520  plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString());
521  else
522  plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)),
523  QLatin1String(pluginSpec.mid(colonPos+1)));
524  qDebug() << " created" << plugin;
525  }
526 }
527 
528 #ifndef QT_NO_QWS_INPUTMETHODS
530 {
531 public:
535  QString language() { return QString(); }
536 
537  void reset() {}
538  bool isComposing() const { return false; }
539 
540 };
541 #endif // QT_NO_QWS_INPUTMETHODS
542 
544 {
545  Q_UNUSED(type);
546 
548  char *p;
549  char **argv = priv->argv;
550  int argc = priv->argc;
551 
552  if (argv && *argv) { //apparently, we allow people to pass 0 on the other platforms
553  p = strrchr(argv[0], '/');
554  appName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
555  }
556 
557  QList<QByteArray> pluginList;
558  QString platformPluginPath = QLatin1String(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH"));
559  QByteArray platformName;
560 #ifdef QT_QPA_DEFAULT_PLATFORM_NAME
561  platformName = QT_QPA_DEFAULT_PLATFORM_NAME;
562 #endif
563  QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM");
564  if (!platformNameEnv.isEmpty()) {
565  platformName = platformNameEnv;
566  }
567 
568  // Get command line params
569 
570  int j = argc ? 1 : 0;
571  for (int i=1; i<argc; i++) {
572  if (argv[i] && *argv[i] != '-') {
573  argv[j++] = argv[i];
574  continue;
575  }
576  QByteArray arg = argv[i];
577  if (arg == "-fn" || arg == "-font") {
578  if (++i < argc)
579  appFont = QString::fromLocal8Bit(argv[i]);
580  } else if (arg == "-platformpluginpath") {
581  if (++i < argc)
582  platformPluginPath = QLatin1String(argv[i]);
583  } else if (arg == "-platform") {
584  if (++i < argc)
585  platformName = argv[i];
586  } else if (arg == "-plugin") {
587  if (++i < argc)
588  pluginList << argv[i];
589  } else {
590  argv[j++] = argv[i];
591  }
592  }
593 
594  if (j < priv->argc) {
595  priv->argv[j] = 0;
596  priv->argc = j;
597  }
598 
599 #if 0
600  QByteArray pluginEnv = qgetenv("QT_QPA_PLUGINS");
601  if (!pluginEnv.isEmpty()) {
602  pluginList.append(pluginEnv.split(';'));
603  }
604 #endif
605 
606  init_platform(QLatin1String(platformName), platformPluginPath);
607  init_plugins(pluginList);
608 
611 #ifndef QT_NO_CURSOR
612 // QCursorData::initialize();
613 #endif
614 
615  qApp->setObjectName(appName);
616 
617 #ifndef QT_NO_QWS_INPUTMETHODS
618  qApp->setInputContext(new QDummyInputContext(qApp));
619 #endif
620 }
621 
623 {
625 
627 #ifndef QT_NO_CURSOR
629 #endif
630  QFont::cleanup();
634 
635  QApplicationPrivate::active_window = 0; //### this should not be necessary
636 }
637 
638 
639 #ifdef QT3_SUPPORT
640 void QApplication::setMainWidget(QWidget *mainWidget)
641 {
643  if (QApplicationPrivate::main_widget && windowIcon().isNull()
645  setWindowIcon(QApplicationPrivate::main_widget->windowIcon());
646 }
647 #endif
648 
649 void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e)
650 {
651  static QWeakPointer<QWidget> implicit_mouse_grabber;
652 
654  // move first
655  Qt::MouseButtons stateChange = e->buttons ^ buttons;
656  if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) {
659  QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop
660  stateChange = Qt::NoButton;
661  }
662 
663  QWidget * tlw = e->widget.data();
664 
665  QPoint localPoint = e->localPos;
666  QPoint globalPoint = e->globalPos;
667  QWidget *mouseWindow = tlw;
668 
669  Qt::MouseButton button = Qt::NoButton;
670 
671 
672  if (qt_last_x != globalPoint.x() || qt_last_y != globalPoint.y()) {
673  type = QEvent::MouseMove;
674  qt_last_x = globalPoint.x();
675  qt_last_y = globalPoint.y();
676  if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance||
677  qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance)
679  }
680  else { // check to see if a new button has been pressed/released
681  for (int check = Qt::LeftButton;
682  check <= Qt::XButton2;
683  check = check << 1) {
684  if (check & stateChange) {
685  button = Qt::MouseButton(check);
686  break;
687  }
688  }
689  if (button == Qt::NoButton) {
690  // Ignore mouse events that don't change the current state
691  return;
692  }
693  buttons = e->buttons;
694  if (button & e->buttons) {
695  if ((e->timestamp - mousePressTime) < static_cast<ulong>(QApplication::doubleClickInterval()) && button == mousePressButton) {
698  }
699  else {
702  mousePressButton = button;
705  }
706  }
707  else
709  }
710 
711  if (self->inPopupMode()) {
712  //popup mouse handling is magical...
713  mouseWindow = qApp->activePopupWidget();
714 
715  implicit_mouse_grabber.clear();
716  //### how should popup mode and implicit mouse grab interact?
717 
718  } else if (tlw && app_do_modal && !qt_try_modal(tlw, QEvent::MouseButtonRelease) ) {
719  //even if we're blocked by modality, we should deliver the mouse release event..
720  //### this code is not completely correct: multiple buttons can be pressed simultaneously
721  if (!(implicit_mouse_grabber && buttons == Qt::NoButton)) {
722  //qDebug() << "modal blocked mouse event to" << tlw;
723  return;
724  }
725  }
726 
727  // find the tlw if we didn't get it from the plugin
728  if (!mouseWindow) {
729  mouseWindow = QApplication::topLevelAt(globalPoint);
730  }
731 
732  if (!mouseWindow && !implicit_mouse_grabber)
733  mouseWindow = QApplication::desktop();
734 
735  if (mouseWindow && mouseWindow != tlw) {
736  //we did not get a sensible localPoint from the window system, so let's calculate it
737  localPoint = mouseWindow->mapFromGlobal(globalPoint);
738  }
739 
740  // which child should have it?
741  QWidget *mouseWidget = mouseWindow;
742  if (mouseWindow) {
743  QWidget *w = mouseWindow->childAt(localPoint);
744  if (w) {
745  mouseWidget = w;
746  }
747  }
748 
749  //handle implicit mouse grab
750  if (type == QEvent::MouseButtonPress && !implicit_mouse_grabber) {
751  implicit_mouse_grabber = mouseWidget;
752 
753  Q_ASSERT(mouseWindow);
754  mouseWindow->activateWindow(); //focus
755  } else if (implicit_mouse_grabber) {
756  mouseWidget = implicit_mouse_grabber.data();
757  mouseWindow = mouseWidget->window();
758  if (mouseWindow != tlw)
759  localPoint = mouseWindow->mapFromGlobal(globalPoint);
760  }
761 
762  Q_ASSERT(mouseWidget);
763 
764  //localPoint is local to mouseWindow, but it needs to be local to mouseWidget
765  localPoint = mouseWidget->mapFrom(mouseWindow, localPoint);
766 
767  if (buttons == Qt::NoButton) {
768  //qDebug() << "resetting mouse grabber";
769  implicit_mouse_grabber.clear();
770  }
771 
772  if (mouseWidget != qt_last_mouse_receiver) {
773  dispatchEnterLeave(mouseWidget, qt_last_mouse_receiver);
774  qt_last_mouse_receiver = mouseWidget;
775  }
776 
777  // Remember, we might enter a modal event loop when sending the event,
778  // so think carefully before adding code below this point.
779 
780 
781  QMouseEvent ev(type, localPoint, globalPoint, button, buttons, QApplication::keyboardModifiers());
782 
784  foreach (QWeakPointer<QPlatformCursor> cursor, cursors) {
785  if (cursor)
786  cursor.data()->pointerEvent(ev);
787  }
788 
789  // qDebug() << "sending mouse event" << ev.type() << localPoint << globalPoint << ev.button() << ev.buttons() << mouseWidget << "mouse grabber" << implicit_mouse_grabber;
790 
791  int oldOpenPopupCount = openPopupCount;
792  QApplication::sendSpontaneousEvent(mouseWidget, &ev);
793 
794 #ifndef QT_NO_CONTEXTMENU
795  if (type == QEvent::MouseButtonPress && button == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) {
797  QApplication::sendSpontaneousEvent(mouseWidget, &e);
798  }
799 #endif // QT_NO_CONTEXTMENU
800 }
801 
802 void QApplicationPrivate::processPlatformPanelEvent(QWindowSystemInterfacePrivate::PlatformPanelEvent *e)
803 {
804  if (!e->widget)
805  return;
806 
808  // a modal window is blocking this window, don't allow events through
809  return;
810  }
811 
814 }
815 
816 //### there's a lot of duplicated logic here -- refactoring required!
817 
818 void QApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e)
819 {
820 
821  if (!e->widget)
822  return;
823 
824 // QPoint localPoint = ev.pos();
825  QPoint globalPoint = e->globalPos;
826 // bool trustLocalPoint = !!tlw; //is there something the local point can be local to?
827  QWidget *mouseWidget;
828 
829  qt_last_x = globalPoint.x();
830  qt_last_y = globalPoint.y();
831 
832  QWidget *mouseWindow = e->widget.data();
833 
834  // find the tlw if we didn't get it from the plugin
835  if (!mouseWindow) {
836  mouseWindow = QApplication::topLevelAt(globalPoint);
837  }
838 
839  if (!mouseWindow)
840  return;
841 
842  mouseWidget = mouseWindow;
843 
844  if (app_do_modal && !qt_try_modal(mouseWindow, QEvent::Wheel) ) {
845  qDebug() << "modal blocked wheel event" << mouseWindow;
846  return;
847  }
848  QPoint p = mouseWindow->mapFromGlobal(globalPoint);
849  QWidget *w = mouseWindow->childAt(p);
850  if (w) {
851  mouseWidget = w;
852  p = mouseWidget->mapFromGlobal(globalPoint);
853  }
854 
855  QWheelEvent ev(p, globalPoint, e->delta, buttons, QApplication::keyboardModifiers(),
856  e->orient);
857  QApplication::sendSpontaneousEvent(mouseWidget, &ev);
858 }
859 
860 
861 
862 // Remember, Qt convention is: keyboard state is state *before*
863 
864 void QApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e)
865 {
866  QWidget *focusW = 0;
867  if (self->inPopupMode()) {
868  QWidget *popupW = qApp->activePopupWidget();
869  focusW = popupW->focusWidget() ? popupW->focusWidget() : popupW;
870  }
871  if (!focusW)
872  focusW = QApplication::focusWidget();
873  if (!focusW) {
874  focusW = e->widget.data();
875  }
876  if (!focusW)
877  focusW = QApplication::activeWindow();
878 
879  //qDebug() << "handleKeyEvent" << hex << e->key() << e->modifiers() << e->text() << "widget" << focusW;
880 
881  if (!focusW)
882  return;
883  if (app_do_modal && !qt_try_modal(focusW, e->keyType))
884  return;
885 
886  if (e->nativeScanCode || e->nativeVirtualKey || e->nativeModifiers) {
887  QKeyEventEx ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount,
890  } else {
891  QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount);
893  }
894 }
895 
896 void QApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e)
897 {
898  if (!e->enter)
899  return;
900 
902  qt_last_mouse_receiver = e->enter.data();
903 }
904 
905 void QApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e)
906 {
907  if (!e->leave)
908  return;
909 
910  QApplicationPrivate::dispatchEnterLeave(0,qt_last_mouse_receiver);
911 
912  if (e->leave.data() && !e->leave.data()->isAncestorOf(qt_last_mouse_receiver)) //(???) this should not happen
914  qt_last_mouse_receiver = 0;
915 
916 }
917 
918 void QApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e)
919 {
921 }
922 
923 void QApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
924 {
925  if (e->tlw.isNull())
926  return;
927  QWidget *tlw = e->tlw.data();
928  if (!tlw->isWindow())
929  return; //geo of native child widgets is controlled by lighthouse
930  //so we already have sent the events; besides this new rect
931  //is not mapped to parent
932 
933  QRect newRect = e->newGeometry;
934  QRect cr(tlw->geometry());
935  bool isResize = cr.size() != newRect.size();
936  bool isMove = cr.topLeft() != newRect.topLeft();
937  tlw->data->crect = newRect;
938  if (isResize) {
939  QResizeEvent e(tlw->data->crect.size(), cr.size());
941  tlw->update();
942  }
943 
944  if (isMove) {
945  //### frame geometry
946  QMoveEvent e(tlw->data->crect.topLeft(), cr.topLeft());
948  }
949 }
950 
951 void QApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e)
952 {
953  if (e->topLevel.isNull()) {
954  //qDebug() << "QApplicationPrivate::processCloseEvent NULL";
955  return;
956  }
957  e->topLevel.data()->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
958 }
959 
960 void QApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e)
961 {
963 }
964 
965 void QApplicationPrivate::reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e)
966 {
967  // This operation only makes sense after the QApplication constructor runs
969  return;
970 
971  QApplication::desktop()->d_func()->updateScreenList();
972  // signal anything listening for creation or deletion of screens
974  emit desktop->screenCountChanged(e->count);
975 }
976 
977 void QApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e)
978 {
979  // This operation only makes sense after the QApplication constructor runs
981  return;
982 
983  QApplication::desktop()->d_func()->updateScreenList();
984 
985  // signal anything listening for screen geometry changes
987  emit desktop->resized(e->index);
988 
989  // make sure maximized and fullscreen windows are updated
991  for (int i = list.size() - 1; i >= 0; --i) {
992  QWidget *w = list.at(i);
993  if (w->isFullScreen())
994  w->d_func()->setFullScreenSize_helper();
995  else if (w->isMaximized())
996  w->d_func()->setMaxWindowState_helper();
997  }
998 }
999 
1000 void QApplicationPrivate::reportAvailableGeometryChange(
1002 {
1003  // This operation only makes sense after the QApplication constructor runs
1005  return;
1006 
1007  QApplication::desktop()->d_func()->updateScreenList();
1008 
1009  // signal anything listening for screen geometry changes
1011  emit desktop->workAreaResized(e->index);
1012 
1013  // make sure maximized and fullscreen windows are updated
1015  for (int i = list.size() - 1; i >= 0; --i) {
1016  QWidget *w = list.at(i);
1017  if (w->isFullScreen())
1018  w->d_func()->setFullScreenSize_helper();
1019  else if (w->isMaximized())
1020  w->d_func()->setMaxWindowState_helper();
1021  }
1022 }
1023 
1024 void QApplicationPrivate::reportLocaleChange()
1025 {
1027 }
1028 
static int keyboardInputInterval()
static QWidget * main_widget
void qt_cleanup()
static QApplicationPrivate * self
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
static QColormap instance(int screen=-1)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
The QKeyEvent class describes a key event.
Definition: qevent.h:224
Qt::KeyboardModifiers modifiers
This property holds the keyboard modifier flags that existed immediately before the event occurred...
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
bool inPopupMode() const
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
static QStringList keys(const QString &platformPluginPath=QString())
Returns the list of valid keys, i.e.
int type
Definition: qmetatype.cpp:239
static void beep()
Sounds the bell, using the default volume and sound.
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
QPointer< QWidget > widget
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
QString language()
This function must be implemented in any subclasses to return a language code (e. ...
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
static bool fade_tooltip
QRect crect
Definition: qwidget.h:131
static int mousePressY
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
QList< QWidget * > QWidgetList
Definition: qwindowdefs.h:89
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 initializeWidgetPaletteHash()
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or 0 if no application wi...
static Qt::MouseButtons buttons
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static int wheel_scroll_lines
void workAreaResized(int)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
static void init_plugins(const QList< QByteArray > pluginList)
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
static bool testAttribute(uint flag)
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
static bool qt_try_modal(QWidget *widget, QEvent::Type type)
static QWidget * active_window
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static void cleanup()
Internal function that cleans up the font system.
Definition: qfont_mac.cpp:93
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void closePopup(QWidget *popup)
static int cursorFlashTime()
static void cleanup_platform()
QString appName() const
Qt::MouseButtons buttons
This property holds the mouse buttons pressed when the event was generated.
The QString class provides a Unicode character string.
Definition: qstring.h:83
static bool animate_ui
bool isNull() const
Returns true if this object is holding a reference to a null pointer.
bool isComposing() const
This function indicates whether InputMethodStart event had been sent to the current focus widget...
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static int wheelScrollLines()
T * data() const
QStringList keys
static int mousePressX
int key
This property holds the code of the key that was pressed or released.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
#define Q_Q(Class)
Definition: qglobal.h:2483
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
static int keyboard_input_time
Q_CORE_EXPORT void qDebug(const char *,...)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static QList< WindowSystemEvent * > windowSystemEventQueue
static QObject * create(const QString &, const QString &)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QMoveEvent class contains event parameters for move events.
Definition: qevent.h:334
void qt_qpa_set_cursor(QWidget *w, bool force)
static bool isEmpty(const char *str)
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
static void initialize()
Internal function that initializes the font system.
Definition: qfont_mac.cpp:131
#define qApp
static int openPopupCount
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
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
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
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static void clear()
Removes all pixmaps from the cache.
#define QT_PREPEND_NAMESPACE(name)
This macro qualifies identifier with the full namespace.
Definition: qglobal.h:87
QWidgetData * data
Definition: qwidget.h:815
static bool sendSpontaneousEvent(QObject *receiver, QEvent *event)
static int mouse_double_click_time
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
Q_CORE_EXPORT void qWarning(const char *,...)
static Qt::MouseButton mousePressButton
static void setKeyboardInputInterval(int)
virtual QList< QPlatformScreen * > screens() const =0
Accessor function to a list of all the screens on the current system.
static bool animate_combo
static void alert(QWidget *widget, int duration=0)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static int mouse_double_click_distance
void resized(int)
UIEffect
Definition: qnamespace.h:1252
static QPlatformIntegration * create(const QString &key, const QString &platformPluginPath=QString())
unsigned long ulong
Definition: qglobal.h:997
virtual bool isVirtualDesktop()
Returns if the current windowing system configuration defines all the screens to be one desktop(virtu...
static void setActiveWindow(QWidget *act)
Sets the active window to the active widget in response to a system event.
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
static QWidget * topLevelAt(const QPoint &p)
Returns the top-level widget at the given point; returns 0 if there is no such widget.
QString identifierName()
This function must be implemented in any subclasses to return the identifier name of the input method...
bool isMaximized() const
Definition: qwidget.cpp:3074
QPointer< QWidget > qt_last_mouse_receiver
static bool startingUp()
Returns true if an application object has not been created yet; otherwise returns false...
static void enterModal_sys(QWidget *)
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).
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static bool animate_tooltip
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays...
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
static bool tryModalHelper(QWidget *widget, QWidget **rettop=0)
Q_CORE_EXPORT void qFatal(const char *,...)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static void setCursorFlashTime(int)
static bool isEffectEnabled(Qt::UIEffect)
Returns true if effect is enabled; otherwise returns false.
static Qt::KeyboardModifiers keyboardModifiers()
Returns the current state of the modifier keys on the keyboard.
QString & append(QChar c)
Definition: qstring.cpp:1777
The QWindowStateChangeEvent class provides the window state before a window state change...
Definition: qevent.h:705
static bool app_do_modal
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
static QAbstractEventDispatcher * eventDispatcher
static QInputContext * inputContext
static void init_platform(const QString &name, const QString &platformPluginPath)
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
int qt_last_x
static QString appFont
static bool animate_toolbox
static void initialize()
static ulong mousePressTime
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
static void setWheelScrollLines(int)
QDummyInputContext(QObject *parent=0)
bool isFullScreen() const
Definition: qwidget.cpp:3153
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void screenCountChanged(int)
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void reset()
This function can be reimplemented in a subclass to reset the state of the input method.
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)
void clear()
Clears this QWeakPointer object, dropping the reference that it may have had to the pointer...
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QObject * parent
Definition: qobject.h:92
static void setOverrideCursor(const QCursor &)
Use changeOverrideCursor(cursor) (if replace is true) or setOverrideCursor(cursor) (if replace is fal...
static QString appName
static void cleanup()
Definition: qcursor.cpp:402
QWidgetList * qt_modal_stack
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
static void setDoubleClickInterval(int)
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
static void restoreOverrideCursor()
Undoes the last setOverrideCursor().
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
static void translateRawTouchEvent(QWidget *widget, QTouchEvent::DeviceType deviceType, const QList< QTouchEvent::TouchPoint > &touchPoints)
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 void leaveModal_sys(QWidget *)
static const KeyPair *const end
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
QWidget * qt_button_down
void qt_init(QApplicationPrivate *priv, int type)
static int doubleClickInterval()
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
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
static void setEffectEnabled(Qt::UIEffect, bool enable=true)
Enables the UI effect effect if enable is true, otherwise the effect will not be used.
static void cleanup()
static QList< QWeakPointer< QPlatformCursor > > getInstances()
void openPopup(QWidget *popup)
static bool animate_menu
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300
virtual QPlatformNativeInterface * nativeInterface() const
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
virtual void pointerEvent(const QMouseEvent &event)
This method is called by Qt whenever a QMouseEvent is generated by the underlying pointer input...
static int cursor_flash_time
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770
MouseButton
Definition: qnamespace.h:150
int qt_last_y