Changeset View
Changeset View
Standalone View
Standalone View
virtualdesktops.cpp
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 58 | [this](VirtualDesktop *desktop) { | |||
---|---|---|---|---|---|
63 | connect(desktop, &VirtualDesktop::nameChanged, this, | 63 | connect(desktop, &VirtualDesktop::nameChanged, this, | ||
64 | [this, desktop, pvd]() { | 64 | [this, desktop, pvd]() { | ||
65 | pvd->setName(desktop->name()); | 65 | pvd->setName(desktop->name()); | ||
66 | } | 66 | } | ||
67 | ); | 67 | ); | ||
68 | } | 68 | } | ||
69 | ); | 69 | ); | ||
70 | 70 | | |||
71 | //handle removed: from VirtualDesktopManager to the wayland interface | 71 | //handle removed: from VirtualDesktopManager to the wayland interface | ||
zzag: I think it would be better to use m_virtualDesktopManagement as the context object. | |||||
zzag: Also, I think we don't need this lambda at all. | |||||
72 | connect(this, &VirtualDesktopManager::desktopRemoved, this, | 72 | connect(this, &VirtualDesktopManager::desktopRemoved, this, | ||
73 | [this](VirtualDesktop *desktop) { | 73 | [this](VirtualDesktop *desktop) { | ||
74 | m_virtualDesktopManagement->removeDesktop(desktop->id()); | 74 | m_virtualDesktopManagement->removeDesktop(desktop->id()); | ||
75 | } | 75 | } | ||
76 | ); | 76 | ); | ||
77 | 77 | | |||
78 | //create a new desktop when the client asks to | 78 | //create a new desktop when the client asks to | ||
79 | connect (m_virtualDesktopManagement, &PlasmaVirtualDesktopManagementInterface::desktopCreateRequested, this, | 79 | connect (m_virtualDesktopManagement, &PlasmaVirtualDesktopManagementInterface::desktopCreateRequested, this, | ||
▲ Show 20 Lines • Show All 545 Lines • ▼ Show 20 Line(s) | |||||
625 | 625 | | |||
626 | void VirtualDesktopManager::setRows(uint rows) | 626 | void VirtualDesktopManager::setRows(uint rows) | ||
627 | { | 627 | { | ||
628 | if (rows == 0 || rows > count() || rows == m_rows) { | 628 | if (rows == 0 || rows > count() || rows == m_rows) { | ||
629 | return; | 629 | return; | ||
630 | } | 630 | } | ||
631 | 631 | | |||
632 | m_rows = rows; | 632 | m_rows = rows; | ||
633 | if (m_virtualDesktopManagement) { | ||||
634 | m_virtualDesktopManagement->setRows(m_rows); | ||||
635 | } | ||||
633 | 636 | | |||
634 | int columns = count() / m_rows; | 637 | int columns = count() / m_rows; | ||
635 | if (count() % m_rows > 0) { | 638 | if (count() % m_rows > 0) { | ||
636 | columns++; | 639 | columns++; | ||
637 | } | 640 | } | ||
638 | if (m_rootInfo) { | 641 | if (m_rootInfo) { | ||
639 | m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, m_rows, NET::DesktopLayoutCornerTopLeft); | 642 | m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, m_rows, NET::DesktopLayoutCornerTopLeft); | ||
640 | m_rootInfo->activate(); | 643 | m_rootInfo->activate(); | ||
Show All 32 Lines | 672 | if (m_rootInfo) { | |||
673 | orientation = m_rootInfo->desktopLayoutOrientation() == NET::OrientationHorizontal ? Qt::Horizontal : Qt::Vertical; | 676 | orientation = m_rootInfo->desktopLayoutOrientation() == NET::OrientationHorizontal ? Qt::Horizontal : Qt::Vertical; | ||
674 | } | 677 | } | ||
675 | 678 | | |||
676 | if (columns == 0) { | 679 | if (columns == 0) { | ||
677 | // Not given, set default layout | 680 | // Not given, set default layout | ||
678 | m_rows = count() == 1u ? 1 : 2; | 681 | m_rows = count() == 1u ? 1 : 2; | ||
679 | columns = count() / m_rows; | 682 | columns = count() / m_rows; | ||
680 | } | 683 | } | ||
684 | if (m_virtualDesktopManagement) { | ||||
zzag: Unrelated whitespace change. | |||||
685 | m_virtualDesktopManagement->setRows(m_rows); | ||||
686 | } | ||||
681 | setNETDesktopLayout(orientation, | 687 | setNETDesktopLayout(orientation, | ||
682 | columns, m_rows, 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now. | 688 | columns, m_rows, 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now. | ||
683 | ); | 689 | ); | ||
684 | } | 690 | } | ||
685 | 691 | | |||
686 | void VirtualDesktopManager::load() | 692 | void VirtualDesktopManager::load() | ||
687 | { | 693 | { | ||
688 | s_loadingDesktopSettings = true; | 694 | s_loadingDesktopSettings = true; | ||
Show All 30 Lines | 708 | for (int i = 1; i <= n; i++) { | |||
719 | } | 725 | } | ||
720 | 726 | | |||
721 | // TODO: update desktop focus chain, why? | 727 | // TODO: update desktop focus chain, why? | ||
722 | // m_desktopFocusChain.value()[i-1] = i; | 728 | // m_desktopFocusChain.value()[i-1] = i; | ||
723 | } | 729 | } | ||
724 | 730 | | |||
725 | int rows = group.readEntry<int>("Rows", 2); | 731 | int rows = group.readEntry<int>("Rows", 2); | ||
726 | m_rows = qBound(1, rows, n); | 732 | m_rows = qBound(1, rows, n); | ||
733 | if (m_virtualDesktopManagement) { | ||||
734 | m_virtualDesktopManagement->setRows(m_rows); | ||||
735 | } | ||||
727 | 736 | | |||
728 | if (m_rootInfo) { | 737 | if (m_rootInfo) { | ||
729 | // avoid weird cases like having 3 rows for 4 desktops, where the last row is unused | 738 | // avoid weird cases like having 3 rows for 4 desktops, where the last row is unused | ||
730 | int columns = n / m_rows; | 739 | int columns = n / m_rows; | ||
731 | if (n % m_rows > 0) { | 740 | if (n % m_rows > 0) { | ||
732 | columns++; | 741 | columns++; | ||
733 | } | 742 | } | ||
734 | m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, m_rows, NET::DesktopLayoutCornerTopLeft); | 743 | m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, m_rows, NET::DesktopLayoutCornerTopLeft); | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 816 | while (width * height < count) { | |||
808 | if (orientation == Qt::Horizontal) { | 817 | if (orientation == Qt::Horizontal) { | ||
809 | ++width; | 818 | ++width; | ||
810 | } else { | 819 | } else { | ||
811 | ++height; | 820 | ++height; | ||
812 | } | 821 | } | ||
813 | } | 822 | } | ||
814 | 823 | | |||
815 | m_rows = qMax(1u, height); | 824 | m_rows = qMax(1u, height); | ||
825 | if (m_virtualDesktopManagement) { | ||||
826 | m_virtualDesktopManagement->setRows(m_rows); | ||||
827 | } | ||||
816 | 828 | | |||
817 | m_grid.update(QSize(width, height), orientation, m_desktops); | 829 | m_grid.update(QSize(width, height), orientation, m_desktops); | ||
818 | // TODO: why is there no call to m_rootInfo->setDesktopLayout? | 830 | // TODO: why is there no call to m_rootInfo->setDesktopLayout? | ||
819 | emit layoutChanged(width, height); | 831 | emit layoutChanged(width, height); | ||
820 | emit rowsChanged(height); | 832 | emit rowsChanged(height); | ||
821 | } | 833 | } | ||
822 | 834 | | |||
823 | void VirtualDesktopManager::initShortcuts() | 835 | void VirtualDesktopManager::initShortcuts() | ||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |
I think it would be better to use m_virtualDesktopManagement as the context object.