Changeset View
Changeset View
Standalone View
Standalone View
effects/presentwindows/presentwindows.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
50 | 50 | | |||
51 | PresentWindowsEffect::PresentWindowsEffect() | 51 | PresentWindowsEffect::PresentWindowsEffect() | ||
52 | : m_proxy(this) | 52 | : m_proxy(this) | ||
53 | , m_activated(false) | 53 | , m_activated(false) | ||
54 | , m_ignoreMinimized(false) | 54 | , m_ignoreMinimized(false) | ||
55 | , m_decalOpacity(0.0) | 55 | , m_decalOpacity(0.0) | ||
56 | , m_hasKeyboardGrab(false) | 56 | , m_hasKeyboardGrab(false) | ||
57 | , m_mode(ModeCurrentDesktop) | 57 | , m_mode(ModeCurrentDesktop) | ||
58 | , m_managerWindow(NULL) | 58 | , m_managerWindow(nullptr) | ||
59 | , m_needInitialSelection(false) | 59 | , m_needInitialSelection(false) | ||
60 | , m_highlightedWindow(NULL) | 60 | , m_highlightedWindow(nullptr) | ||
61 | , m_filterFrame(NULL) | 61 | , m_filterFrame(nullptr) | ||
62 | , m_closeView(NULL) | 62 | , m_closeView(nullptr) | ||
63 | , m_closeWindow(NULL) | 63 | , m_closeWindow(nullptr) | ||
64 | , m_exposeAction(new QAction(this)) | 64 | , m_exposeAction(new QAction(this)) | ||
65 | , m_exposeAllAction(new QAction(this)) | 65 | , m_exposeAllAction(new QAction(this)) | ||
66 | , m_exposeClassAction(new QAction(this)) | 66 | , m_exposeClassAction(new QAction(this)) | ||
67 | { | 67 | { | ||
68 | initConfig<PresentWindowsConfig>(); | 68 | initConfig<PresentWindowsConfig>(); | ||
69 | auto announceSupportProperties = [this] { | 69 | auto announceSupportProperties = [this] { | ||
70 | m_atomDesktop = effects->announceSupportProperty("_KDE_PRESENT_WINDOWS_DESKTOP", this); | 70 | m_atomDesktop = effects->announceSupportProperty("_KDE_PRESENT_WINDOWS_DESKTOP", this); | ||
71 | m_atomWindows = effects->announceSupportProperty("_KDE_PRESENT_WINDOWS_GROUP", this); | 71 | m_atomWindows = effects->announceSupportProperty("_KDE_PRESENT_WINDOWS_GROUP", this); | ||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Line(s) | 242 | while (i != m_windowData.end()) { | |||
245 | ++i; | 245 | ++i; | ||
246 | } | 246 | } | ||
247 | m_windowData.clear(); | 247 | m_windowData.clear(); | ||
248 | 248 | | |||
249 | foreach (EffectWindow * w, effects->stackingOrder()) { | 249 | foreach (EffectWindow * w, effects->stackingOrder()) { | ||
250 | w->setData(WindowForceBlurRole, QVariant()); | 250 | w->setData(WindowForceBlurRole, QVariant()); | ||
251 | w->setData(WindowForceBackgroundContrastRole, QVariant()); | 251 | w->setData(WindowForceBackgroundContrastRole, QVariant()); | ||
252 | } | 252 | } | ||
253 | effects->setActiveFullScreenEffect(NULL); | 253 | effects->setActiveFullScreenEffect(nullptr); | ||
254 | effects->addRepaintFull(); | 254 | effects->addRepaintFull(); | ||
255 | } else if (m_activated && m_needInitialSelection) { | 255 | } else if (m_activated && m_needInitialSelection) { | ||
256 | m_needInitialSelection = false; | 256 | m_needInitialSelection = false; | ||
257 | QMouseEvent me(QEvent::MouseMove, cursorPos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); | 257 | QMouseEvent me(QEvent::MouseMove, cursorPos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); | ||
258 | windowInputMouseEvent(&me); | 258 | windowInputMouseEvent(&me); | ||
259 | } | 259 | } | ||
260 | 260 | | |||
261 | // Update windows that are changing brightness or opacity | 261 | // Update windows that are changing brightness or opacity | ||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 284 | if (m_activated || m_motionManager.areWindowsMoving() || m_closeWindow) { | |||
320 | if (winData->deleted) { | 320 | if (winData->deleted) { | ||
321 | data.setTranslucent(); | 321 | data.setTranslucent(); | ||
322 | if (winData->opacity <= 0.0 && winData->referenced) { | 322 | if (winData->opacity <= 0.0 && winData->referenced) { | ||
323 | // it's possible that another effect has referenced the window | 323 | // it's possible that another effect has referenced the window | ||
324 | // we have to keep the window in the list to prevent flickering | 324 | // we have to keep the window in the list to prevent flickering | ||
325 | winData->referenced = false; | 325 | winData->referenced = false; | ||
326 | w->unrefWindow(); | 326 | w->unrefWindow(); | ||
327 | if (w == m_closeWindow) { | 327 | if (w == m_closeWindow) { | ||
328 | m_closeWindow = NULL; | 328 | m_closeWindow = nullptr; | ||
329 | } | 329 | } | ||
330 | } else | 330 | } else | ||
331 | w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE); | 331 | w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE); | ||
332 | } | 332 | } | ||
333 | 333 | | |||
334 | // desktop windows on other desktops (Plasma activity per desktop) should not be painted | 334 | // desktop windows on other desktops (Plasma activity per desktop) should not be painted | ||
335 | if (w->isDesktop() && !w->isOnCurrentDesktop()) | 335 | if (w->isDesktop() && !w->isOnCurrentDesktop()) | ||
336 | w->disablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP); | 336 | w->disablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP); | ||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | 469 | if (m_closeView && w == effects->findWindow(m_closeView->winId())) { | |||
482 | w->setData(WindowForceBlurRole, QVariant(true)); | 482 | w->setData(WindowForceBlurRole, QVariant(true)); | ||
483 | w->setData(WindowForceBackgroundContrastRole, QVariant(true)); | 483 | w->setData(WindowForceBackgroundContrastRole, QVariant(true)); | ||
484 | } | 484 | } | ||
485 | } | 485 | } | ||
486 | 486 | | |||
487 | void PresentWindowsEffect::slotWindowClosed(EffectWindow *w) | 487 | void PresentWindowsEffect::slotWindowClosed(EffectWindow *w) | ||
488 | { | 488 | { | ||
489 | if (m_managerWindow == w) | 489 | if (m_managerWindow == w) | ||
490 | m_managerWindow = NULL; | 490 | m_managerWindow = nullptr; | ||
491 | DataHash::iterator winData = m_windowData.find(w); | 491 | DataHash::iterator winData = m_windowData.find(w); | ||
492 | if (winData == m_windowData.end()) | 492 | if (winData == m_windowData.end()) | ||
493 | return; | 493 | return; | ||
494 | winData->deleted = true; | 494 | winData->deleted = true; | ||
495 | if (!winData->referenced) { | 495 | if (!winData->referenced) { | ||
496 | winData->referenced = true; | 496 | winData->referenced = true; | ||
497 | w->refWindow(); | 497 | w->refWindow(); | ||
498 | } | 498 | } | ||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | |||||
584 | } | 584 | } | ||
585 | 585 | | |||
586 | void PresentWindowsEffect::inputEventUpdate(const QPoint &pos, QEvent::Type type, Qt::MouseButton button) | 586 | void PresentWindowsEffect::inputEventUpdate(const QPoint &pos, QEvent::Type type, Qt::MouseButton button) | ||
587 | { | 587 | { | ||
588 | // Which window are we hovering over? Always trigger as we don't always get move events before clicking | 588 | // Which window are we hovering over? Always trigger as we don't always get move events before clicking | ||
589 | // We cannot use m_motionManager.windowAtPoint() as the window might not be visible | 589 | // We cannot use m_motionManager.windowAtPoint() as the window might not be visible | ||
590 | EffectWindowList windows = m_motionManager.managedWindows(); | 590 | EffectWindowList windows = m_motionManager.managedWindows(); | ||
591 | bool hovering = false; | 591 | bool hovering = false; | ||
592 | EffectWindow *highlightCandidate = NULL; | 592 | EffectWindow *highlightCandidate = nullptr; | ||
593 | for (int i = 0; i < windows.size(); ++i) { | 593 | for (int i = 0; i < windows.size(); ++i) { | ||
594 | DataHash::const_iterator winData = m_windowData.constFind(windows.at(i)); | 594 | DataHash::const_iterator winData = m_windowData.constFind(windows.at(i)); | ||
595 | if (winData == m_windowData.constEnd()) | 595 | if (winData == m_windowData.constEnd()) | ||
596 | continue; | 596 | continue; | ||
597 | if (m_motionManager.transformedGeometry(windows.at(i)).contains(pos) && | 597 | if (m_motionManager.transformedGeometry(windows.at(i)).contains(pos) && | ||
598 | winData->visible && !winData->deleted) { | 598 | winData->visible && !winData->deleted) { | ||
599 | hovering = true; | 599 | hovering = true; | ||
600 | if (windows.at(i) && m_highlightedWindow != windows.at(i)) | 600 | if (windows.at(i) && m_highlightedWindow != windows.at(i)) | ||
601 | highlightCandidate = windows.at(i); | 601 | highlightCandidate = windows.at(i); | ||
602 | break; | 602 | break; | ||
603 | } | 603 | } | ||
604 | } | 604 | } | ||
605 | if (!hovering) | 605 | if (!hovering) | ||
606 | setHighlightedWindow(NULL); | 606 | setHighlightedWindow(nullptr); | ||
607 | if (m_highlightedWindow && m_motionManager.transformedGeometry(m_highlightedWindow).contains(pos)) | 607 | if (m_highlightedWindow && m_motionManager.transformedGeometry(m_highlightedWindow).contains(pos)) | ||
608 | updateCloseWindow(); | 608 | updateCloseWindow(); | ||
609 | else if (m_closeView) | 609 | else if (m_closeView) | ||
610 | m_closeView->hide(); | 610 | m_closeView->hide(); | ||
611 | 611 | | |||
612 | if (type == QEvent::MouseButtonRelease) { | 612 | if (type == QEvent::MouseButtonRelease) { | ||
613 | if (highlightCandidate) | 613 | if (highlightCandidate) | ||
614 | setHighlightedWindow(highlightCandidate); | 614 | setHighlightedWindow(highlightCandidate); | ||
▲ Show 20 Lines • Show All 331 Lines • ▼ Show 20 Line(s) | 943 | if (w->caption().contains(m_windowFilter, Qt::CaseInsensitive) || | |||
946 | windowlist.append(w); | 946 | windowlist.append(w); | ||
947 | windowlists[w->screen()].append(w); | 947 | windowlists[w->screen()].append(w); | ||
948 | winData->visible = true; | 948 | winData->visible = true; | ||
949 | } else | 949 | } else | ||
950 | winData->visible = false; | 950 | winData->visible = false; | ||
951 | } | 951 | } | ||
952 | } | 952 | } | ||
953 | if (windowlist.isEmpty()) { | 953 | if (windowlist.isEmpty()) { | ||
954 | setHighlightedWindow(NULL); | 954 | setHighlightedWindow(nullptr); | ||
955 | return; | 955 | return; | ||
956 | } | 956 | } | ||
957 | 957 | | |||
958 | // We filtered out the highlighted window | 958 | // We filtered out the highlighted window | ||
959 | if (m_highlightedWindow) { | 959 | if (m_highlightedWindow) { | ||
960 | DataHash::iterator winData = m_windowData.find(m_highlightedWindow); | 960 | DataHash::iterator winData = m_windowData.find(m_highlightedWindow); | ||
961 | if (winData != m_windowData.end() && !winData->visible) | 961 | if (winData != m_windowData.end() && !winData->visible) | ||
962 | setHighlightedWindow(findFirstWindow()); | 962 | setHighlightedWindow(findFirstWindow()); | ||
Show All 18 Lines | 967 | for (int screen = 0; screen < screens; screen++) { | |||
981 | // No point continuing if there is no windows to process | 981 | // No point continuing if there is no windows to process | ||
982 | if (!windows.count()) | 982 | if (!windows.count()) | ||
983 | continue; | 983 | continue; | ||
984 | 984 | | |||
985 | calculateWindowTransformations(windows, screen, m_motionManager); | 985 | calculateWindowTransformations(windows, screen, m_motionManager); | ||
986 | } | 986 | } | ||
987 | 987 | | |||
988 | // Resize text frames if required | 988 | // Resize text frames if required | ||
989 | QFontMetrics* metrics = NULL; // All fonts are the same | 989 | QFontMetrics* metrics = nullptr; // All fonts are the same | ||
990 | foreach (EffectWindow * w, m_motionManager.managedWindows()) { | 990 | foreach (EffectWindow * w, m_motionManager.managedWindows()) { | ||
991 | DataHash::iterator winData = m_windowData.find(w); | 991 | DataHash::iterator winData = m_windowData.find(w); | ||
992 | if (winData == m_windowData.end()) | 992 | if (winData == m_windowData.end()) | ||
993 | continue; | 993 | continue; | ||
994 | if (!metrics) | 994 | if (!metrics) | ||
995 | metrics = new QFontMetrics(winData->textFrame->font()); | 995 | metrics = new QFontMetrics(winData->textFrame->font()); | ||
996 | QRect geom = m_motionManager.targetGeometry(w).toRect(); | 996 | QRect geom = m_motionManager.targetGeometry(w).toRect(); | ||
997 | QString string = metrics->elidedText(w->caption(), Qt::ElideRight, geom.width() * 0.9); | 997 | QString string = metrics->elidedText(w->caption(), Qt::ElideRight, geom.width() * 0.9); | ||
▲ Show 20 Lines • Show All 531 Lines • ▼ Show 20 Line(s) | 1526 | { | |||
1529 | if (m_activated == active) | 1529 | if (m_activated == active) | ||
1530 | return; | 1530 | return; | ||
1531 | m_activated = active; | 1531 | m_activated = active; | ||
1532 | if (m_activated) { | 1532 | if (m_activated) { | ||
1533 | effects->setShowingDesktop(false); | 1533 | effects->setShowingDesktop(false); | ||
1534 | m_needInitialSelection = true; | 1534 | m_needInitialSelection = true; | ||
1535 | m_closeButtonCorner = (Qt::Corner)effects->kwinOption(KWin::CloseButtonCorner).toInt(); | 1535 | m_closeButtonCorner = (Qt::Corner)effects->kwinOption(KWin::CloseButtonCorner).toInt(); | ||
1536 | m_decalOpacity = 0.0; | 1536 | m_decalOpacity = 0.0; | ||
1537 | m_highlightedWindow = NULL; | 1537 | m_highlightedWindow = nullptr; | ||
1538 | m_windowFilter.clear(); | 1538 | m_windowFilter.clear(); | ||
1539 | 1539 | | |||
1540 | if (!(m_doNotCloseWindows || m_closeView)) { | 1540 | if (!(m_doNotCloseWindows || m_closeView)) { | ||
1541 | m_closeView = new CloseWindowView(); | 1541 | m_closeView = new CloseWindowView(); | ||
1542 | connect(m_closeView, &CloseWindowView::requestClose, this, &PresentWindowsEffect::closeWindow); | 1542 | connect(m_closeView, &CloseWindowView::requestClose, this, &PresentWindowsEffect::closeWindow); | ||
1543 | } | 1543 | } | ||
1544 | 1544 | | |||
1545 | // Add every single window to m_windowData (Just calling [w] creates it) | 1545 | // Add every single window to m_windowData (Just calling [w] creates it) | ||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | 1608 | } else { | |||
1638 | m_hasKeyboardGrab = false; | 1638 | m_hasKeyboardGrab = false; | ||
1639 | 1639 | | |||
1640 | // destroy atom on manager window | 1640 | // destroy atom on manager window | ||
1641 | if (m_managerWindow) { | 1641 | if (m_managerWindow) { | ||
1642 | if (m_mode == ModeSelectedDesktop && m_atomDesktop != XCB_ATOM_NONE) | 1642 | if (m_mode == ModeSelectedDesktop && m_atomDesktop != XCB_ATOM_NONE) | ||
1643 | m_managerWindow->deleteProperty(m_atomDesktop); | 1643 | m_managerWindow->deleteProperty(m_atomDesktop); | ||
1644 | else if (m_mode == ModeWindowGroup && m_atomWindows != XCB_ATOM_NONE) | 1644 | else if (m_mode == ModeWindowGroup && m_atomWindows != XCB_ATOM_NONE) | ||
1645 | m_managerWindow->deleteProperty(m_atomWindows); | 1645 | m_managerWindow->deleteProperty(m_atomWindows); | ||
1646 | m_managerWindow = NULL; | 1646 | m_managerWindow = nullptr; | ||
1647 | } | 1647 | } | ||
1648 | } | 1648 | } | ||
1649 | effects->addRepaintFull(); // Trigger the first repaint | 1649 | effects->addRepaintFull(); // Trigger the first repaint | ||
1650 | } | 1650 | } | ||
1651 | 1651 | | |||
1652 | //----------------------------------------------------------------------------- | 1652 | //----------------------------------------------------------------------------- | ||
1653 | // Filter box | 1653 | // Filter box | ||
1654 | 1654 | | |||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
1704 | { | 1704 | { | ||
1705 | if (w->isDesktop() || w == m_closeWindow) | 1705 | if (w->isDesktop() || w == m_closeWindow) | ||
1706 | return true; | 1706 | return true; | ||
1707 | return isSelectableWindow(w); | 1707 | return isSelectableWindow(w); | ||
1708 | } | 1708 | } | ||
1709 | 1709 | | |||
1710 | void PresentWindowsEffect::setHighlightedWindow(EffectWindow *w) | 1710 | void PresentWindowsEffect::setHighlightedWindow(EffectWindow *w) | ||
1711 | { | 1711 | { | ||
1712 | if (w == m_highlightedWindow || (w != NULL && !m_motionManager.isManaging(w))) | 1712 | if (w == m_highlightedWindow || (w != nullptr && !m_motionManager.isManaging(w))) | ||
1713 | return; | 1713 | return; | ||
1714 | 1714 | | |||
1715 | if (m_closeView) | 1715 | if (m_closeView) | ||
1716 | m_closeView->hide(); | 1716 | m_closeView->hide(); | ||
1717 | if (m_highlightedWindow) { | 1717 | if (m_highlightedWindow) { | ||
1718 | effects->setElevatedWindow(m_highlightedWindow, false); | 1718 | effects->setElevatedWindow(m_highlightedWindow, false); | ||
1719 | m_highlightedWindow->addRepaintFull(); // Trigger the first repaint | 1719 | m_highlightedWindow->addRepaintFull(); // Trigger the first repaint | ||
1720 | } | 1720 | } | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 1788 | { | |||
1795 | 1795 | | |||
1796 | // Detect across the width of the desktop | 1796 | // Detect across the width of the desktop | ||
1797 | if (xdiff != 0) { | 1797 | if (xdiff != 0) { | ||
1798 | if (xdiff > 0) { | 1798 | if (xdiff > 0) { | ||
1799 | // Detect right | 1799 | // Detect right | ||
1800 | for (int i = 0; i < xdiff; i++) { | 1800 | for (int i = 0; i < xdiff; i++) { | ||
1801 | QRectF wArea = m_motionManager.transformedGeometry(w); | 1801 | QRectF wArea = m_motionManager.transformedGeometry(w); | ||
1802 | detectRect = QRect(0, wArea.y(), area.width(), wArea.height()); | 1802 | detectRect = QRect(0, wArea.y(), area.width(), wArea.height()); | ||
1803 | next = NULL; | 1803 | next = nullptr; | ||
1804 | foreach (EffectWindow * e, m_motionManager.managedWindows()) { | 1804 | foreach (EffectWindow * e, m_motionManager.managedWindows()) { | ||
1805 | DataHash::const_iterator winData = m_windowData.find(e); | 1805 | DataHash::const_iterator winData = m_windowData.find(e); | ||
1806 | if (winData == m_windowData.end() || !winData->visible) | 1806 | if (winData == m_windowData.end() || !winData->visible) | ||
1807 | continue; | 1807 | continue; | ||
1808 | QRectF eArea = m_motionManager.transformedGeometry(e); | 1808 | QRectF eArea = m_motionManager.transformedGeometry(e); | ||
1809 | if (eArea.intersects(detectRect) && | 1809 | if (eArea.intersects(detectRect) && | ||
1810 | eArea.x() > wArea.x()) { | 1810 | eArea.x() > wArea.x()) { | ||
1811 | if (next == NULL) | 1811 | if (next == nullptr) | ||
1812 | next = e; | 1812 | next = e; | ||
1813 | else { | 1813 | else { | ||
1814 | QRectF nArea = m_motionManager.transformedGeometry(next); | 1814 | QRectF nArea = m_motionManager.transformedGeometry(next); | ||
1815 | if (eArea.x() < nArea.x()) | 1815 | if (eArea.x() < nArea.x()) | ||
1816 | next = e; | 1816 | next = e; | ||
1817 | } | 1817 | } | ||
1818 | } | 1818 | } | ||
1819 | } | 1819 | } | ||
1820 | if (next == NULL) { | 1820 | if (next == nullptr) { | ||
1821 | if (wrap) // We are at the right-most window, now get the left-most one to wrap | 1821 | if (wrap) // We are at the right-most window, now get the left-most one to wrap | ||
1822 | return relativeWindow(w, -1000, 0, false); | 1822 | return relativeWindow(w, -1000, 0, false); | ||
1823 | break; // No more windows to the right | 1823 | break; // No more windows to the right | ||
1824 | } | 1824 | } | ||
1825 | w = next; | 1825 | w = next; | ||
1826 | } | 1826 | } | ||
1827 | return w; | 1827 | return w; | ||
1828 | } else { | 1828 | } else { | ||
1829 | // Detect left | 1829 | // Detect left | ||
1830 | for (int i = 0; i < -xdiff; i++) { | 1830 | for (int i = 0; i < -xdiff; i++) { | ||
1831 | QRectF wArea = m_motionManager.transformedGeometry(w); | 1831 | QRectF wArea = m_motionManager.transformedGeometry(w); | ||
1832 | detectRect = QRect(0, wArea.y(), area.width(), wArea.height()); | 1832 | detectRect = QRect(0, wArea.y(), area.width(), wArea.height()); | ||
1833 | next = NULL; | 1833 | next = nullptr; | ||
1834 | foreach (EffectWindow * e, m_motionManager.managedWindows()) { | 1834 | foreach (EffectWindow * e, m_motionManager.managedWindows()) { | ||
1835 | DataHash::const_iterator winData = m_windowData.find(e); | 1835 | DataHash::const_iterator winData = m_windowData.find(e); | ||
1836 | if (winData == m_windowData.end() || !winData->visible) | 1836 | if (winData == m_windowData.end() || !winData->visible) | ||
1837 | continue; | 1837 | continue; | ||
1838 | QRectF eArea = m_motionManager.transformedGeometry(e); | 1838 | QRectF eArea = m_motionManager.transformedGeometry(e); | ||
1839 | if (eArea.intersects(detectRect) && | 1839 | if (eArea.intersects(detectRect) && | ||
1840 | eArea.x() + eArea.width() < wArea.x() + wArea.width()) { | 1840 | eArea.x() + eArea.width() < wArea.x() + wArea.width()) { | ||
1841 | if (next == NULL) | 1841 | if (next == nullptr) | ||
1842 | next = e; | 1842 | next = e; | ||
1843 | else { | 1843 | else { | ||
1844 | QRectF nArea = m_motionManager.transformedGeometry(next); | 1844 | QRectF nArea = m_motionManager.transformedGeometry(next); | ||
1845 | if (eArea.x() + eArea.width() > nArea.x() + nArea.width()) | 1845 | if (eArea.x() + eArea.width() > nArea.x() + nArea.width()) | ||
1846 | next = e; | 1846 | next = e; | ||
1847 | } | 1847 | } | ||
1848 | } | 1848 | } | ||
1849 | } | 1849 | } | ||
1850 | if (next == NULL) { | 1850 | if (next == nullptr) { | ||
1851 | if (wrap) // We are at the left-most window, now get the right-most one to wrap | 1851 | if (wrap) // We are at the left-most window, now get the right-most one to wrap | ||
1852 | return relativeWindow(w, 1000, 0, false); | 1852 | return relativeWindow(w, 1000, 0, false); | ||
1853 | break; // No more windows to the left | 1853 | break; // No more windows to the left | ||
1854 | } | 1854 | } | ||
1855 | w = next; | 1855 | w = next; | ||
1856 | } | 1856 | } | ||
1857 | return w; | 1857 | return w; | ||
1858 | } | 1858 | } | ||
1859 | } | 1859 | } | ||
1860 | 1860 | | |||
1861 | // Detect across the height of the desktop | 1861 | // Detect across the height of the desktop | ||
1862 | if (ydiff != 0) { | 1862 | if (ydiff != 0) { | ||
1863 | if (ydiff > 0) { | 1863 | if (ydiff > 0) { | ||
1864 | // Detect down | 1864 | // Detect down | ||
1865 | for (int i = 0; i < ydiff; i++) { | 1865 | for (int i = 0; i < ydiff; i++) { | ||
1866 | QRectF wArea = m_motionManager.transformedGeometry(w); | 1866 | QRectF wArea = m_motionManager.transformedGeometry(w); | ||
1867 | detectRect = QRect(wArea.x(), 0, wArea.width(), area.height()); | 1867 | detectRect = QRect(wArea.x(), 0, wArea.width(), area.height()); | ||
1868 | next = NULL; | 1868 | next = nullptr; | ||
1869 | foreach (EffectWindow * e, m_motionManager.managedWindows()) { | 1869 | foreach (EffectWindow * e, m_motionManager.managedWindows()) { | ||
1870 | DataHash::const_iterator winData = m_windowData.find(e); | 1870 | DataHash::const_iterator winData = m_windowData.find(e); | ||
1871 | if (winData == m_windowData.end() || !winData->visible) | 1871 | if (winData == m_windowData.end() || !winData->visible) | ||
1872 | continue; | 1872 | continue; | ||
1873 | QRectF eArea = m_motionManager.transformedGeometry(e); | 1873 | QRectF eArea = m_motionManager.transformedGeometry(e); | ||
1874 | if (eArea.intersects(detectRect) && | 1874 | if (eArea.intersects(detectRect) && | ||
1875 | eArea.y() > wArea.y()) { | 1875 | eArea.y() > wArea.y()) { | ||
1876 | if (next == NULL) | 1876 | if (next == nullptr) | ||
1877 | next = e; | 1877 | next = e; | ||
1878 | else { | 1878 | else { | ||
1879 | QRectF nArea = m_motionManager.transformedGeometry(next); | 1879 | QRectF nArea = m_motionManager.transformedGeometry(next); | ||
1880 | if (eArea.y() < nArea.y()) | 1880 | if (eArea.y() < nArea.y()) | ||
1881 | next = e; | 1881 | next = e; | ||
1882 | } | 1882 | } | ||
1883 | } | 1883 | } | ||
1884 | } | 1884 | } | ||
1885 | if (next == NULL) { | 1885 | if (next == nullptr) { | ||
1886 | if (wrap) // We are at the bottom-most window, now get the top-most one to wrap | 1886 | if (wrap) // We are at the bottom-most window, now get the top-most one to wrap | ||
1887 | return relativeWindow(w, 0, -1000, false); | 1887 | return relativeWindow(w, 0, -1000, false); | ||
1888 | break; // No more windows to the bottom | 1888 | break; // No more windows to the bottom | ||
1889 | } | 1889 | } | ||
1890 | w = next; | 1890 | w = next; | ||
1891 | } | 1891 | } | ||
1892 | return w; | 1892 | return w; | ||
1893 | } else { | 1893 | } else { | ||
1894 | // Detect up | 1894 | // Detect up | ||
1895 | for (int i = 0; i < -ydiff; i++) { | 1895 | for (int i = 0; i < -ydiff; i++) { | ||
1896 | QRectF wArea = m_motionManager.transformedGeometry(w); | 1896 | QRectF wArea = m_motionManager.transformedGeometry(w); | ||
1897 | detectRect = QRect(wArea.x(), 0, wArea.width(), area.height()); | 1897 | detectRect = QRect(wArea.x(), 0, wArea.width(), area.height()); | ||
1898 | next = NULL; | 1898 | next = nullptr; | ||
1899 | foreach (EffectWindow * e, m_motionManager.managedWindows()) { | 1899 | foreach (EffectWindow * e, m_motionManager.managedWindows()) { | ||
1900 | DataHash::const_iterator winData = m_windowData.find(e); | 1900 | DataHash::const_iterator winData = m_windowData.find(e); | ||
1901 | if (winData == m_windowData.end() || !winData->visible) | 1901 | if (winData == m_windowData.end() || !winData->visible) | ||
1902 | continue; | 1902 | continue; | ||
1903 | QRectF eArea = m_motionManager.transformedGeometry(e); | 1903 | QRectF eArea = m_motionManager.transformedGeometry(e); | ||
1904 | if (eArea.intersects(detectRect) && | 1904 | if (eArea.intersects(detectRect) && | ||
1905 | eArea.y() + eArea.height() < wArea.y() + wArea.height()) { | 1905 | eArea.y() + eArea.height() < wArea.y() + wArea.height()) { | ||
1906 | if (next == NULL) | 1906 | if (next == nullptr) | ||
1907 | next = e; | 1907 | next = e; | ||
1908 | else { | 1908 | else { | ||
1909 | QRectF nArea = m_motionManager.transformedGeometry(next); | 1909 | QRectF nArea = m_motionManager.transformedGeometry(next); | ||
1910 | if (eArea.y() + eArea.height() > nArea.y() + nArea.height()) | 1910 | if (eArea.y() + eArea.height() > nArea.y() + nArea.height()) | ||
1911 | next = e; | 1911 | next = e; | ||
1912 | } | 1912 | } | ||
1913 | } | 1913 | } | ||
1914 | } | 1914 | } | ||
1915 | if (next == NULL) { | 1915 | if (next == nullptr) { | ||
1916 | if (wrap) // We are at the top-most window, now get the bottom-most one to wrap | 1916 | if (wrap) // We are at the top-most window, now get the bottom-most one to wrap | ||
1917 | return relativeWindow(w, 0, 1000, false); | 1917 | return relativeWindow(w, 0, 1000, false); | ||
1918 | break; // No more windows to the top | 1918 | break; // No more windows to the top | ||
1919 | } | 1919 | } | ||
1920 | w = next; | 1920 | w = next; | ||
1921 | } | 1921 | } | ||
1922 | return w; | 1922 | return w; | ||
1923 | } | 1923 | } | ||
1924 | } | 1924 | } | ||
1925 | 1925 | | |||
1926 | abort(); // Should never get here | 1926 | abort(); // Should never get here | ||
1927 | } | 1927 | } | ||
1928 | 1928 | | |||
1929 | EffectWindow* PresentWindowsEffect::findFirstWindow() const | 1929 | EffectWindow* PresentWindowsEffect::findFirstWindow() const | ||
1930 | { | 1930 | { | ||
1931 | EffectWindow *topLeft = NULL; | 1931 | EffectWindow *topLeft = nullptr; | ||
1932 | QRectF topLeftGeometry; | 1932 | QRectF topLeftGeometry; | ||
1933 | foreach (EffectWindow * w, m_motionManager.managedWindows()) { | 1933 | foreach (EffectWindow * w, m_motionManager.managedWindows()) { | ||
1934 | DataHash::const_iterator winData = m_windowData.find(w); | 1934 | DataHash::const_iterator winData = m_windowData.find(w); | ||
1935 | if (winData == m_windowData.end()) | 1935 | if (winData == m_windowData.end()) | ||
1936 | continue; | 1936 | continue; | ||
1937 | QRectF geometry = m_motionManager.transformedGeometry(w); | 1937 | QRectF geometry = m_motionManager.transformedGeometry(w); | ||
1938 | if (winData->visible == false) | 1938 | if (winData->visible == false) | ||
1939 | continue; // Not visible | 1939 | continue; // Not visible | ||
1940 | if (winData->deleted) | 1940 | if (winData->deleted) | ||
1941 | continue; // Window has been closed | 1941 | continue; // Window has been closed | ||
1942 | if (topLeft == NULL) { | 1942 | if (topLeft == nullptr) { | ||
1943 | topLeft = w; | 1943 | topLeft = w; | ||
1944 | topLeftGeometry = geometry; | 1944 | topLeftGeometry = geometry; | ||
1945 | } else if (geometry.x() < topLeftGeometry.x() || geometry.y() < topLeftGeometry.y()) { | 1945 | } else if (geometry.x() < topLeftGeometry.x() || geometry.y() < topLeftGeometry.y()) { | ||
1946 | topLeft = w; | 1946 | topLeft = w; | ||
1947 | topLeftGeometry = geometry; | 1947 | topLeftGeometry = geometry; | ||
1948 | } | 1948 | } | ||
1949 | } | 1949 | } | ||
1950 | return topLeft; | 1950 | return topLeft; | ||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |