Skip to content

plugins/magiclamp: Improve animation direction heuristic

Currently, depending on the output setup, the magic lamp can pick wrong animation direction. Unfortunately, we can't solely use the window's screen's center to decide the animation direction. We need to use the window's position relative to the icon rect.

This change reworks the animation direction heuristic:

  • (assume that there's a horizontal panel at the bottom of the screen)
  • compute how much the top window edge will move down, i.e. max(icon.y - window.y, 0)
  • compute how much the bottom window edge will move up, i.e. max(window.y + window.height - icon.y - icon.height, 0)
  • use the direction with the highest distance/score
  • if both scores are equal, the animation direction does not matter. The heuristic finds a window edge that's the closest to its opposite screen edge and animate the window in direction of window edge -> screen edge

Visual aids

IMG_20230604_141009

note: the sticker on the left shows normal case, the sticker on the right shows the case when max(icon.y - window.y, 0) == max(window.y + window.height - icon.y - icon.height, 0) and how the direction is picked

Edited by Vlad Zahorodnii

Merge request reports

Loading