LayoutPoint MultiColumnFragmentainerGroup::visualPointToFlowThreadPoint(const LayoutPoint& visualPoint) const { unsigned columnIndex = columnIndexAtVisualPoint(visualPoint); LayoutRect columnRect = columnRectAt(columnIndex); LayoutPoint localPoint(visualPoint); localPoint.moveBy(-columnRect.location()); // Before converting to a flow thread position, if the block direction coordinate is outside the // column, snap to the bounds of the column, and reset the inline direction coordinate to the // start position in the column. The effect of this is that if the block position is before the // column rectangle, we'll get to the beginning of this column, while if the block position is // after the column rectangle, we'll get to the beginning of the next column. if (!m_columnSet.isHorizontalWritingMode()) { LayoutUnit columnStart = m_columnSet.style()->isLeftToRightDirection() ? LayoutUnit() : columnRect.height(); if (localPoint.x() < 0) localPoint = LayoutPoint(LayoutUnit(), columnStart); else if (localPoint.x() > logicalHeight()) localPoint = LayoutPoint(logicalHeight(), columnStart); return LayoutPoint(localPoint.x() + logicalTopInFlowThreadAt(columnIndex), localPoint.y()); } LayoutUnit columnStart = m_columnSet.style()->isLeftToRightDirection() ? LayoutUnit() : columnRect.width(); if (localPoint.y() < 0) localPoint = LayoutPoint(columnStart, LayoutUnit()); else if (localPoint.y() > logicalHeight()) localPoint = LayoutPoint(columnStart, logicalHeight()); return LayoutPoint(localPoint.x(), localPoint.y() + logicalTopInFlowThreadAt(columnIndex)); }
int LComponent::reallyContains ( lua_State* ) { if (child) { Point<int> localPoint( LUA::getPoint() ); bool returnTrueIfWithinAChild = LUA::getBoolean(); return LUA::returnBoolean( child->reallyContains( localPoint, returnTrueIfWithinAChild ) ); } else return 0; }
/** \brief Retrieve info from window, needed for accel layer */ void UI_getWindowInfo(void *draw, GUI_WindowInfo *xinfo) { ADM_assert(videoWindow); QWidget* widget = videoWindow->parentWidget(); xinfo->widget = videoWindow; xinfo->systemWindowId = 0; #if defined(_WIN32) xinfo->display=(void *)videoWindow->winId(); xinfo->systemWindowId=videoWindow->winId(); #elif defined(__APPLE__) #if defined(ADM_CPU_X86_64) xinfo->display = (void*)videoWindow->winId(); xinfo->systemWindowId=videoWindow->winId(); #else xinfo->display = HIViewGetWindow(HIViewRef(widget->winId())); xinfo->systemWindowId= HIViewGetWindow(HIViewRef(widget->winId())); #endif #else #if QT_VERSION < QT_VERSION_CHECK(5,0,0) const QX11Info &info=videoWindow->x11Info(); xinfo->display=info.display(); #else xinfo->display=XOpenDisplay(NULL); #endif xinfo->systemWindowId=videoWindow->winId(); #endif QPoint localPoint(0,0); QPoint windowPoint = videoWindow->mapToGlobal(localPoint); xinfo->x = windowPoint.x(); xinfo->y = windowPoint.y(); xinfo->width = displayW; xinfo->height = displayH; }
void BlockPhysicsComponent::rasterize(Polygon2 const &polygon) { Polygon2 localPolygon; for (int i = 0; i < polygon.getSize(); ++i) { b2Vec2 worldPoint(polygon.vertices[i].x, polygon.vertices[i].y); b2Vec2 localPoint = body_->GetLocalPoint(worldPoint); localPolygon.vertices.push_back(Vector2(localPoint.x, localPoint.y)); } Box2 bounds = localPolygon.getBoundingBox(); int minX = int(10.0f * bounds.p1.x + 0.05f); int minY = int(10.0f * bounds.p1.y + 0.05f); int maxX = int(10.0f * bounds.p2.x + 0.05f); int maxY = int(10.0f * bounds.p2.y + 0.05f); for (int y = minY; y <= maxY; ++y) { for (int x = minX; x <= maxX; ++x) { Vector2 localPoint(0.1f * float(x), 0.1f * float(y)); if (localPolygon.containsPoint(localPoint)) { for (int dy = -1; dy <= 1; ++dy) { for (int dx = -1; dx <= 1; ++dx) { if (dx == 0 || dy == 0) { setElement(x + dx, y + dy, 1); } } } } } } }
void Hero::_armEventHandler(cocos2d::EventCustom* event) { const auto eventObject = (dragonBones::EventObject*)event->getUserData(); if (eventObject->type == dragonBones::EventObject::COMPLETE) { _isAttacking = false; _hitCount = 0; const auto animationName = "ready_" + _weaponName; _armArmature->getAnimation().fadeIn(animationName); } else if (eventObject->type == dragonBones::EventObject::FRAME_EVENT) { if (eventObject->name == "ready") { _isAttacking = false; _hitCount++; } else if (eventObject->name == "fire") { const auto display = (dragonBones::CCArmatureDisplay*)(eventObject->armature->getDisplay()); const auto firePointBone = eventObject->armature->getBone("bow"); const auto transform = display->getNodeToWorldTransform(); cocos2d::Vec3 localPoint(firePointBone->global.x, -firePointBone->global.y, 0.f); cocos2d::Vec2 globalPoint; transform.transformPoint(&localPoint); globalPoint.set(localPoint.x, localPoint.y); auto radian = 0.f; if (_faceDir > 0) { radian = firePointBone->global.getRotation() + display->getRotation() * dragonBones::ANGLE_TO_RADIAN; } else { radian = dragonBones::PI - (firePointBone->global.getRotation() + display->getRotation() * dragonBones::ANGLE_TO_RADIAN); } switch (_weaponsLevel[_weaponIndex]) { case 0: _fire(globalPoint, radian); break; case 1: _fire(globalPoint, radian + 3.f * dragonBones::ANGLE_TO_RADIAN); _fire(globalPoint, radian - 3.f * dragonBones::ANGLE_TO_RADIAN); break; case 2: _fire(globalPoint, radian + 6.f * dragonBones::ANGLE_TO_RADIAN); _fire(globalPoint, radian); _fire(globalPoint, radian - 6.f * dragonBones::ANGLE_TO_RADIAN); break; } } } }
PositionWithAffinity HitTestResult::position() const { if (!m_innerPossiblyPseudoNode) return PositionWithAffinity(); RenderObject* renderer = this->renderer(); if (!renderer) return PositionWithAffinity(); return renderer->positionForPoint(localPoint()); }
bool HitTestResult::isMisspelled() const { if (!targetNode() || !targetNode()->renderer()) return false; VisiblePosition pos(targetNode()->renderer()->positionForPoint(localPoint())); if (pos.isNull()) return false; return m_innerNonSharedNode->document().markers().markersInRange( makeRange(pos, pos).get(), DocumentMarker::MisspellingMarkers()).size() > 0; }
bool WindowManager::mousePressEvent(QObject *object, QEvent *event) { // cast event and check buttons/modifiers QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); if (!(Qt::NoModifier==mouseEvent->modifiers() && Qt::LeftButton==mouseEvent->button())) { return false; } // check lock if (isLocked()) { return false; } else { setLocked(true); } // cast to widget QWidget *widget = static_cast<QWidget*>(object); // check if widget can be dragged from current position if (isBlackListed(widget) || !canDrag(widget)) { return false; } // retrieve widget's child at event position QPoint position(mouseEvent->pos()); QWidget *child = widget->childAt(position); if (!canDrag(widget, child, position)) { return false; } // save target and drag point _target = widget; _dragPoint = position; _globalDragPoint = mouseEvent->globalPos(); _dragAboutToStart = true; // send a move event to the current child with same position // if received, it is caught to actually start the drag QPoint localPoint(_dragPoint); if (child) { localPoint = child->mapFrom(widget, localPoint); } else { child = widget; } QMouseEvent localMouseEvent(QEvent::MouseMove, localPoint, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); qApp->sendEvent(child, &localMouseEvent); // never eat event return false; }
void Mecha::_frameEventHandler(cocos2d::EventCustom* event) { const auto eventObject = (dragonBones::EventObject*)event->getUserData(); if (eventObject->name == "onFire") { const auto display = (dragonBones::CCArmatureDisplay*)eventObject->armature->getDisplay(); const auto firePointBone = eventObject->armature->getBone("firePoint"); const auto transform = display->getNodeToWorldTransform(); cocos2d::Vec3 localPoint(firePointBone->global.x, -firePointBone->global.y, 0.f); cocos2d::Vec2 globalPoint; transform.transformPoint(&localPoint); globalPoint.set(localPoint.x, localPoint.y); _fire(globalPoint); } }
void ossimGui::ImageScrollWidget::wheelEvent ( QWheelEvent * e ) { //QScrollArea::wheelEvent(e); if(!m_inputBounds.hasNans()) { ossimIpt origin = m_inputBounds.ul(); ossimIpt localPoint(m_scrollOrigin.x +e->x(), m_scrollOrigin.y+e->y()); ossimIpt viewPoint(localPoint.x+origin.x, localPoint.y+origin.y); ossimDrect rect = viewportBoundsInViewSpace(); emit wheel(e, rect, viewPoint);//viewportPoint, localPoint, viewPoint); } }
void ossimGui::ImageScrollWidget::mousePressEvent ( QMouseEvent * e ) { QScrollArea::mousePressEvent(e); m_activePointStart = e->pos(); m_activePointEnd = e->pos(); if(!m_inputBounds.hasNans()) { ossimIpt origin = m_inputBounds.ul(); ossimIpt localPoint(m_scrollOrigin.x +e->x(), m_scrollOrigin.y+e->y()); ossimIpt viewPoint(localPoint.x+origin.x, localPoint.y+origin.y); ossimDrect rect = viewportBoundsInViewSpace(); // Save the measured point position // (viewPoint = view<-scroll<-local) ossim_uint32 idxLayer = 0; ossimImageSource* src = m_layers->layer(idxLayer)->chain(); ossimGui::GatherImageViewProjTransVisitor visitor; src->accept(visitor); if (visitor.getTransformList().size() == 1) { // Transform to true image coordinates and save ossimRefPtr<IvtGeomTransform> ivtg = visitor.getTransformList()[0].get(); if (ivtg.valid()) { ivtg->viewToImage(viewPoint, m_measImgPoint); } } m_measPoint = viewPoint; m_drawPts = true; update(); // m_regOverlay->setMeasPoint(m_measPoint); // cout << "\n ImageScrollWidget::mousePressEvent (" // << viewPoint.x << ", "<< viewPoint.y << ") (" // << m_measImgPoint.x << ", "<< m_measImgPoint.y << ")" // << endl; emit mousePress(e, rect, viewPoint);//viewportPoint, localPoint, viewPoint); } }
void ossimGui::ImageScrollWidget::mouseReleaseEvent ( QMouseEvent * e ) { QScrollArea::mouseReleaseEvent(e); m_activePointEnd = e->pos(); if(!m_inputBounds.hasNans()) { ossimIpt origin = m_inputBounds.ul(); ossimIpt localPoint(m_scrollOrigin.x +e->x(), m_scrollOrigin.y+e->y()); ossimIpt viewPoint(localPoint.x+origin.x, localPoint.y+origin.y); ossimDrect rect = viewportBoundsInViewSpace(); emit mouseRelease(e, rect, viewPoint);//viewportPoint, localPoint, viewPoint); } }
void ossimGui::ImageScrollWidget::mouseMoveEvent ( QMouseEvent * e ) { QScrollArea::mouseMoveEvent(e); if(e->buttons() & Qt::LeftButton) { m_activePointEnd = e->pos(); if(m_layers->numberOfLayers() > 1) { m_widget->update(); } } if(!m_inputBounds.hasNans()) { ossimIpt origin = m_inputBounds.ul(); ossimIpt localPoint(m_scrollOrigin.x +e->x(), m_scrollOrigin.y+e->y()); ossimIpt viewPoint(localPoint.x+origin.x, localPoint.y+origin.y); ossimDrect rect = viewportBoundsInViewSpace(); emit mouseMove(e, rect, viewPoint);//viewportPoint, localPoint, viewPoint); } }
void QBBEventThread::handlePointerEvent(screen_event_t event) { errno = 0; // Query the window that was clicked void *qnxWindow; int result = screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &qnxWindow); if (result) { qFatal("QBB: failed to query event window, errno=%d", errno); } // Query the button states int buttonState = 0; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_BUTTONS, &buttonState); if (result) { qFatal("QBB: failed to query event button state, errno=%d", errno); } // Query the window position int windowPos[2]; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos); if (result) { qFatal("QBB: failed to query event window position, errno=%d", errno); } // Query the screen position int pos[2]; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, pos); if (result) { qFatal("QBB: failed to query event position, errno=%d", errno); } // Query the wheel delta int wheelDelta = 0; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheelDelta); if (result) { qFatal("QBB: failed to query event wheel delta, errno=%d", errno); } // map window to top-level widget QWidget* w = QWidget::find( (WId)qnxWindow ); // Generate enter and leave events as needed. if (qnxWindow != mLastMouseWindow) { QWidget* wOld = QWidget::find( (WId)mLastMouseWindow ); if (wOld) { QWindowSystemInterface::handleLeaveEvent(wOld); #if defined(QBBEVENTTHREAD_DEBUG) qDebug() << "QBB: Qt leave, w=" << wOld; #endif } if (w) { QWindowSystemInterface::handleEnterEvent(w); #if defined(QBBEVENTTHREAD_DEBUG) qDebug() << "QBB: Qt enter, w=" << w; #endif } } // Apply scaling to wheel delta and invert value for Qt. We'll probably want to scale // this via a system preference at some point. But for now this is a sane value and makes // the wheel usable. wheelDelta *= -10; // convert point to local coordinates QPoint globalPoint(pos[0], pos[1]); QPoint localPoint(windowPos[0], windowPos[1]); // Convert buttons. Qt::MouseButtons buttons = Qt::NoButton; if (buttonState & 1) buttons |= Qt::LeftButton; if (buttonState & 2) buttons |= Qt::MidButton; if (buttonState & 4) buttons |= Qt::RightButton; if (w) { // Inject mouse event into Qt only if something has changed. if (mLastGlobalMousePoint != globalPoint || mLastLocalMousePoint != localPoint || mLastButtonState != buttons) { QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons); #if defined(QBBEVENTTHREAD_DEBUG) qDebug() << "QBB: Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << (int)buttons; #endif } if (wheelDelta) { // Screen only supports a single wheel, so we will assume Vertical orientation for // now since that is pretty much standard. QWindowSystemInterface::handleWheelEvent(w, localPoint, globalPoint, wheelDelta, Qt::Vertical); #if defined(QBBEVENTTHREAD_DEBUG) qDebug() << "QBB: Qt wheel, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), d=" << (int)wheelDelta; #endif } } mLastGlobalMousePoint = globalPoint; mLastLocalMousePoint = localPoint; mLastButtonState = buttons; }
void PSSMLightShadowMap::_calcPlanesCullForShadowCasters(Vector< Vector<PlaneF> > &out, const Frustum &viewFrustum, const Point3F &_ligthDir) { #define ENABLE_CULL_ASSERT PROFILE_SCOPE(PSSMLightShadowMap_render_getCullFrustrum); Point3F ligthDir = _ligthDir; PlaneF lightFarPlane, lightNearPlane; MatrixF lightFarPlaneMat(true); MatrixF invLightFarPlaneMat(true); // init data { ligthDir.normalize(); Point3F viewDir = viewFrustum.getTransform().getForwardVector(); viewDir.normalize(); const Point3F viewPosition = viewFrustum.getPosition(); const F32 viewDistance = viewFrustum.getBounds().len(); lightNearPlane = PlaneF(viewPosition + (viewDistance * -ligthDir), ligthDir); const Point3F lightFarPlanePos = viewPosition + (viewDistance * ligthDir); lightFarPlane = PlaneF(lightFarPlanePos, -ligthDir); lightFarPlaneMat = MathUtils::createOrientFromDir(-ligthDir); lightFarPlaneMat.setPosition(lightFarPlanePos); lightFarPlaneMat.invertTo(&invLightFarPlaneMat); } Vector<Point2F> projVertices; //project all frustum vertices into plane // all vertices are 2d and local to far plane projVertices.setSize(8); for (int i = 0; i < 8; ++i) // { const Point3F &point = viewFrustum.getPoints()[i]; #ifdef ENABLE_CULL_ASSERT AssertFatal( PlaneF::Front == lightNearPlane.whichSide(point), "" ); AssertFatal( PlaneF::Front == lightFarPlane.whichSide(point), "" ); #endif Point3F localPoint(lightFarPlane.project(point)); invLightFarPlaneMat.mulP(localPoint); projVertices[i] = Point2F(localPoint.x, localPoint.z); } //create hull arround projected proints Vector<Point2F> hullVerts; MathUtils::mBuildHull2D(projVertices, hullVerts); Vector<PlaneF> planes; planes.push_back(lightNearPlane); planes.push_back(lightFarPlane); //build planes for (int i = 0; i < (hullVerts.size() - 1); ++i) { Point2F pos2D = (hullVerts[i] + hullVerts[i + 1]) / 2; Point3F pos3D(pos2D.x, 0, pos2D.y); Point3F pos3DA(hullVerts[i].x, 0, hullVerts[i].y); Point3F pos3DB(hullVerts[i + 1].x, 0, hullVerts[i + 1].y); // move hull points to 3d space lightFarPlaneMat.mulP(pos3D); lightFarPlaneMat.mulP(pos3DA); lightFarPlaneMat.mulP(pos3DB); PlaneF plane(pos3D, MathUtils::mTriangleNormal(pos3DB, pos3DA, (pos3DA - ligthDir))); planes.push_back(plane); } //recalculate planes for each splits for (int split = 0; split < mNumSplits; ++split) { Frustum subFrustum(viewFrustum); subFrustum.cropNearFar(mSplitDist[split], mSplitDist[split + 1]); subFrustum.setFarDist(getMin(subFrustum.getFarDist()*2.5f, viewFrustum.getFarDist())); subFrustum.update(); Vector<PlaneF> subPlanes = planes; for (int planeIdx = 0; planeIdx < subPlanes.size(); ++planeIdx) { PlaneF &plane = subPlanes[planeIdx]; F32 minDist = 0; //calculate near vertex distance for (int vertexIdx = 0; vertexIdx < 8; ++vertexIdx) { Point3F point = subFrustum.getPoints()[vertexIdx]; minDist = getMin(plane.distToPlane(point), minDist); } // move plane to near vertex Point3F newPos = plane.getPosition() + (plane.getNormal() * minDist); plane = PlaneF(newPos, plane.getNormal()); #ifdef ENABLE_CULL_ASSERT for(int x = 0; x < 8; ++x) { AssertFatal( PlaneF::Back != plane.whichSide( subFrustum.getPoints()[x] ), ""); } #endif } out.push_back(subPlanes); } #undef ENABLE_CULL_ASSERT }
void QBBEventThread::handleTouchEvent(screen_event_t event, int qnxType) { // get display coordinates of touch errno = 0; int pos[2]; int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, pos); if (result) { qFatal("QBB: failed to query event position, errno=%d", errno); } // get window coordinates of touch errno = 0; int windowPos[2]; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos); if (result) { qFatal("QBB: failed to query event window position, errno=%d", errno); } // determine which finger touched errno = 0; int touchId; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_ID, &touchId); if (result) { qFatal("QBB: failed to query event touch id, errno=%d", errno); } // determine which window was touched errno = 0; void *qnxWindow; result = screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &qnxWindow); if (result) { qFatal("QBB: failed to query event window, errno=%d", errno); } // check if finger is valid if (touchId < MAX_TOUCH_POINTS) { // map window to top-level widget QWidget* w = QWidget::find( (WId)qnxWindow ); // Generate enter and leave events as needed. if (qnxWindow != mLastMouseWindow) { QWidget* wOld = QWidget::find( (WId)mLastMouseWindow ); if (wOld) { QWindowSystemInterface::handleLeaveEvent(wOld); #if defined(QBBEVENTTHREAD_DEBUG) qDebug() << "QBB: Qt leave, w=" << wOld; #endif } if (w) { QWindowSystemInterface::handleEnterEvent(w); #if defined(QBBEVENTTHREAD_DEBUG) qDebug() << "QBB: Qt enter, w=" << w; #endif } } if (w) { // convert primary touch to mouse event if (touchId == 0) { // convert point to local coordinates QPoint globalPoint(pos[0], pos[1]); QPoint localPoint(windowPos[0], windowPos[1]); // map touch state to button state Qt::MouseButtons buttons = (qnxType == SCREEN_EVENT_MTOUCH_RELEASE) ? Qt::NoButton : Qt::LeftButton; // inject event into Qt QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons); #if defined(QBBEVENTTHREAD_DEBUG) qDebug() << "QBB: Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << buttons; #endif } // get size of screen which contains window QPlatformScreen* platformScreen = QPlatformScreen::platformScreenForWidget(w); QSize screenSize = platformScreen->physicalSize(); // update cached position of current touch point mTouchPoints[touchId].normalPosition = QPointF( ((qreal)pos[0]) / screenSize.width(), ((qreal)pos[1]) / screenSize.height() ); mTouchPoints[touchId].area = QRectF( pos[0], pos[1], 0.0, 0.0 ); // determine event type and update state of current touch point QEvent::Type type = QEvent::None; switch (qnxType) { case SCREEN_EVENT_MTOUCH_TOUCH: mTouchPoints[touchId].state = Qt::TouchPointPressed; type = QEvent::TouchBegin; break; case SCREEN_EVENT_MTOUCH_MOVE: mTouchPoints[touchId].state = Qt::TouchPointMoved; type = QEvent::TouchUpdate; break; case SCREEN_EVENT_MTOUCH_RELEASE: mTouchPoints[touchId].state = Qt::TouchPointReleased; type = QEvent::TouchEnd; break; } // build list of active touch points QList<QWindowSystemInterface::TouchPoint> pointList; for (int i = 0; i < MAX_TOUCH_POINTS; i++) { if (i == touchId) { // current touch point is always active pointList.append(mTouchPoints[i]); } else if (mTouchPoints[i].state != Qt::TouchPointReleased) { // finger is down but did not move mTouchPoints[i].state = Qt::TouchPointStationary; pointList.append(mTouchPoints[i]); } } // inject event into Qt QWindowSystemInterface::handleTouchEvent(w, type, QTouchEvent::TouchScreen, pointList); #if defined(QBBEVENTTHREAD_DEBUG) qDebug() << "QBB: Qt touch, w=" << w << ", p=(" << pos[0] << "," << pos[1] << "), t=" << type; #endif } } }
bool Zone::IsInside(const Vector3& point) const { // Use an oriented bounding box test Vector3 localPoint(GetInverseWorldTransform() * point); return boundingBox_.IsInside(localPoint) != OUTSIDE; }
void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event) { errno = 0; // Query the window that was clicked screen_window_t qnxWindow; void *handle; int result = screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &handle); if (result) { qFatal("QQNX: failed to query event window, errno=%d", errno); } qnxWindow = static_cast<screen_window_t>(handle); // Query the button states int buttonState = 0; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_BUTTONS, &buttonState); if (result) { qFatal("QQNX: failed to query event button state, errno=%d", errno); } // Query the window position int windowPos[2]; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos); if (result) { qFatal("QQNX: failed to query event window position, errno=%d", errno); } // Query the screen position int pos[2]; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, pos); if (result) { qFatal("QQNX: failed to query event position, errno=%d", errno); } // Query the wheel delta int wheelDelta = 0; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheelDelta); if (result) { qFatal("QQNX: failed to query event wheel delta, errno=%d", errno); } // Map window handle to top-level QWindow QWindow *w = QQnxIntegration::window(qnxWindow); // Generate enter and leave events as needed. if (qnxWindow != m_lastMouseWindow) { QWindow *wOld = QQnxIntegration::window(m_lastMouseWindow); if (wOld) { QWindowSystemInterface::handleLeaveEvent(wOld); qScreenEventDebug() << Q_FUNC_INFO << "Qt leave, w=" << wOld; } if (w) { QWindowSystemInterface::handleEnterEvent(w); qScreenEventDebug() << Q_FUNC_INFO << "Qt enter, w=" << w; } } // If we don't have a navigator, we don't get activation events. if (buttonState && w && w != QGuiApplication::focusWindow() && !m_qnxIntegration->supportsNavigatorEvents()) QWindowSystemInterface::handleWindowActivated(w); m_lastMouseWindow = qnxWindow; // Apply scaling to wheel delta and invert value for Qt. We'll probably want to scale // this via a system preference at some point. But for now this is a sane value and makes // the wheel usable. wheelDelta *= -10; // convert point to local coordinates QPoint globalPoint(pos[0], pos[1]); QPoint localPoint(windowPos[0], windowPos[1]); // Convert buttons. // Some QNX header files invert 'Right Button versus "Left Button' ('Right' == 0x01). But they also offer a 'Button Swap' bit, // so we may receive events as shown. (If this is wrong, the fix is easy.) // QNX Button mask is 8 buttons wide, with a maximum value of x080. Qt::MouseButtons buttons = Qt::NoButton; if (buttonState & 0x01) buttons |= Qt::LeftButton; if (buttonState & 0x02) buttons |= Qt::MidButton; if (buttonState & 0x04) buttons |= Qt::RightButton; if (buttonState & 0x08) buttons |= Qt::ExtraButton1; // AKA 'Qt::BackButton' if (buttonState & 0x10) buttons |= Qt::ExtraButton2; // AKA 'Qt::ForwardButton' if (buttonState & 0x20) buttons |= Qt::ExtraButton3; if (buttonState & 0x40) buttons |= Qt::ExtraButton4; if (buttonState & 0x80) buttons |= Qt::ExtraButton5; if (w) { // Inject mouse event into Qt only if something has changed. if (m_lastGlobalMousePoint != globalPoint || m_lastLocalMousePoint != localPoint || m_lastButtonState != buttons) { QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons); qScreenEventDebug() << Q_FUNC_INFO << "Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << static_cast<int>(buttons); } if (wheelDelta) { // Screen only supports a single wheel, so we will assume Vertical orientation for // now since that is pretty much standard. QWindowSystemInterface::handleWheelEvent(w, localPoint, globalPoint, wheelDelta, Qt::Vertical); qScreenEventDebug() << Q_FUNC_INFO << "Qt wheel, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), d=" << static_cast<int>(wheelDelta); } } m_lastGlobalMousePoint = globalPoint; m_lastLocalMousePoint = localPoint; m_lastButtonState = buttons; }