Warning, file /plasma/latte-dock/app/view/windowstracker/allscreenstracker.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002 *  Copyright 2019  Michail Vourlakos <mvourlakos@gmail.com>
0003 *
0004 *  This file is part of Latte-Dock
0005 *
0006 *  Latte-Dock is free software; you can redistribute it and/or
0007 *  modify it under the terms of the GNU General Public License as
0008 *  published by the Free Software Foundation; either version 2 of
0009 *  the License, or (at your option) any later version.
0010 *
0011 *  Latte-Dock is distributed in the hope that it will be useful,
0012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 *  GNU General Public License for more details.
0015 *
0016 *  You should have received a copy of the GNU General Public License
0017 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 
0020 #include "allscreenstracker.h"
0021 
0022 // local
0023 #include "../view.h"
0024 #include "../../layout/genericlayout.h"
0025 #include "../../wm/schemecolors.h"
0026 #include "../../wm/tracker/lastactivewindow.h"
0027 #include "../../wm/tracker/windowstracker.h"
0028 
0029 namespace Latte {
0030 namespace ViewPart {
0031 namespace TrackerPart {
0032 
0033 AllScreensTracker::AllScreensTracker(WindowsTracker *parent)
0034     : QObject(parent),
0035       m_latteView(parent->view()),
0036       m_wm(parent->wm())
0037 {
0038     init();
0039 }
0040 
0041 AllScreensTracker::~AllScreensTracker()
0042 {
0043 }
0044 
0045 void  AllScreensTracker::init()
0046 {
0047     if (!m_currentLastActiveWindow && lastActiveWindow()) {
0048         initSignalsForInformation();
0049     }
0050 
0051     connect(m_latteView, &Latte::View::layoutChanged, this, [&]() {
0052         if (m_latteView->layout()) {
0053             initSignalsForInformation();
0054         }
0055     });
0056 
0057     connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::informationAnnouncedForLayout, this, [&](const Latte::Layout::GenericLayout *layout) {
0058         if (m_latteView->layout() == layout) {
0059             initSignalsForInformation();
0060         }
0061     });
0062 
0063     connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::activeWindowMaximizedChangedForLayout, this, [&](const Latte::Layout::GenericLayout *layout) {
0064         if (m_latteView->layout() == layout) {
0065             emit activeWindowMaximizedChanged();
0066         }
0067     });
0068 
0069     connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::existsWindowActiveChangedForLayout, this, [&](const Latte::Layout::GenericLayout *layout) {
0070         if (m_latteView->layout() == layout) {
0071             emit existsWindowActiveChanged();
0072         }
0073     });
0074 
0075     connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::existsWindowMaximizedChangedForLayout, this, [&](const Latte::Layout::GenericLayout *layout) {
0076         if (m_latteView->layout() == layout) {
0077             emit existsWindowMaximizedChanged();
0078         }
0079     });
0080 
0081     connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::activeWindowSchemeChangedForLayout, this, [&](const Latte::Layout::GenericLayout *layout) {
0082         if (m_latteView->layout() == layout) {
0083             emit activeWindowSchemeChanged();
0084         }
0085     });
0086 }
0087 
0088 void AllScreensTracker::initSignalsForInformation()
0089 {
0090     m_currentLastActiveWindow = lastActiveWindow();
0091 
0092     emit lastActiveWindowChanged();
0093     emit activeWindowMaximizedChanged();
0094     emit existsWindowActiveChanged();
0095     emit existsWindowMaximizedChanged();
0096     emit activeWindowSchemeChanged();
0097 }
0098 
0099 bool AllScreensTracker::activeWindowMaximized() const
0100 {
0101     return m_wm->windowsTracker()->activeWindowMaximized(m_latteView->layout());
0102 }
0103 
0104 bool AllScreensTracker::existsWindowActive() const
0105 {
0106     return m_wm->windowsTracker()->existsWindowActive(m_latteView->layout());
0107 }
0108 
0109 bool AllScreensTracker::existsWindowMaximized() const
0110 {
0111     return m_wm->windowsTracker()->existsWindowMaximized(m_latteView->layout());
0112 }
0113 
0114 WindowSystem::SchemeColors *AllScreensTracker::activeWindowScheme() const
0115 {
0116     return m_wm->windowsTracker()->activeWindowScheme(m_latteView->layout());
0117 }
0118 
0119 WindowSystem::Tracker::LastActiveWindow *AllScreensTracker::lastActiveWindow()
0120 {
0121     return m_wm->windowsTracker()->lastActiveWindow(m_latteView->layout());
0122 }
0123 
0124 
0125 //! Window Functions
0126 void AllScreensTracker::requestMoveLastWindow(int localX, int localY)
0127 {
0128     m_wm->windowsTracker()->lastActiveWindow(m_latteView->layout())->requestMove(m_latteView, localX, localY);
0129 }
0130 
0131 }
0132 }
0133 }