diff --git a/app/wm/tracker/trackedgeneralinfo.cpp b/app/wm/tracker/trackedgeneralinfo.cpp index 0b121fff..1decc466 100644 --- a/app/wm/tracker/trackedgeneralinfo.cpp +++ b/app/wm/tracker/trackedgeneralinfo.cpp @@ -1,149 +1,157 @@ /* * 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 "trackedgeneralinfo.h" //local #include "trackerwindows.h" #include "../schemecolors.h" namespace Latte { namespace WindowSystem { namespace Tracker { TrackedGeneralInfo::TrackedGeneralInfo(Tracker::Windows *tracker) : QObject(tracker) , m_wm(tracker->wm()), m_tracker(tracker) { m_lastActiveWindow = new LastActiveWindow(this); emit lastActiveWindowChanged(); } TrackedGeneralInfo::~TrackedGeneralInfo() { if (m_lastActiveWindow) { auto law = m_lastActiveWindow; m_lastActiveWindow = nullptr; emit lastActiveWindowChanged(); law->deleteLater(); } } bool TrackedGeneralInfo::enabled() const { return m_enabled; } void TrackedGeneralInfo::setEnabled(bool enabled) { if (m_enabled == enabled) { return; } m_enabled = enabled; } bool TrackedGeneralInfo::activeWindowMaximized() const { return m_activeWindowMaximized; } void TrackedGeneralInfo::setActiveWindowMaximized(bool activeMaximized) { if (m_activeWindowMaximized == activeMaximized) { return; } m_activeWindowMaximized = activeMaximized; } bool TrackedGeneralInfo::existsWindowActive() const { return m_existsWindowActive; } void TrackedGeneralInfo::setExistsWindowActive(bool exists) { if (m_existsWindowActive == exists) { return; } m_existsWindowActive = exists; } bool TrackedGeneralInfo::existsWindowMaximized() const { return m_existsWindowMaximized; } void TrackedGeneralInfo::setExistsWindowMaximized(bool maximized) { if (m_existsWindowMaximized == maximized) { return; } m_existsWindowMaximized = maximized; } LastActiveWindow *TrackedGeneralInfo::lastActiveWindow() const { return m_lastActiveWindow; } SchemeColors *TrackedGeneralInfo::activeWindowScheme() const { return m_activeWindowScheme; } void TrackedGeneralInfo::setActiveWindowScheme(SchemeColors *scheme) { if (m_activeWindowScheme == scheme) { return; } m_activeWindowScheme = scheme; } AbstractWindowInterface *TrackedGeneralInfo::wm() { return m_wm; } void TrackedGeneralInfo::setActiveWindow(const WindowId &wid) { m_lastActiveWindow->setInformation(m_tracker->infoFor(wid)); } +bool TrackedGeneralInfo::isTrackedOnActivity(const QString &activity) const +{ + //! TODO:: needs to be updated for Layouts case + //! a way to access the first enabled View::activities in that specific + //! layout + return true; +} + bool TrackedGeneralInfo::isTracking(const WindowInfoWrap &winfo) const { return (winfo.isValid() && !winfo.isPlasmaDesktop() && !winfo.isMinimized() && winfo.isOnDesktop(m_wm->currentDesktop()) - && winfo.isOnActivity(m_wm->currentActivity())); - /*&& m_view->isOnActivity(m_wm->currentActivity()));*/ + && winfo.isOnActivity(m_wm->currentActivity()) + && isTrackedOnActivity(m_wm->currentActivity())); } } } } diff --git a/app/wm/tracker/trackedgeneralinfo.h b/app/wm/tracker/trackedgeneralinfo.h index 0e5ba19f..0af8d088 100644 --- a/app/wm/tracker/trackedgeneralinfo.h +++ b/app/wm/tracker/trackedgeneralinfo.h @@ -1,97 +1,100 @@ /* * 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 WINDOWSYSTEMTRACKEDGENERALINFO_H #define WINDOWSYSTEMTRACKEDGENERALINFO_H // local #include "lastactivewindow.h" #include "../windowinfowrap.h" // Qt #include namespace Latte { namespace WindowSystem { class SchemeColors; namespace Tracker { class Windows; } } } namespace Latte { namespace WindowSystem { namespace Tracker { class TrackedGeneralInfo : public QObject { Q_OBJECT Q_PROPERTY(Latte::WindowSystem::Tracker::LastActiveWindow *activeWindow READ lastActiveWindow NOTIFY lastActiveWindowChanged) public: TrackedGeneralInfo(Tracker::Windows *tracker); ~TrackedGeneralInfo() override; bool enabled() const; void setEnabled(bool enabled); bool activeWindowMaximized() const; void setActiveWindowMaximized(bool activeMaximized); bool existsWindowActive() const; void setExistsWindowActive(bool exists); bool existsWindowMaximized() const; void setExistsWindowMaximized(bool maximized); LastActiveWindow *lastActiveWindow() const; SchemeColors *activeWindowScheme() const; void setActiveWindowScheme(SchemeColors *scheme); AbstractWindowInterface *wm(); void setActiveWindow(const WindowId &wid); virtual bool isTracking(const WindowInfoWrap &winfo) const; signals: void lastActiveWindowChanged(); +protected: + virtual bool isTrackedOnActivity(const QString &activity) const; + private: bool m_enabled; bool m_activeWindowMaximized; bool m_existsWindowActive; bool m_existsWindowMaximized; LastActiveWindow *m_lastActiveWindow{nullptr}; SchemeColors *m_activeWindowScheme{nullptr}; AbstractWindowInterface *m_wm{nullptr}; Tracker::Windows *m_tracker{nullptr}; }; } } } #endif diff --git a/persistentmenu.cpp b/app/wm/tracker/trackedlayoutinfo.cpp similarity index 100% copy from persistentmenu.cpp copy to app/wm/tracker/trackedlayoutinfo.cpp diff --git a/persistentmenu.cpp b/app/wm/tracker/trackedlayoutinfo.h similarity index 100% rename from persistentmenu.cpp rename to app/wm/tracker/trackedlayoutinfo.h diff --git a/app/wm/tracker/trackedviewinfo.cpp b/app/wm/tracker/trackedviewinfo.cpp index 1a0d81b8..88d87266 100644 --- a/app/wm/tracker/trackedviewinfo.cpp +++ b/app/wm/tracker/trackedviewinfo.cpp @@ -1,112 +1,117 @@ /* * 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 "trackedviewinfo.h" //local #include "trackerwindows.h" #include "../schemecolors.h" #include "../../view/view.h" namespace Latte { namespace WindowSystem { namespace Tracker { TrackedViewInfo::TrackedViewInfo(Tracker::Windows *tracker, Latte::View *view) : TrackedGeneralInfo(tracker) , m_view(view) { } TrackedViewInfo::~TrackedViewInfo() { } bool TrackedViewInfo::activeWindowTouching() const { return m_activeWindowTouching; } void TrackedViewInfo::setActiveWindowTouching(bool touching) { if (m_activeWindowTouching == touching) { return; } m_activeWindowTouching = touching; } bool TrackedViewInfo::existsWindowTouching() const { return m_existsWindowTouching; } void TrackedViewInfo::setExistsWindowTouching(bool touching) { if (m_existsWindowTouching == touching) { return; } m_existsWindowTouching = touching; } QRect TrackedViewInfo::availableScreenGeometry() const { return m_availableScreenGeometry; } void TrackedViewInfo::setAvailableScreenGeometry(QRect geometry) { if (m_availableScreenGeometry == geometry) { return; } m_availableScreenGeometry = geometry; } SchemeColors *TrackedViewInfo::touchingWindowScheme() const { return m_touchingWindowScheme; } void TrackedViewInfo::setTouchingWindowScheme(SchemeColors *scheme) { if (m_touchingWindowScheme == scheme) { return; } m_touchingWindowScheme = scheme; } Latte::View *TrackedViewInfo::view() const { return m_view; } +bool TrackedViewInfo::isTrackedOnActivity(const QString &activity) const +{ + return m_view->isOnActivity(activity); +} + bool TrackedViewInfo::isTracking(const WindowInfoWrap &winfo) const { return TrackedGeneralInfo::isTracking(winfo) && m_availableScreenGeometry.contains(winfo.geometry().center()); } } } } diff --git a/app/wm/tracker/trackedviewinfo.h b/app/wm/tracker/trackedviewinfo.h index ddaf3102..188a9738 100644 --- a/app/wm/tracker/trackedviewinfo.h +++ b/app/wm/tracker/trackedviewinfo.h @@ -1,84 +1,87 @@ /* * 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 WINDOWSYSTEMTRACKEDVIEWINFO_H #define WINDOWSYSTEMTRACKEDVIEWINFO_H // local #include "trackedgeneralinfo.h" #include "../windowinfowrap.h" // Qt #include #include namespace Latte { class View; namespace WindowSystem { class SchemeColors; namespace Tracker { class Windows; } } } namespace Latte { namespace WindowSystem { namespace Tracker { class TrackedViewInfo : public TrackedGeneralInfo { Q_OBJECT public: TrackedViewInfo(Tracker::Windows *tracker, Latte::View *view); ~TrackedViewInfo() override; bool activeWindowTouching() const; void setActiveWindowTouching(bool touching); bool existsWindowTouching() const; void setExistsWindowTouching(bool touching); QRect availableScreenGeometry() const; void setAvailableScreenGeometry(QRect geometry); SchemeColors *touchingWindowScheme() const; void setTouchingWindowScheme(SchemeColors *scheme); Latte::View *view() const; bool isTracking(const WindowInfoWrap &winfo) const override; +protected: + bool isTrackedOnActivity(const QString &activity) const override; + private: bool m_activeWindowTouching; bool m_existsWindowTouching; QRect m_availableScreenGeometry; SchemeColors *m_touchingWindowScheme{nullptr}; Latte::View *m_view{nullptr}; }; } } } #endif