diff --git a/app/wm/tracker/CMakeLists.txt b/app/wm/tracker/CMakeLists.txt index 6baf2923..6157f76d 100644 --- a/app/wm/tracker/CMakeLists.txt +++ b/app/wm/tracker/CMakeLists.txt @@ -1,9 +1,10 @@ set(lattedock-app_SRCS ${lattedock-app_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/lastactivewindow.cpp ${CMAKE_CURRENT_SOURCE_DIR}/schemes.cpp ${CMAKE_CURRENT_SOURCE_DIR}/trackedgeneralinfo.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/trackedlayoutinfo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/trackedviewinfo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/trackerwindows.cpp PARENT_SCOPE ) diff --git a/app/wm/tracker/trackedgeneralinfo.cpp b/app/wm/tracker/trackedgeneralinfo.cpp index 1decc466..9b321168 100644 --- a/app/wm/tracker/trackedgeneralinfo.cpp +++ b/app/wm/tracker/trackedgeneralinfo.cpp @@ -1,157 +1,167 @@ /* * 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 "../abstractwindowinterface.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); + connect(m_wm, &AbstractWindowInterface::currentActivityChanged, this, [&]() { + updateTrackingCurrentActivity(); + }); + 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; } +bool TrackedGeneralInfo::isTrackingCurrentActivity() const +{ + return m_isTrackingCurrentActivity; +} + +void TrackedGeneralInfo::updateTrackingCurrentActivity() +{ + m_isTrackingCurrentActivity = ( m_activities.isEmpty() + || m_activities[0] == "0" + || m_activities.contains(m_wm->currentActivity())); +} + + 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() + && isTrackingCurrentActivity() && !winfo.isPlasmaDesktop() && !winfo.isMinimized() && winfo.isOnDesktop(m_wm->currentDesktop()) - && winfo.isOnActivity(m_wm->currentActivity()) - && isTrackedOnActivity(m_wm->currentActivity())); + && winfo.isOnActivity(m_wm->currentActivity())); } } } } diff --git a/app/wm/tracker/trackedgeneralinfo.h b/app/wm/tracker/trackedgeneralinfo.h index 0af8d088..dd2367c2 100644 --- a/app/wm/tracker/trackedgeneralinfo.h +++ b/app/wm/tracker/trackedgeneralinfo.h @@ -1,100 +1,106 @@ /* * 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); + bool isTrackingCurrentActivity() const; + 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; + void updateTrackingCurrentActivity(); + +protected: + QStringList m_activities; + + LastActiveWindow *m_lastActiveWindow{nullptr}; + AbstractWindowInterface *m_wm{nullptr}; + Tracker::Windows *m_tracker{nullptr}; private: bool m_enabled; bool m_activeWindowMaximized; bool m_existsWindowActive; bool m_existsWindowMaximized; - LastActiveWindow *m_lastActiveWindow{nullptr}; + bool m_isTrackingCurrentActivity{true}; SchemeColors *m_activeWindowScheme{nullptr}; - - AbstractWindowInterface *m_wm{nullptr}; - Tracker::Windows *m_tracker{nullptr}; }; } } } #endif diff --git a/app/wm/tracker/trackedlayoutinfo.cpp b/app/wm/tracker/trackedlayoutinfo.cpp index e69de29b..69c6e82f 100644 --- a/app/wm/tracker/trackedlayoutinfo.cpp +++ b/app/wm/tracker/trackedlayoutinfo.cpp @@ -0,0 +1,54 @@ +/* +* 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 "trackedlayoutinfo.h" + +//local +#include "trackerwindows.h" +#include "../../layout/genericlayout.h" + +namespace Latte { +namespace WindowSystem { +namespace Tracker { + + +TrackedLayoutInfo::TrackedLayoutInfo(Tracker::Windows *tracker, Latte::Layout::GenericLayout *layout) + : TrackedGeneralInfo(tracker), + m_layout(layout) +{ + m_activities = m_layout->appliedActivities(); + + connect(m_layout, &Latte::Layout::GenericLayout::activitiesChanged, this, [&]() { + m_activities = m_layout->appliedActivities(); + updateTrackingCurrentActivity(); + }); +} + +TrackedLayoutInfo::~TrackedLayoutInfo() +{ +} + +Latte::Layout::GenericLayout *TrackedLayoutInfo::layout() const +{ + return m_layout; +} + +} +} +} diff --git a/app/wm/tracker/trackedlayoutinfo.h b/app/wm/tracker/trackedlayoutinfo.h index e69de29b..54c01df6 100644 --- a/app/wm/tracker/trackedlayoutinfo.h +++ b/app/wm/tracker/trackedlayoutinfo.h @@ -0,0 +1,64 @@ +/* +* 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 WINDOWSYSTEMTRACKEDLAYOUTINFO_H +#define WINDOWSYSTEMTRACKEDLAYOUTINFO_H + +// local +#include "trackedgeneralinfo.h" +#include "../windowinfowrap.h" + +// Qt +#include +#include + +namespace Latte { +namespace Layout { +class GenericLayout; +} +namespace WindowSystem { +namespace Tracker { +class Windows; +} +} +} + + +namespace Latte { +namespace WindowSystem { +namespace Tracker { + +class TrackedLayoutInfo : public TrackedGeneralInfo { + Q_OBJECT + +public: + TrackedLayoutInfo(Tracker::Windows *tracker, Latte::Layout::GenericLayout *layout); + ~TrackedLayoutInfo() override; + + Latte::Layout::GenericLayout *layout() const; + +private: + Latte::Layout::GenericLayout *m_layout{nullptr}; +}; + +} +} +} + +#endif diff --git a/app/wm/tracker/trackedviewinfo.cpp b/app/wm/tracker/trackedviewinfo.cpp index 88d87266..3fdb885c 100644 --- a/app/wm/tracker/trackedviewinfo.cpp +++ b/app/wm/tracker/trackedviewinfo.cpp @@ -1,117 +1,118 @@ /* * 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) { + m_activities = m_view->activities(); + + connect(m_view, &Latte::View::activitiesChanged, this, [&]() { + m_activities = m_view->activities(); + updateTrackingCurrentActivity(); + }); } 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) + 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 188a9738..ddaf3102 100644 --- a/app/wm/tracker/trackedviewinfo.h +++ b/app/wm/tracker/trackedviewinfo.h @@ -1,87 +1,84 @@ /* * 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