void TransparentPlugin::setState() { QWidget *main = getMainWindow(); if (main == NULL) return; #ifdef WIN32 if (timer == NULL){ timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(tick())); main->installEventFilter(this); SetWindowLongW(main->winId(), GWL_EXSTYLE, GetWindowLongW(main->winId(), GWL_EXSTYLE) | WS_EX_LAYERED); SetLayeredWindowAttributes(main->winId(), main->colorGroup().background().rgb(), 0, LWA_ALPHA); RedrawWindow(main->winId(), NULL, NULL, RDW_UPDATENOW); main->setMouseTracking(true); m_bState = !main->isActiveWindow(); } bool bNewState = main->isActiveWindow(); if (bNewState == m_bState){ BYTE d = bNewState ? 255 : QMIN((100 - getTransparency()) * 256 / 100, 255); SetLayeredWindowAttributes(main->winId(), main->colorGroup().background().rgb(), d, LWA_ALPHA); return; } m_bState = bNewState; startTime = GetTickCount(); timer->start(10); #else if (top == NULL) top = new TransparentTop(main, getTransparency()); top->setTransparent(getTransparency()); #endif }
void WindowMenu::onAboutToShow() { QWidget* win = QApplication::activeWindow(); pMinimize_->setEnabled(win); pZoom_->setEnabled(win && win->maximumSize() != win->minimumSize()); pBringAllToFront_->setEnabled(win); for (int i = windows_.size() - 1; i >= 0; i--) { QAction* pAction = windows_[i]; removeAction(pAction); windows_.removeAt(i); pAction->deleteLater(); } QWidgetList topLevels = QApplication::topLevelWidgets(); for (int i = 0; i < topLevels.size(); i++) { QWidget* pWindow = topLevels.at(i); if (!pWindow->isVisible()) continue; QAction* pAction = new QAction(pWindow->windowTitle(), pWindow); pAction->setData(QVariant::fromValue(pWindow)); pAction->setCheckable(true); if (pWindow->isActiveWindow()) pAction->setChecked(true); insertAction(pWindowPlaceholder_, pAction); connect(pAction, SIGNAL(triggered()), this, SLOT(showWindow())); windows_.append(pAction); } }
/*! \reimp */ QAccessible::State QAccessibleWidget::state(int child) const { if (child) return Normal; QAccessible::State state = Normal; QWidget *w = widget(); if (w->testAttribute(Qt::WA_WState_Visible) == false) state |= Invisible; if (w->focusPolicy() != Qt::NoFocus && w->isActiveWindow()) state |= Focusable; if (w->hasFocus()) state |= Focused; if (!w->isEnabled()) state |= Unavailable; if (w->isWindow()) { if (w->windowFlags() & Qt::WindowSystemMenuHint) state |= Movable; if (w->minimumSize() != w->maximumSize()) state |= Sizeable; } return state; }
bool QPropertyDelegate::eventFilter(QObject *object, QEvent *event) { QWidget *editor = ::qobject_cast<QWidget*>(object); if(!editor) return false; GD_ASSERT(editor == mActiveEditor); if(event->type() == QEvent::KeyPress) { switch(static_cast<QKeyEvent *>(event)->key()) { case Qt::Key_Tab: emit commitData(editor); emit closeEditor(editor, QAbstractItemDelegate::EditNextItem); mActiveEditor = 0; return true; case Qt::Key_Backtab: emit commitData(editor); emit closeEditor(editor, QAbstractItemDelegate::EditPreviousItem); mActiveEditor = 0; return true; case Qt::Key_Enter: case Qt::Key_Return: emit commitData(editor); emit closeEditor(editor, QAbstractItemDelegate::SubmitModelCache); mActiveEditor = 0; return true; case Qt::Key_Escape: // don't commit data emit closeEditor(editor, QAbstractItemDelegate::RevertModelCache); mActiveEditor = 0; return true; default: break; } } else if(event->type() == QEvent::FocusOut && !editor->isActiveWindow()) { #ifndef QT_NO_DRAGANDDROP // The window may loose focus during an drag operation. // i.e when dragging involves the task bar on Windows. //if(QDragManager::self() && QDragManager::self()->object != 0) // return false; #endif if( QApplication::activeModalWidget() && QApplication::activeModalWidget()->parent() == editor ) return true; emit commitData(editor); emit closeEditor(editor, NoHint); mActiveEditor = 0; return true; } return false; }
bool TabWidget::isActiveChatWindow() { QWidget *widget = m_self->parentWidget(); if (widget->isMinimized() || widget->isHidden()) return false; # if defined(Q_OS_WIN32) if (widget->isActiveWindow()) { HWND active = GetForegroundWindow(); if (active == (HWND) widget->window()->internalWinId() || ::IsChild(active, (HWND) widget->window()->internalWinId())) return true; else return false; } else return false; # else return widget->isActiveWindow(); # endif }
void tst_QWindowContainer::testActivation() { QWidget root; QWindow *window = new QWindow(); QWidget *container = QWidget::createWindowContainer(window, &root); container->setGeometry(100, 100, 200, 100); root.setGeometry(100, 100, 400, 300); root.show(); root.activateWindow(); QVERIFY(QTest::qWaitForWindowExposed(&root)); QVERIFY(QTest::qWaitForWindowActive(root.windowHandle())); QVERIFY(QGuiApplication::focusWindow() == root.windowHandle()); // Verify that all states in the root widget indicate it is active QVERIFY(root.windowHandle()->isActive()); QVERIFY(root.isActiveWindow()); QCOMPARE(root.palette().currentColorGroup(), QPalette::Active); // Under KDE (ubuntu 12.10), we experience that doing two activateWindow in a row // does not work. The second gets ignored by the window manager, even though the // timestamp in the xcb connection is unique for both. if (QGuiApplication::platformName() == "xcb") QTest::qWait(100); window->requestActivate(); QTRY_VERIFY(QGuiApplication::focusWindow() == window); // Verify that all states in the root widget still indicate it is active QVERIFY(root.windowHandle()->isActive()); QVERIFY(root.isActiveWindow()); QCOMPARE(root.palette().currentColorGroup(), QPalette::Active); }
void TransparentTop::transparentChanged() { #ifdef WIN32 QWidget *p = static_cast<QWidget*>(parent()); bool bTransparent = true; if (pMain->TransparentIfInactive) bTransparent = !p->isActiveWindow(); setTransparent(p, useTransparent && bTransparent, transparent); #endif #if defined(USE_KDE) && defined(HAVE_KROOTPIXMAP_H) if (useTransparent){ rootpixmap->start(); }else{ rootpixmap->stop(); saveBG = QPixmap(); genBG = QPixmap(); genFade = 0; emit backgroundUpdated(); } #endif }
/*! \reimp */ QAccessible::State QAccessibleWidget::state() const { QAccessible::State state; QWidget *w = widget(); if (w->testAttribute(Qt::WA_WState_Visible) == false) state.invisible = true; if (w->focusPolicy() != Qt::NoFocus) state.focusable = true; if (w->hasFocus()) state.focused = true; if (!w->isEnabled()) state.disabled = true; if (w->isWindow()) { if (w->windowFlags() & Qt::WindowSystemMenuHint) state.movable = true; if (w->minimumSize() != w->maximumSize()) state.sizeable = true; if (w->isActiveWindow()) state.active = true; } return state; }
void QWidgetWindow::handleMouseEvent(QMouseEvent *event) { static const QEvent::Type contextMenuTrigger = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool() ? QEvent::MouseButtonRelease : QEvent::MouseButtonPress; if (qApp->d_func()->inPopupMode()) { QWidget *activePopupWidget = qApp->activePopupWidget(); QWidget *popup = activePopupWidget; QPoint mapped = event->pos(); if (popup != m_widget) mapped = popup->mapFromGlobal(event->globalPos()); bool releaseAfter = false; QWidget *popupChild = popup->childAt(mapped); if (popup != qt_popup_down) { qt_button_down = 0; qt_popup_down = 0; } switch (event->type()) { case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: qt_button_down = popupChild; qt_popup_down = popup; break; case QEvent::MouseButtonRelease: releaseAfter = true; break; default: break; // nothing for mouse move } int oldOpenPopupCount = openPopupCount; if (popup->isEnabled()) { // deliver event qt_replay_popup_mouse_event = false; QWidget *receiver = popup; QPoint widgetPos = mapped; if (qt_button_down) receiver = qt_button_down; else if (popupChild) receiver = popupChild; if (receiver != popup) widgetPos = receiver->mapFromGlobal(event->globalPos()); QWidget *alien = m_widget->childAt(m_widget->mapFromGlobal(event->globalPos())); QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers()); QGuiApplicationPrivate::setMouseEventSource(&e, QGuiApplicationPrivate::mouseEventSource(event)); e.setTimestamp(event->timestamp()); QApplicationPrivate::sendMouseEvent(receiver, &e, alien, m_widget, &qt_button_down, qt_last_mouse_receiver); } else { // close disabled popups when a mouse button is pressed or released switch (event->type()) { case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: case QEvent::MouseButtonRelease: popup->close(); break; default: break; } } if (qApp->activePopupWidget() != activePopupWidget && qt_replay_popup_mouse_event) { if (m_widget->windowType() != Qt::Popup) qt_button_down = 0; if (event->type() == QEvent::MouseButtonPress) { // the popup disappeared, replay the mouse press event QWidget *w = QApplication::widgetAt(event->globalPos()); if (w && !QApplicationPrivate::isBlockedByModal(w)) { // activate window of the widget under mouse pointer if (!w->isActiveWindow()) { w->activateWindow(); w->raise(); } QWindow *win = w->windowHandle(); if (!win) win = w->nativeParentWidget()->windowHandle(); if (win && win->geometry().contains(event->globalPos())) { const QPoint localPos = win->mapFromGlobal(event->globalPos()); QMouseEvent e(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers()); QGuiApplicationPrivate::setMouseEventSource(&e, QGuiApplicationPrivate::mouseEventSource(event)); e.setTimestamp(event->timestamp()); QApplication::sendSpontaneousEvent(win, &e); } } } qt_replay_popup_mouse_event = false; #ifndef QT_NO_CONTEXTMENU } else if (event->type() == contextMenuTrigger && event->button() == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) { QWidget *popupEvent = popup; if (qt_button_down) popupEvent = qt_button_down; else if(popupChild) popupEvent = popupChild; QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers()); QApplication::sendSpontaneousEvent(popupEvent, &e); #endif } if (releaseAfter) { qt_button_down = 0; qt_popup_down = 0; } return; } // modal event handling if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type())) return; // which child should have it? QWidget *widget = m_widget->childAt(event->pos()); QPoint mapped = event->pos(); if (!widget) widget = m_widget; if (event->type() == QEvent::MouseButtonPress) qt_button_down = widget; QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(), qt_button_down, widget); if (!receiver) { if (event->type() == QEvent::MouseButtonRelease) QApplicationPrivate::mouse_buttons &= ~event->button(); return; } if ((event->type() != QEvent::MouseButtonPress) || !(event->flags().testFlag(Qt::MouseEventCreatedDoubleClick))) { // The preceding statement excludes MouseButtonPress events which caused // creation of a MouseButtonDblClick event. QTBUG-25831 QMouseEvent translated(event->type(), mapped, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers()); QGuiApplicationPrivate::setMouseEventSource(&translated, QGuiApplicationPrivate::mouseEventSource(event)); translated.setTimestamp(event->timestamp()); QApplicationPrivate::sendMouseEvent(receiver, &translated, widget, m_widget, &qt_button_down, qt_last_mouse_receiver); } #ifndef QT_NO_CONTEXTMENU if (event->type() == contextMenuTrigger && event->button() == Qt::RightButton) { QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers()); QGuiApplication::sendSpontaneousEvent(receiver, &e); } #endif }
QString qt_mac_get_save_file_name(const QFileDialogArgs &args, QString *pwd, QString *selectedFilter) { QWidget *parent = args.parent; OSErr err; QString retstr; NavDialogCreationOptions options; NavGetDefaultDialogCreationOptions(&options); static const int w = 450, h = 350; if (args.options & QFileDialog::DontConfirmOverwrite) options.optionFlags |= kNavDontConfirmReplacement; options.modality = kWindowModalityAppModal; options.location.h = options.location.v = -1; if (!args.directory.isEmpty()) options.saveFileName = QCFString::toCFStringRef(args.selection); if (!args.caption.isEmpty()) options.windowTitle = QCFString::toCFStringRef(args.caption); if (parent && parent->isVisible()) { WindowClass wclass; GetWindowClass(qt_mac_window_for(parent), &wclass); if (!(args.options & QFileDialog::DontUseSheet) && (wclass == kDocumentWindowClass || wclass == kFloatingWindowClass || wclass == kMovableModalWindowClass)) { options.modality = kWindowModalityWindowModal; options.parentWindow = qt_mac_window_for(parent); // The parent needs to be active for the sheet to get keyboard focus. if (!parent->isActiveWindow()) parent->activateWindow(); } else { parent = parent->window(); QString s = parent->windowTitle(); options.clientName = CFStringCreateWithCharacters(0, (UniChar *)s.unicode(), s.length()); options.location.h = (parent->x() + (parent->width() / 2)) - (w / 2); options.location.v = (parent->y() + (parent->height() / 2)) - (h / 2); QRect r = QApplication::desktop()->screenGeometry( QApplication::desktop()->screenNumber(parent)); if (options.location.h + w > r.right()) options.location.h -= (options.location.h + w) - r.right() + 10; if (options.location.v + h > r.bottom()) options.location.v -= (options.location.v + h) - r.bottom() + 10; } #if 0 } else if (QWidget *p = qApp->mainWidget()) { static int last_screen = -1; int scr = QApplication::desktop()->screenNumber(p); if (last_screen != scr) { QRect r = QApplication::desktop()->screenGeometry(scr); options.location.h = (r.x() + (r.width() / 2)) - (w / 2); options.location.v = (r.y() + (r.height() / 2)) - (h / 2); } #endif } QList<qt_mac_filter_name*> filts = qt_mac_make_filters_list(args.filter); qt_mac_nav_filter_type t; t.saveDialog = true; t.index = 0; t.filts = &filts; if (filts.count() > 1) { int i = 0; CFStringRef *arr = static_cast<CFStringRef *>(malloc(sizeof(CFStringRef) * filts.count())); for (QList<qt_mac_filter_name*>::const_iterator it = filts.constBegin(); it != filts.constEnd(); ++it) arr[i++] = QCFString::toCFStringRef((*it)->description); options.popupExtension = CFArrayCreate(0, reinterpret_cast<const void **>(arr), filts.count(), 0); } NavDialogRef dlg; if (NavCreatePutFileDialog(&options, 'cute', kNavGenericSignature, make_navProcUPP(), static_cast<void *>(filts.isEmpty() ? 0 : &t), &dlg)) { qDebug("Shouldn't happen %s:%d", __FILE__, __LINE__); return retstr; } if (pwd && !pwd->isEmpty()) { FSRef fsref; if (qt_mac_create_fsref(*pwd, &fsref) == noErr) { AEDesc desc; if (AECreateDesc(typeFSRef, &fsref, sizeof(FSRef), &desc) == noErr) NavCustomControl(dlg, kNavCtlSetLocation, (void*)&desc); } } NavDialogRun(dlg); if (selectedFilter) { NavMenuItemSpec navSpec; bzero(&navSpec, sizeof(NavMenuItemSpec)); qt_mac_filter_name *sel_filt_name = qt_mac_make_filters_list(*selectedFilter).at(0); for (int i = 0; i < filts.count(); ++i) { const qt_mac_filter_name *filter = filts.at(i); if (sel_filt_name->description == filter->description && sel_filt_name->regxp == filter->regxp && sel_filt_name->filter == filter->filter) { navSpec.menuType = i; break; } } NavCustomControl(dlg, kNavCtlSelectCustomType, &navSpec); } if (options.modality == kWindowModalityWindowModal) { //simulate modality QWidget modal_widg(parent, Qt::Sheet); modal_widg.createWinId(); QApplicationPrivate::enterModal(&modal_widg); while (g_nav_blocking) qApp->processEvents(QEventLoop::WaitForMoreEvents); QApplicationPrivate::leaveModal(&modal_widg); } if (NavDialogGetUserAction(dlg) != kNavUserActionSaveAs) { NavDialogDispose(dlg); return retstr; } NavReplyRecord ret; NavDialogGetReply(dlg, &ret); NavDialogDispose(dlg); long count; err = AECountItems(&(ret.selection), &count); if (!ret.validRecord || err != noErr || !count) { NavDisposeReply(&ret); return retstr; } AEKeyword keyword; DescType type; Size size; FSRef ref; err = AEGetNthPtr(&(ret.selection), 1, typeFSRef, &keyword, &type, &ref, sizeof(ref), &size); if (err == noErr) { if (!str_buffer) { qAddPostRoutine(cleanup_str_buffer); str_buffer = (UInt8 *)malloc(1024); } FSRefMakePath(&ref, str_buffer, 1024); retstr = QString::fromUtf8((const char *)str_buffer); //now filename CFStringGetCString(ret.saveFileName, (char *)str_buffer, 1024, kCFStringEncodingUTF8); retstr += QLatin1String("/") + QString::fromUtf8((const char *)str_buffer); } NavDisposeReply(&ret); if (selectedFilter) *selectedFilter = filts.at(t.index)->filter; while (!filts.isEmpty()) delete filts.takeFirst(); return retstr; }
bool CFileListItemDelegate::eventFilter(QObject * object, QEvent * event) { QWidget *editor = qobject_cast<QWidget*>(object); if (!editor) return false; if (event->type() == QEvent::KeyPress) { switch (static_cast<QKeyEvent *>(event)->key()) { case Qt::Key_Tab: emit closeEditor(editor, EditNextItem); return true; case Qt::Key_Backtab: emit closeEditor(editor, EditPreviousItem); return true; case Qt::Key_Enter: // Numpad Enter case Qt::Key_Return: // don't filter enter key events for QTextEdit if (!qobject_cast<QTextEdit *>(editor) && !qobject_cast<QPlainTextEdit*>(editor)) { // commit data emit commitData(editor); emit closeEditor(editor); return true; } return QStyledItemDelegate::eventFilter(object, event); case Qt::Key_Escape: // don't commit data emit closeEditor(editor, QAbstractItemDelegate::RevertModelCache); return true; case Qt::Key_Up: case Qt::Key_Down: // don't commit data emit closeEditor(editor, QAbstractItemDelegate::RevertModelCache); // Don't consume the event so that the TreeView will handle this event and highlight the next item properly return QStyledItemDelegate::eventFilter(object, event); default: return QStyledItemDelegate::eventFilter(object, event); } } else if (event->type() == QEvent::FocusOut || (event->type() == QEvent::Hide && editor->isWindow())) { //the Hide event will take care of he editors that are in fact complete dialogs if (!editor->isActiveWindow() || (QApplication::focusWidget() != editor)) { QWidget *w = QApplication::focusWidget(); while (w) { // don't worry about focus changes internally in the editor if (w == editor) return QStyledItemDelegate::eventFilter(object, event); w = w->parentWidget(); } emit closeEditor(editor, NoHint); } } else if (event->type() == QEvent::ShortcutOverride) { if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) { event->accept(); return true; } } return QStyledItemDelegate::eventFilter(object, event); }
void QWidgetWindow::handleMouseEvent(QMouseEvent *event) { static const QEvent::Type contextMenuTrigger = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool() ? QEvent::MouseButtonRelease : QEvent::MouseButtonPress; if (qApp->d_func()->inPopupMode()) { QWidget *activePopupWidget = qApp->activePopupWidget(); QPoint mapped = event->pos(); if (activePopupWidget != m_widget) mapped = activePopupWidget->mapFromGlobal(event->globalPos()); bool releaseAfter = false; QWidget *popupChild = activePopupWidget->childAt(mapped); if (activePopupWidget != qt_popup_down) { qt_button_down = 0; qt_popup_down = 0; } switch (event->type()) { case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: qt_button_down = popupChild; qt_popup_down = activePopupWidget; break; case QEvent::MouseButtonRelease: releaseAfter = true; break; default: break; // nothing for mouse move } int oldOpenPopupCount = openPopupCount; if (activePopupWidget->isEnabled()) { // deliver event qt_replay_popup_mouse_event = false; QWidget *receiver = activePopupWidget; QPoint widgetPos = mapped; if (qt_button_down) receiver = qt_button_down; else if (popupChild) receiver = popupChild; if (receiver != activePopupWidget) widgetPos = receiver->mapFromGlobal(event->globalPos()); QWidget *alien = receiver; #if !defined(Q_OS_OSX) && !defined(Q_OS_IOS) // Cocoa tracks popups const bool reallyUnderMouse = activePopupWidget->rect().contains(mapped); const bool underMouse = activePopupWidget->underMouse(); if (activePopupWidget != m_widget || (!underMouse && qt_button_down)) { // If active popup menu is not the first-level popup menu then we must emulate enter/leave events, // because first-level popup menu grabs the mouse and enter/leave events are delivered only to it // by QPA. Make an exception for first-level popup menu when the mouse button is pressed on widget. if (underMouse != reallyUnderMouse) { if (reallyUnderMouse) { QApplicationPrivate::dispatchEnterLeave(receiver, Q_NULLPTR, event->screenPos()); qt_last_mouse_receiver = receiver; } else { QApplicationPrivate::dispatchEnterLeave(Q_NULLPTR, qt_last_mouse_receiver, event->screenPos()); qt_last_mouse_receiver = receiver; receiver = activePopupWidget; } } } else if (!reallyUnderMouse) { alien = Q_NULLPTR; } #endif QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers(), event->source()); e.setTimestamp(event->timestamp()); QApplicationPrivate::sendMouseEvent(receiver, &e, alien, receiver->window(), &qt_button_down, qt_last_mouse_receiver); qt_last_mouse_receiver = receiver; } else { // close disabled popups when a mouse button is pressed or released switch (event->type()) { case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: case QEvent::MouseButtonRelease: activePopupWidget->close(); break; default: break; } } if (qApp->activePopupWidget() != activePopupWidget && qt_replay_popup_mouse_event && QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ReplayMousePressOutsidePopup).toBool()) { if (m_widget->windowType() != Qt::Popup) qt_button_down = 0; if (event->type() == QEvent::MouseButtonPress) { // the popup disappeared, replay the mouse press event QWidget *w = QApplication::widgetAt(event->globalPos()); if (w && !QApplicationPrivate::isBlockedByModal(w)) { // activate window of the widget under mouse pointer if (!w->isActiveWindow()) { w->activateWindow(); w->raise(); } QWindow *win = w->windowHandle(); if (!win) win = w->nativeParentWidget()->windowHandle(); if (win) { const QRect globalGeometry = win->isTopLevel() ? win->geometry() : QRect(win->mapToGlobal(QPoint(0, 0)), win->size()); if (globalGeometry.contains(event->globalPos())) { // Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec() const QPoint localPos = win->mapFromGlobal(event->globalPos()); QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers(), event->source()); QCoreApplicationPrivate::setEventSpontaneous(e, true); e->setTimestamp(event->timestamp()); QCoreApplication::postEvent(win, e); } } } } qt_replay_popup_mouse_event = false; #ifndef QT_NO_CONTEXTMENU } else if (event->type() == contextMenuTrigger && event->button() == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) { QWidget *popupEvent = activePopupWidget; if (qt_button_down) popupEvent = qt_button_down; else if(popupChild) popupEvent = popupChild; QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers()); QApplication::sendSpontaneousEvent(popupEvent, &e); #endif } if (releaseAfter) { qt_button_down = 0; qt_popup_down = 0; } return; } // modal event handling if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type())) return; // which child should have it? QWidget *widget = m_widget->childAt(event->pos()); QPoint mapped = event->pos(); if (!widget) widget = m_widget; if (event->type() == QEvent::MouseButtonPress) qt_button_down = widget; QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(), qt_button_down, widget); if (!receiver) { if (event->type() == QEvent::MouseButtonRelease) QApplicationPrivate::mouse_buttons &= ~event->button(); return; } if ((event->type() != QEvent::MouseButtonPress) || !(event->flags().testFlag(Qt::MouseEventCreatedDoubleClick))) { // The preceding statement excludes MouseButtonPress events which caused // creation of a MouseButtonDblClick event. QTBUG-25831 QMouseEvent translated(event->type(), mapped, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers(), event->source()); translated.setTimestamp(event->timestamp()); QApplicationPrivate::sendMouseEvent(receiver, &translated, widget, m_widget, &qt_button_down, qt_last_mouse_receiver); event->setAccepted(translated.isAccepted()); } #ifndef QT_NO_CONTEXTMENU if (event->type() == contextMenuTrigger && event->button() == Qt::RightButton && m_widget->rect().contains(event->pos())) { QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers()); QGuiApplication::sendSpontaneousEvent(receiver, &e); } #endif }