simplify code in windowstracker

pull/5/head
Michail Vourlakos 6 years ago
parent 946dca4475
commit e1d44bc157

@ -264,7 +264,7 @@ void WindowsTracker::updateFlags()
WindowId activeTouchWinId; WindowId activeTouchWinId;
for (const auto &winfo : m_windows) { for (const auto &winfo : m_windows) {
if (winfo.isPlasmaDesktop()) { if (winfo.isPlasmaDesktop() || !inCurrentDesktopActivity(winfo)) {
continue; continue;
} }
@ -341,53 +341,38 @@ void WindowsTracker::updateFlags()
} }
} }
bool WindowsTracker::isActive(const WindowInfoWrap &winfo) bool WindowsTracker::inCurrentDesktopActivity(const WindowInfoWrap &winfo)
{ {
if (winfo.isValid() && winfo.isActive() && !winfo.isMinimized() return (winfo.isValid() && m_wm->isOnCurrentDesktop(winfo.wid()) && m_wm->isOnCurrentActivity(winfo.wid()));
&& m_wm->isOnCurrentDesktop(winfo.wid()) && m_wm->isOnCurrentActivity(winfo.wid())) { }
return true;
}
return false; bool WindowsTracker::isActive(const WindowInfoWrap &winfo)
{
return (winfo.isValid() && winfo.isActive() && !winfo.isMinimized());
} }
bool WindowsTracker::isActiveInCurrentScreen(const WindowInfoWrap &winfo) bool WindowsTracker::isActiveInCurrentScreen(const WindowInfoWrap &winfo)
{ {
if (winfo.isValid() && winfo.isActive() && !winfo.isMinimized() return (winfo.isValid() && winfo.isActive() && !winfo.isMinimized()
&& m_wm->isOnCurrentDesktop(winfo.wid()) && m_wm->isOnCurrentActivity(winfo.wid()) && m_availableScreenGeometry.contains(winfo.geometry().center()));
&& m_availableScreenGeometry.contains(winfo.geometry().center())) {
return true;
}
return false;
} }
bool WindowsTracker::isMaximizedInCurrentScreen(const WindowInfoWrap &winfo) bool WindowsTracker::isMaximizedInCurrentScreen(const WindowInfoWrap &winfo)
{ {
//! updated implementation to identify the screen that the maximized window is present //! 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 //! in order to avoid: https://bugs.kde.org/show_bug.cgi?id=397700
return (winfo.isValid() && !winfo.isMinimized() && winfo.isMaximized()
if (winfo.isValid() && !winfo.isMinimized() && m_wm->isOnCurrentDesktop(winfo.wid()) && m_wm->isOnCurrentActivity(winfo.wid())) { && m_availableScreenGeometry.contains(winfo.geometry().center()));
if (winfo.isMaximized() && m_availableScreenGeometry.contains(winfo.geometry().center())) {
return true;
}
}
return false;
} }
bool WindowsTracker::isTouchingView(const WindowInfoWrap &winfo) bool WindowsTracker::isTouchingView(const WindowInfoWrap &winfo)
{ {
if (winfo.isValid() && !winfo.isMinimized() && m_wm->isOnCurrentDesktop(winfo.wid()) && m_wm->isOnCurrentActivity(winfo.wid())) { return (winfo.isValid() && !winfo.isMinimized() && m_latteView->visibility()->intersects(winfo));
return m_latteView->visibility()->intersects(winfo);
}
return false;
} }
bool WindowsTracker::isTouchingViewEdge(const WindowInfoWrap &winfo) bool WindowsTracker::isTouchingViewEdge(const WindowInfoWrap &winfo)
{ {
if (winfo.isValid() && !winfo.isMinimized() && m_wm->isOnCurrentDesktop(winfo.wid()) && m_wm->isOnCurrentActivity(winfo.wid())) { if (winfo.isValid() && !winfo.isMinimized()) {
bool touchingViewEdge{false}; bool touchingViewEdge{false};
QRect screenGeometry = m_latteView->screenGeometry(); QRect screenGeometry = m_latteView->screenGeometry();

@ -96,6 +96,7 @@ private:
//! this is a garbage collector to collect such windows in order to not break the windows array validity. //! this is a garbage collector to collect such windows in order to not break the windows array validity.
void cleanupFaultyWindows(); void cleanupFaultyWindows();
bool inCurrentDesktopActivity(const WindowInfoWrap &winfo);
bool isActive(const WindowInfoWrap &winfo); bool isActive(const WindowInfoWrap &winfo);
bool isActiveInCurrentScreen(const WindowInfoWrap &winfo); bool isActiveInCurrentScreen(const WindowInfoWrap &winfo);
bool isMaximizedInCurrentScreen(const WindowInfoWrap &winfo); bool isMaximizedInCurrentScreen(const WindowInfoWrap &winfo);

Loading…
Cancel
Save