Changeset View
Changeset View
Standalone View
Standalone View
virtualdesktops.cpp
Show First 20 Lines • Show All 530 Lines • ▼ Show 20 Line(s) | 530 | if (m_current == newDesktop) { | |||
---|---|---|---|---|---|
531 | return false; | 531 | return false; | ||
532 | } | 532 | } | ||
533 | const uint oldDesktop = current(); | 533 | const uint oldDesktop = current(); | ||
534 | m_current = newDesktop; | 534 | m_current = newDesktop; | ||
535 | emit currentChanged(oldDesktop, newDesktop->x11DesktopNumber()); | 535 | emit currentChanged(oldDesktop, newDesktop->x11DesktopNumber()); | ||
536 | return true; | 536 | return true; | ||
537 | } | 537 | } | ||
538 | 538 | | |||
539 | static bool s_loadingDesktopSettings = false; | ||||
540 | | ||||
539 | void VirtualDesktopManager::setCount(uint count) | 541 | void VirtualDesktopManager::setCount(uint count) | ||
540 | { | 542 | { | ||
541 | count = qBound<uint>(1, count, VirtualDesktopManager::maximum()); | 543 | count = qBound<uint>(1, count, VirtualDesktopManager::maximum()); | ||
542 | if (count == uint(m_desktops.count())) { | 544 | if (count == uint(m_desktops.count())) { | ||
543 | // nothing to change | 545 | // nothing to change | ||
544 | return; | 546 | return; | ||
545 | } | 547 | } | ||
546 | QList<VirtualDesktop *> newDesktops; | 548 | QList<VirtualDesktop *> newDesktops; | ||
Show All 13 Lines | 551 | if ((uint)m_desktops.count() > count) { | |||
560 | for (auto desktop : desktopsToRemove) { | 562 | for (auto desktop : desktopsToRemove) { | ||
561 | emit desktopRemoved(desktop); | 563 | emit desktopRemoved(desktop); | ||
562 | desktop->deleteLater(); | 564 | desktop->deleteLater(); | ||
563 | } | 565 | } | ||
564 | } else { | 566 | } else { | ||
565 | while (uint(m_desktops.count()) < count) { | 567 | while (uint(m_desktops.count()) < count) { | ||
566 | auto vd = new VirtualDesktop(this); | 568 | auto vd = new VirtualDesktop(this); | ||
567 | vd->setX11DesktopNumber(m_desktops.count() + 1); | 569 | vd->setX11DesktopNumber(m_desktops.count() + 1); | ||
568 | if (!m_isLoading) { | 570 | if (!s_loadingDesktopSettings) { | ||
569 | vd->setId(QUuid::createUuid().toString().toUtf8()); | 571 | vd->setId(QUuid::createUuid().toString().toUtf8()); | ||
570 | } | 572 | } | ||
571 | m_desktops << vd; | 573 | m_desktops << vd; | ||
572 | newDesktops << vd; | 574 | newDesktops << vd; | ||
573 | if (m_rootInfo) { | 575 | if (m_rootInfo) { | ||
574 | connect(vd, &VirtualDesktop::nameChanged, this, | 576 | connect(vd, &VirtualDesktop::nameChanged, this, | ||
575 | [this, vd]() { | 577 | [this, vd]() { | ||
576 | if (m_rootInfo) { | 578 | if (m_rootInfo) { | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 650 | if (width == 0 && height == 0) { | |||
649 | // Not given, set default layout | 651 | // Not given, set default layout | ||
650 | height = count() == 1u ? 1 : 2; | 652 | height = count() == 1u ? 1 : 2; | ||
651 | } | 653 | } | ||
652 | setNETDesktopLayout(orientation, | 654 | setNETDesktopLayout(orientation, | ||
653 | width, height, 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now. | 655 | width, height, 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now. | ||
654 | ); | 656 | ); | ||
655 | } | 657 | } | ||
656 | 658 | | |||
657 | static bool s_loadingDesktopSettings = false; | | |||
658 | | ||||
659 | void VirtualDesktopManager::load() | 659 | void VirtualDesktopManager::load() | ||
660 | { | 660 | { | ||
661 | s_loadingDesktopSettings = true; | 661 | s_loadingDesktopSettings = true; | ||
662 | if (!m_config) { | 662 | if (!m_config) { | ||
663 | return; | 663 | return; | ||
664 | } | 664 | } | ||
665 | //FIXME: how to avoid this? | | |||
666 | m_isLoading = true; | | |||
667 | QString groupname; | 665 | QString groupname; | ||
668 | if (screen_number == 0) { | 666 | if (screen_number == 0) { | ||
669 | groupname = QStringLiteral("Desktops"); | 667 | groupname = QStringLiteral("Desktops"); | ||
670 | } else { | 668 | } else { | ||
671 | groupname.sprintf("Desktops-screen-%d", screen_number); | 669 | groupname.sprintf("Desktops-screen-%d", screen_number); | ||
672 | } | 670 | } | ||
673 | KConfigGroup group(m_config, groupname); | 671 | KConfigGroup group(m_config, groupname); | ||
674 | const int n = group.readEntry("Number", 1); | 672 | const int n = group.readEntry("Number", 1); | ||
Show All 30 Lines | 698 | if (m_rootInfo) { | |||
705 | if (n % rows > 0) { | 703 | if (n % rows > 0) { | ||
706 | columns++; | 704 | columns++; | ||
707 | } | 705 | } | ||
708 | m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, rows, NET::DesktopLayoutCornerTopLeft); | 706 | m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, rows, NET::DesktopLayoutCornerTopLeft); | ||
709 | m_rootInfo->activate(); | 707 | m_rootInfo->activate(); | ||
710 | } | 708 | } | ||
711 | 709 | | |||
712 | s_loadingDesktopSettings = false; | 710 | s_loadingDesktopSettings = false; | ||
713 | m_isLoading = false; | | |||
714 | } | 711 | } | ||
715 | 712 | | |||
716 | void VirtualDesktopManager::save() | 713 | void VirtualDesktopManager::save() | ||
717 | { | 714 | { | ||
718 | if (s_loadingDesktopSettings) { | 715 | if (s_loadingDesktopSettings) { | ||
719 | return; | 716 | return; | ||
720 | } | 717 | } | ||
721 | if (!m_config) { | 718 | if (!m_config) { | ||
▲ Show 20 Lines • Show All 178 Lines • Show Last 20 Lines |