effects/magiclamp: Improve animation direction heuristic
If the panel is placed between two outputs, the magic lamp can pick wrong direction and the animation will look bad. This change improves the direction heuristic by making it analyze the position of the center point of the screen where the window is relative to the center point of the icon in the task manager. The screen center is used instead of the window center in order to properly handle edge cases such as where the window center is offscreen. For example, if the panel is vertical (e.g. it's attached to the left side of a monitor), the magic lamp will pick the following directions: - if the window is to the left side of the panel, the window will be animated so it moves to the right hand side - if the window is to the right side of the panel, the window will be animated so it moves to the left hand side Without this change, the window will always move to the left hand side. BUG: 463581
This commit is contained in:
parent
223b01f9e7
commit
124d915408
1 changed files with 4 additions and 4 deletions
|
@ -145,18 +145,18 @@ void MagicLampEffect::apply(EffectWindow *w, int mask, WindowPaintData &data, Wi
|
|||
}
|
||||
if (panel) {
|
||||
// Assumption: width of horizonal panel is greater than its height and vice versa
|
||||
// The panel has to border one screen edge, so get it's screen area
|
||||
QRectF panelScreen = effects->clientArea(ScreenArea, panel);
|
||||
const QRectF windowScreen = effects->clientArea(ScreenArea, w);
|
||||
|
||||
if (panel->width() >= panel->height()) {
|
||||
// horizontal panel
|
||||
if (panel->y() <= panelScreen.height() / 2) {
|
||||
if (icon.center().y() <= windowScreen.center().y()) {
|
||||
position = Top;
|
||||
} else {
|
||||
position = Bottom;
|
||||
}
|
||||
} else {
|
||||
// vertical panel
|
||||
if (panel->x() <= panelScreen.width() / 2) {
|
||||
if (icon.center().x() <= windowScreen.center().x()) {
|
||||
position = Left;
|
||||
} else {
|
||||
position = Right;
|
||||
|
|
Loading…
Reference in a new issue