diff --git a/app/view/windowstracker/allscreenstracker.cpp b/app/view/windowstracker/allscreenstracker.cpp index d4c59f36..04319498 100644 --- a/app/view/windowstracker/allscreenstracker.cpp +++ b/app/view/windowstracker/allscreenstracker.cpp @@ -1,120 +1,140 @@ /* * 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 "allscreenstracker.h" // local #include "../view.h" #include "../../layout/genericlayout.h" #include "../../wm/schemecolors.h" #include "../../wm/tracker/lastactivewindow.h" #include "../../wm/tracker/trackerwindows.h" namespace Latte { namespace ViewPart { namespace TrackerPart { AllScreensTracker::AllScreensTracker(WindowsTracker *parent) : QObject(parent), m_latteView(parent->view()), m_wm(parent->wm()) { init(); } AllScreensTracker::~AllScreensTracker() { } void AllScreensTracker::init() { + if (!m_currentLastActiveWindow && lastActiveWindow()) { + initSignalsForInformation(); + } + + connect(m_latteView, &Latte::View::layoutChanged, this, [&]() { + if (m_latteView->layout()) { + initSignalsForInformation(); + } + }); + connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::informationAnnouncedForLayout, this, [&](const Latte::Layout::GenericLayout *layout) { if (m_latteView->layout() == layout) { initSignalsForInformation(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::activeWindowMaximizedChangedForLayout, this, [&](const Latte::Layout::GenericLayout *layout) { if (m_latteView->layout() == layout) { emit activeWindowMaximizedChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::existsWindowActiveChangedForLayout, this, [&](const Latte::Layout::GenericLayout *layout) { if (m_latteView->layout() == layout) { emit existsWindowActiveChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::existsWindowMaximizedChangedForLayout, this, [&](const Latte::Layout::GenericLayout *layout) { if (m_latteView->layout() == layout) { emit existsWindowMaximizedChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::activeWindowSchemeChangedForLayout, this, [&](const Latte::Layout::GenericLayout *layout) { if (m_latteView->layout() == layout) { emit activeWindowSchemeChanged(); } }); } void AllScreensTracker::initSignalsForInformation() { - connect(lastActiveWindow(), &WindowSystem::Tracker::LastActiveWindow::draggingStarted, + if (m_currentLastActiveWindow) { + disconnect(m_currentLastActiveWindow, &WindowSystem::Tracker::LastActiveWindow::draggingStarted, + this, &AllScreensTracker::activeWindowDraggingStarted); + } + + m_currentLastActiveWindow = lastActiveWindow(); + connect(m_currentLastActiveWindow, &WindowSystem::Tracker::LastActiveWindow::draggingStarted, this, &AllScreensTracker::activeWindowDraggingStarted); emit lastActiveWindowChanged(); + emit activeWindowMaximizedChanged(); + emit existsWindowActiveChanged(); + emit existsWindowMaximizedChanged(); + emit activeWindowSchemeChanged(); } bool AllScreensTracker::activeWindowMaximized() const { return m_wm->windowsTracker()->activeWindowMaximized(m_latteView->layout()); } bool AllScreensTracker::existsWindowActive() const { return m_wm->windowsTracker()->existsWindowActive(m_latteView->layout()); } bool AllScreensTracker::existsWindowMaximized() const { return m_wm->windowsTracker()->existsWindowMaximized(m_latteView->layout()); } WindowSystem::SchemeColors *AllScreensTracker::activeWindowScheme() const { return m_wm->windowsTracker()->activeWindowScheme(m_latteView->layout()); } WindowSystem::Tracker::LastActiveWindow *AllScreensTracker::lastActiveWindow() { return m_wm->windowsTracker()->lastActiveWindow(m_latteView->layout()); } //! Window Functions void AllScreensTracker::requestMoveLastWindow(int localX, int localY) { m_wm->windowsTracker()->lastActiveWindow(m_latteView->layout())->requestMove(m_latteView, localX, localY); } } } } diff --git a/app/view/windowstracker/allscreenstracker.h b/app/view/windowstracker/allscreenstracker.h index 125ab1c6..9939202f 100644 --- a/app/view/windowstracker/allscreenstracker.h +++ b/app/view/windowstracker/allscreenstracker.h @@ -1,96 +1,99 @@ /* * 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 WINDOWSALLSCREENSTRACKER_H #define WINDOWSALLSCREENSTRACKER_H // local #include "../../wm/abstractwindowinterface.h" // Qt #include namespace Latte{ class View; namespace ViewPart { class WindowsTracker; } namespace WindowSystem { class AbstractWindowInterface; class SchemeColors; namespace Tracker { class LastActiveWindow; } } } namespace Latte { namespace ViewPart { namespace TrackerPart { class AllScreensTracker : public QObject { Q_OBJECT Q_PROPERTY(bool activeWindowMaximized READ activeWindowMaximized NOTIFY activeWindowMaximizedChanged) Q_PROPERTY(bool existsWindowActive READ existsWindowActive NOTIFY existsWindowActiveChanged) Q_PROPERTY(bool existsWindowMaximized READ existsWindowMaximized NOTIFY existsWindowMaximizedChanged) Q_PROPERTY(Latte::WindowSystem::SchemeColors *activeWindowScheme READ activeWindowScheme NOTIFY activeWindowSchemeChanged) Q_PROPERTY(Latte::WindowSystem::Tracker::LastActiveWindow *lastActiveWindow READ lastActiveWindow NOTIFY lastActiveWindowChanged) public: explicit AllScreensTracker(WindowsTracker *parent); virtual ~AllScreensTracker(); bool activeWindowMaximized() const; bool existsWindowActive() const; bool existsWindowMaximized() const; WindowSystem::SchemeColors *activeWindowScheme() const; WindowSystem::Tracker::LastActiveWindow *lastActiveWindow(); public slots: Q_INVOKABLE void requestMoveLastWindow(int localX, int localY); signals: void activeWindowDraggingStarted(); void activeWindowMaximizedChanged(); void existsWindowActiveChanged(); void existsWindowMaximizedChanged(); void activeWindowSchemeChanged(); void lastActiveWindowChanged(); private slots: void initSignalsForInformation(); private: void init(); +private: + Latte::WindowSystem::Tracker::LastActiveWindow *m_currentLastActiveWindow{nullptr}; + Latte::View *m_latteView{nullptr}; WindowSystem::AbstractWindowInterface *m_wm{nullptr}; }; } } } #endif diff --git a/app/view/windowstracker/currentscreentracker.cpp b/app/view/windowstracker/currentscreentracker.cpp index bf93edcc..82584d24 100644 --- a/app/view/windowstracker/currentscreentracker.cpp +++ b/app/view/windowstracker/currentscreentracker.cpp @@ -1,155 +1,153 @@ /* * 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 "currentscreentracker.h" // local #include "../view.h" #include "../../wm/schemecolors.h" #include "../../wm/tracker/lastactivewindow.h" #include "../../wm/tracker/trackerwindows.h" namespace Latte { namespace ViewPart { namespace TrackerPart { CurrentScreenTracker::CurrentScreenTracker(WindowsTracker *parent) : QObject(parent), m_latteView(parent->view()), m_wm(parent->wm()) { init(); - - m_wm->windowsTracker()->addView(m_latteView); } CurrentScreenTracker::~CurrentScreenTracker() { m_wm->windowsTracker()->removeView(m_latteView); } void CurrentScreenTracker::init() { connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::informationAnnounced, this, [&](const Latte::View *view) { if (m_latteView == view) { initSignalsForInformation(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::activeWindowMaximizedChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit activeWindowMaximizedChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::activeWindowTouchingChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit activeWindowTouchingChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::existsWindowActiveChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit existsWindowActiveChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::existsWindowMaximizedChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit existsWindowMaximizedChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::existsWindowTouchingChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit existsWindowTouchingChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::activeWindowSchemeChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit activeWindowSchemeChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::touchingWindowSchemeChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit touchingWindowSchemeChanged(); } }); } void CurrentScreenTracker::initSignalsForInformation() { connect(lastActiveWindow(), &WindowSystem::Tracker::LastActiveWindow::draggingStarted, this, &CurrentScreenTracker::activeWindowDraggingStarted); emit lastActiveWindowChanged(); } bool CurrentScreenTracker::activeWindowMaximized() const { return m_wm->windowsTracker()->activeWindowMaximized(m_latteView); } bool CurrentScreenTracker::activeWindowTouching() const { return m_wm->windowsTracker()->activeWindowTouching(m_latteView); } bool CurrentScreenTracker::existsWindowActive() const { return m_wm->windowsTracker()->existsWindowActive(m_latteView); } bool CurrentScreenTracker::existsWindowMaximized() const { return m_wm->windowsTracker()->existsWindowMaximized(m_latteView); } bool CurrentScreenTracker::existsWindowTouching() const { return m_wm->windowsTracker()->existsWindowTouching(m_latteView); } WindowSystem::SchemeColors *CurrentScreenTracker::activeWindowScheme() const { return m_wm->windowsTracker()->activeWindowScheme(m_latteView); } WindowSystem::SchemeColors *CurrentScreenTracker::touchingWindowScheme() const { return m_wm->windowsTracker()->touchingWindowScheme(m_latteView); } WindowSystem::Tracker::LastActiveWindow *CurrentScreenTracker::lastActiveWindow() { return m_wm->windowsTracker()->lastActiveWindow(m_latteView); } //! Window Functions void CurrentScreenTracker::requestMoveLastWindow(int localX, int localY) { m_wm->windowsTracker()->lastActiveWindow(m_latteView)->requestMove(m_latteView, localX, localY); } } } } diff --git a/app/view/windowstracker/windowstracker.cpp b/app/view/windowstracker/windowstracker.cpp index 731551d3..8ba55fe2 100644 --- a/app/view/windowstracker/windowstracker.cpp +++ b/app/view/windowstracker/windowstracker.cpp @@ -1,111 +1,113 @@ /* * 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 "windowstracker.h" // local #include "currentscreentracker.h" #include "allscreenstracker.h" #include "../view.h" #include "../../lattecorona.h" #include "../../wm/tracker/trackerwindows.h" namespace Latte { namespace ViewPart { WindowsTracker::WindowsTracker(Latte::View *parent) : QObject(parent), m_latteView(parent) { qDebug() << "WindowsTracker creating..."; auto corona = qobject_cast(m_latteView->corona()); m_wm = corona->wm(); m_allScreensTracker = new TrackerPart::AllScreensTracker(this); m_currentScreenTracker = new TrackerPart::CurrentScreenTracker(this); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::enabledChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit enabledChanged(); } }); connect(m_allScreensTracker, &TrackerPart::AllScreensTracker::activeWindowDraggingStarted, this, &WindowsTracker::activeWindowDraggingStarted); connect(m_currentScreenTracker, &TrackerPart::CurrentScreenTracker::activeWindowDraggingStarted, this, &WindowsTracker::activeWindowDraggingStarted); + m_wm->windowsTracker()->addView(m_latteView); + emit allScreensChanged(); emit currentScreenChanged(); } WindowsTracker::~WindowsTracker() { qDebug() << "WindowsTracker removing..."; if (m_allScreensTracker) { m_allScreensTracker->deleteLater(); } if (m_currentScreenTracker) { m_currentScreenTracker->deleteLater(); } } Latte::View *WindowsTracker::view() const { return m_latteView; } WindowSystem::AbstractWindowInterface *WindowsTracker::wm() const { return m_wm; } bool WindowsTracker::enabled() const { return m_wm->windowsTracker()->enabled(m_latteView); } void WindowsTracker::setEnabled(bool active) { m_wm->windowsTracker()->setEnabled(m_latteView, active); } TrackerPart::AllScreensTracker *WindowsTracker::allScreens() const { return m_allScreensTracker; } TrackerPart::CurrentScreenTracker *WindowsTracker::currentScreen() const { return m_currentScreenTracker; } //! Window Functions void WindowsTracker::setWindowOnActivities(QWindow &window, const QStringList &activities) { m_wm->setWindowOnActivities(window, activities); } } }