1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-26 23:21:37 +03:00

under wayland recognize plasma shell better

--the plasma desktop is now identified as the
org.kde.plasmashell window that has the size
of a QScreen->geometry()
This commit is contained in:
Michail Vourlakos 2019-02-11 19:40:24 +02:00
parent 68805c4a98
commit 14afda3dc1
2 changed files with 31 additions and 10 deletions

View File

@ -123,7 +123,7 @@ void WaylandInterface::initWindowManagement(KWayland::Client::PlasmaWindowManage
connect(m_windowManagement, &PlasmaWindowManagement::windowCreated, this, &WaylandInterface::windowCreatedProxy); connect(m_windowManagement, &PlasmaWindowManagement::windowCreated, this, &WaylandInterface::windowCreatedProxy);
connect(m_windowManagement, &PlasmaWindowManagement::activeWindowChanged, this, [&]() noexcept { connect(m_windowManagement, &PlasmaWindowManagement::activeWindowChanged, this, [&]() noexcept {
auto w = m_windowManagement->activeWindow(); auto w = m_windowManagement->activeWindow();
if (!w || (w && w->appId() != QLatin1String("latte-dock"))) { if (!w || (w && (!isPlasmaDesktop(w) && w->appId() != QLatin1String("latte-dock")))) {
emit activeWindowChanged(w ? w->internalId() : 0); emit activeWindowChanged(w ? w->internalId() : 0);
} }
@ -331,7 +331,11 @@ WindowInfoWrap WaylandInterface::requestInfo(WindowId wid) const
auto w = windowFor(wid); auto w = windowFor(wid);
if (w) { if (w) {
if (isValidWindow(w)) { if (isPlasmaDesktop(w)) {
winfoWrap.setIsValid(true);
winfoWrap.setIsPlasmaDesktop(true);
winfoWrap.setWid(wid);
} else if (isValidWindow(w)) {
winfoWrap.setIsValid(true); winfoWrap.setIsValid(true);
winfoWrap.setWid(wid); winfoWrap.setWid(wid);
winfoWrap.setIsActive(w->isActive()); winfoWrap.setIsActive(w->isActive());
@ -342,10 +346,6 @@ WindowInfoWrap WaylandInterface::requestInfo(WindowId wid) const
winfoWrap.setIsShaded(w->isShaded()); winfoWrap.setIsShaded(w->isShaded());
winfoWrap.setGeometry(w->geometry()); winfoWrap.setGeometry(w->geometry());
winfoWrap.setHasSkipTaskbar(w->skipTaskbar()); winfoWrap.setHasSkipTaskbar(w->skipTaskbar());
} else if (w->appId() == QLatin1String("org.kde.plasmashell")) {
winfoWrap.setIsValid(true);
winfoWrap.setIsPlasmaDesktop(true);
winfoWrap.setWid(wid);
} }
} else { } else {
return {}; return {};
@ -398,14 +398,34 @@ void WaylandInterface::requestToggleMaximized(WindowId wid) const
} }
} }
inline bool WaylandInterface::isValidWindow(const KWayland::Client::PlasmaWindow *w) const bool WaylandInterface::isPlasmaDesktop(const KWayland::Client::PlasmaWindow *w) const
{ {
if (!w || (w->appId() != QLatin1String("org.kde.plasmashell"))) {
return false;
}
bool hasScreenGeometry{false};
foreach(auto scr, qGuiApp->screens()) {
if (!w->geometry().isEmpty() && w->geometry() == scr->geometry()) {
hasScreenGeometry = true;
break;
}
}
return hasScreenGeometry;
}
bool WaylandInterface::isValidWindow(const KWayland::Client::PlasmaWindow *w) const
{
//! DEPRECATED comment is case we must reenable this
//! because wayland does not have any way yet to identify the window type //! because wayland does not have any way yet to identify the window type
//! a trick is to just consider windows as valid when they can be shown in the //! a trick is to just consider windows as valid when they can be shown in the
//! taskbar. Of course that creates issues with plasma native dialogs //! taskbar. Of course that creates issues with plasma native dialogs
//! e.g. widgets explorer, Activities etc. that are not used to hide //! e.g. widgets explorer, Activities etc. that are not used to hide
//! the dodge views appropriately //! the dodge views appropriately
return w->isValid() && w->appId()!=QLatin1String("latte-dock") && !w->skipTaskbar();
return w->isValid() && !isPlasmaDesktop(w) && w->appId()!=QLatin1String("latte-dock");// && !w->skipTaskbar();
} }
void WaylandInterface::windowCreatedProxy(KWayland::Client::PlasmaWindow *w) void WaylandInterface::windowCreatedProxy(KWayland::Client::PlasmaWindow *w)
@ -437,7 +457,7 @@ void WaylandInterface::windowCreatedProxy(KWayland::Client::PlasmaWindow *w)
//qDebug() << "window changed:" << qobject_cast<PlasmaWindow *>(w)->appId(); //qDebug() << "window changed:" << qobject_cast<PlasmaWindow *>(w)->appId();
PlasmaWindow *pW = qobject_cast<PlasmaWindow*>(w); PlasmaWindow *pW = qobject_cast<PlasmaWindow*>(w);
if (pW && pW->appId() != QLatin1String("latte-dock")) { if (pW && !isPlasmaDesktop(pW) && pW->appId() != QLatin1String("latte-dock")) {
emit windowChanged(pW->internalId()); emit windowChanged(pW->internalId());
} }
}); });

View File

@ -88,7 +88,8 @@ public:
private: private:
void init(); void init();
inline bool isValidWindow(const KWayland::Client::PlasmaWindow *w) const; bool isValidWindow(const KWayland::Client::PlasmaWindow *w) const;
bool isPlasmaDesktop(const KWayland::Client::PlasmaWindow *w) const;
void windowCreatedProxy(KWayland::Client::PlasmaWindow *w); void windowCreatedProxy(KWayland::Client::PlasmaWindow *w);
KWayland::Client::PlasmaWindow *windowFor(WindowId wid) const; KWayland::Client::PlasmaWindow *windowFor(WindowId wid) const;
KWayland::Client::PlasmaShell *waylandCoronaInterface() const; KWayland::Client::PlasmaShell *waylandCoronaInterface() const;