1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-02-05 05:47:26 +03:00

x11:validate windows added before accepting them

--this way when Plasma Desktop is reloaded or during
startup after Latte is loaded then Plasma desktop
window is still totally ignored.
This commit is contained in:
Michail Vourlakos 2020-03-05 21:20:25 +02:00
parent 5cc6ce5484
commit b82d9dfdbe
2 changed files with 28 additions and 7 deletions

View File

@ -51,9 +51,10 @@ XWindowInterface::XWindowInterface(QObject *parent)
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::windowAdded, this, &XWindowInterface::windowAddedProxy);
connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged, this, [&](int desktop) {
m_currentDesktop = QString(desktop);
emit currentDesktopChanged();
@ -66,8 +67,7 @@ XWindowInterface::XWindowInterface(QObject *parent)
for(auto wid : KWindowSystem::self()->windows()) {
emit windowAdded(wid);
windowChangedProxy(wid,0,0);
windowAddedProxy(wid);
}
}
@ -681,7 +681,7 @@ bool XWindowInterface::isValidWindow(const KWindowInfo &winfo) const
return !(isMenu || isDock);
}
void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2)
bool XWindowInterface::isAcceptableWindow(WId wid)
{
const KWindowInfo info(wid, NET::WMGeometry, NET::WM2WindowClass);
@ -689,22 +689,41 @@ void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::P
//! ignored windows do not trackd
if (m_ignoredWindows.contains(wid) || m_plasmaIgnoredWindows.contains(wid)) {
return;
return false;
}
if (winClass == QLatin1String("plasmashell")) {
if (isPlasmaPanel(info.geometry()) || isFullScreenWindow(wid)) {
registerPlasmaIgnoredWindow(wid);
return;
return false;
}
} else if ((winClass == QLatin1String("latte-dock"))
|| (winClass == QLatin1String("ksmserver"))) {
if (isFullScreenWindow(wid)) {
registerPlasmaIgnoredWindow(wid);
return;
return false;
}
}
return true;
}
void XWindowInterface::windowAddedProxy(WId wid)
{
if (!isAcceptableWindow(wid)) {
return;
}
emit windowAdded(wid);
considerWindowChanged(wid);
}
void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2)
{
if (!isAcceptableWindow(wid)) {
return;
}
//! accept only NET::Properties events,
//! 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)

View File

@ -86,6 +86,8 @@ private:
bool isValidWindow(const KWindowInfo &winfo) const;
bool isFullScreenWindow(WindowId wid) const;
bool isAcceptableWindow(WId wid);
void windowAddedProxy(WId wid);
void windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2);
QUrl windowUrl(WindowId wid) const;