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