mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-01 01:17:51 +03:00
initial support History for LastActiveWindow
This commit is contained in:
parent
4ae9b1b91c
commit
79ae6a6de4
@ -43,6 +43,9 @@ LastActiveWindow::LastActiveWindow(TrackedGeneralInfo *trackedInfo)
|
||||
m_windowsTracker(trackedInfo->wm()->windowsTracker()),
|
||||
m_wm(trackedInfo->wm())
|
||||
{
|
||||
connect(m_windowsTracker, &Windows::activeWindowChanged, this, &LastActiveWindow::windowChanged);
|
||||
connect(m_windowsTracker, &Windows::windowChanged, this, &LastActiveWindow::windowChanged);
|
||||
connect(m_windowsTracker, &Windows::windowRemoved, this, &LastActiveWindow::windowRemoved);
|
||||
}
|
||||
|
||||
LastActiveWindow::~LastActiveWindow()
|
||||
@ -236,6 +239,14 @@ void LastActiveWindow::setWinId(QVariant winId)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_history.contains(winId)) {
|
||||
m_history.prepend(winId);
|
||||
} else {
|
||||
int p = m_history.indexOf(winId);
|
||||
//! move to start
|
||||
m_history.move(p, 0);
|
||||
}
|
||||
|
||||
m_winId = winId;
|
||||
emit winIdChanged();
|
||||
}
|
||||
@ -268,9 +279,32 @@ void LastActiveWindow::setInformation(const WindowInfoWrap &info)
|
||||
|
||||
}
|
||||
|
||||
//! PRIVATE SLOTS
|
||||
void LastActiveWindow::windowChanged(const WindowId &wid)
|
||||
{
|
||||
if (m_winId == wid && !wid.isNull()) {
|
||||
setInformation(m_windowsTracker->infoFor(wid));
|
||||
}
|
||||
}
|
||||
|
||||
void LastActiveWindow::windowRemoved(const WindowId &wid)
|
||||
{
|
||||
bool wasFirst{false};
|
||||
|
||||
if (m_history.contains(wid)) {
|
||||
if (m_history[0] == wid) {
|
||||
wasFirst = true;
|
||||
}
|
||||
|
||||
m_history.removeAll(wid);
|
||||
}
|
||||
|
||||
if (wasFirst && !m_history.isEmpty()) {
|
||||
setInformation(m_windowsTracker->infoFor(m_history[0]));
|
||||
}
|
||||
}
|
||||
|
||||
//! FUNCTIONALITY
|
||||
|
||||
|
||||
void LastActiveWindow::requestActivate()
|
||||
{
|
||||
m_wm->requestActivate(m_winId);
|
||||
|
@ -96,6 +96,12 @@ public slots:
|
||||
|
||||
Q_INVOKABLE bool canBeDragged();
|
||||
|
||||
|
||||
private slots:
|
||||
void windowChanged(const WindowId &wid);
|
||||
void windowRemoved(const WindowId &wid);
|
||||
|
||||
|
||||
signals:
|
||||
void draggingStarted();
|
||||
|
||||
@ -151,6 +157,8 @@ private:
|
||||
|
||||
QVariant m_winId;
|
||||
|
||||
QList<WindowId> m_history;
|
||||
|
||||
TrackedGeneralInfo *m_trackedInfo{nullptr};
|
||||
AbstractWindowInterface *m_wm{nullptr};
|
||||
Tracker::Windows *m_windowsTracker{nullptr};
|
||||
|
@ -37,9 +37,6 @@ TrackedGeneralInfo::TrackedGeneralInfo(Tracker::Windows *tracker, Latte::View *v
|
||||
{
|
||||
m_lastActiveWindow = new LastActiveWindow(this);
|
||||
|
||||
connect(tracker, &Windows::windowChanged, this, &TrackedGeneralInfo::windowChanged);
|
||||
connect(tracker, &Windows::activeWindowChanged, this, &TrackedGeneralInfo::windowChanged);
|
||||
|
||||
emit lastActiveWindowChanged();
|
||||
}
|
||||
|
||||
@ -145,13 +142,6 @@ 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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,9 +79,6 @@ public:
|
||||
signals:
|
||||
void lastActiveWindowChanged();
|
||||
|
||||
private slots:
|
||||
void windowChanged(const WindowId &wid);
|
||||
|
||||
private:
|
||||
bool m_enabled;
|
||||
bool m_activeWindowMaximized;
|
||||
|
@ -68,6 +68,8 @@ void Windows::init()
|
||||
connect(m_wm, &AbstractWindowInterface::windowRemoved, this, [&](WindowId wid) {
|
||||
m_windows.remove(wid);
|
||||
updateViewsHints();
|
||||
|
||||
emit windowRemoved(wid);
|
||||
});
|
||||
|
||||
connect(m_wm, &AbstractWindowInterface::windowAdded, this, [&](WindowId wid) {
|
||||
|
@ -90,6 +90,7 @@ signals:
|
||||
//! inform consumers for window changes
|
||||
void activeWindowChanged(const WindowId &wid);
|
||||
void windowChanged(const WindowId &wid);
|
||||
void windowRemoved(const WindowId &wid);
|
||||
|
||||
private slots:
|
||||
void updateAvailableScreenGeometries();
|
||||
|
Loading…
Reference in New Issue
Block a user