VirtualDesktops: POC per-output desktops
This commit is contained in:
parent
2fb6271c02
commit
128dfe09fd
3 changed files with 56 additions and 2 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include "virtualdesktops.h"
|
#include "virtualdesktops.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "wayland/plasmavirtualdesktop.h"
|
#include "wayland/plasmavirtualdesktop.h"
|
||||||
|
#include "workspace.h"
|
||||||
// KDE
|
// KDE
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KGlobalAccel>
|
#include <KGlobalAccel>
|
||||||
|
@ -519,6 +520,15 @@ VirtualDesktop *VirtualDesktopManager::currentDesktop() const
|
||||||
return m_current;
|
return m_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VirtualDesktop *VirtualDesktopManager::currentDesktop(Output *output) const
|
||||||
|
{
|
||||||
|
if (!m_currentForOutput.contains(output)) {
|
||||||
|
qInfo("Output not in list :/");
|
||||||
|
return m_current;
|
||||||
|
}
|
||||||
|
return m_currentForOutput[output];
|
||||||
|
}
|
||||||
|
|
||||||
bool VirtualDesktopManager::setCurrent(uint newDesktop)
|
bool VirtualDesktopManager::setCurrent(uint newDesktop)
|
||||||
{
|
{
|
||||||
if (newDesktop < 1 || newDesktop > count()) {
|
if (newDesktop < 1 || newDesktop > count()) {
|
||||||
|
@ -538,6 +548,33 @@ bool VirtualDesktopManager::setCurrent(VirtualDesktop *newDesktop)
|
||||||
VirtualDesktop *oldDesktop = currentDesktop();
|
VirtualDesktop *oldDesktop = currentDesktop();
|
||||||
m_current = newDesktop;
|
m_current = newDesktop;
|
||||||
Q_EMIT currentChanged(oldDesktop, newDesktop);
|
Q_EMIT currentChanged(oldDesktop, newDesktop);
|
||||||
|
for (auto *output : Workspace::self()->outputs()) {
|
||||||
|
m_currentForOutput[output] = m_current;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VirtualDesktopManager::setCurrentForOutput(uint newDesktop, Output *targetOutput)
|
||||||
|
{
|
||||||
|
if (newDesktop < 1 || newDesktop > count()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
auto d = desktopForX11Id(newDesktop);
|
||||||
|
Q_ASSERT(d);
|
||||||
|
return setCurrentForOutput(d, targetOutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VirtualDesktopManager::setCurrentForOutput(VirtualDesktop *newDesktop, Output *targetOutput)
|
||||||
|
{
|
||||||
|
Q_ASSERT(newDesktop);
|
||||||
|
Q_ASSERT(targetOutput);
|
||||||
|
Q_ASSERT(m_currentForOutput.contains(targetOutput));
|
||||||
|
if (m_currentForOutput[targetOutput] == newDesktop) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
VirtualDesktop *oldDesktop = m_currentForOutput[targetOutput];
|
||||||
|
m_currentForOutput[targetOutput] = newDesktop;
|
||||||
|
Q_EMIT currentChanged(oldDesktop, newDesktop);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,6 +631,12 @@ void VirtualDesktopManager::setCount(uint count)
|
||||||
updateLayout();
|
updateLayout();
|
||||||
updateRootInfo();
|
updateRootInfo();
|
||||||
|
|
||||||
|
// TODO: Figure out a better place
|
||||||
|
qInfo("setCount()");
|
||||||
|
for (Output *output : Workspace::self()->outputs()) {
|
||||||
|
m_currentForOutput[output] = m_current;
|
||||||
|
}
|
||||||
|
|
||||||
if (!s_loadingDesktopSettings) {
|
if (!s_loadingDesktopSettings) {
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
@ -883,7 +926,9 @@ void VirtualDesktopManager::slotSwitchTo()
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setCurrent(i);
|
qInfo("Active output: %p", Workspace::self()->activeOutput());
|
||||||
|
qInfo("Setting to desktop %d on output %p", i, Workspace::self()->activeOutput());
|
||||||
|
setCurrentForOutput(i, Workspace::self()->activeOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VirtualDesktopManager::setNavigationWrappingAround(bool enabled)
|
void VirtualDesktopManager::setNavigationWrappingAround(bool enabled)
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace KWin
|
||||||
|
|
||||||
class Options;
|
class Options;
|
||||||
class PlasmaVirtualDesktopManagementInterface;
|
class PlasmaVirtualDesktopManagementInterface;
|
||||||
|
class Output;
|
||||||
|
|
||||||
class KWIN_EXPORT VirtualDesktop : public QObject
|
class KWIN_EXPORT VirtualDesktop : public QObject
|
||||||
{
|
{
|
||||||
|
@ -197,6 +198,8 @@ public:
|
||||||
*/
|
*/
|
||||||
VirtualDesktop *currentDesktop() const;
|
VirtualDesktop *currentDesktop() const;
|
||||||
|
|
||||||
|
VirtualDesktop *currentDesktop(Output *output) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves to the desktop through the algorithm described by Direction.
|
* Moves to the desktop through the algorithm described by Direction.
|
||||||
* @param wrap If @c true wraps around to the other side of the layout
|
* @param wrap If @c true wraps around to the other side of the layout
|
||||||
|
@ -352,6 +355,9 @@ public Q_SLOTS:
|
||||||
*/
|
*/
|
||||||
bool setCurrent(VirtualDesktop *current);
|
bool setCurrent(VirtualDesktop *current);
|
||||||
|
|
||||||
|
bool setCurrentForOutput(VirtualDesktop *current, Output *output);
|
||||||
|
bool setCurrentForOutput(uint current, Output *output);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the layout to a new number of rows. The number of columns will be calculated accordingly
|
* Updates the layout to a new number of rows. The number of columns will be calculated accordingly
|
||||||
*/
|
*/
|
||||||
|
@ -515,6 +521,7 @@ private:
|
||||||
|
|
||||||
QList<VirtualDesktop *> m_desktops;
|
QList<VirtualDesktop *> m_desktops;
|
||||||
QPointer<VirtualDesktop> m_current;
|
QPointer<VirtualDesktop> m_current;
|
||||||
|
QHash<Output *, QPointer<VirtualDesktop>> m_currentForOutput;
|
||||||
quint32 m_rows = 2;
|
quint32 m_rows = 2;
|
||||||
bool m_navigationWrapsAround;
|
bool m_navigationWrapsAround;
|
||||||
VirtualDesktopGrid m_grid;
|
VirtualDesktopGrid m_grid;
|
||||||
|
|
|
@ -834,7 +834,9 @@ bool Window::isOnDesktop(VirtualDesktop *desktop) const
|
||||||
|
|
||||||
bool Window::isOnCurrentDesktop() const
|
bool Window::isOnCurrentDesktop() const
|
||||||
{
|
{
|
||||||
return isOnDesktop(VirtualDesktopManager::self()->currentDesktop());
|
bool is = isOnDesktop(VirtualDesktopManager::self()->currentDesktop(output()));
|
||||||
|
qInfo("isOnDesktop %d", is);
|
||||||
|
return isOnDesktop(VirtualDesktopManager::self()->currentDesktop(output()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ShadeMode Window::shadeMode() const
|
ShadeMode Window::shadeMode() const
|
||||||
|
|
Loading…
Reference in a new issue