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.
master
Vlad Zahorodnii 1 year ago
parent 2ff040a744
commit d3c82fa103

@ -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)

@ -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;

@ -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;

@ -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());

Loading…
Cancel
Save