mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-21 10:50:30 +03:00
new heuristic to identify plasma desktop window
This commit is contained in:
parent
54f1e3576e
commit
a03655f176
@ -377,12 +377,12 @@ bool Windows::intersects(Latte::View *view, const WindowInfoWrap &winfo)
|
||||
|
||||
bool Windows::isActive(const WindowInfoWrap &winfo)
|
||||
{
|
||||
return (winfo.isValid() && winfo.isActive() && !winfo.isMinimized());
|
||||
return (winfo.isValid() && winfo.isActive() && !winfo.isPlasmaDesktop() && !winfo.isMinimized());
|
||||
}
|
||||
|
||||
bool Windows::isActiveInViewScreen(Latte::View *view, const WindowInfoWrap &winfo)
|
||||
{
|
||||
return (winfo.isValid() && winfo.isActive() && !winfo.isMinimized()
|
||||
return (winfo.isValid() && winfo.isActive() && !winfo.isPlasmaDesktop() && !winfo.isMinimized()
|
||||
&& m_views[view]->availableScreenGeometry().contains(winfo.geometry().center()));
|
||||
}
|
||||
|
||||
@ -402,19 +402,19 @@ bool Windows::isMaximizedInViewScreen(Latte::View *view, const WindowInfoWrap &w
|
||||
|
||||
//! updated implementation to identify the screen that the maximized window is present
|
||||
//! in order to avoid: https://bugs.kde.org/show_bug.cgi?id=397700
|
||||
return (winfo.isValid() && !winfo.isMinimized()
|
||||
return (winfo.isValid() && !winfo.isPlasmaDesktop() && !winfo.isMinimized()
|
||||
&& (winfo.isMaximized() || viewIntersectsMaxVert() || viewIntersectsMaxHoriz())
|
||||
&& m_views[view]->availableScreenGeometry().contains(winfo.geometry().center()));
|
||||
}
|
||||
|
||||
bool Windows::isTouchingView(Latte::View *view, const WindowSystem::WindowInfoWrap &winfo)
|
||||
{
|
||||
return (winfo.isValid() && intersects(view, winfo));
|
||||
return (winfo.isValid() && !winfo.isPlasmaDesktop() && intersects(view, winfo));
|
||||
}
|
||||
|
||||
bool Windows::isTouchingViewEdge(Latte::View *view, const WindowInfoWrap &winfo)
|
||||
{
|
||||
if (winfo.isValid() && !winfo.isMinimized()) {
|
||||
if (winfo.isValid() && !winfo.isPlasmaDesktop() && !winfo.isMinimized()) {
|
||||
bool touchingViewEdge{false};
|
||||
|
||||
QRect screenGeometry = view->screenGeometry();
|
||||
@ -470,6 +470,19 @@ void Windows::updateAvailableScreenGeometries()
|
||||
}
|
||||
}
|
||||
|
||||
void Windows::setPlasmaDesktop(WindowId wid)
|
||||
{
|
||||
if (!m_windows.contains(wid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_windows[wid].isPlasmaDesktop()) {
|
||||
m_windows[wid].setIsPlasmaDesktop(true);
|
||||
qDebug() << " plasmashell updated...";
|
||||
updateViewsHints();
|
||||
}
|
||||
}
|
||||
|
||||
void Windows::updateViewsHints()
|
||||
{
|
||||
for (const auto view : m_views.keys()) {
|
||||
|
@ -71,6 +71,8 @@ public:
|
||||
QIcon iconFor(WindowId wid);
|
||||
QString appNameFor(WindowId wid);
|
||||
|
||||
void setPlasmaDesktop(WindowId wid);
|
||||
|
||||
AbstractWindowInterface *wm();
|
||||
|
||||
signals:
|
||||
|
@ -464,7 +464,7 @@ bool XWindowInterface::isValidWindow(const KWindowInfo &winfo) const
|
||||
return true;
|
||||
}
|
||||
|
||||
constexpr auto types = NET::DesktopMask | NET::DockMask | NET::MenuMask | NET::SplashMask | NET::PopupMenuMask | NET::NormalMask | NET::DialogMask;
|
||||
constexpr auto types = NET::DockMask | NET::MenuMask | NET::SplashMask | NET::PopupMenuMask | NET::NormalMask | NET::DialogMask;
|
||||
NET::WindowType winType = winfo.windowType(types);
|
||||
const auto winClass = KWindowInfo(winfo.win(), 0, NET::WM2WindowClass).windowClassName();
|
||||
|
||||
@ -473,8 +473,7 @@ bool XWindowInterface::isValidWindow(const KWindowInfo &winfo) const
|
||||
return false;
|
||||
}
|
||||
|
||||
//! reject desktop window
|
||||
if (winType != -1 && (winType & NET::Desktop)) {
|
||||
if (m_desktopId == winfo.win()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -497,14 +496,28 @@ bool XWindowInterface::isValidWindow(const KWindowInfo &winfo) const
|
||||
//! GTK2+ dialogs case e.g. inkscape, gimp2, etc...
|
||||
//! are both Popups and Splash types, this is why
|
||||
//! we can not black list them here
|
||||
|
||||
return !(isMenu || isDock);
|
||||
}
|
||||
|
||||
bool XWindowInterface::hasScreenGeometry(const KWindowInfo &winfo) const
|
||||
{
|
||||
bool hasScreenGeometry{false};
|
||||
|
||||
for (const auto scr : qGuiApp->screens()) {
|
||||
if (!winfo.geometry().isEmpty() && winfo.geometry() == scr->geometry()) {
|
||||
hasScreenGeometry = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return hasScreenGeometry;
|
||||
}
|
||||
|
||||
void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2)
|
||||
{
|
||||
const auto winType = KWindowInfo(wid, NET::WMWindowType).windowType(NET::DesktopMask);
|
||||
const auto winClass = KWindowInfo(wid, 0, NET::WM2WindowClass).windowClassName();
|
||||
const KWindowInfo info(wid, NET::WMGeometry, NET::WM2WindowClass);
|
||||
|
||||
const auto winClass = info.windowClassName();
|
||||
|
||||
//! ignore latte related windows from tracking
|
||||
if (winClass == "latte-dock") {
|
||||
@ -512,9 +525,10 @@ void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::P
|
||||
}
|
||||
|
||||
//! update desktop id
|
||||
if (winType != -1 && (winType & NET::Desktop)) {
|
||||
if (winClass == "plasmashell" && hasScreenGeometry(info)) {
|
||||
m_desktopId = wid;
|
||||
emit windowChanged(wid);
|
||||
windowsTracker()->setPlasmaDesktop(wid);
|
||||
considerWindowChanged(wid);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -554,7 +568,6 @@ void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::P
|
||||
|
||||
//! ignore windows that do not respect normal windows types
|
||||
if (!isValidWindow(wid)) {
|
||||
qDebug() << "rejected window...";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,7 @@ public:
|
||||
void setEdgeStateFor(QWindow *view, bool active) const override;
|
||||
|
||||
private:
|
||||
bool hasScreenGeometry(const KWindowInfo &winfo) const;
|
||||
bool isValidWindow(WindowId wid) const;
|
||||
bool isValidWindow(const KWindowInfo &winfo) const;
|
||||
void windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2);
|
||||
@ -81,7 +82,7 @@ private:
|
||||
QUrl windowUrl(WindowId wid) const;
|
||||
|
||||
private:
|
||||
WindowId m_desktopId;
|
||||
WindowId m_desktopId{-1};
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user