mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-28 10:03:52 +03:00
update LastActiveWindow with signals
This commit is contained in:
parent
c0e3004717
commit
4ae9b1b91c
@ -32,10 +32,14 @@ namespace Tracker {
|
||||
TrackedGeneralInfo::TrackedGeneralInfo(Tracker::Windows *tracker, Latte::View *view)
|
||||
: QObject(tracker) ,
|
||||
m_wm(tracker->wm()),
|
||||
m_view(view)
|
||||
m_view(view),
|
||||
m_tracker(tracker)
|
||||
{
|
||||
m_lastActiveWindow = new LastActiveWindow(this);
|
||||
|
||||
connect(tracker, &Windows::windowChanged, this, &TrackedGeneralInfo::windowChanged);
|
||||
connect(tracker, &Windows::activeWindowChanged, this, &TrackedGeneralInfo::windowChanged);
|
||||
|
||||
emit lastActiveWindowChanged();
|
||||
}
|
||||
|
||||
@ -135,6 +139,19 @@ AbstractWindowInterface *TrackedGeneralInfo::wm()
|
||||
return m_wm;
|
||||
}
|
||||
|
||||
|
||||
void TrackedGeneralInfo::setActiveWindow(const WindowId &wid)
|
||||
{
|
||||
m_lastActiveWindow->setInformation(m_tracker->infoFor(wid));
|
||||
}
|
||||
|
||||
void TrackedGeneralInfo::windowChanged(const WindowId &wid)
|
||||
{
|
||||
if (m_lastActiveWindow->winId() == wid && !wid.isNull()) {
|
||||
m_lastActiveWindow->setInformation(m_tracker->infoFor(wid));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,9 +74,14 @@ public:
|
||||
Latte::View *view();
|
||||
AbstractWindowInterface *wm();
|
||||
|
||||
void setActiveWindow(const WindowId &wid);
|
||||
|
||||
signals:
|
||||
void lastActiveWindowChanged();
|
||||
|
||||
private slots:
|
||||
void windowChanged(const WindowId &wid);
|
||||
|
||||
private:
|
||||
bool m_enabled;
|
||||
bool m_activeWindowMaximized;
|
||||
@ -89,6 +94,7 @@ private:
|
||||
SchemeColors *m_activeWindowScheme{nullptr};
|
||||
|
||||
AbstractWindowInterface *m_wm{nullptr};
|
||||
Tracker::Windows *m_tracker{nullptr};
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -60,15 +60,9 @@ void Windows::init()
|
||||
|
||||
connect(m_wm, &AbstractWindowInterface::windowChanged, this, [&](WindowId wid) {
|
||||
m_windows[wid] = m_wm->requestInfo(wid);
|
||||
|
||||
for (const auto view : m_views.keys()) {
|
||||
WindowId lastWinId = m_views[view]->lastActiveWindow()->winId();
|
||||
if (lastWinId == wid) {
|
||||
m_views[view]->lastActiveWindow()->setInformation(m_windows[lastWinId]);
|
||||
}
|
||||
}
|
||||
|
||||
updateViewsHints();
|
||||
|
||||
emit windowChanged(wid);
|
||||
});
|
||||
|
||||
connect(m_wm, &AbstractWindowInterface::windowRemoved, this, [&](WindowId wid) {
|
||||
@ -84,16 +78,19 @@ void Windows::init()
|
||||
});
|
||||
|
||||
connect(m_wm, &AbstractWindowInterface::activeWindowChanged, this, [&](WindowId wid) {
|
||||
//! for some reason this is needed in order to update properly activeness values
|
||||
//! when the active window changes the previous active windows should be also updated
|
||||
for (const auto view : m_views.keys()) {
|
||||
WindowId lastWinId = m_views[view]->lastActiveWindow()->winId();
|
||||
if (m_windows.contains(lastWinId)) {
|
||||
if ((lastWinId) != wid && m_windows.contains(lastWinId)) {
|
||||
m_windows[lastWinId] = m_wm->requestInfo(lastWinId);
|
||||
m_views[view]->lastActiveWindow()->setInformation(m_windows[lastWinId]);
|
||||
}
|
||||
}
|
||||
|
||||
m_windows[wid] = m_wm->requestInfo(wid);
|
||||
updateViewsHints();
|
||||
|
||||
emit activeWindowChanged(wid);
|
||||
});
|
||||
|
||||
connect(m_wm, &AbstractWindowInterface::currentDesktopChanged, this, [&] {
|
||||
@ -324,7 +321,7 @@ LastActiveWindow *Windows::lastActiveWindow(Latte::View *view)
|
||||
return m_views[view]->lastActiveWindow();
|
||||
}
|
||||
|
||||
bool Windows::isValidFor(WindowId wid) const
|
||||
bool Windows::isValidFor(const WindowId &wid) const
|
||||
{
|
||||
if (!m_windows.contains(wid)) {
|
||||
return false;
|
||||
@ -333,7 +330,7 @@ bool Windows::isValidFor(WindowId wid) const
|
||||
return m_windows[wid].isValid() && !m_windows[wid].isPlasmaDesktop();
|
||||
}
|
||||
|
||||
QIcon Windows::iconFor(WindowId wid)
|
||||
QIcon Windows::iconFor(const WindowId &wid)
|
||||
{
|
||||
if (!m_windows.contains(wid)) {
|
||||
return QIcon();
|
||||
@ -355,7 +352,7 @@ QIcon Windows::iconFor(WindowId wid)
|
||||
return m_windows[wid].icon();
|
||||
}
|
||||
|
||||
QString Windows::appNameFor(WindowId wid)
|
||||
QString Windows::appNameFor(const WindowId &wid)
|
||||
{
|
||||
if (!m_windows.contains(wid)) {
|
||||
return QString();
|
||||
@ -371,6 +368,17 @@ QString Windows::appNameFor(WindowId wid)
|
||||
return m_windows[wid].appName();
|
||||
}
|
||||
|
||||
WindowInfoWrap Windows::infoFor(const WindowId &wid) const
|
||||
{
|
||||
if (!m_windows.contains(wid)) {
|
||||
return WindowInfoWrap();
|
||||
}
|
||||
|
||||
return m_windows[wid];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Windows Criteria Functions
|
||||
|
||||
bool Windows::inCurrentDesktopActivity(const WindowInfoWrap &winfo)
|
||||
@ -397,16 +405,16 @@ bool Windows::isActiveInViewScreen(Latte::View *view, const WindowInfoWrap &winf
|
||||
bool Windows::isMaximizedInViewScreen(Latte::View *view, const WindowInfoWrap &winfo)
|
||||
{
|
||||
auto viewIntersectsMaxVert = [&]() noexcept -> bool {
|
||||
return ((winfo.isMaxVert()
|
||||
|| (view->screen() && view->screen()->availableSize().height() <= winfo.geometry().height()))
|
||||
&& intersects(view, winfo));
|
||||
};
|
||||
return ((winfo.isMaxVert()
|
||||
|| (view->screen() && view->screen()->availableSize().height() <= winfo.geometry().height()))
|
||||
&& intersects(view, winfo));
|
||||
};
|
||||
|
||||
auto viewIntersectsMaxHoriz = [&]() noexcept -> bool {
|
||||
return ((winfo.isMaxHoriz()
|
||||
|| (view->screen() && view->screen()->availableSize().width() <= winfo.geometry().width()))
|
||||
&& intersects(view, winfo));
|
||||
};
|
||||
return ((winfo.isMaxHoriz()
|
||||
|| (view->screen() && view->screen()->availableSize().width() <= winfo.geometry().width()))
|
||||
&& intersects(view, winfo));
|
||||
};
|
||||
|
||||
//! updated implementation to identify the screen that the maximized window is present
|
||||
//! in order to avoid: https://bugs.kde.org/show_bug.cgi?id=397700
|
||||
@ -531,7 +539,6 @@ void Windows::updateHints(Latte::View *view)
|
||||
}
|
||||
|
||||
if (isActiveInViewScreen(view, winfo)) {
|
||||
m_views[view]->lastActiveWindow()->setInformation(winfo);
|
||||
foundActiveInCurScreen = true;
|
||||
activeWinId = winfo.wid();
|
||||
}
|
||||
@ -598,6 +605,11 @@ void Windows::updateHints(Latte::View *view)
|
||||
setTouchingWindowScheme(view, nullptr);
|
||||
}
|
||||
|
||||
//! update LastActiveWindow
|
||||
if (foundActiveInCurScreen) {
|
||||
m_views[view]->setActiveWindow(activeWinId);
|
||||
}
|
||||
|
||||
//! Debug
|
||||
//qDebug() << "TRACKING | SCREEN: " << view->positioner()->currentScreenId() << " , EDGE:" << view->location() << " , ENABLED:" << enabled(view);
|
||||
//qDebug() << "TRACKING | activeWindowTouching: " << foundActiveTouchInCurScreen << " ,activeWindowMaximized: " << activeWindowMaximized(view);
|
||||
|
@ -67,9 +67,10 @@ public:
|
||||
SchemeColors *touchingWindowScheme(Latte::View *view) const;
|
||||
LastActiveWindow *lastActiveWindow(Latte::View *view);
|
||||
|
||||
bool isValidFor(WindowId wid) const;
|
||||
QIcon iconFor(WindowId wid);
|
||||
QString appNameFor(WindowId wid);
|
||||
bool isValidFor(const WindowId &wid) const;
|
||||
QIcon iconFor(const WindowId &wid);
|
||||
QString appNameFor(const WindowId &wid);
|
||||
WindowInfoWrap infoFor(const WindowId &wid) const;
|
||||
|
||||
void setPlasmaDesktop(WindowId wid);
|
||||
|
||||
@ -85,6 +86,11 @@ signals:
|
||||
void activeWindowSchemeChanged(const Latte::View *view);
|
||||
void touchingWindowSchemeChanged(const Latte::View *view);
|
||||
|
||||
//! overloading WM signals in order to update first m_windows and afterwards
|
||||
//! inform consumers for window changes
|
||||
void activeWindowChanged(const WindowId &wid);
|
||||
void windowChanged(const WindowId &wid);
|
||||
|
||||
private slots:
|
||||
void updateAvailableScreenGeometries();
|
||||
|
||||
|
@ -63,12 +63,13 @@ public:
|
||||
, m_isPlasmaDesktop(o.m_isPlasmaDesktop)
|
||||
, m_isKeepAbove(o.m_isKeepAbove)
|
||||
, m_hasSkipTaskbar(o.m_hasSkipTaskbar)
|
||||
, m_isOnAllDesktops(o.m_isOnAllDesktops) {
|
||||
, m_isOnAllDesktops(o.m_isOnAllDesktops)
|
||||
, m_display(o.m_display) {
|
||||
}
|
||||
|
||||
WindowInfoWrap(WindowInfoWrap &&o) noexcept
|
||||
: m_wid(std::move(o.m_wid))
|
||||
, m_geometry(std::move(o.m_geometry))
|
||||
: m_wid(o.m_wid)
|
||||
, m_geometry(o.m_geometry)
|
||||
, m_isValid(o.m_isValid)
|
||||
, m_isActive(o.m_isActive)
|
||||
, m_isMinimized(o.m_isMinimized)
|
||||
@ -79,7 +80,8 @@ public:
|
||||
, m_isPlasmaDesktop(o.m_isPlasmaDesktop)
|
||||
, m_isKeepAbove(o.m_isKeepAbove)
|
||||
, m_hasSkipTaskbar(o.m_hasSkipTaskbar)
|
||||
, m_isOnAllDesktops(o.m_isOnAllDesktops) {
|
||||
, m_isOnAllDesktops(o.m_isOnAllDesktops)
|
||||
, m_display(o.m_display) {
|
||||
}
|
||||
|
||||
inline WindowInfoWrap &operator=(WindowInfoWrap &&rhs) noexcept;
|
||||
|
Loading…
x
Reference in New Issue
Block a user