bool QWidgetWindow::event(QEvent *event) { if (m_widget->testAttribute(Qt::WA_DontShowOnScreen)) { // \a event is uninteresting for QWidgetWindow, the event was probably // generated before WA_DontShowOnScreen was set return m_widget->event(event); } switch (event->type()) { case QEvent::Close: handleCloseEvent(static_cast<QCloseEvent *>(event)); return true; case QEvent::Enter: case QEvent::Leave: handleEnterLeaveEvent(event); return true; // these should not be sent to QWidget, the corresponding events // are sent by QApplicationPrivate::notifyActiveWindowChange() case QEvent::FocusIn: handleFocusInEvent(static_cast<QFocusEvent *>(event)); // Fallthrough case QEvent::FocusOut: { #ifndef QT_NO_ACCESSIBILITY QAccessible::State state; state.active = true; QAccessibleStateChangeEvent ev(widget(), state); QAccessible::updateAccessibility(&ev); #endif return false; } case QEvent::FocusAboutToChange: if (QApplicationPrivate::focus_widget) { if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled)) qApp->inputMethod()->commit(); QGuiApplication::sendSpontaneousEvent(QApplicationPrivate::focus_widget, event); } return true; case QEvent::KeyPress: case QEvent::KeyRelease: case QEvent::ShortcutOverride: handleKeyEvent(static_cast<QKeyEvent *>(event)); return true; case QEvent::MouseMove: case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseButtonDblClick: handleMouseEvent(static_cast<QMouseEvent *>(event)); return true; case QEvent::NonClientAreaMouseMove: case QEvent::NonClientAreaMouseButtonPress: case QEvent::NonClientAreaMouseButtonRelease: case QEvent::NonClientAreaMouseButtonDblClick: handleNonClientAreaMouseEvent(static_cast<QMouseEvent *>(event)); return true; case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: case QEvent::TouchCancel: handleTouchEvent(static_cast<QTouchEvent *>(event)); return true; case QEvent::Move: handleMoveEvent(static_cast<QMoveEvent *>(event)); return true; case QEvent::Resize: handleResizeEvent(static_cast<QResizeEvent *>(event)); return true; #ifndef QT_NO_WHEELEVENT case QEvent::Wheel: handleWheelEvent(static_cast<QWheelEvent *>(event)); return true; #endif #ifndef QT_NO_DRAGANDDROP case QEvent::DragEnter: case QEvent::DragMove: handleDragEnterMoveEvent(static_cast<QDragMoveEvent *>(event)); return true; case QEvent::DragLeave: handleDragLeaveEvent(static_cast<QDragLeaveEvent *>(event)); return true; case QEvent::Drop: handleDropEvent(static_cast<QDropEvent *>(event)); return true; #endif case QEvent::Expose: handleExposeEvent(static_cast<QExposeEvent *>(event)); return true; case QEvent::WindowStateChange: handleWindowStateChangedEvent(static_cast<QWindowStateChangeEvent *>(event)); return true; case QEvent::ThemeChange: { QEvent widgetEvent(QEvent::ThemeChange); QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent); } return true; #ifndef QT_NO_TABLETEVENT case QEvent::TabletPress: case QEvent::TabletMove: case QEvent::TabletRelease: handleTabletEvent(static_cast<QTabletEvent *>(event)); return true; #endif #ifndef QT_NO_GESTURES case QEvent::NativeGesture: handleGestureEvent(static_cast<QNativeGestureEvent *>(event)); return true; #endif #ifndef QT_NO_CONTEXTMENU case QEvent::ContextMenu: handleContextMenuEvent(static_cast<QContextMenuEvent *>(event)); return true; #endif // Handing show events to widgets (see below) here would cause them to be triggered twice case QEvent::Show: case QEvent::Hide: return QWindow::event(event); case QEvent::WindowBlocked: qt_button_down = 0; break; default: break; } return m_widget->event(event) || QWindow::event(event); }
OSStatus GHOST_SystemCarbon::handleMouseEvent(EventRef event) { OSStatus err = eventNotHandledErr; GHOST_IWindow *window = m_windowManager->getActiveWindow(); UInt32 kind = ::GetEventKind(event); switch (kind) { case kEventMouseDown: case kEventMouseUp: // Handle Mac application responsibilities if ((kind == kEventMouseDown) && handleMouseDown(event)) { err = noErr; } else { GHOST_TEventType type = (kind == kEventMouseDown) ? GHOST_kEventButtonDown : GHOST_kEventButtonUp; EventMouseButton button; /* Window still gets mouse up after command-H */ if (m_windowManager->getActiveWindow()) { // handle any tablet events that may have come with the mouse event (optional) handleTabletEvent(event); ::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button); pushEvent(new GHOST_EventButton(getMilliSeconds(), type, window, convertButton(button))); err = noErr; } } break; case kEventMouseMoved: case kEventMouseDragged: { Point mousePos; if (window) { //handle any tablet events that may have come with the mouse event (optional) handleTabletEvent(event); ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos); pushEvent(new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, mousePos.h, mousePos.v)); err = noErr; } break; } case kEventMouseWheelMoved: { OSStatus status; //UInt32 modifiers; EventMouseWheelAxis axis; SInt32 delta; //status = ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifiers), NULL, &modifiers); //GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed"); status = ::GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis); GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed"); if (axis == kEventMouseWheelAxisY) { status = ::GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(delta), NULL, &delta); GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed"); /* * Limit mouse wheel delta to plus and minus one. */ delta = delta > 0 ? 1 : -1; pushEvent(new GHOST_EventWheel(getMilliSeconds(), window, delta)); err = noErr; } } break; } return err; }