mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-26 11:21:40 +03:00
update application data after 1500ms from startup
--when an application is tracked from the lastactivewindow infrastructure it is updating the application name/icon 1500 ms after its first startup in order to fix apps cases where they update their StartupWMClass a bit delayed BUG:413671
This commit is contained in:
parent
6849a4906d
commit
d5b7694d4d
@ -56,6 +56,17 @@ LastActiveWindow::LastActiveWindow(TrackedGeneralInfo *trackedInfo)
|
||||
|
||||
connect(m_windowsTracker, &Windows::windowChanged, this, &LastActiveWindow::windowChanged);
|
||||
connect(m_windowsTracker, &Windows::windowRemoved, this, &LastActiveWindow::windowRemoved);
|
||||
|
||||
//! delayed application data
|
||||
m_updateApplicationDataTimer.setInterval(1500);
|
||||
m_updateApplicationDataTimer.setSingleShot(true);
|
||||
connect(&m_updateApplicationDataTimer, &QTimer::timeout, this, [&]() {
|
||||
if (m_delayedApplicationDataWid>=0 && m_delayedApplicationDataWid == m_winId && !m_initializedApplicationData.contains(m_winId)) {
|
||||
setAppName(m_windowsTracker->appNameFor(m_winId, true));
|
||||
m_delayedApplicationDataWid = -1;
|
||||
m_initializedApplicationData.append(m_winId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
LastActiveWindow::~LastActiveWindow()
|
||||
@ -315,6 +326,14 @@ void LastActiveWindow::setInformation(const WindowInfoWrap &info)
|
||||
|
||||
if (firstActiveness) {
|
||||
updateColorScheme();
|
||||
|
||||
//delayed application data
|
||||
m_updateApplicationDataTimer.stop();
|
||||
|
||||
if (!m_initializedApplicationData.contains(info.wid())) {
|
||||
m_delayedApplicationDataWid = info.wid();
|
||||
m_updateApplicationDataTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
if (info.appName().isEmpty()) {
|
||||
@ -380,6 +399,10 @@ void LastActiveWindow::windowChanged(const WindowId &wid)
|
||||
|
||||
void LastActiveWindow::windowRemoved(const WindowId &wid)
|
||||
{
|
||||
if (m_initializedApplicationData.contains(wid)) {
|
||||
m_initializedApplicationData.removeAll(wid);
|
||||
}
|
||||
|
||||
if (m_history.contains(wid)) {
|
||||
bool firstItemRemoved{false};
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
// Qt
|
||||
#include <QObject>
|
||||
#include <QRect>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Latte {
|
||||
class View;
|
||||
@ -174,6 +175,13 @@ private:
|
||||
|
||||
QList<WindowId> m_history;
|
||||
|
||||
//! Some applications delay their application name/icon identification
|
||||
//! such as Libreoffice that updates its StartupWMClass after
|
||||
//! its startup
|
||||
QTimer m_updateApplicationDataTimer;
|
||||
QList<WindowId> m_initializedApplicationData;
|
||||
WindowId m_delayedApplicationDataWid{-1};
|
||||
|
||||
TrackedGeneralInfo *m_trackedInfo{nullptr};
|
||||
AbstractWindowInterface *m_wm{nullptr};
|
||||
Tracker::Windows *m_windowsTracker{nullptr};
|
||||
|
@ -583,13 +583,13 @@ QIcon Windows::iconFor(const WindowId &wid)
|
||||
return m_windows[wid].icon();
|
||||
}
|
||||
|
||||
QString Windows::appNameFor(const WindowId &wid)
|
||||
QString Windows::appNameFor(const WindowId &wid, bool forceUpdate)
|
||||
{
|
||||
if (!m_windows.contains(wid)) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
if (m_windows[wid].appName().isEmpty()) {
|
||||
if (m_windows[wid].appName().isEmpty() || forceUpdate) {
|
||||
AppData data = m_wm->appDataFor(wid);
|
||||
|
||||
m_windows[wid].setAppName(data.name);
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
//! Windows management
|
||||
bool isValidFor(const WindowId &wid) const;
|
||||
QIcon iconFor(const WindowId &wid);
|
||||
QString appNameFor(const WindowId &wid);
|
||||
QString appNameFor(const WindowId &wid, bool forceUpdate = false);
|
||||
WindowInfoWrap infoFor(const WindowId &wid) const;
|
||||
|
||||
void setPlasmaDesktop(WindowId wid);
|
||||
|
Loading…
Reference in New Issue
Block a user