mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-24 17:33:50 +03:00
improve activities and desktops WM filtering
This commit is contained in:
parent
c7eb97a879
commit
59a4d63ca6
@ -32,6 +32,9 @@ namespace WindowSystem {
|
||||
AbstractWindowInterface::AbstractWindowInterface(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_activities = new KActivities::Consumer(this);
|
||||
m_currentActivity = m_activities->currentActivity();
|
||||
|
||||
m_corona = qobject_cast<Latte::Corona *>(parent);
|
||||
m_windowsTracker = new Tracker::Windows(this);
|
||||
m_schemesTracker = new Tracker::Schemes(this);
|
||||
@ -50,6 +53,12 @@ AbstractWindowInterface::AbstractWindowInterface(QObject *parent)
|
||||
connect(this, &AbstractWindowInterface::windowChanged, this, [&](WindowId wid) {
|
||||
qDebug() << "WINDOW CHANGED ::: " << wid;
|
||||
});
|
||||
|
||||
connect(m_activities.data(), &KActivities::Consumer::currentActivityChanged, this, [&](const QString &id) {
|
||||
m_currentActivity = id;
|
||||
emit currentActivityChanged();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
AbstractWindowInterface::~AbstractWindowInterface()
|
||||
@ -60,6 +69,16 @@ AbstractWindowInterface::~AbstractWindowInterface()
|
||||
m_windowsTracker->deleteLater();
|
||||
}
|
||||
|
||||
QString AbstractWindowInterface::currentDesktop() const
|
||||
{
|
||||
return m_currentDesktop;
|
||||
}
|
||||
|
||||
QString AbstractWindowInterface::currentActivity() const
|
||||
{
|
||||
return m_currentActivity;
|
||||
}
|
||||
|
||||
Latte::Corona *AbstractWindowInterface::corona()
|
||||
{
|
||||
return m_corona;
|
||||
|
@ -91,8 +91,6 @@ public:
|
||||
virtual WindowId activeWindow() const = 0;
|
||||
virtual WindowInfoWrap requestInfo(WindowId wid) const = 0;
|
||||
virtual WindowInfoWrap requestInfoActive() const = 0;
|
||||
virtual bool isOnCurrentDesktop(WindowId wid) const = 0;
|
||||
virtual bool isOnCurrentActivity(WindowId wid) const = 0;
|
||||
|
||||
virtual void setKeepAbove(const QDialog &dialog, bool above = true) const = 0;
|
||||
virtual void skipTaskBar(const QDialog &dialog) const = 0;
|
||||
@ -116,6 +114,9 @@ public:
|
||||
virtual WindowId winIdFor(QString appId, QRect geometry) const = 0;
|
||||
virtual AppData appDataFor(WindowId wid) const = 0;
|
||||
|
||||
QString currentDesktop() const;
|
||||
QString currentActivity() const;
|
||||
|
||||
Latte::Corona *corona();
|
||||
Tracker::Schemes *schemesTracker();
|
||||
Tracker::Windows *windowsTracker() const;
|
||||
@ -129,6 +130,9 @@ signals:
|
||||
void currentActivityChanged();
|
||||
|
||||
protected:
|
||||
QString m_currentDesktop;
|
||||
QString m_currentActivity;
|
||||
|
||||
QPointer<KActivities::Consumer> m_activities;
|
||||
|
||||
//! Sending too fast plenty of signals for the same window
|
||||
|
@ -385,7 +385,7 @@ WindowInfoWrap Windows::infoFor(const WindowId &wid) const
|
||||
|
||||
bool Windows::inCurrentDesktopActivity(const WindowInfoWrap &winfo)
|
||||
{
|
||||
return (winfo.isValid() && m_wm->isOnCurrentDesktop(winfo.wid()) && m_wm->isOnCurrentActivity(winfo.wid()));
|
||||
return (winfo.isValid() && winfo.isOnDesktop(m_wm->currentDesktop()) && winfo.isOnActivity(m_wm->currentActivity()));
|
||||
}
|
||||
|
||||
bool Windows::intersects(Latte::View *view, const WindowInfoWrap &winfo)
|
||||
|
@ -106,12 +106,6 @@ WaylandInterface::WaylandInterface(QObject *parent)
|
||||
: AbstractWindowInterface(parent)
|
||||
{
|
||||
m_corona = qobject_cast<Latte::Corona *>(parent);
|
||||
|
||||
m_activities = new KActivities::Consumer(this);
|
||||
|
||||
|
||||
connect(m_activities.data(), &KActivities::Consumer::currentActivityChanged
|
||||
, this, &WaylandInterface::currentActivityChanged);
|
||||
}
|
||||
|
||||
WaylandInterface::~WaylandInterface()
|
||||
@ -335,28 +329,6 @@ WindowInfoWrap WaylandInterface::requestInfoActive() const
|
||||
return requestInfo(w->internalId());
|
||||
}
|
||||
|
||||
bool WaylandInterface::isOnCurrentDesktop(WindowId wid) const
|
||||
{
|
||||
if (!m_windowManagement) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WaylandInterface::isOnCurrentActivity(WindowId wid) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
WindowInfoWrap WaylandInterface::requestInfo(WindowId wid) const
|
||||
{
|
||||
WindowInfoWrap winfoWrap;
|
||||
@ -378,9 +350,14 @@ WindowInfoWrap WaylandInterface::requestInfo(WindowId wid) const
|
||||
winfoWrap.setIsFullscreen(w->isFullscreen());
|
||||
winfoWrap.setIsShaded(w->isShaded());
|
||||
winfoWrap.setIsOnAllDesktops(w->isOnAllDesktops());
|
||||
winfoWrap.setIsOnAllActivities(true);
|
||||
winfoWrap.setGeometry(w->geometry());
|
||||
winfoWrap.setHasSkipTaskbar(w->skipTaskbar());
|
||||
winfoWrap.setDisplay(w->title());
|
||||
#if KF5_VERSION_MINOR >= 52
|
||||
winfoWrap.setDesktops(w->plasmaVirtualDesktops());
|
||||
#endif
|
||||
winfoWrap.setActivities(QStringList());
|
||||
}
|
||||
} else {
|
||||
return {};
|
||||
|
@ -70,8 +70,6 @@ public:
|
||||
WindowId activeWindow() const override;
|
||||
WindowInfoWrap requestInfo(WindowId wid) const override;
|
||||
WindowInfoWrap requestInfoActive() const override;
|
||||
bool isOnCurrentDesktop(WindowId wid) const override;
|
||||
bool isOnCurrentActivity(WindowId wid) const override;
|
||||
|
||||
void setKeepAbove(const QDialog &dialog, bool above = true) const override;
|
||||
void skipTaskBar(const QDialog &dialog) const override;
|
||||
@ -128,7 +126,6 @@ private:
|
||||
#if KF5_VERSION_MINOR >= 52
|
||||
//! VirtualDesktopsSupport
|
||||
KWayland::Client::PlasmaVirtualDesktopManagement *m_virtualDesktopManagement{nullptr};
|
||||
QString m_currentDesktop;
|
||||
QStringList m_desktops;
|
||||
#endif
|
||||
|
||||
|
@ -150,13 +150,13 @@ public:
|
||||
inline WindowId wid() const noexcept;
|
||||
inline void setWid(const WindowId &wid) noexcept;
|
||||
|
||||
inline QVariantList desktops() const noexcept;
|
||||
inline void setDesktops(const QVariantList &desktops) noexcept;
|
||||
inline QStringList desktops() const noexcept;
|
||||
inline void setDesktops(const QStringList &desktops) noexcept;
|
||||
|
||||
inline QStringList activities() const noexcept;
|
||||
inline void setActivities(const QStringList &activities) noexcept;
|
||||
|
||||
inline bool isOnDesktop(const QVariant &desktop) const noexcept;
|
||||
inline bool isOnDesktop(const QString &desktop) const noexcept;
|
||||
inline bool isOnActivity(const QString &activity) const noexcept;
|
||||
|
||||
private:
|
||||
@ -181,7 +181,7 @@ private:
|
||||
|
||||
QIcon m_icon;
|
||||
|
||||
QVariantList m_desktops;
|
||||
QStringList m_desktops;
|
||||
QStringList m_activities;
|
||||
};
|
||||
|
||||
@ -420,12 +420,12 @@ inline void WindowInfoWrap::setWid(const WindowId &wid) noexcept
|
||||
m_wid = wid;
|
||||
}
|
||||
|
||||
inline QVariantList WindowInfoWrap::desktops() const noexcept
|
||||
inline QStringList WindowInfoWrap::desktops() const noexcept
|
||||
{
|
||||
return m_desktops;
|
||||
}
|
||||
|
||||
inline void WindowInfoWrap::setDesktops(const QVariantList &desktops) noexcept
|
||||
inline void WindowInfoWrap::setDesktops(const QStringList &desktops) noexcept
|
||||
{
|
||||
m_desktops = desktops;
|
||||
}
|
||||
@ -441,7 +441,7 @@ inline void WindowInfoWrap::setActivities(const QStringList &activities) noexcep
|
||||
}
|
||||
// END: definitions
|
||||
|
||||
inline bool WindowInfoWrap::isOnDesktop(const QVariant &desktop) const noexcept
|
||||
inline bool WindowInfoWrap::isOnDesktop(const QString &desktop) const noexcept
|
||||
{
|
||||
return m_isOnAllDesktops || m_desktops.contains(desktop);
|
||||
}
|
||||
|
@ -47,19 +47,21 @@ namespace WindowSystem {
|
||||
XWindowInterface::XWindowInterface(QObject *parent)
|
||||
: AbstractWindowInterface(parent)
|
||||
{
|
||||
m_activities = new KActivities::Consumer(this);
|
||||
m_currentDesktop = QString(KWindowSystem::self()->currentDesktop());
|
||||
|
||||
connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this, &AbstractWindowInterface::activeWindowChanged);
|
||||
connect(KWindowSystem::self(), &KWindowSystem::windowAdded, this, &AbstractWindowInterface::windowAdded);
|
||||
connect(KWindowSystem::self(), &KWindowSystem::windowRemoved, this, &AbstractWindowInterface::windowRemoved);
|
||||
connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged, this, &XWindowInterface::currentDesktopChanged);
|
||||
|
||||
connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged, this, [&](int desktop) {
|
||||
m_currentDesktop = QString(desktop);
|
||||
emit currentDesktopChanged();
|
||||
});
|
||||
|
||||
connect(KWindowSystem::self()
|
||||
, static_cast<void (KWindowSystem::*)(WId, NET::Properties, NET::Properties2)>
|
||||
(&KWindowSystem::windowChanged)
|
||||
, this, &XWindowInterface::windowChangedProxy);
|
||||
|
||||
connect(m_activities.data(), &KActivities::Consumer::currentActivityChanged, this, &XWindowInterface::currentActivityChanged);
|
||||
}
|
||||
|
||||
XWindowInterface::~XWindowInterface()
|
||||
@ -266,20 +268,6 @@ WindowInfoWrap XWindowInterface::requestInfoActive() const
|
||||
return requestInfo(KWindowSystem::activeWindow());
|
||||
}
|
||||
|
||||
bool XWindowInterface::isOnCurrentDesktop(WindowId wid) const
|
||||
{
|
||||
KWindowInfo winfo(wid.value<WId>(), NET::WMDesktop);
|
||||
return winfo.valid() && winfo.isOnCurrentDesktop();
|
||||
}
|
||||
|
||||
bool XWindowInterface::isOnCurrentActivity(WindowId wid) const
|
||||
{
|
||||
KWindowInfo winfo(wid.value<WId>(), 0, NET::WM2Activities);
|
||||
|
||||
return winfo.valid()
|
||||
&& (winfo.activities().contains(m_activities->currentActivity()) || winfo.activities().empty());
|
||||
}
|
||||
|
||||
WindowInfoWrap XWindowInterface::requestInfo(WindowId wid) const
|
||||
{
|
||||
const KWindowInfo winfo{wid.value<WId>(), NET::WMFrameExtents
|
||||
@ -289,7 +277,8 @@ WindowInfoWrap XWindowInterface::requestInfo(WindowId wid) const
|
||||
| NET::WMState
|
||||
| NET::WMName
|
||||
| NET::WMVisibleName,
|
||||
NET::WM2WindowClass};
|
||||
NET::WM2WindowClass
|
||||
| NET::WM2Activities};
|
||||
|
||||
//! update desktop id
|
||||
|
||||
@ -311,10 +300,14 @@ WindowInfoWrap XWindowInterface::requestInfo(WindowId wid) const
|
||||
winfoWrap.setIsFullscreen(winfo.hasState(NET::FullScreen));
|
||||
winfoWrap.setIsShaded(winfo.hasState(NET::Shaded));
|
||||
winfoWrap.setIsOnAllDesktops(winfo.onAllDesktops());
|
||||
winfoWrap.setIsOnAllActivities(winfo.activities().empty());
|
||||
winfoWrap.setGeometry(winfo.frameGeometry());
|
||||
winfoWrap.setIsKeepAbove(winfo.hasState(NET::KeepAbove));
|
||||
winfoWrap.setHasSkipTaskbar(winfo.hasState(NET::SkipTaskbar));
|
||||
winfoWrap.setDisplay(winfo.visibleName());
|
||||
|
||||
winfoWrap.setDesktops({QString(winfo.desktop())});
|
||||
winfoWrap.setActivities(winfo.activities());
|
||||
} else if (m_desktopId == wid) {
|
||||
winfoWrap.setIsValid(true);
|
||||
winfoWrap.setIsPlasmaDesktop(true);
|
||||
@ -500,7 +493,7 @@ void XWindowInterface::requestToggleMinimized(WindowId wid) const
|
||||
}
|
||||
|
||||
if (wInfo.isMinimized()) {
|
||||
bool onCurrent = isOnCurrentDesktop(wid);
|
||||
bool onCurrent = wInfo.isOnDesktop(m_currentDesktop);
|
||||
|
||||
KWindowSystem::unminimizeWindow(wid.toUInt());
|
||||
|
||||
@ -619,7 +612,7 @@ void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::P
|
||||
//! ignore when the user presses a key, or a window is sending X events etc.
|
||||
//! without needing to (e.g. Firefox, https://bugzilla.mozilla.org/show_bug.cgi?id=1389953)
|
||||
//! NET::WM2UserTime, NET::WM2IconPixmap etc....
|
||||
if (prop1 == 0) {
|
||||
if (prop1 == 0 && !(prop2 & NET::WM2Activities)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -629,7 +622,8 @@ void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::P
|
||||
&& !(prop1 & NET::WMGeometry)
|
||||
&& !(prop1 & NET::ActiveWindow)
|
||||
&& !(prop1 & NET::WMDesktop)
|
||||
&& !(prop1 & (NET::WMName | NET::WMVisibleName)) ) {
|
||||
&& !(prop1 & (NET::WMName | NET::WMVisibleName)
|
||||
&& !(prop2 & NET::WM2Activities)) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -54,8 +54,6 @@ public:
|
||||
WindowId activeWindow() const override;
|
||||
WindowInfoWrap requestInfo(WindowId wid) const override;
|
||||
WindowInfoWrap requestInfoActive() const override;
|
||||
bool isOnCurrentDesktop(WindowId wid) const override;
|
||||
bool isOnCurrentActivity(WindowId wid) const override;
|
||||
|
||||
void setKeepAbove(const QDialog &dialog, bool above = true) const override;
|
||||
void skipTaskBar(const QDialog &dialog) const override;
|
||||
|
Loading…
Reference in New Issue
Block a user