]> git.mdlowis.com Git - proto/labwc.git/commit
Adjust views to account for output layout changes
authorJohn Lindgren <john@jlindgren.net>
Fri, 31 Dec 2021 22:30:55 +0000 (17:30 -0500)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 1 Jan 2022 16:20:13 +0000 (16:20 +0000)
commita837fefc80a4a77e4e0353e4b8a14ece258a642a
treec20db58fe45dc9791e064e27d737ae85d833453d
parent12b05604a2bf128d818822288de253908d9d03a8
Adjust views to account for output layout changes

labwc currently doesn't handle output layout changes very well:

 - Windows can end up "lost" completely offscreen
 - Maximized/fullscreen windows can end up spanning multiple outputs

Currently, new_output_notify() and output_destroy_notify() contain logic
to update the cursor and force a repaint when outputs are added or
removed.  This logic in fact needs to run on any output layout change,
so consolidate it into a new function, output_update_for_layout_change().

Then add a second new function, view_adjust_for_layout_change(), which
adjusts window placement to account for the new layout.

The behavior is roughly as follows:

 - Normal windows that end up offscreen are centered on the closest
   output (making use of the existing view_center() logic)
 - Maximized windows are re-maximized on the closest output.  Logic is
   also added to the unmaximize step to check that the original
   unmaximized position is still on-screen.
 - Fullscreen windows are re-fullscreened on the same output if
   possible; otherwise they are un-fullscreened.

Minimized windows don't require any special handling.  Their placement
is adjusted just the same, but invisible to the user until they are
later unminimized.

There is some positioning glitch still with un-fullscreening a window
whose output has been disconnected/disabled; it can end up in an
unexpected position (but at least has the correct size and decoration).
I don't think this is due to a bug in my change per se, but perhaps the
change has exposed a bug elsewhere.

Fixes: #177
include/labwc.h
src/output.c
src/view.c