mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-27 06:03:51 +03:00
support VirtualDesktops for kwayland>=5.52
--This of course needs Plasma>=5.15 BUG: 398106
This commit is contained in:
parent
61e9e629c5
commit
a8a19bb550
@ -300,6 +300,19 @@ void Corona::setupWaylandIntegration()
|
||||
}
|
||||
});
|
||||
|
||||
#if KF5_VERSION_MINOR >= 52
|
||||
QObject::connect(registry, &KWayland::Client::Registry::plasmaVirtualDesktopManagementAnnounced,
|
||||
[this, registry] (quint32 name, quint32 version) {
|
||||
KWayland::Client::PlasmaVirtualDesktopManagement *vdm = registry->createPlasmaVirtualDesktopManagement(name, version, this);
|
||||
|
||||
WindowSystem::WaylandInterface *wI = qobject_cast<WindowSystem::WaylandInterface *>(m_wm);
|
||||
|
||||
if (wI) {
|
||||
wI->initVirtualDesktopManagement(vdm);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
|
||||
registry->setup();
|
||||
connection->roundtrip();
|
||||
}
|
||||
@ -722,13 +735,13 @@ void Corona::closeApplication()
|
||||
{
|
||||
//! this code must be called asynchronously because it is called
|
||||
//! also from qml (Settings window).
|
||||
QTimer::singleShot(5, [this]() {
|
||||
QTimer::singleShot(300, [this]() {
|
||||
m_layoutsManager->hideLatteSettingsDialog();
|
||||
m_layoutsManager->synchronizer()->hideAllViews();
|
||||
});
|
||||
|
||||
//! give the time for the views to hide themselves
|
||||
QTimer::singleShot(500, [this]() {
|
||||
QTimer::singleShot(800, [this]() {
|
||||
qGuiApp->quit();
|
||||
});
|
||||
}
|
||||
|
@ -221,7 +221,10 @@ SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona)
|
||||
});
|
||||
|
||||
connect(aboutAction, &QAction::triggered, m_corona, &Latte::Corona::aboutApplication);
|
||||
connect(quitAction, &QAction::triggered, m_corona, &Latte::Corona::closeApplication);
|
||||
connect(quitAction, &QAction::triggered, this, [&]() {
|
||||
close();
|
||||
m_corona->closeApplication();
|
||||
});
|
||||
|
||||
//! update all layouts view when runningActivities changed. This way we update immediately
|
||||
//! the running Activities in Activities checkboxes which are shown as bold
|
||||
|
@ -39,6 +39,10 @@
|
||||
#include <KWindowInfo>
|
||||
#include <KWayland/Client/surface.h>
|
||||
|
||||
#if KF5_VERSION_MINOR >= 52
|
||||
#include <KWayland/Client/plasmavirtualdesktop.h>
|
||||
#endif
|
||||
|
||||
// X11
|
||||
#include <NETWM>
|
||||
|
||||
@ -120,18 +124,78 @@ void WaylandInterface::init()
|
||||
|
||||
void WaylandInterface::initWindowManagement(KWayland::Client::PlasmaWindowManagement *windowManagement)
|
||||
{
|
||||
if (m_windowManagement == windowManagement) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_windowManagement = windowManagement;
|
||||
|
||||
connect(m_windowManagement, &PlasmaWindowManagement::windowCreated, this, &WaylandInterface::windowCreatedProxy);
|
||||
connect(m_windowManagement, &PlasmaWindowManagement::activeWindowChanged, this, [&]() noexcept {
|
||||
auto w = m_windowManagement->activeWindow();
|
||||
if (!w || (w && (!isPlasmaDesktop(w) && w->appId() != QLatin1String("latte-dock")))) {
|
||||
emit activeWindowChanged(w ? w->internalId() : 0);
|
||||
}
|
||||
auto w = m_windowManagement->activeWindow();
|
||||
if (!w || (w && (!isPlasmaDesktop(w) && w->appId() != QLatin1String("latte-dock")))) {
|
||||
emit activeWindowChanged(w ? w->internalId() : 0);
|
||||
}
|
||||
|
||||
}, Qt::QueuedConnection);
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
#if KF5_VERSION_MINOR >= 52
|
||||
void WaylandInterface::initVirtualDesktopManagement(KWayland::Client::PlasmaVirtualDesktopManagement *virtualDesktopManagement)
|
||||
{
|
||||
if (m_virtualDesktopManagement == virtualDesktopManagement) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_virtualDesktopManagement = virtualDesktopManagement;
|
||||
|
||||
connect(m_virtualDesktopManagement, &KWayland::Client::PlasmaVirtualDesktopManagement::desktopCreated, this,
|
||||
[this](const QString &id, quint32 position) {
|
||||
addDesktop(id, position);
|
||||
});
|
||||
|
||||
connect(m_virtualDesktopManagement, &KWayland::Client::PlasmaVirtualDesktopManagement::desktopRemoved, this,
|
||||
[this](const QString &id) {
|
||||
m_desktops.removeAll(id);
|
||||
|
||||
if (m_currentDesktop == id) {
|
||||
setCurrentDesktop(QString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void WaylandInterface::addDesktop(const QString &id, quint32 position)
|
||||
{
|
||||
if (m_desktops.contains(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_desktops.append(id);
|
||||
|
||||
const KWayland::Client::PlasmaVirtualDesktop *desktop = m_virtualDesktopManagement->getVirtualDesktop(id);
|
||||
|
||||
QObject::connect(desktop, &KWayland::Client::PlasmaVirtualDesktop::activated, this,
|
||||
[desktop, this]() {
|
||||
setCurrentDesktop(desktop->id());
|
||||
}
|
||||
);
|
||||
|
||||
if (desktop->isActive()) {
|
||||
setCurrentDesktop(id);
|
||||
}
|
||||
}
|
||||
|
||||
void WaylandInterface::setCurrentDesktop(QString desktop)
|
||||
{
|
||||
if (m_currentDesktop == desktop) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_currentDesktop = desktop;
|
||||
emit currentDesktopChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
KWayland::Client::PlasmaShell *WaylandInterface::waylandCoronaInterface() const
|
||||
{
|
||||
return m_corona->waylandCoronaInterface();
|
||||
@ -150,18 +214,18 @@ void WaylandInterface::setViewStruts(QWindow &view, const QRect &rect, Plasma::T
|
||||
auto w = m_ghostWindows[view.winId()];
|
||||
|
||||
switch (location) {
|
||||
case Plasma::Types::TopEdge:
|
||||
case Plasma::Types::BottomEdge:
|
||||
w->setGeometry({rect.x() + rect.width() / 2, rect.y(), 1, rect.height()});
|
||||
break;
|
||||
case Plasma::Types::TopEdge:
|
||||
case Plasma::Types::BottomEdge:
|
||||
w->setGeometry({rect.x() + rect.width() / 2, rect.y(), 1, rect.height()});
|
||||
break;
|
||||
|
||||
case Plasma::Types::LeftEdge:
|
||||
case Plasma::Types::RightEdge:
|
||||
w->setGeometry({rect.x(), rect.y() + rect.height() / 2, rect.width(), 1});
|
||||
break;
|
||||
case Plasma::Types::LeftEdge:
|
||||
case Plasma::Types::RightEdge:
|
||||
w->setGeometry({rect.x(), rect.y() + rect.height() / 2, rect.width(), 1});
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@ -207,24 +271,24 @@ void WaylandInterface::slideWindow(QWindow &view, AbstractWindowInterface::Slide
|
||||
auto slideLocation = KWindowEffects::NoEdge;
|
||||
|
||||
switch (location) {
|
||||
case Slide::Top:
|
||||
slideLocation = KWindowEffects::TopEdge;
|
||||
break;
|
||||
case Slide::Top:
|
||||
slideLocation = KWindowEffects::TopEdge;
|
||||
break;
|
||||
|
||||
case Slide::Bottom:
|
||||
slideLocation = KWindowEffects::BottomEdge;
|
||||
break;
|
||||
case Slide::Bottom:
|
||||
slideLocation = KWindowEffects::BottomEdge;
|
||||
break;
|
||||
|
||||
case Slide::Left:
|
||||
slideLocation = KWindowEffects::LeftEdge;
|
||||
break;
|
||||
case Slide::Left:
|
||||
slideLocation = KWindowEffects::LeftEdge;
|
||||
break;
|
||||
|
||||
case Slide::Right:
|
||||
slideLocation = KWindowEffects::RightEdge;
|
||||
break;
|
||||
case Slide::Right:
|
||||
slideLocation = KWindowEffects::RightEdge;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
KWindowEffects::slideWindow(view.winId(), slideLocation, -1);
|
||||
@ -244,10 +308,10 @@ void WaylandInterface::setEdgeStateFor(QWindow *view, bool active) const
|
||||
}
|
||||
|
||||
if (window->parentView()->surface() && window->parentView()->visibility()
|
||||
&& (window->parentView()->visibility()->mode() == Types::DodgeActive
|
||||
|| window->parentView()->visibility()->mode() == Types::DodgeMaximized
|
||||
|| window->parentView()->visibility()->mode() == Types::DodgeAllWindows
|
||||
|| window->parentView()->visibility()->mode() == Types::AutoHide)) {
|
||||
&& (window->parentView()->visibility()->mode() == Types::DodgeActive
|
||||
|| window->parentView()->visibility()->mode() == Types::DodgeMaximized
|
||||
|| window->parentView()->visibility()->mode() == Types::DodgeAllWindows
|
||||
|| window->parentView()->visibility()->mode() == Types::AutoHide)) {
|
||||
if (active) {
|
||||
window->showWithMask();
|
||||
window->surface()->requestHideAutoHidingPanel();
|
||||
@ -298,26 +362,23 @@ WindowInfoWrap WaylandInterface::requestInfoActive() const
|
||||
bool WaylandInterface::isOnCurrentDesktop(WindowId wid) const
|
||||
{
|
||||
if (!m_windowManagement) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
auto it = std::find_if(m_windowManagement->windows().constBegin(), m_windowManagement->windows().constEnd(), [&wid](PlasmaWindow * w) noexcept {
|
||||
return w->isValid() && w->internalId() == wid;
|
||||
});
|
||||
#if KF5_VERSION_MINOR >= 52
|
||||
auto window = windowFor(wid);
|
||||
if (window) {
|
||||
QStringList wvds = window->plasmaVirtualDesktops();
|
||||
return (wvds.isEmpty() || (!wvds.isEmpty() && wvds.contains(m_currentDesktop)));
|
||||
}
|
||||
#endif
|
||||
|
||||
//qDebug() << "desktop:" << (it != m_windowManagement->windows().constEnd() ? (*it)->virtualDesktop() : -1) << KWindowSystem::currentDesktop();
|
||||
//return true;
|
||||
return it != m_windowManagement->windows().constEnd() && ((*it)->virtualDesktop() == KWindowSystem::currentDesktop() || (*it)->isOnAllDesktops());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WaylandInterface::isOnCurrentActivity(WindowId wid) const
|
||||
{
|
||||
auto it = std::find_if(m_windowManagement->windows().constBegin(), m_windowManagement->windows().constEnd(), [&wid](PlasmaWindow * w) noexcept {
|
||||
return w->isValid() && w->internalId() == wid;
|
||||
});
|
||||
|
||||
//TODO: Not yet implemented
|
||||
return it != m_windowManagement->windows().constEnd() && true;
|
||||
return true;
|
||||
}
|
||||
|
||||
WindowInfoWrap WaylandInterface::requestInfo(WindowId wid) const
|
||||
@ -353,8 +414,8 @@ WindowInfoWrap WaylandInterface::requestInfo(WindowId wid) const
|
||||
KWayland::Client::PlasmaWindow *WaylandInterface::windowFor(WindowId wid) const
|
||||
{
|
||||
auto it = std::find_if(m_windowManagement->windows().constBegin(), m_windowManagement->windows().constEnd(), [&wid](PlasmaWindow * w) noexcept {
|
||||
return w->isValid() && w->internalId() == wid;
|
||||
});
|
||||
return w->isValid() && w->internalId() == wid;
|
||||
});
|
||||
|
||||
if (it == m_windowManagement->windows().constEnd()) {
|
||||
return nullptr;
|
||||
@ -460,18 +521,30 @@ void WaylandInterface::windowCreatedProxy(KWayland::Client::PlasmaWindow *w)
|
||||
emit windowRemoved(win->internalId());
|
||||
});
|
||||
|
||||
connect(w, SIGNAL(activeChanged()), mapper, SLOT(map()));
|
||||
connect(w, SIGNAL(fullscreenChanged()), mapper, SLOT(map()));
|
||||
connect(w, SIGNAL(geometryChanged()), mapper, SLOT(map()));
|
||||
connect(w, SIGNAL(maximizedChanged()), mapper, SLOT(map()));
|
||||
connect(w, SIGNAL(minimizedChanged()), mapper, SLOT(map()));
|
||||
connect(w, SIGNAL(shadedChanged()), mapper, SLOT(map()));
|
||||
connect(w, SIGNAL(skipTaskbarChanged()), mapper, SLOT(map()));
|
||||
connect(w, SIGNAL(onAllDesktopsChanged()), mapper, SLOT(map()));
|
||||
connect(w, SIGNAL(virtualDesktopChanged()), mapper, SLOT(map()));
|
||||
connect(w, SIGNAL(activeChanged()), mapper, SLOT(map()) );
|
||||
connect(w, SIGNAL(fullscreenChanged()), mapper, SLOT(map()) );
|
||||
connect(w, SIGNAL(geometryChanged()), mapper, SLOT(map()) );
|
||||
connect(w, SIGNAL(maximizedChanged()), mapper, SLOT(map()) );
|
||||
connect(w, SIGNAL(minimizedChanged()), mapper, SLOT(map()) );
|
||||
connect(w, SIGNAL(shadedChanged()), mapper, SLOT(map()) );
|
||||
connect(w, SIGNAL(skipTaskbarChanged()), mapper, SLOT(map()) );
|
||||
connect(w, SIGNAL(onAllDesktopsChanged()), mapper, SLOT(map()) );
|
||||
connect(w, SIGNAL(virtualDesktopChanged()), mapper, SLOT(map()) );
|
||||
|
||||
#if KF5_VERSION_MINOR >= 52
|
||||
connect(w, &KWayland::Client::PlasmaWindow::plasmaVirtualDesktopEntered, this,
|
||||
[w, this] {
|
||||
mapper->map(w);
|
||||
});
|
||||
|
||||
connect(w, &KWayland::Client::PlasmaWindow::plasmaVirtualDesktopLeft, this,
|
||||
[w, this] {
|
||||
mapper->map(w);
|
||||
});
|
||||
#endif
|
||||
|
||||
connect(mapper, static_cast<void (QSignalMapper::*)(QObject *)>(&QSignalMapper::mapped)
|
||||
, this, [&](QObject * w) noexcept {
|
||||
, this, [&](QObject * w) noexcept {
|
||||
//qDebug() << "window changed:" << qobject_cast<PlasmaWindow *>(w)->appId();
|
||||
PlasmaWindow *pW = qobject_cast<PlasmaWindow*>(w);
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define WAYLANDINTERFACE_H
|
||||
|
||||
// local
|
||||
#include <config-latte.h>
|
||||
#include "abstractwindowinterface.h"
|
||||
#include "windowinfowrap.h"
|
||||
|
||||
@ -88,6 +89,11 @@ public:
|
||||
|
||||
void initWindowManagement(KWayland::Client::PlasmaWindowManagement *windowManagement);
|
||||
|
||||
#if KF5_VERSION_MINOR >= 52
|
||||
//! VirtualDesktopsSupport
|
||||
void initVirtualDesktopManagement(KWayland::Client::PlasmaVirtualDesktopManagement *virtualDesktopManagement);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void init();
|
||||
bool isValidWindow(const KWayland::Client::PlasmaWindow *w) const;
|
||||
@ -96,6 +102,13 @@ private:
|
||||
KWayland::Client::PlasmaWindow *windowFor(WindowId wid) const;
|
||||
KWayland::Client::PlasmaShell *waylandCoronaInterface() const;
|
||||
|
||||
#if KF5_VERSION_MINOR >= 52
|
||||
//! VirtualDesktopsSupport
|
||||
void setCurrentDesktop(QString desktop);
|
||||
void addDesktop(const QString &id, quint32 position);
|
||||
#endif
|
||||
|
||||
private:
|
||||
QSignalMapper *mapper{nullptr};
|
||||
|
||||
friend class Private::GhostWindow;
|
||||
@ -103,6 +116,13 @@ private:
|
||||
|
||||
KWayland::Client::PlasmaWindowManagement *m_windowManagement{nullptr};
|
||||
|
||||
#if KF5_VERSION_MINOR >= 52
|
||||
//! VirtualDesktopsSupport
|
||||
KWayland::Client::PlasmaVirtualDesktopManagement *m_virtualDesktopManagement{nullptr};
|
||||
QString m_currentDesktop;
|
||||
QStringList m_desktops;
|
||||
#endif
|
||||
|
||||
Latte::Corona *m_corona{nullptr};
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user