Skip to content

Commit 850603d

Browse files
authored
bugfix after 0.4.2
1 parent c74a041 commit 850603d

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

panel.cpp

+28-20
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,19 @@ void Panel::updateWinList() {
206206
});
207207
}
208208
else {
209-
if (!desktopInfo.isOnCurrentDesktop()) {
209+
if (desktopInfo.isOnCurrentDesktop()) {
210+
KWindowInfo nameInfo(*it, NET::WMName);
211+
QString newName = nameInfo.name();;
212+
unsigned short sz = newName.length();
213+
newName.truncate(15);
214+
if (newName.length() < sz) {
215+
newName += "...";
216+
}
217+
if (winWidgets[*it]->text() != newName) {
218+
winWidgets[*it]->setText(newName);
219+
}
220+
}
221+
else {
210222
delete winWidgets[*it];
211223
winWidgets.remove(*it);
212224
}
@@ -219,14 +231,16 @@ void Panel::updateWinTitles() {
219231
for (auto it = winIDs->cbegin(), end = winIDs->cend(); it != end; ++it) {
220232
KWindowInfo pIDInfo(*it, NET::WMPid);
221233
if (pIDInfo.pid() != panelPID) {
222-
QString title = KWindowSystem::readNameProperty(*it, 39);
223-
unsigned short sz = title.length();
224-
title.truncate(15);
225-
if (title.length() < sz) {
226-
title += "...";
227-
}
228-
if (winWidgets[*it]->text() != title) {
229-
winWidgets[*it]->setText(title);
234+
if (winWidgets.contains(*it)) {
235+
QString title = KWindowSystem::readNameProperty(*it, 39);
236+
unsigned short sz = title.length();
237+
title.truncate(15);
238+
if (title.length() < sz) {
239+
title += "...";
240+
}
241+
if (winWidgets[*it]->text() != title) {
242+
winWidgets[*it]->setText(title);
243+
}
230244
}
231245
}
232246
}
@@ -245,6 +259,7 @@ void Panel::accentActiveWindow() {
245259

246260

247261
void Panel::updateWorkspaces() {
262+
this->updateWinList();
248263
visibleDesktop = KWindowSystem::currentDesktop();
249264
for (qint8 workspace = 0; workspace < countWorkspaces; ++workspace) {
250265
if ((workspace+1) == visibleDesktop) {
@@ -363,16 +378,7 @@ void Panel::setRepeatingActions() {
363378
// Window list applet
364379
if (activeAppletsList.contains("windowlist")) {
365380
if (!QString::compare(getenv("XDG_SESSION_TYPE"), "x11", Qt::CaseInsensitive)) {
366-
/* QTimer* updateWinListTimer = new QTimer(this);
367-
updateWinListTimer->setInterval(400);
368-
this->connect(updateWinListTimer, &QTimer::timeout, this, [this]() {
369-
this->updateWinList();
370-
});
371-
updateWinListTimer->start();
372-
activeTimers.append(updateWinListTimer);*/
373-
374381
this->connect(KWindowSystem::self(), &KWindowSystem::windowAdded, this, &Panel::updateWinList);
375-
//this->connect(KWindowSystem::self(), &KWindowSystem::windowRemoved, this, &Panel::updateWinList);
376382
this->connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this, &Panel::accentActiveWindow);
377383

378384
QTimer* updateTitleTimer = new QTimer(this);
@@ -382,7 +388,6 @@ void Panel::setRepeatingActions() {
382388
});
383389
updateTitleTimer->start();
384390
activeTimers.append(updateTitleTimer);
385-
386391
}
387392
else {
388393
qDebug() << "Window List applet currently works only on X11. Skipping...";
@@ -401,7 +406,10 @@ void Panel::setRepeatingActions() {
401406
updateWorkspacesTimer->start();
402407
activeTimers.append(updateWorkspacesTimer);*/
403408

404-
this->connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged, this, &Panel::updateWorkspaces);
409+
this->connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged, this, [this]() {
410+
qDebug() << "WORKSPACE";
411+
this->updateWorkspaces();
412+
});
405413
}
406414

407415
// Local IP applet

0 commit comments

Comments
 (0)