Changeset View
Changeset View
Standalone View
Standalone View
virtualdesktops.cpp
Show All 19 Lines | |||||
20 | *********************************************************************/ | 20 | *********************************************************************/ | ||
21 | #include "virtualdesktops.h" | 21 | #include "virtualdesktops.h" | ||
22 | #include "input.h" | 22 | #include "input.h" | ||
23 | // KDE | 23 | // KDE | ||
24 | #include <KConfigGroup> | 24 | #include <KConfigGroup> | ||
25 | #include <KGlobalAccel> | 25 | #include <KGlobalAccel> | ||
26 | #include <KLocalizedString> | 26 | #include <KLocalizedString> | ||
27 | #include <NETWM> | 27 | #include <NETWM> | ||
28 | | ||||
29 | #include <KWayland/Server/plasmavirtualdesktop_interface.h> | ||||
28 | // Qt | 30 | // Qt | ||
29 | #include <QAction> | 31 | #include <QAction> | ||
32 | #include <QUuid> | ||||
30 | 33 | | |||
31 | #include <algorithm> | 34 | #include <algorithm> | ||
32 | 35 | #include <QDebug> | |||
33 | namespace KWin { | 36 | namespace KWin { | ||
34 | 37 | | |||
35 | extern int screen_number; | 38 | extern int screen_number; | ||
36 | 39 | | |||
37 | VirtualDesktop::VirtualDesktop(QObject *parent) | 40 | VirtualDesktop::VirtualDesktop(QObject *parent) | ||
38 | : QObject(parent) | 41 | : QObject(parent) | ||
39 | { | 42 | { | ||
40 | } | 43 | } | ||
41 | 44 | | |||
42 | VirtualDesktop::~VirtualDesktop() | 45 | VirtualDesktop::~VirtualDesktop() | ||
43 | { | 46 | { | ||
44 | emit aboutToBeDestroyed(); | 47 | emit aboutToBeDestroyed(); | ||
45 | } | 48 | } | ||
46 | 49 | | |||
50 | void VirtualDesktopManager::setVirtualDesktopManagement(KWayland::Server::PlasmaVirtualDesktopManagementInterface *management) | ||||
51 | { | ||||
52 | using namespace KWayland::Server; | ||||
53 | Q_ASSERT(!m_virtualDesktopManagement); | ||||
54 | m_virtualDesktopManagement = management; | ||||
55 | | ||||
56 | connect(this, &VirtualDesktopManager::desktopCreated, this, | ||||
57 | [this](VirtualDesktop *desktop) { | ||||
58 | using namespace KWayland::Server; | ||||
59 | PlasmaVirtualDesktopInterface *pvd = m_virtualDesktopManagement->createDesktop(desktop->id(), desktop->x11DesktopNumber() - 1); | ||||
60 | pvd->setName(desktop->name()); | ||||
61 | pvd->sendDone(); | ||||
62 | connect(desktop, &VirtualDesktop::nameChanged, this, | ||||
63 | [this, desktop, pvd]() { | ||||
64 | pvd->setName(desktop->name()); | ||||
65 | } | ||||
66 | ); | ||||
67 | } | ||||
68 | ); | ||||
69 | | ||||
70 | //handle removed: from VirtualDesktopManager to the wayland interface | ||||
71 | connect(this, &VirtualDesktopManager::desktopRemoved, this, | ||||
72 | [this](VirtualDesktop *desktop) { | ||||
73 | m_virtualDesktopManagement->removeDesktop(desktop->id()); | ||||
74 | } | ||||
75 | ); | ||||
76 | | ||||
77 | //create a new desktop when the client asks to | ||||
78 | connect (m_virtualDesktopManagement, &PlasmaVirtualDesktopManagementInterface::desktopCreateRequested, this, | ||||
79 | [this](const QString &name, quint32 position) { | ||||
80 | VirtualDesktop *vd = createVirtualDesktop(position); | ||||
81 | if (vd) { | ||||
82 | vd->setName(name); | ||||
83 | } | ||||
84 | } | ||||
85 | ); | ||||
86 | | ||||
87 | //remove when the client asks to | ||||
88 | connect (m_virtualDesktopManagement, &PlasmaVirtualDesktopManagementInterface::desktopRemoveRequested, this, | ||||
89 | [this](const QString &id) { | ||||
90 | //here there can be some nice kauthorized check? | ||||
91 | //remove only from VirtualDesktopManager, the other connections will remove it from m_virtualDesktopManagement as well | ||||
92 | removeVirtualDesktop(id.toUtf8()); | ||||
93 | } | ||||
94 | ); | ||||
95 | | ||||
96 | for (quint32 i = 1; i <= count(); ++i) { | ||||
97 | VirtualDesktop *internalDesktop = desktopForX11Id(i); | ||||
98 | PlasmaVirtualDesktopInterface *desktop = m_virtualDesktopManagement->createDesktop(internalDesktop->id()); | ||||
99 | | ||||
100 | desktop->setName(desktop->name()); | ||||
101 | desktop->sendDone(); | ||||
102 | | ||||
103 | connect(desktop, &PlasmaVirtualDesktopInterface::activateRequested, this, | ||||
104 | [this, desktop] () { | ||||
105 | setCurrent(desktopForId(desktop->id().toUtf8())); | ||||
106 | } | ||||
107 | ); | ||||
108 | } | ||||
109 | //Now we are sure all ids are there | ||||
110 | save(); | ||||
111 | | ||||
112 | connect(this, &VirtualDesktopManager::currentChanged, this, | ||||
113 | [this]() { | ||||
114 | for (auto *deskInt : m_virtualDesktopManagement->desktops()) { | ||||
115 | if (deskInt->id() == currentDesktop()->id()) { | ||||
116 | deskInt->setActive(true); | ||||
117 | } else { | ||||
118 | deskInt->setActive(false); | ||||
119 | } | ||||
120 | } | ||||
121 | } | ||||
122 | ); | ||||
123 | } | ||||
124 | | ||||
47 | void VirtualDesktop::setId(const QByteArray &id) | 125 | void VirtualDesktop::setId(const QByteArray &id) | ||
48 | { | 126 | { | ||
49 | Q_ASSERT(m_id.isEmpty()); | 127 | Q_ASSERT(m_id.isEmpty()); | ||
50 | m_id = id; | 128 | m_id = id; | ||
51 | } | 129 | } | ||
52 | 130 | | |||
53 | void VirtualDesktop::setX11DesktopNumber(uint number) | 131 | void VirtualDesktop::setX11DesktopNumber(uint number) | ||
54 | { | 132 | { | ||
55 | Q_ASSERT(m_x11DesktopNumber == 0); | 133 | //x11DesktopNumber can be changed now | ||
134 | if (static_cast<uint>(m_x11DesktopNumber) == number) { | ||||
135 | return; | ||||
136 | } | ||||
137 | | ||||
56 | m_x11DesktopNumber = number; | 138 | m_x11DesktopNumber = number; | ||
139 | | ||||
140 | if (m_x11DesktopNumber != 0) { | ||||
141 | emit x11DesktopNumberChanged(); | ||||
142 | } | ||||
57 | } | 143 | } | ||
58 | 144 | | |||
59 | void VirtualDesktop::setName(const QString &name) | 145 | void VirtualDesktop::setName(const QString &name) | ||
60 | { | 146 | { | ||
61 | if (m_name == name) { | 147 | if (m_name == name) { | ||
62 | return; | 148 | return; | ||
63 | } | 149 | } | ||
64 | m_name = name; | 150 | m_name = name; | ||
65 | emit nameChanged(); | 151 | emit nameChanged(); | ||
66 | } | 152 | } | ||
67 | 153 | | |||
68 | VirtualDesktopGrid::VirtualDesktopGrid() | 154 | VirtualDesktopGrid::VirtualDesktopGrid() | ||
69 | : m_size(1, 2) // Default to tow rows | 155 | : m_size(1, 2) // Default to tow rows | ||
70 | , m_grid(QVector<QVector<VirtualDesktop*>>{QVector<VirtualDesktop*>{}, QVector<VirtualDesktop*>{}}) | 156 | , m_grid(QVector<QVector<VirtualDesktop*>>{QVector<VirtualDesktop*>{}, QVector<VirtualDesktop*>{}}) | ||
71 | { | 157 | { | ||
72 | } | 158 | } | ||
zzag: Unrelated change. | |||||
73 | 159 | | |||
74 | VirtualDesktopGrid::~VirtualDesktopGrid() = default; | 160 | VirtualDesktopGrid::~VirtualDesktopGrid() = default; | ||
75 | 161 | | |||
76 | void VirtualDesktopGrid::update(const QSize &size, Qt::Orientation orientation, const QVector<VirtualDesktop*> &desktops) | 162 | void VirtualDesktopGrid::update(const QSize &size, Qt::Orientation orientation, const QVector<VirtualDesktop*> &desktops) | ||
77 | { | 163 | { | ||
78 | // Set private variables | 164 | // Set private variables | ||
79 | m_size = size; | 165 | m_size = size; | ||
80 | const uint width = size.width(); | 166 | const uint width = size.width(); | ||
▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Line(s) | |||||
320 | VirtualDesktop *VirtualDesktopManager::desktopForX11Id(uint id) const | 406 | VirtualDesktop *VirtualDesktopManager::desktopForX11Id(uint id) const | ||
321 | { | 407 | { | ||
322 | if (id == 0 || id > count()) { | 408 | if (id == 0 || id > count()) { | ||
323 | return nullptr; | 409 | return nullptr; | ||
324 | } | 410 | } | ||
325 | return m_desktops.at(id - 1); | 411 | return m_desktops.at(id - 1); | ||
326 | } | 412 | } | ||
327 | 413 | | |||
414 | VirtualDesktop *VirtualDesktopManager::desktopForId(const QByteArray &id) const | ||||
415 | { | ||||
416 | auto desk = std::find_if( | ||||
417 | m_desktops.constBegin(), | ||||
418 | m_desktops.constEnd(), | ||||
zzag: Would be great to reformat it. | |||||
419 | [id] (const VirtualDesktop *desk ) { | ||||
420 | return desk->id() == id; | ||||
421 | } | ||||
zzag: IMHO, one shall not put `else` after `return`. | |||||
422 | ); | ||||
423 | | ||||
424 | if (desk != m_desktops.constEnd()) { | ||||
425 | return *desk; | ||||
426 | } | ||||
427 | | ||||
428 | return nullptr; | ||||
429 | } | ||||
430 | | ||||
431 | VirtualDesktop *VirtualDesktopManager::createVirtualDesktop(uint number, const QString &name) | ||||
432 | { | ||||
433 | //too many, can't insert new ones | ||||
434 | if ((uint)m_desktops.count() == VirtualDesktopManager::maximum()) { | ||||
I suggest to put * and not deduce raw pointer types because (a) it improves readability int x = 42; const auto foo = &x; *foo = 3; // totally fine, foo is of type int *const const auto *bar = &x; *bar = 3; // compilation error, bar is of type const int * Still, it would be great to get ack on this topic from Martin. :-) zzag: I suggest to put `*` and not deduce raw pointer types because
(a) it improves readability
(b)… | |||||
435 | return nullptr; | ||||
436 | } | ||||
437 | | ||||
438 | const uint actualNumber = qBound<uint>(0, number, VirtualDesktopManager::maximum()); | ||||
439 | auto *vd = new VirtualDesktop(this); | ||||
440 | vd->setX11DesktopNumber(actualNumber); | ||||
441 | //TODO: depend on Qt 5.11, use toString(QUuid::WithoutBraces) | ||||
442 | vd->setId(QUuid::createUuid().toString().toUtf8()); | ||||
443 | vd->setName(name); | ||||
444 | if (m_rootInfo) { | ||||
445 | connect(vd, &VirtualDesktop::nameChanged, this, | ||||
446 | [this, vd]() { | ||||
447 | if (m_rootInfo) { | ||||
448 | m_rootInfo->setDesktopName(vd->x11DesktopNumber(), vd->name().toUtf8().data()); | ||||
449 | } | ||||
450 | } | ||||
451 | ); | ||||
452 | m_rootInfo->setDesktopName(vd->x11DesktopNumber(), vd->name().toUtf8().data()); | ||||
453 | } | ||||
454 | | ||||
455 | //update the id of displaced desktops | ||||
456 | for (uint i = actualNumber; i < (uint)m_desktops.count(); ++i) { | ||||
457 | m_desktops[i]->setX11DesktopNumber(i + 1); | ||||
458 | if (m_rootInfo) { | ||||
459 | m_rootInfo->setDesktopName(i + 1, m_desktops[i]->name().toUtf8().data()); | ||||
460 | } | ||||
461 | } | ||||
462 | | ||||
463 | m_desktops.insert(actualNumber - 1, vd); | ||||
464 | save(); | ||||
465 | | ||||
466 | updateRootInfo(); | ||||
467 | emit desktopCreated(vd); | ||||
468 | emit countChanged(m_desktops.count()-1, m_desktops.count()); | ||||
469 | return vd; | ||||
470 | } | ||||
471 | | ||||
472 | void VirtualDesktopManager::removeVirtualDesktop(const QByteArray &id) | ||||
473 | { | ||||
474 | //don't end up without any desktop | ||||
475 | if (m_desktops.count() == 1) { | ||||
476 | return; | ||||
477 | } | ||||
478 | auto desktop = desktopForId(id); | ||||
479 | if (!desktop) { | ||||
480 | return; | ||||
481 | } | ||||
482 | | ||||
483 | const uint oldCurrent = m_current->x11DesktopNumber(); | ||||
484 | const uint i = desktop->x11DesktopNumber() - 1; | ||||
485 | m_desktops.remove(i); | ||||
486 | | ||||
487 | for (uint j = i; j < (uint)m_desktops.count(); ++j) { | ||||
488 | m_desktops[j]->setX11DesktopNumber(j + 1); | ||||
489 | if (m_rootInfo) { | ||||
490 | m_rootInfo->setDesktopName(j + 1, m_desktops[j]->name().toUtf8().data()); | ||||
491 | } | ||||
492 | } | ||||
493 | | ||||
494 | const uint newCurrent = qMin(oldCurrent, (uint)m_desktops.count()); | ||||
495 | m_current = m_desktops.at(newCurrent - 1); | ||||
496 | if (oldCurrent != newCurrent) { | ||||
497 | emit currentChanged(oldCurrent, newCurrent); | ||||
498 | } | ||||
499 | | ||||
500 | updateRootInfo(); | ||||
501 | emit desktopRemoved(desktop); | ||||
502 | emit countChanged(m_desktops.count()+1, m_desktops.count()); | ||||
503 | | ||||
504 | desktop->deleteLater(); | ||||
505 | } | ||||
506 | | ||||
328 | uint VirtualDesktopManager::current() const | 507 | uint VirtualDesktopManager::current() const | ||
329 | { | 508 | { | ||
330 | return m_current ? m_current->x11DesktopNumber() : 0; | 509 | return m_current ? m_current->x11DesktopNumber() : 0; | ||
331 | } | 510 | } | ||
332 | 511 | | |||
333 | VirtualDesktop *VirtualDesktopManager::currentDesktop() const | 512 | VirtualDesktop *VirtualDesktopManager::currentDesktop() const | ||
334 | { | 513 | { | ||
335 | return m_current; | 514 | return m_current; | ||
Show All 23 Lines | |||||
359 | 538 | | |||
360 | void VirtualDesktopManager::setCount(uint count) | 539 | void VirtualDesktopManager::setCount(uint count) | ||
361 | { | 540 | { | ||
362 | count = qBound<uint>(1, count, VirtualDesktopManager::maximum()); | 541 | count = qBound<uint>(1, count, VirtualDesktopManager::maximum()); | ||
363 | if (count == uint(m_desktops.count())) { | 542 | if (count == uint(m_desktops.count())) { | ||
364 | // nothing to change | 543 | // nothing to change | ||
365 | return; | 544 | return; | ||
366 | } | 545 | } | ||
546 | QList<VirtualDesktop *> newDesktops; | ||||
367 | const uint oldCount = m_desktops.count(); | 547 | const uint oldCount = m_desktops.count(); | ||
368 | const uint oldCurrent = current(); | 548 | //this explicit check makes it more readable | ||
369 | while (uint(m_desktops.count()) > count) { | 549 | if ((uint)m_desktops.count() > count) { | ||
370 | delete m_desktops.takeLast(); | 550 | const auto desktopsToRemove = m_desktops.mid(count); | ||
551 | m_desktops.resize(count); | ||||
552 | if (m_current) { | ||||
553 | uint oldCurrent = current(); | ||||
554 | uint newCurrent = qMin(oldCurrent, count); | ||||
555 | m_current = m_desktops.at(newCurrent - 1); | ||||
556 | if (oldCurrent != newCurrent) { | ||||
557 | emit currentChanged(oldCurrent, newCurrent); | ||||
558 | } | ||||
371 | } | 559 | } | ||
560 | for (auto desktop : desktopsToRemove) { | ||||
561 | emit desktopRemoved(desktop); | ||||
562 | desktop->deleteLater(); | ||||
563 | } | ||||
564 | } else { | ||||
372 | while (uint(m_desktops.count()) < count) { | 565 | while (uint(m_desktops.count()) < count) { | ||
373 | auto vd = new VirtualDesktop(this); | 566 | auto vd = new VirtualDesktop(this); | ||
374 | vd->setX11DesktopNumber(m_desktops.count() + 1); | 567 | vd->setX11DesktopNumber(m_desktops.count() + 1); | ||
568 | if (!m_isLoading) { | ||||
569 | vd->setId(QUuid::createUuid().toString().toUtf8()); | ||||
570 | } | ||||
375 | m_desktops << vd; | 571 | m_desktops << vd; | ||
572 | newDesktops << vd; | ||||
573 | if (m_rootInfo) { | ||||
574 | connect(vd, &VirtualDesktop::nameChanged, this, | ||||
575 | [this, vd]() { | ||||
576 | if (m_rootInfo) { | ||||
577 | m_rootInfo->setDesktopName(vd->x11DesktopNumber(), vd->name().toUtf8().data()); | ||||
578 | } | ||||
579 | } | ||||
580 | ); | ||||
581 | m_rootInfo->setDesktopName(vd->x11DesktopNumber(), vd->name().toUtf8().data()); | ||||
582 | } | ||||
376 | } | 583 | } | ||
377 | if (oldCount > count) { | | |||
378 | handleDesktopsRemoved(oldCount, oldCurrent); | | |||
379 | } | 584 | } | ||
380 | 585 | | |||
381 | updateRootInfo(); | 586 | updateRootInfo(); | ||
382 | 587 | | |||
383 | save(); | 588 | save(); | ||
589 | for (auto vd : newDesktops) { | ||||
590 | emit desktopCreated(vd); | ||||
591 | } | ||||
384 | emit countChanged(oldCount, m_desktops.count()); | 592 | emit countChanged(oldCount, m_desktops.count()); | ||
385 | } | 593 | } | ||
386 | 594 | | |||
387 | void VirtualDesktopManager::handleDesktopsRemoved(uint previousCount, uint previousCurrent) | 595 | | ||
596 | uint VirtualDesktopManager::rows() const | ||||
597 | { | ||||
598 | return grid().height(); | ||||
599 | } | ||||
600 | | ||||
601 | void VirtualDesktopManager::setRows(uint rows) | ||||
388 | { | 602 | { | ||
389 | if (!m_current) { | 603 | if (static_cast<uint>(grid().height()) == rows || rows == 0 || rows > count()) { | ||
390 | m_current = m_desktops.last(); | 604 | return; | ||
391 | emit currentChanged(previousCurrent, m_current->x11DesktopNumber()); | 605 | } | ||
606 | | ||||
607 | int columns = count() / rows; | ||||
608 | if (count() % rows > 0) { | ||||
609 | columns++; | ||||
610 | } | ||||
611 | if (m_rootInfo) { | ||||
612 | m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, rows, NET::DesktopLayoutCornerTopLeft); | ||||
613 | m_rootInfo->activate(); | ||||
392 | } | 614 | } | ||
393 | emit desktopsRemoved(previousCount); | 615 | | ||
616 | updateLayout(); | ||||
617 | | ||||
618 | //rowsChanged will be emitted by setNETDesktopLayout called by updateLayout | ||||
394 | } | 619 | } | ||
395 | 620 | | |||
396 | void VirtualDesktopManager::updateRootInfo() | 621 | void VirtualDesktopManager::updateRootInfo() | ||
397 | { | 622 | { | ||
398 | if (!m_rootInfo) { | 623 | if (!m_rootInfo) { | ||
399 | // Make sure the layout is still valid | 624 | // Make sure the layout is still valid | ||
400 | updateLayout(); | 625 | updateLayout(); | ||
401 | return; | 626 | return; | ||
Show All 30 Lines | |||||
432 | static bool s_loadingDesktopSettings = false; | 657 | static bool s_loadingDesktopSettings = false; | ||
433 | 658 | | |||
434 | void VirtualDesktopManager::load() | 659 | void VirtualDesktopManager::load() | ||
435 | { | 660 | { | ||
436 | s_loadingDesktopSettings = true; | 661 | s_loadingDesktopSettings = true; | ||
437 | if (!m_config) { | 662 | if (!m_config) { | ||
438 | return; | 663 | return; | ||
439 | } | 664 | } | ||
665 | //FIXME: how to avoid this? | ||||
666 | m_isLoading = true; | ||||
440 | QString groupname; | 667 | QString groupname; | ||
441 | if (screen_number == 0) { | 668 | if (screen_number == 0) { | ||
442 | groupname = QStringLiteral("Desktops"); | 669 | groupname = QStringLiteral("Desktops"); | ||
443 | } else { | 670 | } else { | ||
444 | groupname.sprintf("Desktops-screen-%d", screen_number); | 671 | groupname.sprintf("Desktops-screen-%d", screen_number); | ||
445 | } | 672 | } | ||
446 | KConfigGroup group(m_config, groupname); | 673 | KConfigGroup group(m_config, groupname); | ||
447 | const int n = group.readEntry("Number", 1); | 674 | const int n = group.readEntry("Number", 1); | ||
448 | setCount(n); | 675 | setCount(n); | ||
449 | if (m_rootInfo) { | 676 | | ||
450 | for (int i = 1; i <= n; i++) { | 677 | for (int i = 1; i <= n; i++) { | ||
451 | QString s = group.readEntry(QStringLiteral("Name_%1").arg(i), i18n("Desktop %1", i)); | 678 | QString s = group.readEntry(QStringLiteral("Name_%1").arg(i), i18n("Desktop %1", i)); | ||
679 | if (m_rootInfo) { | ||||
Eww, definitely not. What I assumed we would do would be have kwin start up with 1VD. (ksplash is on all anyway) davidedmundson: Eww, definitely not.
What I assumed we would do would be have kwin start up with 1VD. (ksplash… | |||||
452 | m_rootInfo->setDesktopName(i, s.toUtf8().data()); | 680 | m_rootInfo->setDesktopName(i, s.toUtf8().data()); | ||
681 | } | ||||
682 | m_desktops[i-1]->setName(s.toUtf8().data()); | ||||
683 | | ||||
684 | QString sId = group.readEntry(QStringLiteral("Id_%1").arg(i), QString()); | ||||
685 | | ||||
686 | //load gets called 2 times, see workspace.cpp line 416 and BUG 385260 | ||||
687 | if (m_desktops[i-1]->id().isEmpty()) { | ||||
688 | if (sId.isEmpty()) { | ||||
689 | sId = QUuid::createUuid().toString(); | ||||
690 | } | ||||
691 | m_desktops[i-1]->setId(sId.toUtf8().data()); | ||||
692 | } else { | ||||
693 | Q_ASSERT(sId.isEmpty() || m_desktops[i-1]->id() == sId.toUtf8().data()); | ||||
694 | } | ||||
695 | | ||||
453 | // TODO: update desktop focus chain, why? | 696 | // TODO: update desktop focus chain, why? | ||
454 | // m_desktopFocusChain.value()[i-1] = i; | 697 | // m_desktopFocusChain.value()[i-1] = i; | ||
455 | } | 698 | } | ||
456 | 699 | | |||
700 | if (m_rootInfo) { | ||||
457 | int rows = group.readEntry<int>("Rows", 2); | 701 | int rows = group.readEntry<int>("Rows", 2); | ||
458 | rows = qBound(1, rows, n); | 702 | rows = qBound(1, rows, n); | ||
459 | // avoid weird cases like having 3 rows for 4 desktops, where the last row is unused | 703 | // avoid weird cases like having 3 rows for 4 desktops, where the last row is unused | ||
460 | int columns = n / rows; | 704 | int columns = n / rows; | ||
461 | if (n % rows > 0) { | 705 | if (n % rows > 0) { | ||
462 | columns++; | 706 | columns++; | ||
463 | } | 707 | } | ||
464 | m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, rows, NET::DesktopLayoutCornerTopLeft); | 708 | m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, rows, NET::DesktopLayoutCornerTopLeft); | ||
465 | m_rootInfo->activate(); | 709 | m_rootInfo->activate(); | ||
466 | } | 710 | } | ||
711 | | ||||
467 | s_loadingDesktopSettings = false; | 712 | s_loadingDesktopSettings = false; | ||
713 | m_isLoading = false; | ||||
468 | } | 714 | } | ||
469 | 715 | | |||
470 | void VirtualDesktopManager::save() | 716 | void VirtualDesktopManager::save() | ||
471 | { | 717 | { | ||
472 | if (s_loadingDesktopSettings) { | 718 | if (s_loadingDesktopSettings) { | ||
473 | return; | 719 | return; | ||
474 | } | 720 | } | ||
475 | if (!m_config) { | 721 | if (!m_config) { | ||
Show All 21 Lines | 733 | for (uint i = 1; i <= count(); ++i) { | |||
497 | if (s != defaultvalue) { | 743 | if (s != defaultvalue) { | ||
498 | group.writeEntry(QStringLiteral("Name_%1").arg(i), s); | 744 | group.writeEntry(QStringLiteral("Name_%1").arg(i), s); | ||
499 | } else { | 745 | } else { | ||
500 | QString currentvalue = group.readEntry(QStringLiteral("Name_%1").arg(i), QString()); | 746 | QString currentvalue = group.readEntry(QStringLiteral("Name_%1").arg(i), QString()); | ||
501 | if (currentvalue != defaultvalue) { | 747 | if (currentvalue != defaultvalue) { | ||
502 | group.deleteEntry(QStringLiteral("Name_%1").arg(i)); | 748 | group.deleteEntry(QStringLiteral("Name_%1").arg(i)); | ||
503 | } | 749 | } | ||
504 | } | 750 | } | ||
751 | group.writeEntry(QStringLiteral("Id_%1").arg(i), m_desktops[i-1]->id()); | ||||
505 | } | 752 | } | ||
506 | 753 | | |||
507 | // Save to disk | 754 | // Save to disk | ||
508 | group.sync(); | 755 | group.sync(); | ||
509 | } | 756 | } | ||
510 | 757 | | |||
511 | QString VirtualDesktopManager::defaultName(int desktop) const | 758 | QString VirtualDesktopManager::defaultName(int desktop) const | ||
512 | { | 759 | { | ||
Show All 18 Lines | 775 | while (width * height < count) { | |||
531 | } else { | 778 | } else { | ||
532 | ++height; | 779 | ++height; | ||
533 | } | 780 | } | ||
534 | } | 781 | } | ||
535 | 782 | | |||
536 | m_grid.update(QSize(width, height), orientation, m_desktops); | 783 | m_grid.update(QSize(width, height), orientation, m_desktops); | ||
537 | // TODO: why is there no call to m_rootInfo->setDesktopLayout? | 784 | // TODO: why is there no call to m_rootInfo->setDesktopLayout? | ||
538 | emit layoutChanged(width, height); | 785 | emit layoutChanged(width, height); | ||
786 | emit rowsChanged(height); | ||||
539 | } | 787 | } | ||
540 | 788 | | |||
541 | void VirtualDesktopManager::initShortcuts() | 789 | void VirtualDesktopManager::initShortcuts() | ||
542 | { | 790 | { | ||
543 | initSwitchToShortcuts(); | 791 | initSwitchToShortcuts(); | ||
544 | 792 | | |||
545 | QAction *nextAction = addAction(QStringLiteral("Switch to Next Desktop"), i18n("Switch to Next Desktop"), &VirtualDesktopManager::slotNext); | 793 | QAction *nextAction = addAction(QStringLiteral("Switch to Next Desktop"), i18n("Switch to Next Desktop"), &VirtualDesktopManager::slotNext); | ||
546 | input()->registerTouchpadSwipeShortcut(SwipeDirection::Right, nextAction); | 794 | input()->registerTouchpadSwipeShortcut(SwipeDirection::Right, nextAction); | ||
▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines |
Unrelated change.