void DashboardWindowContainer::mouseWasGrabbedByParent() { // fake a mouse cancel QGraphicsSceneMouseEvent ev; #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) ev.setCanceled(true); #else ev.ignore(); #endif mouseReleaseEvent(&ev); }
void DashboardWindowContainer::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { event->accept(); if (G_UNLIKELY(m_trackingMouseDirection)) { int deltaX = event->pos().x() - event->buttonDownPos(Qt::LeftButton).x(); int deltaY = event->pos().y() - event->buttonDownPos(Qt::LeftButton).y(); if ((deltaX * deltaX + deltaY * deltaY) < Settings::LunaSettings()->tapRadiusSquared) return; m_trackingMouseDirection = false; if (abs(deltaX) > abs(deltaY)) { m_vertLockedMovement = false; Q_EMIT signalItemDragState(true); } else if(m_dashboardManualDrag) { QGraphicsSceneMouseEvent ev; #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) ev.setCanceled(true); #else ev.ignore(); #endif mouseReleaseEvent(&ev); m_dashboardManualDrag = false; } } if(m_isMenu && m_vertLockedMovement) return; if (m_vertLockedMovement) { // Set the flag that a vertical mouse move is in progress, so that we can change the # of items getting painted. if(false == m_verticalMouseMoveInProgress) m_verticalMouseMoveInProgress = true; int deltaY = event->pos().y() - event->lastPos().y(); if (deltaY == 0) { return; } setScrollBottom(m_scrollBottom - deltaY); // Set the direction of the flick if(Ignore == m_FlickDirection) { if(deltaY > 0) { m_FlickDirection = FlickDown; } else { m_FlickDirection = FlickUp; } } showOrHideMasks(); return; } if (DashboardWindow* w = m_draggedWindow.data()) { if(!m_dashboardManualDrag) { // draw the window int deltaX = event->pos().x() - event->lastPos().x(); if (deltaX == 0) return; w->setPos(MAX(w->boundingRect().width()/2, w->pos().x() + deltaX), w->pos().y()); } else { // send the mouse events to the window int winX = event->pos().x() + (m_isMenu ? 0 : w->boundingRect().width()/2); int winY = event->pos().y() - w->pos().y() + w->boundingRect().height()/2; // send the mouse down to the web app side Event ev; ev.type = Event::PenMove; ev.setMainFinger(true); ev.x = winX; ev.y = winY; ev.clickCount = 1; ev.modifiers = Event::modifiersFromQt(event->modifiers()); ev.time = Time::curSysTimeMs(); w->inputEvent(&ev); } } }