diff --git a/app/view/windowstracker.cpp b/app/view/windowstracker.cpp index 10cb8e5e9..b9345e571 100644 --- a/app/view/windowstracker.cpp +++ b/app/view/windowstracker.cpp @@ -26,6 +26,7 @@ #include "../layouts/manager.h" #include "../wm/schemecolors.h" #include "../wm/tracker/windows.h" +#include "../wm/tracker/lastactivewindow.h" #include "../../liblatte2/types.h" namespace Latte { @@ -155,27 +156,27 @@ void WindowsTracker::setWindowOnActivities(QWindow &window, const QStringList &a void WindowsTracker::requestToggleMaximizeForActiveWindow() { - WindowSystem::WindowInfoWrap actInfo = m_wm->windowsTracker()->lastActiveWindowInfo(m_latteView); + Latte::WindowSystem::Tracker::LastActiveWindow *actInfo = m_wm->windowsTracker()->lastActiveWindow(m_latteView); //active window can be toggled only when it is in the same screen - if (actInfo.isValid() && !actInfo.geometry().isNull() && m_latteView->screenGeometry().contains(actInfo.geometry().center())) { - m_wm->requestToggleMaximized(actInfo.wid()); + if (actInfo && !actInfo->geometry().isNull() && m_latteView->screenGeometry().contains(actInfo->geometry().center())) { + m_wm->requestToggleMaximized(actInfo->winId()); } } void WindowsTracker::requestMoveActiveWindow(int localX, int localY) { - WindowSystem::WindowInfoWrap actInfo = m_wm->windowsTracker()->lastActiveWindowInfo(m_latteView); + Latte::WindowSystem::Tracker::LastActiveWindow *actInfo = m_wm->windowsTracker()->lastActiveWindow(m_latteView); //active window can be dragged only when it is in the same screen - if (actInfo.isValid() && !actInfo.geometry().isNull() && m_latteView->screenGeometry().contains(actInfo.geometry().center())) { + if (actInfo && !actInfo->geometry().isNull() && m_latteView->screenGeometry().contains(actInfo->geometry().center())) { QPoint globalPoint{m_latteView->x() + localX, m_latteView->y() + localY}; - m_wm->requestMoveWindow(actInfo.wid(), globalPoint); + m_wm->requestMoveWindow(actInfo->winId(), globalPoint); //! This timer is needed because otherwise the mouse position //! in the dragged window changes to TopLeft corner - QTimer::singleShot(250, this, [&, actInfo, globalPoint]() { + QTimer::singleShot(250, this, [&]() { m_wm->releaseMouseEventFor(m_latteView->winId()); }); @@ -185,11 +186,11 @@ void WindowsTracker::requestMoveActiveWindow(int localX, int localY) bool WindowsTracker::activeWindowCanBeDragged() { - WindowSystem::WindowInfoWrap actInfo = m_wm->windowsTracker()->lastActiveWindowInfo(m_latteView); + Latte::WindowSystem::Tracker::LastActiveWindow *actInfo = m_wm->windowsTracker()->lastActiveWindow(m_latteView); //active window can be dragged only when it is in the same screen - if (actInfo.isValid() && !actInfo.geometry().isNull() && m_latteView->screenGeometry().contains(actInfo.geometry().center())) { - return m_wm->windowCanBeDragged(actInfo.wid()); + if (actInfo && !actInfo->geometry().isNull() && m_latteView->screenGeometry().contains(actInfo->geometry().center())) { + return m_wm->windowCanBeDragged(actInfo->winId()); } return false; diff --git a/app/wm/tracker/CMakeLists.txt b/app/wm/tracker/CMakeLists.txt index ef25c188f..fd7e77454 100644 --- a/app/wm/tracker/CMakeLists.txt +++ b/app/wm/tracker/CMakeLists.txt @@ -1,6 +1,8 @@ set(lattedock-app_SRCS ${lattedock-app_SRCS} + ${CMAKE_CURRENT_SOURCE_DIR}/lastactivewindow.cpp ${CMAKE_CURRENT_SOURCE_DIR}/windows.cpp ${CMAKE_CURRENT_SOURCE_DIR}/schemes.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/trackedinfo.cpp PARENT_SCOPE ) diff --git a/app/wm/tracker/lastactivewindow.cpp b/app/wm/tracker/lastactivewindow.cpp new file mode 100644 index 000000000..e202391b0 --- /dev/null +++ b/app/wm/tracker/lastactivewindow.cpp @@ -0,0 +1,77 @@ +/* +* Copyright 2019 Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +#include "lastactivewindow.h" + +//local +#include "trackedinfo.h" + +namespace Latte { +namespace WindowSystem { +namespace Tracker { + + +LastActiveWindow::LastActiveWindow(TrackedInfo *parent) + : QObject(parent) +{ +} + +LastActiveWindow::~LastActiveWindow() +{ +} + +QRect LastActiveWindow::geometry() const +{ + return m_geometry; +} + +void LastActiveWindow::setGeometry(QRect geometry) +{ + if (m_geometry == geometry) { + return; + } + + m_geometry = geometry; + emit geometryChanged(); +} + +QVariant LastActiveWindow::winId() const +{ + return m_winId; +} + +void LastActiveWindow::setWinId(QVariant winId) +{ + if (m_winId == winId) { + return; + } + + m_winId = winId; + emit winIdChanged(); +} + +void LastActiveWindow::setInformation(const WindowInfoWrap &info) +{ + setWinId(info.wid()); + setGeometry(info.geometry()); +} + +} +} +} diff --git a/app/wm/tracker/lastactivewindow.h b/app/wm/tracker/lastactivewindow.h new file mode 100644 index 000000000..c69f52647 --- /dev/null +++ b/app/wm/tracker/lastactivewindow.h @@ -0,0 +1,76 @@ +/* +* Copyright 2019 Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +#ifndef WINDOWSYSTEMLASTACTIVEWINDOW_H +#define WINDOWSYSTEMLASTACTIVEWINDOW_H + +// local +#include "../windowinfowrap.h" + +// Qt +#include +#include + +namespace Latte { +namespace WindowSystem { +namespace Tracker { +class TrackedInfo; +} +} +} + + +namespace Latte { +namespace WindowSystem { +namespace Tracker { + +class LastActiveWindow : public QObject { + Q_OBJECT + + Q_PROPERTY(QVariant winId READ winId NOTIFY winIdChanged) + +public: + LastActiveWindow(TrackedInfo *parent); + ~LastActiveWindow() override; + + QRect geometry() const; + QVariant winId() const; + + + void setInformation(const WindowInfoWrap &info); + +signals: + void geometryChanged(); + void winIdChanged(); + +private: + void setGeometry(QRect geometry); + void setWinId(QVariant winId); + +private: + QRect m_geometry; + QVariant m_winId; + +}; + +} +} +} + +#endif diff --git a/app/wm/tracker/trackedinfo.cpp b/app/wm/tracker/trackedinfo.cpp new file mode 100644 index 000000000..3f9b43977 --- /dev/null +++ b/app/wm/tracker/trackedinfo.cpp @@ -0,0 +1,183 @@ +/* +* Copyright 2019 Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +#include "trackedinfo.h" + +//local +#include "windows.h" +#include "../schemecolors.h" + +namespace Latte { +namespace WindowSystem { +namespace Tracker { + + +TrackedInfo::TrackedInfo(Tracker::Windows *parent) + : QObject(parent) +{ + m_lastActiveWindow = new LastActiveWindow(this); + + emit lastActiveWindowChanged(); +} + +TrackedInfo::~TrackedInfo() +{ + if (m_lastActiveWindow) { + auto law = m_lastActiveWindow; + m_lastActiveWindow = nullptr; + emit lastActiveWindowChanged(); + + law->deleteLater(); + } +} + +bool TrackedInfo::enabled() const +{ + return m_enabled; +} + +void TrackedInfo::setEnabled(bool enabled) +{ + if (m_enabled == enabled) { + return; + } + + m_enabled = enabled; +} + +bool TrackedInfo::activeWindowMaximized() const +{ + return m_activeWindowMaximized; +} + +void TrackedInfo::setActiveWindowMaximized(bool activeMaximized) +{ + if (m_activeWindowMaximized == activeMaximized) { + return; + } + + m_activeWindowMaximized = activeMaximized; +} + +bool TrackedInfo::activeWindowTouching() const +{ + return m_activeWindowTouching; +} + +void TrackedInfo::setActiveWindowTouching(bool touching) +{ + if (m_activeWindowTouching == touching) { + return; + } + + m_activeWindowTouching = touching; +} + +bool TrackedInfo::existsWindowActive() const +{ + return m_existsWindowActive; +} + +void TrackedInfo::setExistsWindowActive(bool exists) +{ + if (m_existsWindowActive == exists) { + return; + } + + m_existsWindowActive = exists; +} + +bool TrackedInfo::existsWindowMaximized() const +{ + return m_existsWindowMaximized; +} + +void TrackedInfo::setExistsWindowMaximized(bool maximized) +{ + if (m_existsWindowMaximized == maximized) { + return; + } + + m_existsWindowMaximized = maximized; +} + +bool TrackedInfo::existsWindowTouching() const +{ + return m_existsWindowTouching; +} + +void TrackedInfo::setExistsWindowTouching(bool touching) +{ + if (m_existsWindowTouching == touching) { + return; + } + + m_existsWindowTouching = touching; +} + +QRect TrackedInfo::availableScreenGeometry() const +{ + return m_availableScreenGeometry; +} + +void TrackedInfo::setAvailableScreenGeometry(QRect geometry) +{ + if (m_availableScreenGeometry == geometry) { + return; + } + + m_availableScreenGeometry = geometry; +} + +LastActiveWindow *TrackedInfo::lastActiveWindow() const +{ + return m_lastActiveWindow; +} + +SchemeColors *TrackedInfo::activeWindowScheme() const +{ + return m_activeWindowScheme; +} + +void TrackedInfo::setActiveWindowScheme(SchemeColors *scheme) +{ + if (m_activeWindowScheme == scheme) { + return; + } + + m_activeWindowScheme = scheme; +} + +SchemeColors *TrackedInfo::touchingWindowScheme() const +{ + return m_touchingWindowScheme; +} + +void TrackedInfo::setTouchingWindowScheme(SchemeColors *scheme) +{ + if (m_touchingWindowScheme == scheme) { + return; + } + + m_touchingWindowScheme = scheme; +} + +} +} +} diff --git a/app/wm/tracker/trackedinfo.h b/app/wm/tracker/trackedinfo.h new file mode 100644 index 000000000..175992edd --- /dev/null +++ b/app/wm/tracker/trackedinfo.h @@ -0,0 +1,120 @@ +/* +* Copyright 2019 Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +#ifndef WINDOWSYSTEMTRACKEDINFO_H +#define WINDOWSYSTEMTRACKEDINFO_H + +// local +#include "lastactivewindow.h" +#include "../windowinfowrap.h" + +// Qt +#include +#include + +namespace Latte { +namespace WindowSystem { +class SchemeColors; +namespace Tracker { +class Windows; +} +} +} + + +namespace Latte { +namespace WindowSystem { +namespace Tracker { +/* + * + * bool enabled{false}; + bool activeWindowMaximized{false}; + bool activeWindowTouching{false}; + bool existsWindowActive{false}; + bool existsWindowMaximized{false}; + bool existsWindowTouching{false}; + QRect availableScreenGeometry; + WindowId lastActiveWindow; + SchemeColors *activeWindowScheme{nullptr}; + SchemeColors *touchingWindowScheme{nullptr}; + * + */ + +class TrackedInfo : public QObject { + Q_OBJECT + + Q_PROPERTY(Latte::WindowSystem::Tracker::LastActiveWindow *activeWindow READ lastActiveWindow NOTIFY lastActiveWindowChanged) + +public: + TrackedInfo(Tracker::Windows *parent); + ~TrackedInfo() override; + + bool enabled() const; + void setEnabled(bool enabled); + + bool activeWindowMaximized() const; + void setActiveWindowMaximized(bool activeMaximized); + + bool activeWindowTouching() const; + void setActiveWindowTouching(bool touching); + + bool existsWindowActive() const; + void setExistsWindowActive(bool exists); + + bool existsWindowMaximized() const; + void setExistsWindowMaximized(bool maximized); + + bool existsWindowTouching() const; + void setExistsWindowTouching(bool touching); + + QRect availableScreenGeometry() const; + void setAvailableScreenGeometry(QRect geometry); + + LastActiveWindow *lastActiveWindow() const; + + SchemeColors *activeWindowScheme() const; + void setActiveWindowScheme(SchemeColors *scheme); + + SchemeColors *touchingWindowScheme() const; + void setTouchingWindowScheme(SchemeColors *scheme); + +signals: + void lastActiveWindowChanged(); + +private: + bool m_enabled; + bool m_activeWindowMaximized; + bool m_activeWindowTouching; + bool m_existsWindowActive; + bool m_existsWindowMaximized; + bool m_existsWindowTouching; + + QRect m_availableScreenGeometry; + + LastActiveWindow *m_lastActiveWindow{nullptr}; + + SchemeColors *m_activeWindowScheme{nullptr}; + SchemeColors *m_touchingWindowScheme{nullptr}; +}; + +} +} +} + +#endif diff --git a/app/wm/tracker/windows.cpp b/app/wm/tracker/windows.cpp index 1aba1095f..dcd06aafc 100644 --- a/app/wm/tracker/windows.cpp +++ b/app/wm/tracker/windows.cpp @@ -20,7 +20,9 @@ #include "windows.h" // local +#include "lastactivewindow.h" #include "schemes.h" +#include "trackedinfo.h" #include "../abstractwindowinterface.h" #include "../schemecolors.h" #include "../../lattecorona.h" @@ -43,6 +45,13 @@ Windows::Windows(AbstractWindowInterface *parent) Windows::~Windows() { + //! clear all the m_views tracking information + for (QHash::iterator i=m_views.begin(); i!=m_views.end(); ++i) { + i.value()->deleteLater(); + m_views[i.key()] = nullptr; + } + + m_views.clear(); } void Windows::init() @@ -68,9 +77,10 @@ void Windows::init() connect(m_wm, &AbstractWindowInterface::activeWindowChanged, this, [&](WindowId wid) { for (const auto view : m_views.keys()) { - WindowId lastWinId = m_views[view].lastActiveWindow; + WindowId lastWinId = m_views[view]->lastActiveWindow()->winId(); if (m_windows.contains(lastWinId)) { m_windows[lastWinId] = m_wm->requestInfo(lastWinId); + m_views[view]->lastActiveWindow()->setInformation(m_windows[lastWinId]); } } @@ -114,8 +124,7 @@ void Windows::addView(Latte::View *view) return; } - ViewHints hints; - m_views[view] = hints; + m_views[view] = new TrackedInfo(this); updateAvailableScreenGeometries(); updateHints(view); @@ -127,6 +136,7 @@ void Windows::removeView(Latte::View *view) return; } + m_views[view]->deleteLater(); m_views.remove(view); } @@ -138,16 +148,16 @@ bool Windows::enabled(Latte::View *view) return false; } - return m_views[view].enabled; + return m_views[view]->enabled(); } void Windows::setEnabled(Latte::View *view, const bool enabled) { - if (!m_views.contains(view) || m_views[view].enabled == enabled) { + if (!m_views.contains(view) || m_views[view]->enabled() == enabled) { return; } - m_views[view].enabled = enabled; + m_views[view]->setEnabled(enabled); if (enabled) { updateHints(view); @@ -164,16 +174,16 @@ bool Windows::activeWindowMaximized(Latte::View *view) const return false; } - return m_views[view].activeWindowMaximized; + return m_views[view]->activeWindowMaximized(); } void Windows::setActiveWindowMaximized(Latte::View *view, bool activeMaximized) { - if (!m_views.contains(view) || m_views[view].activeWindowMaximized == activeMaximized) { + if (!m_views.contains(view) || m_views[view]->activeWindowMaximized() == activeMaximized) { return; } - m_views[view].activeWindowMaximized = activeMaximized; + m_views[view]->setActiveWindowMaximized(activeMaximized); emit activeWindowMaximizedChanged(view); } @@ -183,16 +193,16 @@ bool Windows::activeWindowTouching(Latte::View *view) const return false; } - return m_views[view].activeWindowTouching; + return m_views[view]->activeWindowTouching(); } void Windows::setActiveWindowTouching(Latte::View *view, bool activeTouching) { - if (!m_views.contains(view) || m_views[view].activeWindowTouching == activeTouching) { + if (!m_views.contains(view) || m_views[view]->activeWindowTouching() == activeTouching) { return; } - m_views[view].activeWindowTouching = activeTouching; + m_views[view]->setActiveWindowTouching(activeTouching); emit activeWindowTouchingChanged(view); } @@ -202,16 +212,16 @@ bool Windows::existsWindowActive(Latte::View *view) const return false; } - return m_views[view].existsWindowActive; + return m_views[view]->existsWindowActive(); } void Windows::setExistsWindowActive(Latte::View *view, bool windowActive) { - if (!m_views.contains(view) || m_views[view].existsWindowActive == windowActive) { + if (!m_views.contains(view) || m_views[view]->existsWindowActive() == windowActive) { return; } - m_views[view].existsWindowActive = windowActive; + m_views[view]->setExistsWindowActive(windowActive); emit existsWindowActiveChanged(view); } @@ -221,16 +231,16 @@ bool Windows::existsWindowMaximized(Latte::View *view) const return false; } - return m_views[view].existsWindowMaximized; + return m_views[view]->existsWindowMaximized(); } void Windows::setExistsWindowMaximized(Latte::View *view, bool windowMaximized) { - if (!m_views.contains(view) || m_views[view].existsWindowMaximized == windowMaximized) { + if (!m_views.contains(view) || m_views[view]->existsWindowMaximized() == windowMaximized) { return; } - m_views[view].existsWindowMaximized = windowMaximized; + m_views[view]->setExistsWindowMaximized(windowMaximized); emit existsWindowMaximizedChanged(view); } @@ -240,16 +250,16 @@ bool Windows::existsWindowTouching(Latte::View *view) const return false; } - return m_views[view].existsWindowTouching; + return m_views[view]->existsWindowTouching(); } void Windows::setExistsWindowTouching(Latte::View *view, bool windowTouching) { - if (!m_views.contains(view) || m_views[view].existsWindowTouching == windowTouching) { + if (!m_views.contains(view) || m_views[view]->existsWindowTouching() == windowTouching) { return; } - m_views[view].existsWindowTouching = windowTouching; + m_views[view]->setExistsWindowTouching(windowTouching); emit existsWindowTouchingChanged(view); } @@ -259,16 +269,16 @@ SchemeColors *Windows::activeWindowScheme(Latte::View *view) const return nullptr; } - return m_views[view].activeWindowScheme; + return m_views[view]->activeWindowScheme(); } void Windows::setActiveWindowScheme(Latte::View *view, WindowSystem::SchemeColors *scheme) { - if (!m_views.contains(view) || m_views[view].activeWindowScheme == scheme) { + if (!m_views.contains(view) || m_views[view]->activeWindowScheme() == scheme) { return; } - m_views[view].activeWindowScheme = scheme; + m_views[view]->setActiveWindowScheme(scheme); emit activeWindowSchemeChanged(view); } @@ -278,32 +288,26 @@ SchemeColors *Windows::touchingWindowScheme(Latte::View *view) const return nullptr; } - return m_views[view].touchingWindowScheme; + return m_views[view]->touchingWindowScheme(); } void Windows::setTouchingWindowScheme(Latte::View *view, WindowSystem::SchemeColors *scheme) { - if (!m_views.contains(view) || m_views[view].touchingWindowScheme == scheme) { + if (!m_views.contains(view) || m_views[view]->touchingWindowScheme() == scheme) { return; } - m_views[view].touchingWindowScheme = scheme; + m_views[view]->setTouchingWindowScheme(scheme); emit touchingWindowSchemeChanged(view); } -WindowInfoWrap Windows::lastActiveWindowInfo(Latte::View *view) +LastActiveWindow *Windows::lastActiveWindow(Latte::View *view) { - WindowInfoWrap info; if (!m_views.contains(view)) { - return info; - } - - if (!m_windows.contains(m_views[view].lastActiveWindow)) { - m_views[view].lastActiveWindow = info.wid(); - return info; + return nullptr; } - return m_wm->requestInfo(m_views[view].lastActiveWindow); + return m_views[view]->lastActiveWindow(); } //! Windows Criteria Functions @@ -326,7 +330,7 @@ bool Windows::isActive(const WindowInfoWrap &winfo) bool Windows::isActiveInViewScreen(Latte::View *view, const WindowInfoWrap &winfo) { return (winfo.isValid() && winfo.isActive() && !winfo.isMinimized() - && m_views[view].availableScreenGeometry.contains(winfo.geometry().center())); + && m_views[view]->availableScreenGeometry().contains(winfo.geometry().center())); } bool Windows::isMaximizedInViewScreen(Latte::View *view, const WindowInfoWrap &winfo) @@ -347,7 +351,7 @@ bool Windows::isMaximizedInViewScreen(Latte::View *view, const WindowInfoWrap &w //! in order to avoid: https://bugs.kde.org/show_bug.cgi?id=397700 return (winfo.isValid() && !winfo.isMinimized() && (winfo.isMaximized() || viewIntersectsMaxVert() || viewIntersectsMaxHoriz()) - && m_views[view].availableScreenGeometry.contains(winfo.geometry().center())); + && m_views[view]->availableScreenGeometry().contains(winfo.geometry().center())); } bool Windows::isTouchingView(Latte::View *view, const WindowSystem::WindowInfoWrap &winfo) @@ -361,7 +365,7 @@ bool Windows::isTouchingViewEdge(Latte::View *view, const WindowInfoWrap &winfo) bool touchingViewEdge{false}; QRect screenGeometry = view->screenGeometry(); - QRect availableScreenGeometry = m_views[view].availableScreenGeometry; + QRect availableScreenGeometry = m_views[view]->availableScreenGeometry(); bool inCurrentScreen{screenGeometry.contains(winfo.geometry().topLeft()) || screenGeometry.contains(winfo.geometry().bottomRight())}; @@ -400,12 +404,12 @@ void Windows::cleanupFaultyWindows() void Windows::updateAvailableScreenGeometries() { for (const auto view : m_views.keys()) { - if (m_views[view].enabled) { + if (m_views[view]->enabled()) { int currentScrId = view->positioner()->currentScreenId(); QRect tempAvailableScreenGeometry = m_wm->corona()->availableScreenRectWithCriteria(currentScrId, {Types::AlwaysVisible}, {}); - if (tempAvailableScreenGeometry != m_views[view].availableScreenGeometry) { - m_views[view].availableScreenGeometry = tempAvailableScreenGeometry; + if (tempAvailableScreenGeometry != m_views[view]->availableScreenGeometry()) { + m_views[view]->setAvailableScreenGeometry(tempAvailableScreenGeometry); updateHints(view); } @@ -416,7 +420,7 @@ void Windows::updateAvailableScreenGeometries() void Windows::updateViewsHints() { for (const auto view : m_views.keys()) { - if (m_views[view].enabled) { + if (m_views[view]->enabled()) { updateHints(view); } } @@ -453,7 +457,7 @@ void Windows::updateHints(Latte::View *view) } if (isActiveInViewScreen(view, winfo)) { - m_views[view].lastActiveWindow = winfo.wid(); + m_views[view]->lastActiveWindow()->setInformation(winfo); foundActiveInCurScreen = true; activeWinId = winfo.wid(); } diff --git a/app/wm/tracker/windows.h b/app/wm/tracker/windows.h index c1b4beba5..cf2353afd 100644 --- a/app/wm/tracker/windows.h +++ b/app/wm/tracker/windows.h @@ -34,6 +34,10 @@ class View; namespace WindowSystem { class AbstractWindowInterface; class SchemeColors; +namespace Tracker { +class LastActiveWindow; +class TrackedInfo; +} } } @@ -41,19 +45,6 @@ namespace Latte { namespace WindowSystem { namespace Tracker { -struct ViewHints { - bool enabled{false}; - bool activeWindowMaximized{false}; - bool activeWindowTouching{false}; - bool existsWindowActive{false}; - bool existsWindowMaximized{false}; - bool existsWindowTouching{false}; - QRect availableScreenGeometry; - WindowId lastActiveWindow; - SchemeColors *activeWindowScheme{nullptr}; - SchemeColors *touchingWindowScheme{nullptr}; -}; - class Windows : public QObject { Q_OBJECT @@ -74,7 +65,7 @@ public: bool existsWindowTouching(Latte::View *view) const; SchemeColors *activeWindowScheme(Latte::View *view) const; SchemeColors *touchingWindowScheme(Latte::View *view) const; - WindowInfoWrap lastActiveWindowInfo(Latte::View *view); + LastActiveWindow *lastActiveWindow(Latte::View *view); signals: void enabledChanged(const Latte::View *view); @@ -115,7 +106,7 @@ private: private: AbstractWindowInterface *m_wm; - QHash m_views; + QHash m_views; QMap m_windows; };