introduce TrackedLayoutInfo

pull/6/head
Michail Vourlakos 6 years ago
parent 2b316aa728
commit 7decc54ddf

@ -3,6 +3,7 @@ set(lattedock-app_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/lastactivewindow.cpp
${CMAKE_CURRENT_SOURCE_DIR}/schemes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/trackedgeneralinfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/trackedlayoutinfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/trackedviewinfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/trackerwindows.cpp
PARENT_SCOPE

@ -21,6 +21,7 @@
//local
#include "trackerwindows.h"
#include "../abstractwindowinterface.h"
#include "../schemecolors.h"
namespace Latte {
@ -35,6 +36,10 @@ TrackedGeneralInfo::TrackedGeneralInfo(Tracker::Windows *tracker)
{
m_lastActiveWindow = new LastActiveWindow(this);
connect(m_wm, &AbstractWindowInterface::currentActivityChanged, this, [&]() {
updateTrackingCurrentActivity();
});
emit lastActiveWindowChanged();
}
@ -105,6 +110,19 @@ void TrackedGeneralInfo::setExistsWindowMaximized(bool maximized)
m_existsWindowMaximized = maximized;
}
bool TrackedGeneralInfo::isTrackingCurrentActivity() const
{
return m_isTrackingCurrentActivity;
}
void TrackedGeneralInfo::updateTrackingCurrentActivity()
{
m_isTrackingCurrentActivity = ( m_activities.isEmpty()
|| m_activities[0] == "0"
|| m_activities.contains(m_wm->currentActivity()));
}
LastActiveWindow *TrackedGeneralInfo::lastActiveWindow() const
{
return m_lastActiveWindow;
@ -134,22 +152,14 @@ void TrackedGeneralInfo::setActiveWindow(const WindowId &wid)
m_lastActiveWindow->setInformation(m_tracker->infoFor(wid));
}
bool TrackedGeneralInfo::isTrackedOnActivity(const QString &activity) const
{
//! TODO:: needs to be updated for Layouts case
//! a way to access the first enabled View::activities in that specific
//! layout
return true;
}
bool TrackedGeneralInfo::isTracking(const WindowInfoWrap &winfo) const
{
return (winfo.isValid()
&& isTrackingCurrentActivity()
&& !winfo.isPlasmaDesktop()
&& !winfo.isMinimized()
&& winfo.isOnDesktop(m_wm->currentDesktop())
&& winfo.isOnActivity(m_wm->currentActivity())
&& isTrackedOnActivity(m_wm->currentActivity()));
&& winfo.isOnActivity(m_wm->currentActivity()));
}
}

@ -62,6 +62,8 @@ public:
bool existsWindowMaximized() const;
void setExistsWindowMaximized(bool maximized);
bool isTrackingCurrentActivity() const;
LastActiveWindow *lastActiveWindow() const;
SchemeColors *activeWindowScheme() const;
@ -77,7 +79,14 @@ signals:
void lastActiveWindowChanged();
protected:
virtual bool isTrackedOnActivity(const QString &activity) const;
void updateTrackingCurrentActivity();
protected:
QStringList m_activities;
LastActiveWindow *m_lastActiveWindow{nullptr};
AbstractWindowInterface *m_wm{nullptr};
Tracker::Windows *m_tracker{nullptr};
private:
bool m_enabled;
@ -85,12 +94,9 @@ private:
bool m_existsWindowActive;
bool m_existsWindowMaximized;
LastActiveWindow *m_lastActiveWindow{nullptr};
bool m_isTrackingCurrentActivity{true};
SchemeColors *m_activeWindowScheme{nullptr};
AbstractWindowInterface *m_wm{nullptr};
Tracker::Windows *m_tracker{nullptr};
};
}

@ -0,0 +1,54 @@
/*
* Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "trackedlayoutinfo.h"
//local
#include "trackerwindows.h"
#include "../../layout/genericlayout.h"
namespace Latte {
namespace WindowSystem {
namespace Tracker {
TrackedLayoutInfo::TrackedLayoutInfo(Tracker::Windows *tracker, Latte::Layout::GenericLayout *layout)
: TrackedGeneralInfo(tracker),
m_layout(layout)
{
m_activities = m_layout->appliedActivities();
connect(m_layout, &Latte::Layout::GenericLayout::activitiesChanged, this, [&]() {
m_activities = m_layout->appliedActivities();
updateTrackingCurrentActivity();
});
}
TrackedLayoutInfo::~TrackedLayoutInfo()
{
}
Latte::Layout::GenericLayout *TrackedLayoutInfo::layout() const
{
return m_layout;
}
}
}
}

@ -0,0 +1,64 @@
/*
* Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef WINDOWSYSTEMTRACKEDLAYOUTINFO_H
#define WINDOWSYSTEMTRACKEDLAYOUTINFO_H
// local
#include "trackedgeneralinfo.h"
#include "../windowinfowrap.h"
// Qt
#include <QObject>
#include <QRect>
namespace Latte {
namespace Layout {
class GenericLayout;
}
namespace WindowSystem {
namespace Tracker {
class Windows;
}
}
}
namespace Latte {
namespace WindowSystem {
namespace Tracker {
class TrackedLayoutInfo : public TrackedGeneralInfo {
Q_OBJECT
public:
TrackedLayoutInfo(Tracker::Windows *tracker, Latte::Layout::GenericLayout *layout);
~TrackedLayoutInfo() override;
Latte::Layout::GenericLayout *layout() const;
private:
Latte::Layout::GenericLayout *m_layout{nullptr};
};
}
}
}
#endif

@ -34,6 +34,12 @@ TrackedViewInfo::TrackedViewInfo(Tracker::Windows *tracker, Latte::View *view)
: TrackedGeneralInfo(tracker) ,
m_view(view)
{
m_activities = m_view->activities();
connect(m_view, &Latte::View::activitiesChanged, this, [&]() {
m_activities = m_view->activities();
updateTrackingCurrentActivity();
});
}
TrackedViewInfo::~TrackedViewInfo()
@ -101,14 +107,9 @@ Latte::View *TrackedViewInfo::view() const
return m_view;
}
bool TrackedViewInfo::isTrackedOnActivity(const QString &activity) const
{
return m_view->isOnActivity(activity);
}
bool TrackedViewInfo::isTracking(const WindowInfoWrap &winfo) const
{
return TrackedGeneralInfo::isTracking(winfo)
return TrackedGeneralInfo::isTracking(winfo)
&& m_availableScreenGeometry.contains(winfo.geometry().center());
}

@ -66,9 +66,6 @@ public:
bool isTracking(const WindowInfoWrap &winfo) const override;
protected:
bool isTrackedOnActivity(const QString &activity) const override;
private:
bool m_activeWindowTouching;
bool m_existsWindowTouching;

Loading…
Cancel
Save