qwidgetwindow.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qwidgetwindow.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets 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 The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/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 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "private/qwindow_p.h"-
41#include "qwidgetwindow_p.h"-
42#include "qlayout.h"-
43-
44#include "private/qwidget_p.h"-
45#include "private/qapplication_p.h"-
46#ifndef QT_NO_ACCESSIBILITY-
47#include <QtGui/qaccessible.h>-
48#endif-
49#include <private/qwidgetbackingstore_p.h>-
50#include <qpa/qwindowsysteminterface_p.h>-
51#include <qpa/qplatformtheme.h>-
52#include <qpa/qplatformwindow.h>-
53#include <private/qgesturemanager_p.h>-
54#include <private/qhighdpiscaling_p.h>-
55-
56QT_BEGIN_NAMESPACE-
57-
58Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets();-
59-
60QWidget *qt_button_down = 0; // widget got last button-down-
61-
62// popup control-
63QWidget *qt_popup_down = 0; // popup that contains the pressed widget-
64extern int openPopupCount;-
65bool qt_replay_popup_mouse_event = false;-
66extern bool qt_try_modal(QWidget *widget, QEvent::Type type);-
67-
68class QWidgetWindowPrivate : public QWindowPrivate-
69{-
70 Q_DECLARE_PUBLIC(QWidgetWindow)-
71public:-
72 QWindow *eventReceiver() Q_DECL_OVERRIDE {-
73 Q_Q(QWidgetWindow);-
74 QWindow *w = q;-
75 while (w->parent() && qobject_cast<QWidgetWindow *>(w) && qobject_cast<QWidgetWindow *>(w->parent())) {
w->parent()Description
TRUEnever evaluated
FALSEnever evaluated
qobject_cast<Q...etWindow *>(w)Description
TRUEnever evaluated
FALSEnever evaluated
qobject_cast<Q...>(w->parent())Description
TRUEnever evaluated
FALSEnever evaluated
0
76 w = w->parent();-
77 }
never executed: end of block
0
78 return w;
never executed: return w;
0
79 }-
80-
81 void clearFocusObject() Q_DECL_OVERRIDE-
82 {-
83 Q_Q(QWidgetWindow);-
84 QWidget *widget = q->widget();-
85 if (widget && widget->focusWidget())
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
widget->focusWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
86 widget->focusWidget()->clearFocus();
never executed: widget->focusWidget()->clearFocus();
0
87 }
never executed: end of block
0
88-
89 QRectF closestAcceptableGeometry(const QRectF &rect) const Q_DECL_OVERRIDE;-
90};-
91-
92QRectF QWidgetWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const-
93{-
94 Q_Q(const QWidgetWindow);-
95 const QWidget *widget = q->widget();-
96 if (!widget || !widget->isWindow() || !widget->hasHeightForWidth())
!widgetDescription
TRUEnever evaluated
FALSEnever evaluated
!widget->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
!widget->hasHeightForWidth()Description
TRUEnever evaluated
FALSEnever evaluated
0
97 return QRect();
never executed: return QRect();
0
98 const QSize oldSize = rect.size().toSize();-
99 const QSize newSize = QLayout::closestAcceptableSize(widget, oldSize);-
100 if (newSize == oldSize)
newSize == oldSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
101 return QRectF();
never executed: return QRectF();
0
102 const int dw = newSize.width() - oldSize.width();-
103 const int dh = newSize.height() - oldSize.height();-
104 QRectF result = rect;-
105 const QRectF currentGeometry(widget->geometry());-
106 const qreal topOffset = result.top() - currentGeometry.top();-
107 const qreal bottomOffset = result.bottom() - currentGeometry.bottom();-
108 if (qAbs(topOffset) > qAbs(bottomOffset))
qAbs(topOffset...(bottomOffset)Description
TRUEnever evaluated
FALSEnever evaluated
0
109 result.setTop(result.top() - dh); // top edge drag
never executed: result.setTop(result.top() - dh);
0
110 else-
111 result.setBottom(result.bottom() + dh); // bottom edge drag
never executed: result.setBottom(result.bottom() + dh);
0
112 const qreal leftOffset = result.left() - currentGeometry.left();-
113 const qreal rightOffset = result.right() - currentGeometry.right();-
114 if (qAbs(leftOffset) > qAbs(rightOffset))
qAbs(leftOffse...s(rightOffset)Description
TRUEnever evaluated
FALSEnever evaluated
0
115 result.setLeft(result.left() - dw); // left edge drag
never executed: result.setLeft(result.left() - dw);
0
116 else-
117 result.setRight(result.right() + dw); // right edge drag
never executed: result.setRight(result.right() + dw);
0
118 return result;
never executed: return result;
0
119}-
120-
121QWidgetWindow::QWidgetWindow(QWidget *widget)-
122 : QWindow(*new QWidgetWindowPrivate(), 0)-
123 , m_widget(widget)-
124{-
125 updateObjectName();-
126 // Enable QOpenGLWidget/QQuickWidget children if the platform plugin supports it,-
127 // and the application developer has not explicitly disabled it.-
128 if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface)
QGuiApplicatio...sterGLSurface)Description
TRUEnever evaluated
FALSEnever evaluated
0
129 && !QApplication::testAttribute(Qt::AA_ForceRasterWidgets)) {
!QApplication:...RasterWidgets)Description
TRUEnever evaluated
FALSEnever evaluated
0
130 setSurfaceType(QSurface::RasterGLSurface);-
131 }
never executed: end of block
0
132 connect(widget, &QObject::objectNameChanged, this, &QWidgetWindow::updateObjectName);-
133 connect(this, SIGNAL(screenChanged(QScreen*)), this, SLOT(handleScreenChange()));-
134}
never executed: end of block
0
135-
136QWidgetWindow::~QWidgetWindow()-
137{-
138}-
139-
140#ifndef QT_NO_ACCESSIBILITY-
141QAccessibleInterface *QWidgetWindow::accessibleRoot() const-
142{-
143 if (m_widget)
m_widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
144 return QAccessible::queryAccessibleInterface(m_widget);
never executed: return QAccessible::queryAccessibleInterface(m_widget);
0
145 return 0;
never executed: return 0;
0
146}-
147#endif-
148-
149QObject *QWidgetWindow::focusObject() const-
150{-
151 QWidget *windowWidget = m_widget;-
152 if (!windowWidget)
!windowWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
153 return Q_NULLPTR;
never executed: return nullptr;
0
154-
155 QWidget *widget = windowWidget->focusWidget();-
156-
157 if (!widget)
!widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
158 widget = windowWidget;
never executed: widget = windowWidget;
0
159-
160 QObject *focusObj = QWidgetPrivate::get(widget)->focusObject();-
161 if (focusObj)
focusObjDescription
TRUEnever evaluated
FALSEnever evaluated
0
162 return focusObj;
never executed: return focusObj;
0
163-
164 return widget;
never executed: return widget;
0
165}-
166-
167static inline bool shouldBePropagatedToWidget(QEvent *event)-
168{-
169 switch (event->type()) {-
170 // Handing show events to widgets would cause them to be triggered twice-
171 case QEvent::Show:
never executed: case QEvent::Show:
0
172 case QEvent::Hide:
never executed: case QEvent::Hide:
0
173 case QEvent::Timer:
never executed: case QEvent::Timer:
0
174 case QEvent::DynamicPropertyChange:
never executed: case QEvent::DynamicPropertyChange:
0
175 case QEvent::ChildAdded:
never executed: case QEvent::ChildAdded:
0
176 case QEvent::ChildRemoved:
never executed: case QEvent::ChildRemoved:
0
177 return false;
never executed: return false;
0
178 default:
never executed: default:
0
179 return true;
never executed: return true;
0
180 }-
181}-
182-
183bool QWidgetWindow::event(QEvent *event)-
184{-
185 if (!m_widget)
!m_widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
186 return QWindow::event(event);
never executed: return QWindow::event(event);
0
187-
188 if (m_widget->testAttribute(Qt::WA_DontShowOnScreen)) {
m_widget->test...tShowOnScreen)Description
TRUEnever evaluated
FALSEnever evaluated
0
189 // \a event is uninteresting for QWidgetWindow, the event was probably-
190 // generated before WA_DontShowOnScreen was set-
191 if (!shouldBePropagatedToWidget(event))
!shouldBePropa...oWidget(event)Description
TRUEnever evaluated
FALSEnever evaluated
0
192 return true;
never executed: return true;
0
193 return QCoreApplication::sendEvent(m_widget, event);
never executed: return QCoreApplication::sendEvent(m_widget, event);
0
194 }-
195-
196 switch (event->type()) {-
197 case QEvent::Close:
never executed: case QEvent::Close:
0
198 handleCloseEvent(static_cast<QCloseEvent *>(event));-
199 return true;
never executed: return true;
0
200-
201 case QEvent::Enter:
never executed: case QEvent::Enter:
0
202 case QEvent::Leave:
never executed: case QEvent::Leave:
0
203 handleEnterLeaveEvent(event);-
204 return true;
never executed: return true;
0
205-
206 // these should not be sent to QWidget, the corresponding events-
207 // are sent by QApplicationPrivate::notifyActiveWindowChange()-
208 case QEvent::FocusIn:
never executed: case QEvent::FocusIn:
0
209 handleFocusInEvent(static_cast<QFocusEvent *>(event));-
210 // Fallthrough-
211 case QEvent::FocusOut: {
code before this statement never executed: case QEvent::FocusOut:
never executed: case QEvent::FocusOut:
0
212#ifndef QT_NO_ACCESSIBILITY-
213 QAccessible::State state;-
214 state.active = true;-
215 QAccessibleStateChangeEvent ev(m_widget, state);-
216 QAccessible::updateAccessibility(&ev);-
217#endif-
218 return false; }
never executed: return false;
0
219-
220 case QEvent::FocusAboutToChange:
never executed: case QEvent::FocusAboutToChange:
0
221 if (QApplicationPrivate::focus_widget) {
QApplicationPr...::focus_widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
222 if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled))
QApplicationPr...MethodEnabled)Description
TRUEnever evaluated
FALSEnever evaluated
0
223 QGuiApplication::inputMethod()->commit();
never executed: QGuiApplication::inputMethod()->commit();
0
224-
225 QGuiApplication::sendSpontaneousEvent(QApplicationPrivate::focus_widget, event);-
226 }
never executed: end of block
0
227 return true;
never executed: return true;
0
228-
229 case QEvent::KeyPress:
never executed: case QEvent::KeyPress:
0
230 case QEvent::KeyRelease:
never executed: case QEvent::KeyRelease:
0
231 case QEvent::ShortcutOverride:
never executed: case QEvent::ShortcutOverride:
0
232 handleKeyEvent(static_cast<QKeyEvent *>(event));-
233 return true;
never executed: return true;
0
234-
235 case QEvent::MouseMove:
never executed: case QEvent::MouseMove:
0
236 case QEvent::MouseButtonPress:
never executed: case QEvent::MouseButtonPress:
0
237 case QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
238 case QEvent::MouseButtonDblClick:
never executed: case QEvent::MouseButtonDblClick:
0
239 handleMouseEvent(static_cast<QMouseEvent *>(event));-
240 return true;
never executed: return true;
0
241-
242 case QEvent::NonClientAreaMouseMove:
never executed: case QEvent::NonClientAreaMouseMove:
0
243 case QEvent::NonClientAreaMouseButtonPress:
never executed: case QEvent::NonClientAreaMouseButtonPress:
0
244 case QEvent::NonClientAreaMouseButtonRelease:
never executed: case QEvent::NonClientAreaMouseButtonRelease:
0
245 case QEvent::NonClientAreaMouseButtonDblClick:
never executed: case QEvent::NonClientAreaMouseButtonDblClick:
0
246 handleNonClientAreaMouseEvent(static_cast<QMouseEvent *>(event));-
247 return true;
never executed: return true;
0
248-
249 case QEvent::TouchBegin:
never executed: case QEvent::TouchBegin:
0
250 case QEvent::TouchUpdate:
never executed: case QEvent::TouchUpdate:
0
251 case QEvent::TouchEnd:
never executed: case QEvent::TouchEnd:
0
252 case QEvent::TouchCancel:
never executed: case QEvent::TouchCancel:
0
253 handleTouchEvent(static_cast<QTouchEvent *>(event));-
254 return true;
never executed: return true;
0
255-
256 case QEvent::Move:
never executed: case QEvent::Move:
0
257 handleMoveEvent(static_cast<QMoveEvent *>(event));-
258 return true;
never executed: return true;
0
259-
260 case QEvent::Resize:
never executed: case QEvent::Resize:
0
261 handleResizeEvent(static_cast<QResizeEvent *>(event));-
262 return true;
never executed: return true;
0
263-
264#ifndef QT_NO_WHEELEVENT-
265 case QEvent::Wheel:
never executed: case QEvent::Wheel:
0
266 handleWheelEvent(static_cast<QWheelEvent *>(event));-
267 return true;
never executed: return true;
0
268#endif-
269-
270#ifndef QT_NO_DRAGANDDROP-
271 case QEvent::DragEnter:
never executed: case QEvent::DragEnter:
0
272 case QEvent::DragMove:
never executed: case QEvent::DragMove:
0
273 handleDragEnterMoveEvent(static_cast<QDragMoveEvent *>(event));-
274 return true;
never executed: return true;
0
275 case QEvent::DragLeave:
never executed: case QEvent::DragLeave:
0
276 handleDragLeaveEvent(static_cast<QDragLeaveEvent *>(event));-
277 return true;
never executed: return true;
0
278 case QEvent::Drop:
never executed: case QEvent::Drop:
0
279 handleDropEvent(static_cast<QDropEvent *>(event));-
280 return true;
never executed: return true;
0
281#endif-
282-
283 case QEvent::Expose:
never executed: case QEvent::Expose:
0
284 handleExposeEvent(static_cast<QExposeEvent *>(event));-
285 return true;
never executed: return true;
0
286-
287 case QEvent::WindowStateChange:
never executed: case QEvent::WindowStateChange:
0
288 handleWindowStateChangedEvent(static_cast<QWindowStateChangeEvent *>(event));-
289 return true;
never executed: return true;
0
290-
291 case QEvent::ThemeChange: {
never executed: case QEvent::ThemeChange:
0
292 QEvent widgetEvent(QEvent::ThemeChange);-
293 QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent);-
294 }-
295 return true;
never executed: return true;
0
296-
297#ifndef QT_NO_TABLETEVENT-
298 case QEvent::TabletPress:
never executed: case QEvent::TabletPress:
0
299 case QEvent::TabletMove:
never executed: case QEvent::TabletMove:
0
300 case QEvent::TabletRelease:
never executed: case QEvent::TabletRelease:
0
301 handleTabletEvent(static_cast<QTabletEvent *>(event));-
302 return true;
never executed: return true;
0
303#endif-
304-
305#ifndef QT_NO_GESTURES-
306 case QEvent::NativeGesture:
never executed: case QEvent::NativeGesture:
0
307 handleGestureEvent(static_cast<QNativeGestureEvent *>(event));-
308 return true;
never executed: return true;
0
309#endif-
310-
311#ifndef QT_NO_CONTEXTMENU-
312 case QEvent::ContextMenu:
never executed: case QEvent::ContextMenu:
0
313 handleContextMenuEvent(static_cast<QContextMenuEvent *>(event));-
314 return true;
never executed: return true;
0
315#endif // QT_NO_CONTEXTMENU-
316-
317 case QEvent::WindowBlocked:
never executed: case QEvent::WindowBlocked:
0
318 qt_button_down = 0;-
319 break;
never executed: break;
0
320-
321 case QEvent::UpdateRequest:
never executed: case QEvent::UpdateRequest:
0
322 // This is not the same as an UpdateRequest for a QWidget. That just-
323 // syncs the backing store while here we also must mark as dirty.-
324 m_widget->repaint();-
325 return true;
never executed: return true;
0
326-
327 default:
never executed: default:
0
328 break;
never executed: break;
0
329 }-
330-
331 if (shouldBePropagatedToWidget(event) && QCoreApplication::sendEvent(m_widget, event))
shouldBePropag...oWidget(event)Description
TRUEnever evaluated
FALSEnever evaluated
QCoreApplicati...widget, event)Description
TRUEnever evaluated
FALSEnever evaluated
0
332 return true;
never executed: return true;
0
333-
334 return QWindow::event(event);
never executed: return QWindow::event(event);
0
335}-
336-
337QPointer<QWidget> qt_last_mouse_receiver = 0;-
338-
339void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)-
340{-
341#if !defined(Q_OS_OSX) && !defined(Q_OS_IOS) // Cocoa tracks popups-
342 // Ignore all enter/leave events from QPA if we are not on the first-level context menu.-
343 // This prevents duplicated events on most platforms. Fake events will be delivered in-
344 // QWidgetWindow::handleMouseEvent(QMouseEvent *). Make an exception whether the widget-
345 // is already under mouse - let the mouse leave.-
346 if (QApplicationPrivate::inPopupMode() && m_widget != QApplication::activePopupWidget() && !m_widget->underMouse())
QApplicationPr...:inPopupMode()Description
TRUEnever evaluated
FALSEnever evaluated
m_widget != QA...ePopupWidget()Description
TRUEnever evaluated
FALSEnever evaluated
!m_widget->underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
0
347 return;
never executed: return;
0
348#endif-
349 if (event->type() == QEvent::Leave) {
event->type() == QEvent::LeaveDescription
TRUEnever evaluated
FALSEnever evaluated
0
350 QWidget *enter = 0;-
351 // Check from window system event queue if the next queued enter targets a window-
352 // in the same window hierarchy (e.g. enter a child of this window). If so,-
353 // remove the enter event from queue and handle both in single dispatch.-
354 QWindowSystemInterfacePrivate::EnterEvent *systemEvent =-
355 static_cast<QWindowSystemInterfacePrivate::EnterEvent *>-
356 (QWindowSystemInterfacePrivate::peekWindowSystemEvent(QWindowSystemInterfacePrivate::Enter));-
357 const QPointF globalPosF = systemEvent ? systemEvent->globalPos : QGuiApplicationPrivate::lastCursorPosition;
systemEventDescription
TRUEnever evaluated
FALSEnever evaluated
0
358 if (systemEvent) {
systemEventDescription
TRUEnever evaluated
FALSEnever evaluated
0
359 if (QWidgetWindow *enterWindow = qobject_cast<QWidgetWindow *>(systemEvent->enter))
QWidgetWindow ...mEvent->enter)Description
TRUEnever evaluated
FALSEnever evaluated
0
360 {-
361 QWindow *thisParent = this;-
362 QWindow *enterParent = enterWindow;-
363 while (thisParent->parent())
thisParent->parent()Description
TRUEnever evaluated
FALSEnever evaluated
0
364 thisParent = thisParent->parent();
never executed: thisParent = thisParent->parent();
0
365 while (enterParent->parent())
enterParent->parent()Description
TRUEnever evaluated
FALSEnever evaluated
0
366 enterParent = enterParent->parent();
never executed: enterParent = enterParent->parent();
0
367 if (thisParent == enterParent) {
thisParent == enterParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
368 QGuiApplicationPrivate::currentMouseWindow = enterWindow;-
369 enter = enterWindow->widget();-
370 QWindowSystemInterfacePrivate::removeWindowSystemEvent(systemEvent);-
371 }
never executed: end of block
0
372 }
never executed: end of block
0
373 }
never executed: end of block
0
374 // Enter-leave between sibling widgets is ignored when there is a mousegrabber - this makes-
375 // both native and non-native widgets work similarly.-
376 // When mousegrabbing, leaves are only generated if leaving the parent window.-
377 if (!enter || !QWidget::mouseGrabber()) {
!enterDescription
TRUEnever evaluated
FALSEnever evaluated
!QWidget::mouseGrabber()Description
TRUEnever evaluated
FALSEnever evaluated
0
378 // Preferred leave target is the last mouse receiver, unless it has native window,-
379 // in which case it is assumed to receive it's own leave event when relevant.-
380 QWidget *leave = m_widget;-
381 if (qt_last_mouse_receiver && !qt_last_mouse_receiver->internalWinId())
qt_last_mouse_receiverDescription
TRUEnever evaluated
FALSEnever evaluated
!qt_last_mouse...nternalWinId()Description
TRUEnever evaluated
FALSEnever evaluated
0
382 leave = qt_last_mouse_receiver.data();
never executed: leave = qt_last_mouse_receiver.data();
0
383 QApplicationPrivate::dispatchEnterLeave(enter, leave, globalPosF);-
384 qt_last_mouse_receiver = enter;-
385 }
never executed: end of block
0
386 } else {
never executed: end of block
0
387 const QEnterEvent *ee = static_cast<QEnterEvent *>(event);-
388 QWidget *child = m_widget->childAt(ee->pos());-
389 QWidget *receiver = child ? child : m_widget.data();
childDescription
TRUEnever evaluated
FALSEnever evaluated
0
390 QWidget *leave = Q_NULLPTR;-
391 if (QApplicationPrivate::inPopupMode() && receiver == m_widget
QApplicationPr...:inPopupMode()Description
TRUEnever evaluated
FALSEnever evaluated
receiver == m_widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
392 && qt_last_mouse_receiver != m_widget) {
qt_last_mouse_...er != m_widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
393 // This allows to deliver the leave event to the native widget-
394 // action on first-level menu.-
395 leave = qt_last_mouse_receiver;-
396 }
never executed: end of block
0
397 QApplicationPrivate::dispatchEnterLeave(receiver, leave, ee->screenPos());-
398 qt_last_mouse_receiver = receiver;-
399 }
never executed: end of block
0
400}-
401-
402QWidget *QWidgetWindow::getFocusWidget(FocusWidgets fw)-
403{-
404 QWidget *tlw = m_widget;-
405 QWidget *w = tlw->nextInFocusChain();-
406-
407 QWidget *last = tlw;-
408-
409 uint focus_flag = qt_tab_all_widgets() ? Qt::TabFocus : Qt::StrongFocus;
qt_tab_all_widgets()Description
TRUEnever evaluated
FALSEnever evaluated
0
410-
411 while (w != tlw)
w != tlwDescription
TRUEnever evaluated
FALSEnever evaluated
0
412 {-
413 if (((w->focusPolicy() & focus_flag) == focus_flag)
((w->focusPoli...== focus_flag)Description
TRUEnever evaluated
FALSEnever evaluated
0
414 && w->isVisibleTo(m_widget) && w->isEnabled())
w->isVisibleTo(m_widget)Description
TRUEnever evaluated
FALSEnever evaluated
w->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
415 {-
416 last = w;-
417 if (fw == FirstFocusWidget)
fw == FirstFocusWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
418 break;
never executed: break;
0
419 }
never executed: end of block
0
420 w = w->nextInFocusChain();-
421 }
never executed: end of block
0
422-
423 return last;
never executed: return last;
0
424}-
425-
426void QWidgetWindow::handleFocusInEvent(QFocusEvent *e)-
427{-
428 QWidget *focusWidget = 0;-
429 if (e->reason() == Qt::BacktabFocusReason)
e->reason() ==...tabFocusReasonDescription
TRUEnever evaluated
FALSEnever evaluated
0
430 focusWidget = getFocusWidget(LastFocusWidget);
never executed: focusWidget = getFocusWidget(LastFocusWidget);
0
431 else if (e->reason() == Qt::TabFocusReason)
e->reason() ==...TabFocusReasonDescription
TRUEnever evaluated
FALSEnever evaluated
0
432 focusWidget = getFocusWidget(FirstFocusWidget);
never executed: focusWidget = getFocusWidget(FirstFocusWidget);
0
433-
434 if (focusWidget != 0)
focusWidget != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
435 focusWidget->setFocus();
never executed: focusWidget->setFocus();
0
436}
never executed: end of block
0
437-
438void QWidgetWindow::handleNonClientAreaMouseEvent(QMouseEvent *e)-
439{-
440 QApplication::sendSpontaneousEvent(m_widget, e);-
441}
never executed: end of block
0
442-
443void QWidgetWindow::handleMouseEvent(QMouseEvent *event)-
444{-
445 static const QEvent::Type contextMenuTrigger =-
446 QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool() ?-
447 QEvent::MouseButtonRelease : QEvent::MouseButtonPress;-
448 if (qApp->d_func()->inPopupMode()) {
(static_cast<Q...>inPopupMode()Description
TRUEnever evaluated
FALSEnever evaluated
0
449 QWidget *activePopupWidget = qApp->activePopupWidget();-
450 QPoint mapped = event->pos();-
451 if (activePopupWidget != m_widget)
activePopupWidget != m_widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
452 mapped = activePopupWidget->mapFromGlobal(event->globalPos());
never executed: mapped = activePopupWidget->mapFromGlobal(event->globalPos());
0
453 bool releaseAfter = false;-
454 QWidget *popupChild = activePopupWidget->childAt(mapped);-
455-
456 if (activePopupWidget != qt_popup_down) {
activePopupWid... qt_popup_downDescription
TRUEnever evaluated
FALSEnever evaluated
0
457 qt_button_down = 0;-
458 qt_popup_down = 0;-
459 }
never executed: end of block
0
460-
461 switch (event->type()) {-
462 case QEvent::MouseButtonPress:
never executed: case QEvent::MouseButtonPress:
0
463 case QEvent::MouseButtonDblClick:
never executed: case QEvent::MouseButtonDblClick:
0
464 qt_button_down = popupChild;-
465 qt_popup_down = activePopupWidget;-
466 break;
never executed: break;
0
467 case QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
468 releaseAfter = true;-
469 break;
never executed: break;
0
470 default:
never executed: default:
0
471 break; // nothing for mouse move
never executed: break;
0
472 }-
473-
474 int oldOpenPopupCount = openPopupCount;-
475-
476 if (activePopupWidget->isEnabled()) {
activePopupWidget->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
477 // deliver event-
478 qt_replay_popup_mouse_event = false;-
479 QWidget *receiver = activePopupWidget;-
480 QPoint widgetPos = mapped;-
481 if (qt_button_down)
qt_button_downDescription
TRUEnever evaluated
FALSEnever evaluated
0
482 receiver = qt_button_down;
never executed: receiver = qt_button_down;
0
483 else if (popupChild)
popupChildDescription
TRUEnever evaluated
FALSEnever evaluated
0
484 receiver = popupChild;
never executed: receiver = popupChild;
0
485 if (receiver != activePopupWidget)
receiver != activePopupWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
486 widgetPos = receiver->mapFromGlobal(event->globalPos());
never executed: widgetPos = receiver->mapFromGlobal(event->globalPos());
0
487-
488#if !defined(Q_OS_OSX) && !defined(Q_OS_IOS) // Cocoa tracks popups-
489 const bool reallyUnderMouse = activePopupWidget->rect().contains(mapped);-
490 const bool underMouse = activePopupWidget->underMouse();-
491 if (underMouse != reallyUnderMouse) {
underMouse != reallyUnderMouseDescription
TRUEnever evaluated
FALSEnever evaluated
0
492 if (reallyUnderMouse) {
reallyUnderMouseDescription
TRUEnever evaluated
FALSEnever evaluated
0
493 const QPoint receiverMapped = receiver->mapFromGlobal(event->screenPos().toPoint());-
494 // Prevent negative mouse position on enter event - this event-
495 // should be properly handled in "handleEnterLeaveEvent()".-
496 if (receiverMapped.x() >= 0 && receiverMapped.y() >= 0) {
receiverMapped.x() >= 0Description
TRUEnever evaluated
FALSEnever evaluated
receiverMapped.y() >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
497 QApplicationPrivate::dispatchEnterLeave(receiver, Q_NULLPTR, event->screenPos());-
498 qt_last_mouse_receiver = receiver;-
499 }
never executed: end of block
0
500 } else {
never executed: end of block
0
501 QApplicationPrivate::dispatchEnterLeave(Q_NULLPTR, qt_last_mouse_receiver, event->screenPos());-
502 qt_last_mouse_receiver = receiver;-
503 receiver = activePopupWidget;-
504 }
never executed: end of block
0
505 }-
506#endif-
507-
508 QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(),-
509 event->button(), event->buttons(), event->modifiers(), event->source());-
510 e.setTimestamp(event->timestamp());-
511 QApplicationPrivate::sendMouseEvent(receiver, &e, receiver, receiver->window(), &qt_button_down, qt_last_mouse_receiver);-
512 qt_last_mouse_receiver = receiver;-
513 } else {
never executed: end of block
0
514 // close disabled popups when a mouse button is pressed or released-
515 switch (event->type()) {-
516 case QEvent::MouseButtonPress:
never executed: case QEvent::MouseButtonPress:
0
517 case QEvent::MouseButtonDblClick:
never executed: case QEvent::MouseButtonDblClick:
0
518 case QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
519 activePopupWidget->close();-
520 break;
never executed: break;
0
521 default:
never executed: default:
0
522 break;
never executed: break;
0
523 }-
524 }-
525-
526 if (qApp->activePopupWidget() != activePopupWidget
(static_cast<Q...ivePopupWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
527 && qt_replay_popup_mouse_event
qt_replay_popup_mouse_eventDescription
TRUEnever evaluated
FALSEnever evaluated
0
528 && QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ReplayMousePressOutsidePopup).toBool()) {
QGuiApplicatio...opup).toBool()Description
TRUEnever evaluated
FALSEnever evaluated
0
529 if (m_widget->windowType() != Qt::Popup)
m_widget->wind...) != Qt::PopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
530 qt_button_down = 0;
never executed: qt_button_down = 0;
0
531 if (event->type() == QEvent::MouseButtonPress) {
event->type() ...useButtonPressDescription
TRUEnever evaluated
FALSEnever evaluated
0
532 // the popup disappeared, replay the mouse press event-
533 QWidget *w = QApplication::widgetAt(event->globalPos());-
534 if (w && !QApplicationPrivate::isBlockedByModal(w)) {
wDescription
TRUEnever evaluated
FALSEnever evaluated
!QApplicationP...ckedByModal(w)Description
TRUEnever evaluated
FALSEnever evaluated
0
535 // activate window of the widget under mouse pointer-
536 if (!w->isActiveWindow()) {
!w->isActiveWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
537 w->activateWindow();-
538 w->window()->raise();-
539 }
never executed: end of block
0
540-
541 QWindow *win = w->windowHandle();-
542 if (!win)
!winDescription
TRUEnever evaluated
FALSEnever evaluated
0
543 win = w->nativeParentWidget()->windowHandle();
never executed: win = w->nativeParentWidget()->windowHandle();
0
544 if (win) {
winDescription
TRUEnever evaluated
FALSEnever evaluated
0
545 const QRect globalGeometry = win->isTopLevel()
win->isTopLevel()Description
TRUEnever evaluated
FALSEnever evaluated
0
546 ? win->geometry()-
547 : QRect(win->mapToGlobal(QPoint(0, 0)), win->size());-
548 if (globalGeometry.contains(event->globalPos())) {
globalGeometry...->globalPos())Description
TRUEnever evaluated
FALSEnever evaluated
0
549 // Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec()-
550 const QPoint localPos = win->mapFromGlobal(event->globalPos());-
551 QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(),-
552 event->button(), event->buttons(), event->modifiers(), event->source());-
553 QCoreApplicationPrivate::setEventSpontaneous(e, true);-
554 e->setTimestamp(event->timestamp());-
555 QCoreApplication::postEvent(win, e);-
556 }
never executed: end of block
0
557 }
never executed: end of block
0
558 }
never executed: end of block
0
559 }
never executed: end of block
0
560 qt_replay_popup_mouse_event = false;-
561#ifndef QT_NO_CONTEXTMENU-
562 } else if (event->type() == contextMenuTrigger
never executed: end of block
event->type() ...extMenuTriggerDescription
TRUEnever evaluated
FALSEnever evaluated
0
563 && event->button() == Qt::RightButton
event->button(...t::RightButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
564 && (openPopupCount == oldOpenPopupCount)) {
(openPopupCoun...penPopupCount)Description
TRUEnever evaluated
FALSEnever evaluated
0
565 QWidget *popupEvent = activePopupWidget;-
566 if (qt_button_down)
qt_button_downDescription
TRUEnever evaluated
FALSEnever evaluated
0
567 popupEvent = qt_button_down;
never executed: popupEvent = qt_button_down;
0
568 else if(popupChild)
popupChildDescription
TRUEnever evaluated
FALSEnever evaluated
0
569 popupEvent = popupChild;
never executed: popupEvent = popupChild;
0
570 QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers());-
571 QApplication::sendSpontaneousEvent(popupEvent, &e);-
572 }
never executed: end of block
0
573#else-
574 Q_UNUSED(contextMenuTrigger)-
575 Q_UNUSED(oldOpenPopupCount)-
576 }-
577#endif-
578-
579 if (releaseAfter) {
releaseAfterDescription
TRUEnever evaluated
FALSEnever evaluated
0
580 qt_button_down = 0;-
581 qt_popup_down = 0;-
582 }
never executed: end of block
0
583 return;
never executed: return;
0
584 }-
585-
586 // modal event handling-
587 if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type()))
QApplicationPr...->modalState()Description
TRUEnever evaluated
FALSEnever evaluated
!qt_try_modal(...event->type())Description
TRUEnever evaluated
FALSEnever evaluated
0
588 return;
never executed: return;
0
589-
590 // which child should have it?-
591 QWidget *widget = m_widget->childAt(event->pos());-
592 QPoint mapped = event->pos();-
593-
594 if (!widget)
!widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
595 widget = m_widget;
never executed: widget = m_widget;
0
596-
597 if (event->type() == QEvent::MouseButtonPress)
event->type() ...useButtonPressDescription
TRUEnever evaluated
FALSEnever evaluated
0
598 qt_button_down = widget;
never executed: qt_button_down = widget;
0
599-
600 QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(),-
601 qt_button_down, widget);-
602-
603 if (!receiver) {
!receiverDescription
TRUEnever evaluated
FALSEnever evaluated
0
604 if (event->type() == QEvent::MouseButtonRelease)
event->type() ...eButtonReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
605 QApplicationPrivate::mouse_buttons &= ~event->button();
never executed: QApplicationPrivate::mouse_buttons &= ~event->button();
0
606 return;
never executed: return;
0
607 }-
608 if ((event->type() != QEvent::MouseButtonPress)
(event->type()...seButtonPress)Description
TRUEnever evaluated
FALSEnever evaluated
0
609 || !(event->flags().testFlag(Qt::MouseEventCreatedDoubleClick))) {
!(event->flags...dDoubleClick))Description
TRUEnever evaluated
FALSEnever evaluated
0
610-
611 // The preceding statement excludes MouseButtonPress events which caused-
612 // creation of a MouseButtonDblClick event. QTBUG-25831-
613 QMouseEvent translated(event->type(), mapped, event->windowPos(), event->screenPos(),-
614 event->button(), event->buttons(), event->modifiers(), event->source());-
615 translated.setTimestamp(event->timestamp());-
616 QApplicationPrivate::sendMouseEvent(receiver, &translated, widget, m_widget,-
617 &qt_button_down, qt_last_mouse_receiver);-
618 event->setAccepted(translated.isAccepted());-
619 }
never executed: end of block
0
620#ifndef QT_NO_CONTEXTMENU-
621 if (event->type() == contextMenuTrigger && event->button() == Qt::RightButton
event->type() ...extMenuTriggerDescription
TRUEnever evaluated
FALSEnever evaluated
event->button(...t::RightButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
622 && m_widget->rect().contains(event->pos())) {
m_widget->rect...(event->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
623 QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers());-
624 QGuiApplication::sendSpontaneousEvent(receiver, &e);-
625 }
never executed: end of block
0
626#endif-
627}
never executed: end of block
0
628-
629void QWidgetWindow::handleTouchEvent(QTouchEvent *event)-
630{-
631 if (event->type() == QEvent::TouchCancel) {
event->type() ...t::TouchCancelDescription
TRUEnever evaluated
FALSEnever evaluated
0
632 QApplicationPrivate::translateTouchCancel(event->device(), event->timestamp());-
633 event->accept();-
634 } else if (qApp->d_func()->inPopupMode()) {
never executed: end of block
(static_cast<Q...>inPopupMode()Description
TRUEnever evaluated
FALSEnever evaluated
0
635 // Ignore touch events for popups. This will cause QGuiApplication to synthesise mouse-
636 // events instead, which QWidgetWindow::handleMouseEvent will forward correctly:-
637 event->ignore();-
638 } else {
never executed: end of block
0
639 event->setAccepted(QApplicationPrivate::translateRawTouchEvent(m_widget, event->device(), event->touchPoints(), event->timestamp()));-
640 }
never executed: end of block
0
641}-
642-
643void QWidgetWindow::handleKeyEvent(QKeyEvent *event)-
644{-
645 if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type()))
QApplicationPr...->modalState()Description
TRUEnever evaluated
FALSEnever evaluated
!qt_try_modal(...event->type())Description
TRUEnever evaluated
FALSEnever evaluated
0
646 return;
never executed: return;
0
647-
648 QObject *receiver = QWidget::keyboardGrabber();-
649 if (!receiver && QApplicationPrivate::inPopupMode()) {
!receiverDescription
TRUEnever evaluated
FALSEnever evaluated
QApplicationPr...:inPopupMode()Description
TRUEnever evaluated
FALSEnever evaluated
0
650 QWidget *popup = QApplication::activePopupWidget();-
651 QWidget *popupFocusWidget = popup->focusWidget();-
652 receiver = popupFocusWidget ? popupFocusWidget : popup;
popupFocusWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
653 }
never executed: end of block
0
654 if (!receiver)
!receiverDescription
TRUEnever evaluated
FALSEnever evaluated
0
655 receiver = focusObject();
never executed: receiver = focusObject();
0
656 QGuiApplication::sendSpontaneousEvent(receiver, event);-
657}
never executed: end of block
0
658-
659bool QWidgetWindow::updateSize()-
660{-
661 bool changed = false;-
662 if (m_widget->testAttribute(Qt::WA_OutsideWSRange))
m_widget->test...utsideWSRange)Description
TRUEnever evaluated
FALSEnever evaluated
0
663 return changed;
never executed: return changed;
0
664 if (m_widget->data->crect.size() != geometry().size()) {
m_widget->data...metry().size()Description
TRUEnever evaluated
FALSEnever evaluated
0
665 changed = true;-
666 m_widget->data->crect.setSize(geometry().size());-
667 }
never executed: end of block
0
668-
669 updateMargins();-
670 return changed;
never executed: return changed;
0
671}-
672-
673bool QWidgetWindow::updatePos()-
674{-
675 bool changed = false;-
676 if (m_widget->testAttribute(Qt::WA_OutsideWSRange))
m_widget->test...utsideWSRange)Description
TRUEnever evaluated
FALSEnever evaluated
0
677 return changed;
never executed: return changed;
0
678 if (m_widget->data->crect.topLeft() != geometry().topLeft()) {
m_widget->data...ry().topLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
679 changed = true;-
680 m_widget->data->crect.moveTopLeft(geometry().topLeft());-
681 }
never executed: end of block
0
682 updateMargins();-
683 return changed;
never executed: return changed;
0
684}-
685-
686void QWidgetWindow::updateMargins()-
687{-
688 const QMargins margins = frameMargins();-
689 QTLWExtra *te = m_widget->d_func()->topData();-
690 te->posIncludesFrame= false;-
691 te->frameStrut.setCoords(margins.left(), margins.top(), margins.right(), margins.bottom());-
692 m_widget->data->fstrut_dirty = false;-
693}
never executed: end of block
0
694-
695static void sendScreenChangeRecursively(QWidget *widget)-
696{-
697 QEvent e(QEvent::ScreenChangeInternal);-
698 QApplication::sendEvent(widget, &e);-
699 QWidgetPrivate *d = QWidgetPrivate::get(widget);-
700 for (int i = 0; i < d->children.size(); ++i) {
i < d->children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
701 QWidget *w = qobject_cast<QWidget *>(d->children.at(i));-
702 if (w)
wDescription
TRUEnever evaluated
FALSEnever evaluated
0
703 sendScreenChangeRecursively(w);
never executed: sendScreenChangeRecursively(w);
0
704 }
never executed: end of block
0
705}
never executed: end of block
0
706-
707void QWidgetWindow::handleScreenChange()-
708{-
709 // Send an event recursively to the widget and its children.-
710 sendScreenChangeRecursively(m_widget);-
711-
712 // Invalidate the backing store buffer and repaint immediately.-
713 if (screen())
screen()Description
TRUEnever evaluated
FALSEnever evaluated
0
714 repaintWindow();
never executed: repaintWindow();
0
715}
never executed: end of block
0
716-
717void QWidgetWindow::repaintWindow()-
718{-
719 if (!m_widget->isVisible() || !m_widget->updatesEnabled() || !m_widget->rect().isValid())
!m_widget->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
!m_widget->updatesEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
!m_widget->rect().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
720 return;
never executed: return;
0
721-
722 QTLWExtra *tlwExtra = m_widget->window()->d_func()->maybeTopData();-
723 if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
tlwExtraDescription
TRUEnever evaluated
FALSEnever evaluated
!tlwExtra->inTopLevelResizeDescription
TRUEnever evaluated
FALSEnever evaluated
tlwExtra->backingStoreDescription
TRUEnever evaluated
FALSEnever evaluated
0
724 tlwExtra->backingStoreTracker->markDirty(m_widget->rect(), m_widget,
never executed: tlwExtra->backingStoreTracker->markDirty(m_widget->rect(), m_widget, QWidgetBackingStore::UpdateNow, QWidgetBackingStore::BufferInvalid);
0
725 QWidgetBackingStore::UpdateNow, QWidgetBackingStore::BufferInvalid);
never executed: tlwExtra->backingStoreTracker->markDirty(m_widget->rect(), m_widget, QWidgetBackingStore::UpdateNow, QWidgetBackingStore::BufferInvalid);
0
726}
never executed: end of block
0
727-
728Qt::WindowState effectiveState(Qt::WindowStates state);-
729-
730// Store normal geometry used for saving application settings.-
731void QWidgetWindow::updateNormalGeometry()-
732{-
733 QTLWExtra *tle = m_widget->d_func()->maybeTopData();-
734 if (!tle)
!tleDescription
TRUEnever evaluated
FALSEnever evaluated
0
735 return;
never executed: return;
0
736 // Ask platform window, default to widget geometry.-
737 QRect normalGeometry;-
738 if (const QPlatformWindow *pw = handle())
const QPlatfor...*pw = handle()Description
TRUEnever evaluated
FALSEnever evaluated
0
739 normalGeometry = QHighDpi::fromNativePixels(pw->normalGeometry(), this);
never executed: normalGeometry = QHighDpi::fromNativePixels(pw->normalGeometry(), this);
0
740 if (!normalGeometry.isValid() && effectiveState(m_widget->windowState()) == Qt::WindowNoState)
!normalGeometry.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
effectiveState...:WindowNoStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
741 normalGeometry = m_widget->geometry();
never executed: normalGeometry = m_widget->geometry();
0
742 if (normalGeometry.isValid())
normalGeometry.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
743 tle->normalGeometry = normalGeometry;
never executed: tle->normalGeometry = normalGeometry;
0
744}
never executed: end of block
0
745-
746void QWidgetWindow::handleMoveEvent(QMoveEvent *event)-
747{-
748 if (updatePos())
updatePos()Description
TRUEnever evaluated
FALSEnever evaluated
0
749 QGuiApplication::sendSpontaneousEvent(m_widget, event);
never executed: QGuiApplication::sendSpontaneousEvent(m_widget, event);
0
750}
never executed: end of block
0
751-
752void QWidgetWindow::handleResizeEvent(QResizeEvent *event)-
753{-
754 QSize oldSize = m_widget->data->crect.size();-
755-
756 if (updateSize()) {
updateSize()Description
TRUEnever evaluated
FALSEnever evaluated
0
757 QGuiApplication::sendSpontaneousEvent(m_widget, event);-
758-
759 if (m_widget->d_func()->paintOnScreen()) {
m_widget->d_fu...aintOnScreen()Description
TRUEnever evaluated
FALSEnever evaluated
0
760 QRegion updateRegion(geometry());-
761 if (m_widget->testAttribute(Qt::WA_StaticContents))
m_widget->test...taticContents)Description
TRUEnever evaluated
FALSEnever evaluated
0
762 updateRegion -= QRect(0, 0, oldSize.width(), oldSize.height());
never executed: updateRegion -= QRect(0, 0, oldSize.width(), oldSize.height());
0
763 m_widget->d_func()->syncBackingStore(updateRegion);-
764 } else {
never executed: end of block
0
765 m_widget->d_func()->syncBackingStore();-
766 }
never executed: end of block
0
767 }-
768}
never executed: end of block
0
769-
770void QWidgetWindow::handleCloseEvent(QCloseEvent *event)-
771{-
772 bool is_closing = m_widget->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);-
773 event->setAccepted(is_closing);-
774}
never executed: end of block
0
775-
776#ifndef QT_NO_WHEELEVENT-
777-
778void QWidgetWindow::handleWheelEvent(QWheelEvent *event)-
779{-
780 if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type()))
QApplicationPr...->modalState()Description
TRUEnever evaluated
FALSEnever evaluated
!qt_try_modal(...event->type())Description
TRUEnever evaluated
FALSEnever evaluated
0
781 return;
never executed: return;
0
782-
783 QWidget *rootWidget = m_widget;-
784 QPoint pos = event->pos();-
785-
786 // Use proper popup window for wheel event. Some QPA sends the wheel-
787 // event to the root menu, so redirect it to the proper popup window.-
788 QWidget *activePopupWidget = QApplication::activePopupWidget();-
789 if (activePopupWidget && activePopupWidget != m_widget) {
activePopupWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
activePopupWidget != m_widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
790 rootWidget = activePopupWidget;-
791 pos = rootWidget->mapFromGlobal(event->globalPos());-
792 }
never executed: end of block
0
793-
794 // which child should have it?-
795 QWidget *widget = rootWidget->childAt(pos);-
796-
797 if (!widget)
!widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
798 widget = rootWidget;
never executed: widget = rootWidget;
0
799-
800 QPoint mapped = widget->mapFrom(rootWidget, pos);-
801-
802 QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->angleDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers(), event->phase(), event->source(), event->inverted());-
803 QGuiApplication::sendSpontaneousEvent(widget, &translated);-
804}
never executed: end of block
0
805-
806#endif // QT_NO_WHEELEVENT-
807-
808#ifndef QT_NO_DRAGANDDROP-
809-
810void QWidgetWindow::handleDragEnterMoveEvent(QDragMoveEvent *event)-
811{-
812 Q_ASSERT(event->type() ==QEvent::DragMove || !m_dragTarget);-
813 // Find a target widget under mouse that accepts drops (QTBUG-22987).-
814 QWidget *widget = m_widget->childAt(event->pos());-
815 if (!widget)
!widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
816 widget = m_widget;
never executed: widget = m_widget;
0
817 for ( ; widget && !widget->isWindow() && !widget->acceptDrops(); widget = widget->parentWidget()) ;
never executed: ;
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
!widget->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
!widget->acceptDrops()Description
TRUEnever evaluated
FALSEnever evaluated
0
818 if (widget && !widget->acceptDrops())
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
!widget->acceptDrops()Description
TRUEnever evaluated
FALSEnever evaluated
0
819 widget = 0;
never executed: widget = 0;
0
820 // Target widget unchanged: DragMove-
821 if (widget && widget == m_dragTarget.data()) {
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
widget == m_dragTarget.data()Description
TRUEnever evaluated
FALSEnever evaluated
0
822 Q_ASSERT(event->type() == QEvent::DragMove);-
823 const QPoint mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->pos()));-
824 QDragMoveEvent translated(mapped, event->possibleActions(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers());-
825 translated.setDropAction(event->dropAction());-
826 if (event->isAccepted()) { // Handling 'DragEnter' should suffice for the application.
event->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
827 translated.accept();-
828 translated.setDropAction(event->dropAction());-
829 }
never executed: end of block
0
830 QGuiApplication::sendSpontaneousEvent(widget, &translated);-
831 if (translated.isAccepted()) {
translated.isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
832 event->accept();-
833 } else {
never executed: end of block
0
834 event->ignore();-
835 }
never executed: end of block
0
836 event->setDropAction(translated.dropAction());-
837 return;
never executed: return;
0
838 }-
839 // Target widget changed: Send DragLeave to previous, DragEnter to new if there is any-
840 if (m_dragTarget.data()) {
m_dragTarget.data()Description
TRUEnever evaluated
FALSEnever evaluated
0
841 QDragLeaveEvent le;-
842 QGuiApplication::sendSpontaneousEvent(m_dragTarget.data(), &le);-
843 m_dragTarget = 0;-
844 }
never executed: end of block
0
845 if (!widget) {
!widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
846 event->ignore();-
847 return;
never executed: return;
0
848 }-
849 m_dragTarget = widget;-
850 const QPoint mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->pos()));-
851 QDragEnterEvent translated(mapped, event->possibleActions(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers());-
852 QGuiApplication::sendSpontaneousEvent(widget, &translated);-
853 if (translated.isAccepted()) {
translated.isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
854 event->accept();-
855 } else {
never executed: end of block
0
856 event->ignore();-
857 }
never executed: end of block
0
858 event->setDropAction(translated.dropAction());-
859}
never executed: end of block
0
860-
861void QWidgetWindow::handleDragLeaveEvent(QDragLeaveEvent *event)-
862{-
863 if (m_dragTarget)
m_dragTargetDescription
TRUEnever evaluated
FALSEnever evaluated
0
864 QGuiApplication::sendSpontaneousEvent(m_dragTarget.data(), event);
never executed: QGuiApplication::sendSpontaneousEvent(m_dragTarget.data(), event);
0
865 m_dragTarget = 0;-
866}
never executed: end of block
0
867-
868void QWidgetWindow::handleDropEvent(QDropEvent *event)-
869{-
870 if (Q_UNLIKELY(m_dragTarget.isNull())) {
__builtin_expe...ull()), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
871 qWarning() << m_widget << ": No drag target set.";-
872 event->ignore();-
873 return;
never executed: return;
0
874 }-
875 const QPoint mapped = m_dragTarget.data()->mapFromGlobal(m_widget->mapToGlobal(event->pos()));-
876 QDropEvent translated(mapped, event->possibleActions(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers());-
877 QGuiApplication::sendSpontaneousEvent(m_dragTarget.data(), &translated);-
878 if (translated.isAccepted())
translated.isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
879 event->accept();
never executed: event->accept();
0
880 event->setDropAction(translated.dropAction());-
881 m_dragTarget = 0;-
882}
never executed: end of block
0
883-
884#endif // QT_NO_DRAGANDDROP-
885-
886void QWidgetWindow::handleExposeEvent(QExposeEvent *event)-
887{-
888 QWidgetPrivate *wPriv = m_widget->d_func();-
889 const bool exposed = isExposed();-
890-
891 if (wPriv->childrenHiddenByWState) {
wPriv->childrenHiddenByWStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
892 // If widgets has been previously hidden by window state change event-
893 // and they aren't yet shown...-
894 if (exposed) {
exposedDescription
TRUEnever evaluated
FALSEnever evaluated
0
895 // If the window becomes exposed...-
896 if (!wPriv->childrenShownByExpose) {
!wPriv->childrenShownByExposeDescription
TRUEnever evaluated
FALSEnever evaluated
0
897 // ... and they haven't been shown by this function yet - show it.-
898 wPriv->showChildren(true);-
899 QShowEvent showEvent;-
900 QCoreApplication::sendSpontaneousEvent(m_widget, &showEvent);-
901 wPriv->childrenShownByExpose = true;-
902 }
never executed: end of block
0
903 } else {
never executed: end of block
0
904 // If the window becomes not exposed...-
905 if (wPriv->childrenShownByExpose) {
wPriv->childrenShownByExposeDescription
TRUEnever evaluated
FALSEnever evaluated
0
906 // ... and child widgets was previously shown by the expose event - hide widgets again.-
907 // This is a workaround, because sometimes when window is minimized programatically,-
908 // the QPA can notify that the window is exposed after changing window state to minimized-
909 // and then, the QPA can send next expose event with null exposed region (not exposed).-
910 wPriv->hideChildren(true);-
911 QHideEvent hideEvent;-
912 QCoreApplication::sendSpontaneousEvent(m_widget, &hideEvent);-
913 wPriv->childrenShownByExpose = false;-
914 }
never executed: end of block
0
915 }
never executed: end of block
0
916 }-
917-
918 if (exposed) {
exposedDescription
TRUEnever evaluated
FALSEnever evaluated
0
919 m_widget->setAttribute(Qt::WA_Mapped);-
920 if (!event->region().isNull())
!event->region().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
921 wPriv->syncBackingStore(event->region());
never executed: wPriv->syncBackingStore(event->region());
0
922 } else {
never executed: end of block
0
923 m_widget->setAttribute(Qt::WA_Mapped, false);-
924 }
never executed: end of block
0
925}-
926-
927void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event)-
928{-
929 // QWindow does currently not know 'active'.-
930 Qt::WindowStates eventState = event->oldState();-
931 Qt::WindowStates widgetState = m_widget->windowState();-
932 if (widgetState & Qt::WindowActive)
widgetState & Qt::WindowActiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
933 eventState |= Qt::WindowActive;
never executed: eventState |= Qt::WindowActive;
0
934-
935 // Determine the new widget state, remember maximized/full screen-
936 // during minimized.-
937 switch (windowState()) {-
938 case Qt::WindowNoState:
never executed: case Qt::WindowNoState:
0
939 widgetState &= ~(Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen);-
940 break;
never executed: break;
0
941 case Qt::WindowMinimized:
never executed: case Qt::WindowMinimized:
0
942 widgetState |= Qt::WindowMinimized;-
943 break;
never executed: break;
0
944 case Qt::WindowMaximized:
never executed: case Qt::WindowMaximized:
0
945 updateNormalGeometry();-
946 widgetState |= Qt::WindowMaximized;-
947 widgetState &= ~(Qt::WindowMinimized | Qt::WindowFullScreen);-
948 break;
never executed: break;
0
949 case Qt::WindowFullScreen:
never executed: case Qt::WindowFullScreen:
0
950 updateNormalGeometry();-
951 widgetState |= Qt::WindowFullScreen;-
952 widgetState &= ~(Qt::WindowMinimized);-
953 break;
never executed: break;
0
954 case Qt::WindowActive: // Not handled by QWindow
never executed: case Qt::WindowActive:
0
955 break;
never executed: break;
0
956 }-
957-
958 // Sent event if the state changed (that is, it is not triggered by-
959 // QWidget::setWindowState(), which also sends an event to the widget).-
960 if (widgetState != int(m_widget->data->window_state)) {
widgetState !=...>window_state)Description
TRUEnever evaluated
FALSEnever evaluated
0
961 m_widget->data->window_state = widgetState;-
962 QWindowStateChangeEvent widgetEvent(eventState);-
963 QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent);-
964 }
never executed: end of block
0
965}
never executed: end of block
0
966-
967bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)-
968{-
969 return m_widget->nativeEvent(eventType, message, result);
never executed: return m_widget->nativeEvent(eventType, message, result);
0
970}-
971-
972#ifndef QT_NO_TABLETEVENT-
973void QWidgetWindow::handleTabletEvent(QTabletEvent *event)-
974{-
975 static QPointer<QWidget> qt_tablet_target = 0;-
976 if (event->type() == QEvent::TabletPress) {
event->type() ...t::TabletPressDescription
TRUEnever evaluated
FALSEnever evaluated
0
977 QWidget *widget = m_widget->childAt(event->pos());-
978 if (!widget)
!widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
979 widget = m_widget;
never executed: widget = m_widget;
0
980-
981 qt_tablet_target = widget;-
982 }
never executed: end of block
0
983-
984 if (qt_tablet_target) {
qt_tablet_targetDescription
TRUEnever evaluated
FALSEnever evaluated
0
985 QPointF delta = event->globalPosF() - event->globalPos();-
986 QPointF mapped = qt_tablet_target->mapFromGlobal(event->globalPos()) + delta;-
987 QTabletEvent ev(event->type(), mapped, event->globalPosF(), event->device(), event->pointerType(),-
988 event->pressure(), event->xTilt(), event->yTilt(), event->tangentialPressure(),-
989 event->rotation(), event->z(), event->modifiers(), event->uniqueId(), event->button(), event->buttons());-
990 ev.setTimestamp(event->timestamp());-
991 QGuiApplication::sendSpontaneousEvent(qt_tablet_target, &ev);-
992 event->setAccepted(ev.isAccepted());-
993 }
never executed: end of block
0
994-
995 if (event->type() == QEvent::TabletRelease && event->buttons() == Qt::NoButton)
event->type() ...:TabletReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
event->buttons...= Qt::NoButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
996 qt_tablet_target = 0;
never executed: qt_tablet_target = 0;
0
997}
never executed: end of block
0
998#endif // QT_NO_TABLETEVENT-
999-
1000#ifndef QT_NO_GESTURES-
1001void QWidgetWindow::handleGestureEvent(QNativeGestureEvent *e)-
1002{-
1003 // copy-pasted code to find correct widget follows:-
1004 QObject *receiver = 0;-
1005 if (QApplicationPrivate::inPopupMode()) {
QApplicationPr...:inPopupMode()Description
TRUEnever evaluated
FALSEnever evaluated
0
1006 QWidget *popup = QApplication::activePopupWidget();-
1007 QWidget *popupFocusWidget = popup->focusWidget();-
1008 receiver = popupFocusWidget ? popupFocusWidget : popup;
popupFocusWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1009 }
never executed: end of block
0
1010 if (!receiver)
!receiverDescription
TRUEnever evaluated
FALSEnever evaluated
0
1011 receiver = QApplication::widgetAt(e->globalPos());
never executed: receiver = QApplication::widgetAt(e->globalPos());
0
1012 if (!receiver)
!receiverDescription
TRUEnever evaluated
FALSEnever evaluated
0
1013 receiver = m_widget; // last resort
never executed: receiver = m_widget;
0
1014-
1015 QApplication::sendSpontaneousEvent(receiver, e);-
1016}
never executed: end of block
0
1017#endif // QT_NO_GESTURES-
1018-
1019#ifndef QT_NO_CONTEXTMENU-
1020void QWidgetWindow::handleContextMenuEvent(QContextMenuEvent *e)-
1021{-
1022 // We are only interested in keyboard originating context menu events here,-
1023 // mouse originated context menu events for widgets are generated in mouse handling methods.-
1024 if (e->reason() != QContextMenuEvent::Keyboard)
e->reason() !=...vent::KeyboardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1025 return;
never executed: return;
0
1026-
1027 QWidget *fw = QWidget::keyboardGrabber();-
1028 if (!fw) {
!fwDescription
TRUEnever evaluated
FALSEnever evaluated
0
1029 if (QApplication::activePopupWidget()) {
QApplication::...ePopupWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1030 fw = (QApplication::activePopupWidget()->focusWidget()
QApplication::...>focusWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1031 ? QApplication::activePopupWidget()->focusWidget()-
1032 : QApplication::activePopupWidget());-
1033 } else if (QApplication::focusWidget()) {
never executed: end of block
QApplication::focusWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1034 fw = QApplication::focusWidget();-
1035 } else {
never executed: end of block
0
1036 fw = m_widget;-
1037 }
never executed: end of block
0
1038 }-
1039 if (fw && fw->isEnabled()) {
fwDescription
TRUEnever evaluated
FALSEnever evaluated
fw->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
1040 QPoint pos = fw->inputMethodQuery(Qt::ImMicroFocus).toRect().center();-
1041 QContextMenuEvent widgetEvent(QContextMenuEvent::Keyboard, pos, fw->mapToGlobal(pos),-
1042 e->modifiers());-
1043 QGuiApplication::sendSpontaneousEvent(fw, &widgetEvent);-
1044 }
never executed: end of block
0
1045}
never executed: end of block
0
1046#endif // QT_NO_CONTEXTMENU-
1047-
1048void QWidgetWindow::updateObjectName()-
1049{-
1050 QString name = m_widget->objectName();-
1051 if (name.isEmpty())
name.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1052 name = QString::fromUtf8(m_widget->metaObject()->className()) + QLatin1String("Class");
never executed: name = QString::fromUtf8(m_widget->metaObject()->className()) + QLatin1String("Class");
0
1053 name += QLatin1String("Window");-
1054 setObjectName(name);-
1055}
never executed: end of block
0
1056-
1057QT_END_NAMESPACE-
1058-
1059#include "moc_qwidgetwindow_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9