Changeset View
Changeset View
Standalone View
Standalone View
effects/presentwindows/presentwindows.cpp
Show First 20 Lines • Show All 547 Lines • ▼ Show 20 Line(s) | 547 | // const QPointF scenePos = m_closeView->mapToScene(widgetPos); | |||
---|---|---|---|---|---|
548 | QMouseEvent event(me->type(), widgetPos, me->pos(), me->button(), me->buttons(), me->modifiers()); | 548 | QMouseEvent event(me->type(), widgetPos, me->pos(), me->button(), me->buttons(), me->modifiers()); | ||
549 | m_closeView->windowInputMouseEvent(&event); | 549 | m_closeView->windowInputMouseEvent(&event); | ||
550 | if (contains) { | 550 | if (contains) { | ||
551 | // filter out | 551 | // filter out | ||
552 | return; | 552 | return; | ||
553 | } | 553 | } | ||
554 | } | 554 | } | ||
555 | } | 555 | } | ||
556 | inputEventUpdate(me->pos(), me->type(), me->button()); | ||||
557 | } | ||||
558 | | ||||
559 | void PresentWindowsEffect::inputEventUpdate(const QPoint &pos, QEvent::Type type, Qt::MouseButton button) | ||||
560 | { | ||||
556 | // Which window are we hovering over? Always trigger as we don't always get move events before clicking | 561 | // Which window are we hovering over? Always trigger as we don't always get move events before clicking | ||
557 | // We cannot use m_motionManager.windowAtPoint() as the window might not be visible | 562 | // We cannot use m_motionManager.windowAtPoint() as the window might not be visible | ||
558 | EffectWindowList windows = m_motionManager.managedWindows(); | 563 | EffectWindowList windows = m_motionManager.managedWindows(); | ||
559 | bool hovering = false; | 564 | bool hovering = false; | ||
560 | EffectWindow *highlightCandidate = NULL; | 565 | EffectWindow *highlightCandidate = NULL; | ||
561 | for (int i = 0; i < windows.size(); ++i) { | 566 | for (int i = 0; i < windows.size(); ++i) { | ||
562 | DataHash::const_iterator winData = m_windowData.constFind(windows.at(i)); | 567 | DataHash::const_iterator winData = m_windowData.constFind(windows.at(i)); | ||
563 | if (winData == m_windowData.constEnd()) | 568 | if (winData == m_windowData.constEnd()) | ||
564 | continue; | 569 | continue; | ||
565 | if (m_motionManager.transformedGeometry(windows.at(i)).contains(cursorPos()) && | 570 | if (m_motionManager.transformedGeometry(windows.at(i)).contains(pos) && | ||
566 | winData->visible && !winData->deleted) { | 571 | winData->visible && !winData->deleted) { | ||
567 | hovering = true; | 572 | hovering = true; | ||
568 | if (windows.at(i) && m_highlightedWindow != windows.at(i)) | 573 | if (windows.at(i) && m_highlightedWindow != windows.at(i)) | ||
569 | highlightCandidate = windows.at(i); | 574 | highlightCandidate = windows.at(i); | ||
570 | break; | 575 | break; | ||
571 | } | 576 | } | ||
572 | } | 577 | } | ||
573 | if (!hovering) | 578 | if (!hovering) | ||
574 | setHighlightedWindow(NULL); | 579 | setHighlightedWindow(NULL); | ||
575 | if (m_highlightedWindow && m_motionManager.transformedGeometry(m_highlightedWindow).contains(me->pos())) | 580 | if (m_highlightedWindow && m_motionManager.transformedGeometry(m_highlightedWindow).contains(pos)) | ||
576 | updateCloseWindow(); | 581 | updateCloseWindow(); | ||
577 | else if (m_closeView) | 582 | else if (m_closeView) | ||
578 | m_closeView->hide(); | 583 | m_closeView->hide(); | ||
579 | 584 | | |||
580 | if (e->type() == QEvent::MouseButtonRelease) { | 585 | if (type == QEvent::MouseButtonRelease) { | ||
581 | if (highlightCandidate) | 586 | if (highlightCandidate) | ||
582 | setHighlightedWindow(highlightCandidate); | 587 | setHighlightedWindow(highlightCandidate); | ||
583 | if (me->button() == Qt::LeftButton) { | 588 | if (button == Qt::LeftButton) { | ||
584 | if (hovering) { | 589 | if (hovering) { | ||
585 | // mouse is hovering above a window - use MouseActionsWindow | 590 | // mouse is hovering above a window - use MouseActionsWindow | ||
586 | mouseActionWindow(m_leftButtonWindow); | 591 | mouseActionWindow(m_leftButtonWindow); | ||
587 | } else { | 592 | } else { | ||
588 | // mouse is hovering above desktop - use MouseActionsDesktop | 593 | // mouse is hovering above desktop - use MouseActionsDesktop | ||
589 | mouseActionDesktop(m_leftButtonDesktop); | 594 | mouseActionDesktop(m_leftButtonDesktop); | ||
590 | } | 595 | } | ||
591 | } | 596 | } | ||
592 | if (me->button() == Qt::MidButton) { | 597 | if (button == Qt::MidButton) { | ||
593 | if (hovering) { | 598 | if (hovering) { | ||
594 | // mouse is hovering above a window - use MouseActionsWindow | 599 | // mouse is hovering above a window - use MouseActionsWindow | ||
595 | mouseActionWindow(m_middleButtonWindow); | 600 | mouseActionWindow(m_middleButtonWindow); | ||
596 | } else { | 601 | } else { | ||
597 | // mouse is hovering above desktop - use MouseActionsDesktop | 602 | // mouse is hovering above desktop - use MouseActionsDesktop | ||
598 | mouseActionDesktop(m_middleButtonDesktop); | 603 | mouseActionDesktop(m_middleButtonDesktop); | ||
599 | } | 604 | } | ||
600 | } | 605 | } | ||
601 | if (me->button() == Qt::RightButton) { | 606 | if (button == Qt::RightButton) { | ||
602 | if (hovering) { | 607 | if (hovering) { | ||
603 | // mouse is hovering above a window - use MouseActionsWindow | 608 | // mouse is hovering above a window - use MouseActionsWindow | ||
604 | mouseActionWindow(m_rightButtonWindow); | 609 | mouseActionWindow(m_rightButtonWindow); | ||
605 | } else { | 610 | } else { | ||
606 | // mouse is hovering above desktop - use MouseActionsDesktop | 611 | // mouse is hovering above desktop - use MouseActionsDesktop | ||
607 | mouseActionDesktop(m_rightButtonDesktop); | 612 | mouseActionDesktop(m_rightButtonDesktop); | ||
608 | } | 613 | } | ||
609 | } | 614 | } | ||
610 | } else if (highlightCandidate && !m_motionManager.areWindowsMoving()) | 615 | } else if (highlightCandidate && !m_motionManager.areWindowsMoving()) | ||
611 | setHighlightedWindow(highlightCandidate); | 616 | setHighlightedWindow(highlightCandidate); | ||
612 | } | 617 | } | ||
613 | 618 | | |||
619 | bool PresentWindowsEffect::touchDown(quint32 id, const QPointF &pos, quint32 time) | ||||
620 | { | ||||
621 | Q_UNUSED(time) | ||||
622 | if (!m_activated) { | ||||
623 | return false; | ||||
624 | } | ||||
625 | // only if we don't track a touch id yet | ||||
626 | if (!m_touch.active) { | ||||
627 | m_touch.active = true; | ||||
628 | m_touch.id = id; | ||||
629 | inputEventUpdate(pos.toPoint()); | ||||
630 | } | ||||
631 | return true; | ||||
632 | } | ||||
633 | | ||||
634 | bool PresentWindowsEffect::touchMotion(quint32 id, const QPointF &pos, quint32 time) | ||||
635 | { | ||||
636 | Q_UNUSED(id) | ||||
637 | Q_UNUSED(time) | ||||
638 | if (!m_activated) { | ||||
639 | return false; | ||||
640 | } | ||||
641 | if (m_touch.active && m_touch.id == id) { | ||||
642 | // only update for the touch id we track | ||||
643 | inputEventUpdate(pos.toPoint()); | ||||
644 | } | ||||
645 | return true; | ||||
646 | } | ||||
647 | | ||||
648 | bool PresentWindowsEffect::touchUp(quint32 id, quint32 time) | ||||
649 | { | ||||
650 | Q_UNUSED(id) | ||||
651 | Q_UNUSED(time) | ||||
652 | if (!m_activated) { | ||||
653 | return false; | ||||
654 | } | ||||
655 | if (m_touch.active && m_touch.id == id) { | ||||
656 | m_touch.active = false; | ||||
657 | m_touch.id = 0; | ||||
658 | if (m_highlightedWindow) { | ||||
659 | mouseActionWindow(m_leftButtonWindow); | ||||
660 | } | ||||
661 | } | ||||
662 | return true; | ||||
663 | } | ||||
664 | | ||||
614 | void PresentWindowsEffect::mouseActionWindow(WindowMouseAction& action) | 665 | void PresentWindowsEffect::mouseActionWindow(WindowMouseAction& action) | ||
615 | { | 666 | { | ||
616 | switch(action) { | 667 | switch(action) { | ||
617 | case WindowActivateAction: | 668 | case WindowActivateAction: | ||
618 | if (m_highlightedWindow) | 669 | if (m_highlightedWindow) | ||
619 | effects->activateWindow(m_highlightedWindow); | 670 | effects->activateWindow(m_highlightedWindow); | ||
620 | setActive(false); | 671 | setActive(false); | ||
621 | break; | 672 | break; | ||
▲ Show 20 Lines • Show All 1355 Lines • Show Last 20 Lines |