From a0226e1de9d9bb172a4f23f73bc9b2b8a5c8310e Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Tue, 4 Jun 2019 19:49:43 +0300 Subject: [PATCH] split trackedinfo to general and view --- app/wm/tracker/CMakeLists.txt | 3 +- app/wm/tracker/lastactivewindow.cpp | 4 +- app/wm/tracker/lastactivewindow.h | 6 +- ...trackedinfo.cpp => trackedgeneralinfo.cpp} | 88 +++------------ .../{trackedinfo.h => trackedgeneralinfo.h} | 25 +---- app/wm/tracker/trackedviewinfo.cpp | 100 ++++++++++++++++++ app/wm/tracker/trackedviewinfo.h | 78 ++++++++++++++ app/wm/tracker/windows.cpp | 6 +- app/wm/tracker/windows.h | 4 +- 9 files changed, 211 insertions(+), 103 deletions(-) rename app/wm/tracker/{trackedinfo.cpp => trackedgeneralinfo.cpp} (53%) rename app/wm/tracker/{trackedinfo.h => trackedgeneralinfo.h} (77%) create mode 100644 app/wm/tracker/trackedviewinfo.cpp create mode 100644 app/wm/tracker/trackedviewinfo.h diff --git a/app/wm/tracker/CMakeLists.txt b/app/wm/tracker/CMakeLists.txt index fd7e77454..685ec0e57 100644 --- a/app/wm/tracker/CMakeLists.txt +++ b/app/wm/tracker/CMakeLists.txt @@ -3,6 +3,7 @@ set(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 + ${CMAKE_CURRENT_SOURCE_DIR}/trackedgeneralinfo.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/trackedviewinfo.cpp PARENT_SCOPE ) diff --git a/app/wm/tracker/lastactivewindow.cpp b/app/wm/tracker/lastactivewindow.cpp index 7f681cf55..da35f8599 100644 --- a/app/wm/tracker/lastactivewindow.cpp +++ b/app/wm/tracker/lastactivewindow.cpp @@ -20,7 +20,7 @@ #include "lastactivewindow.h" // local -#include "trackedinfo.h" +#include "trackedgeneralinfo.h" #include "windows.h" #include "../abstractwindowinterface.h" #include "../tasktools.h" @@ -37,7 +37,7 @@ namespace Latte { namespace WindowSystem { namespace Tracker { -LastActiveWindow::LastActiveWindow(TrackedInfo *trackedInfo) +LastActiveWindow::LastActiveWindow(TrackedGeneralInfo *trackedInfo) : QObject(trackedInfo), m_trackedInfo(trackedInfo), m_windowsTracker(trackedInfo->wm()->windowsTracker()), diff --git a/app/wm/tracker/lastactivewindow.h b/app/wm/tracker/lastactivewindow.h index ae882d01a..adb026b92 100644 --- a/app/wm/tracker/lastactivewindow.h +++ b/app/wm/tracker/lastactivewindow.h @@ -33,7 +33,7 @@ class View; namespace WindowSystem { class AbstractWindowInterface; namespace Tracker { -class TrackedInfo; +class TrackedGeneralInfo; class Windows; } } @@ -63,7 +63,7 @@ class LastActiveWindow : public QObject { Q_PROPERTY(QVariant winId READ winId NOTIFY winIdChanged) public: - LastActiveWindow(TrackedInfo *trackedInfo); + LastActiveWindow(TrackedGeneralInfo *trackedInfo); ~LastActiveWindow() override; bool isActive() const; @@ -151,7 +151,7 @@ private: QVariant m_winId; - TrackedInfo *m_trackedInfo{nullptr}; + TrackedGeneralInfo *m_trackedInfo{nullptr}; AbstractWindowInterface *m_wm{nullptr}; Tracker::Windows *m_windowsTracker{nullptr}; }; diff --git a/app/wm/tracker/trackedinfo.cpp b/app/wm/tracker/trackedgeneralinfo.cpp similarity index 53% rename from app/wm/tracker/trackedinfo.cpp rename to app/wm/tracker/trackedgeneralinfo.cpp index 3df13361e..3963566b4 100644 --- a/app/wm/tracker/trackedinfo.cpp +++ b/app/wm/tracker/trackedgeneralinfo.cpp @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "trackedinfo.h" +#include "trackedgeneralinfo.h" //local #include "windows.h" @@ -29,7 +29,7 @@ namespace WindowSystem { namespace Tracker { -TrackedInfo::TrackedInfo(Tracker::Windows *tracker, Latte::View *view) +TrackedGeneralInfo::TrackedGeneralInfo(Tracker::Windows *tracker, Latte::View *view) : QObject(tracker) , m_wm(tracker->wm()), m_view(view) @@ -39,7 +39,7 @@ TrackedInfo::TrackedInfo(Tracker::Windows *tracker, Latte::View *view) emit lastActiveWindowChanged(); } -TrackedInfo::~TrackedInfo() +TrackedGeneralInfo::~TrackedGeneralInfo() { if (m_lastActiveWindow) { auto law = m_lastActiveWindow; @@ -50,12 +50,12 @@ TrackedInfo::~TrackedInfo() } } -bool TrackedInfo::enabled() const +bool TrackedGeneralInfo::enabled() const { return m_enabled; } -void TrackedInfo::setEnabled(bool enabled) +void TrackedGeneralInfo::setEnabled(bool enabled) { if (m_enabled == enabled) { return; @@ -64,12 +64,12 @@ void TrackedInfo::setEnabled(bool enabled) m_enabled = enabled; } -bool TrackedInfo::activeWindowMaximized() const +bool TrackedGeneralInfo::activeWindowMaximized() const { return m_activeWindowMaximized; } -void TrackedInfo::setActiveWindowMaximized(bool activeMaximized) +void TrackedGeneralInfo::setActiveWindowMaximized(bool activeMaximized) { if (m_activeWindowMaximized == activeMaximized) { return; @@ -78,26 +78,12 @@ void TrackedInfo::setActiveWindowMaximized(bool activeMaximized) 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 +bool TrackedGeneralInfo::existsWindowActive() const { return m_existsWindowActive; } -void TrackedInfo::setExistsWindowActive(bool exists) +void TrackedGeneralInfo::setExistsWindowActive(bool exists) { if (m_existsWindowActive == exists) { return; @@ -106,12 +92,12 @@ void TrackedInfo::setExistsWindowActive(bool exists) m_existsWindowActive = exists; } -bool TrackedInfo::existsWindowMaximized() const +bool TrackedGeneralInfo::existsWindowMaximized() const { return m_existsWindowMaximized; } -void TrackedInfo::setExistsWindowMaximized(bool maximized) +void TrackedGeneralInfo::setExistsWindowMaximized(bool maximized) { if (m_existsWindowMaximized == maximized) { return; @@ -120,45 +106,17 @@ void TrackedInfo::setExistsWindowMaximized(bool maximized) 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 +LastActiveWindow *TrackedGeneralInfo::lastActiveWindow() const { return m_lastActiveWindow; } -SchemeColors *TrackedInfo::activeWindowScheme() const +SchemeColors *TrackedGeneralInfo::activeWindowScheme() const { return m_activeWindowScheme; } -void TrackedInfo::setActiveWindowScheme(SchemeColors *scheme) +void TrackedGeneralInfo::setActiveWindowScheme(SchemeColors *scheme) { if (m_activeWindowScheme == scheme) { return; @@ -167,26 +125,12 @@ void TrackedInfo::setActiveWindowScheme(SchemeColors *scheme) m_activeWindowScheme = scheme; } -SchemeColors *TrackedInfo::touchingWindowScheme() const -{ - return m_touchingWindowScheme; -} - -void TrackedInfo::setTouchingWindowScheme(SchemeColors *scheme) -{ - if (m_touchingWindowScheme == scheme) { - return; - } - - m_touchingWindowScheme = scheme; -} - -Latte::View *TrackedInfo::view() +Latte::View *TrackedGeneralInfo::view() { return m_view; } -AbstractWindowInterface *TrackedInfo::wm() +AbstractWindowInterface *TrackedGeneralInfo::wm() { return m_wm; } diff --git a/app/wm/tracker/trackedinfo.h b/app/wm/tracker/trackedgeneralinfo.h similarity index 77% rename from app/wm/tracker/trackedinfo.h rename to app/wm/tracker/trackedgeneralinfo.h index 708d19abb..3c75681d7 100644 --- a/app/wm/tracker/trackedinfo.h +++ b/app/wm/tracker/trackedgeneralinfo.h @@ -17,8 +17,8 @@ * along with this program. If not, see . */ -#ifndef WINDOWSYSTEMTRACKEDINFO_H -#define WINDOWSYSTEMTRACKEDINFO_H +#ifndef WINDOWSYSTEMTRACKEDGENERALINFO_H +#define WINDOWSYSTEMTRACKEDGENERALINFO_H // local #include "lastactivewindow.h" @@ -26,7 +26,6 @@ // Qt #include -#include namespace Latte { class View; @@ -43,14 +42,14 @@ namespace Latte { namespace WindowSystem { namespace Tracker { -class TrackedInfo : public QObject { +class TrackedGeneralInfo : public QObject { Q_OBJECT Q_PROPERTY(Latte::WindowSystem::Tracker::LastActiveWindow *activeWindow READ lastActiveWindow NOTIFY lastActiveWindowChanged) public: - TrackedInfo(Tracker::Windows *tracker, Latte::View *view); - ~TrackedInfo() override; + TrackedGeneralInfo(Tracker::Windows *tracker, Latte::View *view); + ~TrackedGeneralInfo() override; bool enabled() const; void setEnabled(bool enabled); @@ -58,18 +57,12 @@ public: 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); @@ -78,9 +71,6 @@ public: SchemeColors *activeWindowScheme() const; void setActiveWindowScheme(SchemeColors *scheme); - SchemeColors *touchingWindowScheme() const; - void setTouchingWindowScheme(SchemeColors *scheme); - Latte::View *view(); AbstractWindowInterface *wm(); @@ -90,18 +80,13 @@ signals: private: bool m_enabled; bool m_activeWindowMaximized; - bool m_activeWindowTouching; bool m_existsWindowActive; bool m_existsWindowMaximized; - bool m_existsWindowTouching; - - QRect m_availableScreenGeometry; Latte::View *m_view{nullptr}; LastActiveWindow *m_lastActiveWindow{nullptr}; SchemeColors *m_activeWindowScheme{nullptr}; - SchemeColors *m_touchingWindowScheme{nullptr}; AbstractWindowInterface *m_wm{nullptr}; }; diff --git a/app/wm/tracker/trackedviewinfo.cpp b/app/wm/tracker/trackedviewinfo.cpp new file mode 100644 index 000000000..d3b146cee --- /dev/null +++ b/app/wm/tracker/trackedviewinfo.cpp @@ -0,0 +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 . +*/ + +#include "trackedviewinfo.h" + +//local +#include "windows.h" +#include "../schemecolors.h" +#include "../../view/view.h" + + +namespace Latte { +namespace WindowSystem { +namespace Tracker { + + +TrackedViewInfo::TrackedViewInfo(Tracker::Windows *tracker, Latte::View *view) + : TrackedGeneralInfo(tracker, 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; +} + +} +} +} diff --git a/app/wm/tracker/trackedviewinfo.h b/app/wm/tracker/trackedviewinfo.h new file mode 100644 index 000000000..c92a52bd2 --- /dev/null +++ b/app/wm/tracker/trackedviewinfo.h @@ -0,0 +1,78 @@ +/* +* 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); + +private: + bool m_activeWindowTouching; + bool m_existsWindowTouching; + + QRect m_availableScreenGeometry; + + SchemeColors *m_touchingWindowScheme{nullptr}; +}; + +} +} +} + +#endif diff --git a/app/wm/tracker/windows.cpp b/app/wm/tracker/windows.cpp index db590d66a..6b28c52cb 100644 --- a/app/wm/tracker/windows.cpp +++ b/app/wm/tracker/windows.cpp @@ -22,7 +22,7 @@ // local #include "lastactivewindow.h" #include "schemes.h" -#include "trackedinfo.h" +#include "trackedviewinfo.h" #include "../abstractwindowinterface.h" #include "../schemecolors.h" #include "../../lattecorona.h" @@ -46,7 +46,7 @@ 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) { + for (QHash::iterator i=m_views.begin(); i!=m_views.end(); ++i) { i.value()->deleteLater(); m_views[i.key()] = nullptr; } @@ -138,7 +138,7 @@ void Windows::addView(Latte::View *view) return; } - m_views[view] = new TrackedInfo(this, view); + m_views[view] = new TrackedViewInfo(this, view); updateAvailableScreenGeometries(); updateHints(view); diff --git a/app/wm/tracker/windows.h b/app/wm/tracker/windows.h index b35381235..f14a4c48b 100644 --- a/app/wm/tracker/windows.h +++ b/app/wm/tracker/windows.h @@ -36,7 +36,7 @@ class AbstractWindowInterface; class SchemeColors; namespace Tracker { class LastActiveWindow; -class TrackedInfo; +class TrackedViewInfo; } } } @@ -114,7 +114,7 @@ private: private: AbstractWindowInterface *m_wm; - QHash m_views; + QHash m_views; QMap m_windows; };