From d3c82fa103eda4873d3a5a33fc7de594b98c703c Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 18 May 2023 06:53:57 +0000 Subject: [PATCH] plugins/magiclamp: Make it look good with hidden panels If the panel is hidden, the animation can be clipped some distance away from the screen edge. To fix that, move the icon offscreen. --- src/effects.cpp | 1 + src/effects.h | 1 + src/libkwineffects/kwineffects.h | 1 + src/plugins/magiclamp/magiclamp.cpp | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+) diff --git a/src/effects.cpp b/src/effects.cpp index 109fecdfa9..52efd16691 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -1960,6 +1960,7 @@ WINDOW_HELPER(bool, isLockScreen, isLockScreen) WINDOW_HELPER(pid_t, pid, pid) WINDOW_HELPER(QUuid, internalId, internalId) WINDOW_HELPER(bool, isMinimized, isMinimized) +WINDOW_HELPER(bool, isHidden, isHiddenInternal) WINDOW_HELPER(bool, isModal, isModal) WINDOW_HELPER(bool, isFullScreen, isFullScreen) WINDOW_HELPER(bool, keepAbove, keepAbove) diff --git a/src/effects.h b/src/effects.h index 15992107a5..ad7d7682a4 100644 --- a/src/effects.h +++ b/src/effects.h @@ -373,6 +373,7 @@ public: bool isDeleted() const override; bool isMinimized() const override; + bool isHidden() const override; double opacity() const override; QStringList activities() const override; diff --git a/src/libkwineffects/kwineffects.h b/src/libkwineffects/kwineffects.h index 36618e6444..bb7852b4a2 100644 --- a/src/libkwineffects/kwineffects.h +++ b/src/libkwineffects/kwineffects.h @@ -2324,6 +2324,7 @@ public: virtual void unrefWindow() = 0; virtual bool isDeleted() const = 0; + virtual bool isHidden() const = 0; virtual bool isMinimized() const = 0; virtual double opacity() const = 0; diff --git a/src/plugins/magiclamp/magiclamp.cpp b/src/plugins/magiclamp/magiclamp.cpp index 6188110bf8..8924d07a95 100644 --- a/src/plugins/magiclamp/magiclamp.cpp +++ b/src/plugins/magiclamp/magiclamp.cpp @@ -162,6 +162,25 @@ void MagicLampEffect::apply(EffectWindow *w, int mask, WindowPaintData &data, Wi position = Right; } } + + // If the panel is hidden, move the icon offscreen so the animation looks correct. + if (panel->isHidden()) { + const QRectF panelScreen = effects->clientArea(ScreenArea, panel); + switch (position) { + case Bottom: + icon.moveTop(panelScreen.y() + panelScreen.height()); + break; + case Top: + icon.moveTop(panelScreen.y() - icon.height()); + break; + case Left: + icon.moveLeft(panelScreen.x() - icon.width()); + break; + case Right: + icon.moveLeft(panelScreen.x() + panelScreen.width()); + break; + } + } } else { // we did not find a panel, so it might be autohidden QRectF iconScreen = effects->clientArea(ScreenArea, icon.topLeft(), effects->currentDesktop());