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; const QString oldCaptionSuffix = m_captionSuffix;
updateCaption(); updateCaption();
Q_EMIT captionNormalChanged();
if (m_captionSuffix == oldCaptionSuffix) { if (m_captionSuffix == oldCaptionSuffix) {
Q_EMIT captionChanged(); Q_EMIT captionChanged();
} }

View file

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

View file

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

View file

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