Add Window::captionNormalChanged()

This signal notifies when the client specified caption changes, not when
kwin changes it because it changed the suffix, etc.
This commit is contained in:
Vlad Zahorodnii 2024-01-11 14:41:00 +02:00
parent 68f1570d45
commit 4ab504c994
4 changed files with 11 additions and 4 deletions

View file

@ -476,6 +476,7 @@ void InternalWindow::setCaption(const QString &caption)
const QString oldCaptionSuffix = m_captionSuffix;
updateCaption();
Q_EMIT captionNormalChanged();
if (m_captionSuffix == oldCaptionSuffix) {
Q_EMIT captionChanged();
}

View file

@ -204,9 +204,15 @@ void WaylandWindow::updateCaption()
void WaylandWindow::setCaption(const QString &caption)
{
const QString oldNormal = m_captionNormal;
const QString oldSuffix = m_captionSuffix;
m_captionNormal = caption.simplified();
updateCaption();
if (m_captionNormal != oldNormal) {
Q_EMIT captionNormalChanged();
}
if (m_captionSuffix == oldSuffix) {
// Don't emit caption change twice it already got emitted by the changing suffix.
Q_EMIT captionChanged();

View file

@ -1410,6 +1410,7 @@ Q_SIGNALS:
void paletteChanged(const QPalette &p);
void colorSchemeChanged();
void captionChanged();
void captionNormalChanged();
void maximizedAboutToChange(MaximizeMode mode);
void maximizedChanged();
void transientChanged();

View file

@ -2329,10 +2329,6 @@ void X11Window::setCaption(const QString &_s, bool force)
return;
}
cap_normal = s;
if (!force && !changed) {
Q_EMIT captionChanged();
return;
}
bool reset_name = force;
bool was_suffix = (!cap_suffix.isEmpty());
@ -2363,6 +2359,9 @@ void X11Window::setCaption(const QString &_s, bool force)
info->setVisibleIconName(QString(cap_iconic + cap_suffix).toUtf8().constData());
}
if (changed) {
Q_EMIT captionNormalChanged();
}
Q_EMIT captionChanged();
}