Gui/CaptureOverlay: Constrain toolbars to the specific screen containing the selection edge

Fix for: https://bugs.kde.org/show_bug.cgi?id=468794

Previously, the annotation and finalizer toolbars were positioned relative to the global viewport of all screens combined. On multi-monitor setups, especially those with vertical layouts, this could cause toolbars to:

  • Render on the bezel between screens.
  • Float in invalid coordinates if screens were not aligned perfectly.

I initially tried to solve a problem i came across in my setup in !498 (merged), but didn't consider every aspect. Thanks to @pallaswept for demonstrating the root cause.

This commit introduces screen-aware positioning logic:

  1. getScreenForEdge() identifies which physical screen contains most of the top or bottom edge of the current selection.
  2. The Annotation Toolbar (top) is now constrained to the screen containing most of the selection's top edge.
  3. The Finalizer Toolbar (bottom) is constrained to the screen containing most of the selection's bottom edge.
  4. If the area containing most of the selections edge is on no screen, it will render the toolbars on the screen containg most of the selection area / being the dominant screen

This ensures that even if a selection spans multiple monitors, the controls appear on the relevant screen and are clamped within its bounds.

I don't think option 4 looks great, but I’m out of ideas on how to improve it (Maybe users who take screenshots of mostly empty areas don’t deserve anything better!). Open to suggestions!

Demonstration of the new behavior (black area = no screen = previously contained the toolbars):

image.png

image.png

Area containing the edge too small, dominant screen select for top toolbar:

image.png

BUG: 468794

Edited by Mario

Merge request reports

Loading