kernel/qwidgetwindow.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7QWidget *qt_button_down = 0; -
8static QWidget *qt_tablet_target = 0; -
9 -
10 -
11QWidget *qt_popup_down = 0; -
12extern int openPopupCount; -
13bool qt_replay_popup_mouse_event = false; -
14extern bool qt_try_modal(QWidget *widget, QEvent::Type type); -
15 -
16class QWidgetWindowPrivate : public QWindowPrivate -
17{ -
18 inline QWidgetWindow* q_func() { return static_cast<QWidgetWindow *>(q_ptr); } inline const QWidgetWindow* q_func() const { return static_cast<const QWidgetWindow *>(q_ptr); } friend class QWidgetWindow; -
19public: -
20 QWindow *eventReceiver() { -
21 QWidgetWindow * const q = q_func(); -
22 QWindow *w = q; -
23 while (w->parent() && qobject_cast<QWidgetWindow *>(w) && qobject_cast<QWidgetWindow *>(w->parent())) {
partially evaluated: w->parent()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1812
never evaluated: qobject_cast<QWidgetWindow *>(w)
never evaluated: qobject_cast<QWidgetWindow *>(w->parent())
0-1812
24 w = w->parent(); -
25 }
never executed: }
0
26 return w;
executed: return w;
Execution Count:1812
1812
27 } -
28}; -
29 -
30QWidgetWindow::QWidgetWindow(QWidget *widget) -
31 : QWindow(*new QWidgetWindowPrivate(), 0) -
32 , m_widget(widget) -
33{ -
34 updateObjectName(); -
35 connect(m_widget, &QObject::objectNameChanged, this, &QWidgetWindow::updateObjectName); -
36}
executed: }
Execution Count:3470
3470
37 -
38 -
39QAccessibleInterface *QWidgetWindow::accessibleRoot() const -
40{ -
41 if (m_widget)
-
42 return QAccessible::queryAccessibleInterface(m_widget);
-
43 return 0;
-
44} -
45 -
46 -
47QObject *QWidgetWindow::focusObject() const -
48{ -
49 QWidget *widget = m_widget->focusWidget(); -
50 -
51 if (!widget)
-
52 widget = m_widget;
-
53 -
54 return widget;
-
55} -
56 -
57bool QWidgetWindow::event(QEvent *event) -
58{ -
59 if (m_widget->testAttribute(Qt::WA_DontShowOnScreen)) {
-
60 -
61 -
62 return m_widget->event(event);
-
63 } -
64 -
65 switch (event->type()) { -
66 case QEvent::Close: -
67 handleCloseEvent(static_cast<QCloseEvent *>(event)); -
68 return true;
-
69 -
70 case QEvent::Enter: -
71 case QEvent::Leave: -
72 handleEnterLeaveEvent(event); -
73 return true;
-
74 -
75 -
76 -
77 case QEvent::FocusIn: -
78 case QEvent::FocusOut: { -
79 -
80 QAccessible::State state; -
81 state.active = true; -
82 QAccessibleStateChangeEvent ev(widget(), state); -
83 QAccessible::updateAccessibility(&ev); -
84 -
85 return false; }
-
86 -
87 case QEvent::FocusAboutToChange: -
88 if (QApplicationPrivate::focus_widget) {
-
89 if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled))
-
90 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->commit();
-
91 -
92 QGuiApplication::sendSpontaneousEvent(QApplicationPrivate::focus_widget, event); -
93 }
-
94 return true;
-
95 -
96 case QEvent::KeyPress: -
97 case QEvent::KeyRelease: -
98 case QEvent::ShortcutOverride: -
99 handleKeyEvent(static_cast<QKeyEvent *>(event)); -
100 return true;
-
101 -
102 case QEvent::MouseMove: -
103 case QEvent::MouseButtonPress: -
104 case QEvent::MouseButtonRelease: -
105 case QEvent::MouseButtonDblClick: -
106 handleMouseEvent(static_cast<QMouseEvent *>(event)); -
107 return true;
-
108 -
109 case QEvent::NonClientAreaMouseMove: -
110 case QEvent::NonClientAreaMouseButtonPress: -
111 case QEvent::NonClientAreaMouseButtonRelease: -
112 case QEvent::NonClientAreaMouseButtonDblClick: -
113 handleNonClientAreaMouseEvent(static_cast<QMouseEvent *>(event)); -
114 return true;
-
115 -
116 case QEvent::TouchBegin: -
117 case QEvent::TouchUpdate: -
118 case QEvent::TouchEnd: -
119 case QEvent::TouchCancel: -
120 handleTouchEvent(static_cast<QTouchEvent *>(event)); -
121 return true;
-
122 -
123 case QEvent::Move: -
124 handleMoveEvent(static_cast<QMoveEvent *>(event)); -
125 return true;
-
126 -
127 case QEvent::Resize: -
128 handleResizeEvent(static_cast<QResizeEvent *>(event)); -
129 return true;
-
130 -
131 -
132 case QEvent::Wheel: -
133 handleWheelEvent(static_cast<QWheelEvent *>(event)); -
134 return true;
-
135 -
136 -
137 -
138 case QEvent::DragEnter: -
139 case QEvent::DragMove: -
140 handleDragEnterMoveEvent(static_cast<QDragMoveEvent *>(event)); -
141 return true;
-
142 case QEvent::DragLeave: -
143 handleDragLeaveEvent(static_cast<QDragLeaveEvent *>(event)); -
144 return true;
-
145 case QEvent::Drop: -
146 handleDropEvent(static_cast<QDropEvent *>(event)); -
147 return true;
-
148 -
149 -
150 case QEvent::Expose: -
151 handleExposeEvent(static_cast<QExposeEvent *>(event)); -
152 return true;
-
153 -
154 case QEvent::WindowStateChange: -
155 handleWindowStateChangedEvent(static_cast<QWindowStateChangeEvent *>(event)); -
156 return true;
-
157 -
158 case QEvent::ThemeChange: { -
159 QEvent widgetEvent(QEvent::ThemeChange); -
160 QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent); -
161 } -
162 return true;
-
163 -
164 -
165 case QEvent::TabletPress: -
166 case QEvent::TabletMove: -
167 case QEvent::TabletRelease: -
168 handleTabletEvent(static_cast<QTabletEvent *>(event)); -
169 return true;
-
170 -
171 -
172 case QEvent::ContextMenu: -
173 handleContextMenuEvent(static_cast<QContextMenuEvent *>(event)); -
174 return true;
-
175 -
176 -
177 -
178 case QEvent::Show: -
179 case QEvent::Hide: -
180 return QWindow::event(event);
-
181 -
182 default: -
183 break;
-
184 } -
185 -
186 return m_widget->event(event) || QWindow::event(event);
-
187} -
188 -
189QPointer<QWidget> qt_last_mouse_receiver = 0; -
190 -
191void QWidgetWindow::handleEnterLeaveEvent(QEvent *event) -
192{ -
193 if (event->type() == QEvent::Leave) {
-
194 QWidget *enter = 0; -
195 -
196 -
197 -
198 QWindowSystemInterfacePrivate::EnterEvent *systemEvent = -
199 static_cast<QWindowSystemInterfacePrivate::EnterEvent *> -
200 (QWindowSystemInterfacePrivate::peekWindowSystemEvent(QWindowSystemInterfacePrivate::Enter)); -
201 const QPointF globalPosF = systemEvent ? systemEvent->globalPos : QGuiApplicationPrivate::lastCursorPosition;
-
202 if (systemEvent) {
-
203 if (QWidgetWindow *enterWindow = qobject_cast<QWidgetWindow *>(systemEvent->enter))
-
204 { -
205 QWindow *thisParent = this; -
206 QWindow *enterParent = enterWindow; -
207 while (thisParent->parent())
-
208 thisParent = thisParent->parent();
-
209 while (enterParent->parent())
-
210 enterParent = enterParent->parent();
-
211 if (thisParent == enterParent) {
-
212 QGuiApplicationPrivate::currentMouseWindow = enterWindow; -
213 enter = enterWindow->widget(); -
214 QWindowSystemInterfacePrivate::removeWindowSystemEvent(systemEvent); -
215 }
-
216 }
-
217 }
-
218 -
219 -
220 -
221 if (!enter || !QWidget::mouseGrabber()) {
-
222 -
223 -
224 QWidget *leave = m_widget; -
225 if (qt_last_mouse_receiver && !qt_last_mouse_receiver->internalWinId())
-
226 leave = qt_last_mouse_receiver.data();
-
227 QApplicationPrivate::dispatchEnterLeave(enter, leave, globalPosF); -
228 qt_last_mouse_receiver = enter; -
229 }
-
230 } else {
-
231 const QEnterEvent *ee = static_cast<QEnterEvent *>(event); -
232 QWidget *child = m_widget->childAt(ee->pos()); -
233 QWidget *receiver = child ? child : m_widget;
-
234 QApplicationPrivate::dispatchEnterLeave(receiver, 0, ee->screenPos()); -
235 qt_last_mouse_receiver = receiver; -
236 }
-
237} -
238 -
239void QWidgetWindow::handleNonClientAreaMouseEvent(QMouseEvent *e) -
240{ -
241 QApplication::sendSpontaneousEvent(m_widget, e); -
242}
-
243 -
244void QWidgetWindow::handleMouseEvent(QMouseEvent *event) -
245{ -
246 if ((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->inPopupMode()) {
-
247 QWidget *activePopupWidget = (static_cast<QApplication *>(QCoreApplication::instance()))->activePopupWidget(); -
248 QWidget *popup = activePopupWidget; -
249 QPoint mapped = event->pos(); -
250 if (popup != m_widget)
-
251 mapped = popup->mapFromGlobal(event->globalPos());
-
252 bool releaseAfter = false; -
253 QWidget *popupChild = popup->childAt(mapped); -
254 -
255 if (popup != qt_popup_down) {
-
256 qt_button_down = 0; -
257 qt_popup_down = 0; -
258 }
-
259 -
260 switch (event->type()) { -
261 case QEvent::MouseButtonPress: -
262 case QEvent::MouseButtonDblClick: -
263 qt_button_down = popupChild; -
264 qt_popup_down = popup; -
265 break;
-
266 case QEvent::MouseButtonRelease: -
267 releaseAfter = true; -
268 break;
-
269 default: -
270 break;
-
271 } -
272 -
273 int oldOpenPopupCount = openPopupCount; -
274 -
275 if (popup->isEnabled()) {
-
276 -
277 qt_replay_popup_mouse_event = false; -
278 QWidget *receiver = popup; -
279 QPoint widgetPos = mapped; -
280 if (qt_button_down)
-
281 receiver = qt_button_down;
-
282 else if (popupChild)
-
283 receiver = popupChild;
-
284 if (receiver != popup)
-
285 widgetPos = receiver->mapFromGlobal(event->globalPos());
-
286 QWidget *alien = m_widget->childAt(m_widget->mapFromGlobal(event->globalPos())); -
287 QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers()); -
288 e.setTimestamp(event->timestamp()); -
289 QApplicationPrivate::sendMouseEvent(receiver, &e, alien, m_widget, &qt_button_down, qt_last_mouse_receiver); -
290 } else {
-
291 -
292 switch (event->type()) { -
293 case QEvent::MouseButtonPress: -
294 case QEvent::MouseButtonDblClick: -
295 case QEvent::MouseButtonRelease: -
296 popup->close(); -
297 break;
-
298 default: -
299 break;
-
300 } -
301 }
-
302 -
303 if ((static_cast<QApplication *>(QCoreApplication::instance()))->activePopupWidget() != activePopupWidget
-
304 && qt_replay_popup_mouse_event) {
-
305 if (m_widget->windowType() != Qt::Popup)
-
306 qt_button_down = 0;
-
307 qt_replay_popup_mouse_event = false; -
308 -
309 } else if (event->type() == QEvent::MouseButtonPress
-
310 && event->button() == Qt::RightButton
-
311 && (openPopupCount == oldOpenPopupCount)) {
-
312 QWidget *popupEvent = popup; -
313 if (qt_button_down)
-
314 popupEvent = qt_button_down;
-
315 else if(popupChild)
-
316 popupEvent = popupChild;
-
317 QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers()); -
318 QApplication::sendSpontaneousEvent(popupEvent, &e); -
319 -
320 }
-
321 -
322 if (releaseAfter) {
-
323 qt_button_down = 0; -
324 qt_popup_down = 0; -
325 }
-
326 return;
-
327 } -
328 -
329 -
330 if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type()))
-
331 return;
-
332 -
333 -
334 QWidget *widget = m_widget->childAt(event->pos()); -
335 QPoint mapped = event->pos(); -
336 -
337 if (!widget)
-
338 widget = m_widget;
-
339 -
340 if (event->type() == QEvent::MouseButtonPress && !qt_button_down)
-
341 qt_button_down = widget;
-
342 -
343 QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(), -
344 qt_button_down, widget); -
345 -
346 if (!receiver) {
-
347 if (event->type() == QEvent::MouseButtonRelease)
-
348 QApplicationPrivate::mouse_buttons &= ~event->button();
-
349 return;
-
350 } -
351 -
352 QMouseEvent translated(event->type(), mapped, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers()); -
353 translated.setTimestamp(event->timestamp()); -
354 QApplicationPrivate::sendMouseEvent(receiver, &translated, widget, m_widget, &qt_button_down, -
355 qt_last_mouse_receiver); -
356 -
357 -
358 if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::RightButton) {
-
359 QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers()); -
360 QGuiApplication::sendSpontaneousEvent(receiver, &e); -
361 }
-
362 -
363}
-
364 -
365void QWidgetWindow::handleTouchEvent(QTouchEvent *event) -
366{ -
367 if (event->type() == QEvent::TouchCancel)
-
368 QApplicationPrivate::translateTouchCancel(event->device(), event->timestamp());
-
369 else -
370 QApplicationPrivate::translateRawTouchEvent(m_widget, event->device(), event->touchPoints(), event->timestamp());
-
371} -
372 -
373void QWidgetWindow::handleKeyEvent(QKeyEvent *event) -
374{ -
375 if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type()))
-
376 return;
-
377 -
378 QObject *receiver = 0; -
379 if (QApplicationPrivate::inPopupMode()) {
-
380 QWidget *popup = QApplication::activePopupWidget(); -
381 QWidget *popupFocusWidget = popup->focusWidget(); -
382 receiver = popupFocusWidget ? popupFocusWidget : popup;
-
383 }
-
384 if (!receiver)
-
385 receiver = QWidget::keyboardGrabber();
-
386 if (!receiver)
-
387 receiver = focusObject();
-
388 QGuiApplication::sendSpontaneousEvent(receiver, event); -
389}
-
390 -
391void QWidgetWindow::updateGeometry() -
392{ -
393 if (m_widget->testAttribute(Qt::WA_OutsideWSRange))
-
394 return;
-
395 -
396 const QMargins margins = frameMargins(); -
397 -
398 m_widget->data->crect = geometry(); -
399 QTLWExtra *te = m_widget->d_func()->topData(); -
400 te->posIncludesFrame= false; -
401 te->frameStrut.setCoords(margins.left(), margins.top(), margins.right(), margins.bottom()); -
402 m_widget->data->fstrut_dirty = false; -
403}
-
404 -
405void QWidgetWindow::handleMoveEvent(QMoveEvent *event) -
406{ -
407 updateGeometry(); -
408 QGuiApplication::sendSpontaneousEvent(m_widget, event); -
409}
-
410 -
411void QWidgetWindow::handleResizeEvent(QResizeEvent *event) -
412{ -
413 QSize oldSize = m_widget->data->crect.size(); -
414 -
415 updateGeometry(); -
416 QGuiApplication::sendSpontaneousEvent(m_widget, event); -
417 -
418 if (m_widget->d_func()->paintOnScreen()) {
-
419 QRegion updateRegion(geometry()); -
420 if (m_widget->testAttribute(Qt::WA_StaticContents))
-
421 updateRegion -= QRect(0, 0, oldSize.width(), oldSize.height());
-
422 m_widget->d_func()->syncBackingStore(updateRegion); -
423 } else {
-
424 m_widget->d_func()->syncBackingStore(); -
425 }
-
426} -
427 -
428void QWidgetWindow::handleCloseEvent(QCloseEvent *) -
429{ -
430 m_widget->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent); -
431}
-
432 -
433 -
434 -
435void QWidgetWindow::handleWheelEvent(QWheelEvent *event) -
436{ -
437 if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type()))
-
438 return;
-
439 -
440 -
441 QWidget *widget = m_widget->childAt(event->pos()); -
442 -
443 if (!widget)
-
444 widget = m_widget;
-
445 -
446 QPoint mapped = widget->mapFrom(m_widget, event->pos()); -
447 -
448 QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->angleDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers()); -
449 QGuiApplication::sendSpontaneousEvent(widget, &translated); -
450}
-
451 -
452 -
453 -
454 -
455 -
456void QWidgetWindow::handleDragEnterMoveEvent(QDragMoveEvent *event) -
457{ -
458 qt_noop(); -
459 -
460 QWidget *widget = m_widget->childAt(event->pos()); -
461 if (!widget)
-
462 widget = m_widget;
-
463 for ( ; widget && !widget->isWindow() && !widget->acceptDrops(); widget = widget->parentWidget()) ;
-
464 if (widget && !widget->acceptDrops())
-
465 widget = 0;
-
466 -
467 if (widget && widget == m_dragTarget.data()) {
-
468 qt_noop(); -
469 const QPoint mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->pos())); -
470 QDragMoveEvent translated(mapped, event->possibleActions(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers()); -
471 translated.setDropAction(event->dropAction()); -
472 if (event->isAccepted()) {
-
473 translated.accept(); -
474 translated.setDropAction(event->dropAction()); -
475 }
-
476 QGuiApplication::sendSpontaneousEvent(widget, &translated); -
477 if (translated.isAccepted()) {
-
478 event->accept(); -
479 } else {
-
480 event->ignore(); -
481 }
-
482 event->setDropAction(translated.dropAction()); -
483 return;
-
484 } -
485 -
486 if (m_dragTarget.data()) {
-
487 QDragLeaveEvent le; -
488 QGuiApplication::sendSpontaneousEvent(m_dragTarget.data(), &le); -
489 m_dragTarget = 0; -
490 }
-
491 if (!widget) {
-
492 event->ignore(); -
493 return;
-
494 } -
495 m_dragTarget = widget; -
496 const QPoint mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->pos())); -
497 QDragEnterEvent translated(mapped, event->possibleActions(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers()); -
498 QGuiApplication::sendSpontaneousEvent(widget, &translated); -
499 if (translated.isAccepted()) {
-
500 event->accept(); -
501 } else {
-
502 event->ignore(); -
503 }
-
504 event->setDropAction(translated.dropAction()); -
505}
-
506 -
507void QWidgetWindow::handleDragLeaveEvent(QDragLeaveEvent *event) -
508{ -
509 if (m_dragTarget)
-
510 QGuiApplication::sendSpontaneousEvent(m_dragTarget.data(), event);
-
511 m_dragTarget = 0; -
512}
-
513 -
514void QWidgetWindow::handleDropEvent(QDropEvent *event) -
515{ -
516 const QPoint mapped = m_dragTarget.data()->mapFromGlobal(m_widget->mapToGlobal(event->pos())); -
517 QDropEvent translated(mapped, event->possibleActions(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers()); -
518 QGuiApplication::sendSpontaneousEvent(m_dragTarget.data(), &translated); -
519 if (translated.isAccepted())
-
520 event->accept();
-
521 event->setDropAction(translated.dropAction()); -
522 m_dragTarget = 0; -
523}
-
524 -
525 -
526 -
527void QWidgetWindow::handleExposeEvent(QExposeEvent *event) -
528{ -
529 if (isExposed()) {
-
530 m_widget->setAttribute(Qt::WA_Mapped); -
531 if (!event->region().isNull()) {
-
532 -
533 if (m_widget->internalWinId() && !m_widget->isWindow() && m_widget->isVisible() && m_widget->updatesEnabled()) {
-
534 if (QWidgetBackingStore *bs = m_widget->d_func()->maybeBackingStore())
-
535 bs->markDirty(event->region(), m_widget);
-
536 }
-
537 m_widget->d_func()->syncBackingStore(event->region()); -
538 }
-
539 } else {
-
540 m_widget->setAttribute(Qt::WA_Mapped, false); -
541 }
-
542} -
543 -
544Qt::WindowState effectiveState(Qt::WindowStates state); -
545 -
546void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event) -
547{ -
548 -
549 Qt::WindowStates eventState = event->oldState(); -
550 Qt::WindowStates widgetState = m_widget->windowState(); -
551 if (widgetState & Qt::WindowActive)
-
552 eventState |= Qt::WindowActive;
-
553 -
554 -
555 -
556 switch (windowState()) { -
557 case Qt::WindowNoState: -
558 widgetState &= ~(Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen); -
559 break;
-
560 case Qt::WindowMinimized: -
561 widgetState |= Qt::WindowMinimized; -
562 break;
-
563 case Qt::WindowMaximized: -
564 if (effectiveState(widgetState) == Qt::WindowNoState)
-
565 if (QTLWExtra *tle = m_widget->d_func()->maybeTopData())
-
566 tle->normalGeometry = m_widget->geometry();
-
567 widgetState |= Qt::WindowMaximized; -
568 widgetState &= ~(Qt::WindowMinimized | Qt::WindowFullScreen); -
569 break;
-
570 case Qt::WindowFullScreen: -
571 if (effectiveState(widgetState) == Qt::WindowNoState)
-
572 if (QTLWExtra *tle = m_widget->d_func()->maybeTopData())
-
573 tle->normalGeometry = m_widget->geometry();
-
574 widgetState |= Qt::WindowFullScreen; -
575 widgetState &= ~(Qt::WindowMinimized); -
576 break;
-
577 case Qt::WindowActive: -
578 break;
-
579 } -
580 -
581 -
582 -
583 if (widgetState != int(m_widget->data->window_state)) {
-
584 m_widget->data->window_state = widgetState; -
585 QWindowStateChangeEvent widgetEvent(eventState); -
586 QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent); -
587 }
-
588}
-
589 -
590bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) -
591{ -
592 return m_widget->nativeEvent(eventType, message, result);
-
593} -
594 -
595 -
596void QWidgetWindow::handleTabletEvent(QTabletEvent *event) -
597{ -
598 if (event->type() == QEvent::TabletPress) {
-
599 QWidget *widget = m_widget->childAt(event->pos()); -
600 if (!widget)
-
601 widget = m_widget;
-
602 -
603 qt_tablet_target = widget; -
604 }
-
605 -
606 if (qt_tablet_target) {
-
607 QPointF delta = event->globalPosF() - event->globalPos(); -
608 QPointF mapped = qt_tablet_target->mapFromGlobal(event->globalPos()) + delta; -
609 QTabletEvent ev(event->type(), mapped, event->globalPosF(), event->device(), event->pointerType(), -
610 event->pressure(), event->xTilt(), event->yTilt(), event->tangentialPressure(), -
611 event->rotation(), event->z(), event->modifiers(), event->uniqueId()); -
612 ev.setTimestamp(event->timestamp()); -
613 QGuiApplication::sendSpontaneousEvent(qt_tablet_target, &ev); -
614 }
-
615 -
616 if (event->type() == QEvent::TabletRelease)
-
617 qt_tablet_target = 0;
-
618}
-
619 -
620 -
621 -
622void QWidgetWindow::handleContextMenuEvent(QContextMenuEvent *e) -
623{ -
624 -
625 -
626 if (e->reason() != QContextMenuEvent::Keyboard)
-
627 return;
-
628 -
629 QWidget *fw = QWidget::keyboardGrabber(); -
630 if (!fw) {
-
631 if (QApplication::activePopupWidget()) {
-
632 fw = (QApplication::activePopupWidget()->focusWidget()
-
633 ? QApplication::activePopupWidget()->focusWidget() -
634 : QApplication::activePopupWidget()); -
635 } else if (QApplication::focusWidget()) {
-
636 fw = QApplication::focusWidget(); -
637 } else {
-
638 fw = m_widget; -
639 }
-
640 } -
641 if (fw && fw->isEnabled()) {
-
642 QPoint pos = fw->inputMethodQuery(Qt::ImMicroFocus).toRect().center(); -
643 QContextMenuEvent widgetEvent(QContextMenuEvent::Keyboard, pos, fw->mapToGlobal(pos), -
644 e->modifiers()); -
645 QGuiApplication::sendSpontaneousEvent(fw, &widgetEvent); -
646 }
-
647}
-
648 -
649 -
650void QWidgetWindow::updateObjectName() -
651{ -
652 QString name = m_widget->objectName(); -
653 if (name.isEmpty())
-
654 name = QString::fromUtf8(m_widget->metaObject()->className()) + QString::fromUtf8("" "Class" "", sizeof("Class") - 1);
-
655 name += QString::fromUtf8("" "Window" "", sizeof("Window") - 1); -
656 setObjectName(name); -
657}
-
658 -
659 -
660 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial