File indexing completed on 2024-04-28 16:49:28
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 "windowstracker.h" 0021 0022 // local 0023 #include "currentscreentracker.h" 0024 #include "allscreenstracker.h" 0025 #include "../view.h" 0026 #include "../../lattecorona.h" 0027 #include "../../wm/tracker/windowstracker.h" 0028 0029 0030 namespace Latte { 0031 namespace ViewPart { 0032 0033 WindowsTracker::WindowsTracker(Latte::View *parent) 0034 : QObject(parent), 0035 m_latteView(parent) 0036 { 0037 qDebug() << "WindowsTracker creating..."; 0038 0039 auto corona = qobject_cast<Latte::Corona *>(m_latteView->corona()); 0040 m_wm = corona->wm(); 0041 0042 m_allScreensTracker = new TrackerPart::AllScreensTracker(this); 0043 m_currentScreenTracker = new TrackerPart::CurrentScreenTracker(this); 0044 0045 connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::enabledChanged, this, [&](const Latte::View *view) { 0046 if (m_latteView == view) { 0047 emit enabledChanged(); 0048 } 0049 }); 0050 0051 m_wm->windowsTracker()->addView(m_latteView); 0052 0053 emit allScreensChanged(); 0054 emit currentScreenChanged(); 0055 } 0056 0057 WindowsTracker::~WindowsTracker() 0058 { 0059 qDebug() << "WindowsTracker removing..."; 0060 0061 if (m_allScreensTracker) { 0062 m_allScreensTracker->deleteLater(); 0063 } 0064 0065 if (m_currentScreenTracker) { 0066 m_currentScreenTracker->deleteLater(); 0067 } 0068 } 0069 0070 Latte::View *WindowsTracker::view() const 0071 { 0072 return m_latteView; 0073 } 0074 0075 WindowSystem::AbstractWindowInterface *WindowsTracker::wm() const 0076 { 0077 return m_wm; 0078 } 0079 0080 bool WindowsTracker::enabled() const 0081 { 0082 return m_wm->windowsTracker()->enabled(m_latteView); 0083 } 0084 0085 void WindowsTracker::setEnabled(bool active) 0086 { 0087 m_wm->windowsTracker()->setEnabled(m_latteView, active); 0088 } 0089 0090 0091 TrackerPart::AllScreensTracker *WindowsTracker::allScreens() const 0092 { 0093 return m_allScreensTracker; 0094 } 0095 0096 TrackerPart::CurrentScreenTracker *WindowsTracker::currentScreen() const 0097 { 0098 return m_currentScreenTracker; 0099 } 0100 0101 //! Window Functions 0102 void WindowsTracker::setWindowOnActivities(QWindow &window, const QStringList &activities) 0103 { 0104 m_wm->setWindowOnActivities(window, activities); 0105 } 0106 0107 //! Environment Functions 0108 void WindowsTracker::switchToNextActivity() 0109 { 0110 m_wm->switchToNextActivity(); 0111 } 0112 0113 void WindowsTracker::switchToPreviousActivity() 0114 { 0115 m_wm->switchToPreviousActivity(); 0116 } 0117 0118 void WindowsTracker::switchToNextVirtualDesktop() 0119 { 0120 m_wm->switchToNextVirtualDesktop(); 0121 } 0122 0123 void WindowsTracker::switchToPreviousVirtualDesktop() 0124 { 0125 m_wm->switchToPreviousVirtualDesktop(); 0126 } 0127 0128 } 0129 }