From bc62e7e0944acbff85f68c8c36b290adedc1f800 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 30 Jan 2024 00:20:24 +0200 Subject: [PATCH] Drop Window::{windowShown,windowHidden} They serve the same purpose as Window::hiddenChanged, so drop these signals instead of having multiple signals to indicate the same thing. --- src/effect/effectwindow.cpp | 6 +----- src/effect/effectwindow.h | 20 ++------------------ src/plugins/slidingpopups/slidingpopups.cpp | 12 ++++++++++-- src/plugins/slidingpopups/slidingpopups.h | 1 + src/window.cpp | 7 +------ src/window.h | 2 -- 6 files changed, 15 insertions(+), 33 deletions(-) diff --git a/src/effect/effectwindow.cpp b/src/effect/effectwindow.cpp index 477f027f1f..1905dcbd5e 100644 --- a/src/effect/effectwindow.cpp +++ b/src/effect/effectwindow.cpp @@ -57,11 +57,7 @@ EffectWindow::EffectWindow(WindowItem *windowItem) d->m_x11Window = qobject_cast(d->m_window) != nullptr; connect(d->m_window, &Window::hiddenChanged, this, [this]() { - if (d->m_window->isHidden()) { - Q_EMIT windowHidden(this); - } else { - Q_EMIT windowShown(this); - } + Q_EMIT windowHiddenChanged(this); }); connect(d->m_window, &Window::maximizedChanged, this, [this]() { const MaximizeMode mode = d->m_window->maximizeMode(); diff --git a/src/effect/effectwindow.h b/src/effect/effectwindow.h index a61a221574..2a03ee994e 100644 --- a/src/effect/effectwindow.h +++ b/src/effect/effectwindow.h @@ -825,25 +825,9 @@ Q_SIGNALS: void windowDesktopsChanged(KWin::EffectWindow *window); /** - * The window @p w gets shown again. The window was previously - * initially shown with windowAdded and hidden with windowHidden. - * - * @see windowHidden - * @see windowAdded + * This signal is emitted when a window is hidden or shown. */ - void windowShown(KWin::EffectWindow *w); - - /** - * The window @p w got hidden but not yet closed. - * This can happen when a window is still being used and is supposed to be shown again - * with windowShown. On X11 an example is autohiding panels. On Wayland every - * window first goes through the window hidden state and might get shown again, or might - * get closed the normal way. - * - * @see windowShown - * @see windowClosed - */ - void windowHidden(KWin::EffectWindow *w); + void windowHiddenChanged(KWin::EffectWindow *window); protected: friend EffectWindowVisibleRef; diff --git a/src/plugins/slidingpopups/slidingpopups.cpp b/src/plugins/slidingpopups/slidingpopups.cpp index ab3f1073a8..ac3c2a2869 100644 --- a/src/plugins/slidingpopups/slidingpopups.cpp +++ b/src/plugins/slidingpopups/slidingpopups.cpp @@ -207,8 +207,7 @@ void SlidingPopupsEffect::postPaintWindow(EffectWindow *w) void SlidingPopupsEffect::setupSlideData(EffectWindow *w) { connect(w, &EffectWindow::windowFrameGeometryChanged, this, &SlidingPopupsEffect::slotWindowFrameGeometryChanged); - connect(w, &EffectWindow::windowShown, this, &SlidingPopupsEffect::slideIn); - connect(w, &EffectWindow::windowHidden, this, &SlidingPopupsEffect::slideOut); + connect(w, &EffectWindow::windowHiddenChanged, this, &SlidingPopupsEffect::slotWindowHiddenChanged); // X11 if (m_atom != XCB_ATOM_NONE) { @@ -249,6 +248,15 @@ void SlidingPopupsEffect::slotWindowDeleted(EffectWindow *w) m_animationsData.remove(w); } +void SlidingPopupsEffect::slotWindowHiddenChanged(EffectWindow *w) +{ + if (w->isHidden()) { + slideOut(w); + } else { + slideIn(w); + } +} + void SlidingPopupsEffect::slotPropertyNotify(EffectWindow *w, long atom) { if (!w || atom != m_atom || m_atom == XCB_ATOM_NONE) { diff --git a/src/plugins/slidingpopups/slidingpopups.h b/src/plugins/slidingpopups/slidingpopups.h index 80712247f2..c697b138e3 100644 --- a/src/plugins/slidingpopups/slidingpopups.h +++ b/src/plugins/slidingpopups/slidingpopups.h @@ -55,6 +55,7 @@ private Q_SLOTS: void slotPropertyNotify(EffectWindow *w, long atom); void slotWaylandSlideOnShowChanged(EffectWindow *w); void slotWindowFrameGeometryChanged(EffectWindow *w, const QRectF &); + void slotWindowHiddenChanged(EffectWindow *w); void slideIn(EffectWindow *w); void slideOut(EffectWindow *w); diff --git a/src/window.cpp b/src/window.cpp index 33df850c8a..bf86ffcdcc 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -72,9 +72,6 @@ Window::Window() connect(this, &Window::interactiveMoveResizeStarted, this, &Window::moveResizedChanged); connect(this, &Window::interactiveMoveResizeFinished, this, &Window::moveResizedChanged); - connect(this, &Window::windowShown, this, &Window::hiddenChanged); - connect(this, &Window::windowHidden, this, &Window::hiddenChanged); - connect(this, &Window::paletteChanged, this, &Window::triggerDecorationRepaint); // If the user manually moved the window, don't restore it after the keyboard closes @@ -4290,10 +4287,8 @@ void Window::setHidden(bool hidden) doSetHidden(); if (hidden) { workspace()->activateNextWindow(this); - Q_EMIT windowHidden(this); - } else { - Q_EMIT windowShown(this); } + Q_EMIT hiddenChanged(); } bool Window::isHiddenByShowDesktop() const diff --git a/src/window.h b/src/window.h index bfe0742ca5..6c69e30bcc 100644 --- a/src/window.h +++ b/src/window.h @@ -1332,8 +1332,6 @@ Q_SIGNALS: void damaged(KWin::Window *window); void inputTransformationChanged(); void closed(); - void windowShown(KWin::Window *window); - void windowHidden(KWin::Window *window); /** * Emitted whenever the Window's screen changes. This can happen either in consequence to * a screen being removed/added or if the Window's geometry changes.