1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
/*
SPDX-FileCopyrightText: 2019 Michail Vourlakos <mvourlakos@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "currentscreentracker.h"
// local
#include "../view.h"
#include "../../wm/schemecolors.h"
#include "../../wm/tracker/lastactivewindow.h"
#include "../../wm/tracker/windowstracker.h"
namespace Latte {
namespace ViewPart {
namespace TrackerPart {
CurrentScreenTracker::CurrentScreenTracker(WindowsTracker *parent)
: QObject(parent),
m_latteView(parent->view()),
m_wm(parent->wm())
{
init();
}
CurrentScreenTracker::~CurrentScreenTracker()
{
m_wm->windowsTracker()->removeView(m_latteView);
}
void CurrentScreenTracker::init()
{
if (lastActiveWindow()) {
initSignalsForInformation();
}
connect(m_latteView, &Latte::View::layoutChanged, this, [&]() {
if (m_latteView->layout()) {
initSignalsForInformation();
}
});
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::activeWindowTouchingEdgeChanged, this, [&](const Latte::View *view) {
if (m_latteView == view) {
emit activeWindowTouchingEdgeChanged();
}
});
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::existsWindowTouchingEdgeChanged, this, [&](const Latte::View *view) {
if (m_latteView == view) {
emit existsWindowTouchingEdgeChanged();
}
});
connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::isTouchingBusyVerticalViewChanged, this, [&](const Latte::View *view) {
if (m_latteView == view) {
emit isTouchingBusyVerticalViewChanged();
}
});
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()
{
emit lastActiveWindowChanged();
emit activeWindowMaximizedChanged();
emit activeWindowTouchingChanged();
emit activeWindowTouchingEdgeChanged();
emit existsWindowActiveChanged();
emit existsWindowMaximizedChanged();
emit existsWindowTouchingChanged();
emit existsWindowTouchingEdgeChanged();
emit activeWindowSchemeChanged();
emit touchingWindowSchemeChanged();
}
bool CurrentScreenTracker::activeWindowMaximized() const
{
return m_wm->windowsTracker()->activeWindowMaximized(m_latteView);
}
bool CurrentScreenTracker::activeWindowTouching() const
{
return m_wm->windowsTracker()->activeWindowTouching(m_latteView);
}
bool CurrentScreenTracker::activeWindowTouchingEdge() const
{
return m_wm->windowsTracker()->activeWindowTouchingEdge(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);
}
bool CurrentScreenTracker::existsWindowTouchingEdge() const
{
return m_wm->windowsTracker()->existsWindowTouchingEdge(m_latteView);
}
bool CurrentScreenTracker::isTouchingBusyVerticalView() const
{
return m_wm->windowsTracker()->isTouchingBusyVerticalView(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);
}
}
}
}
|