Page MenuHome

Fix T85638: Child Window Positioning on Multiple Monitors
ClosedPublic

Authored by Harley Acheson (harley) on Feb 19 2021, 12:39 AM.

Details

Summary

This is the bare minimum changes to fix problems positioning child windows when using Multiple Monitors.

The following shows how child windows could be positioned in Blender 291. Middle (main) monitor shown on top is positioned as expected, while left-most monitor (shown bottom left) positions child on middle monitor. Right-most monitor (shown bottom right) positions child on middle monitor.

The following shows child window positioning in blender 293 master. It is improved, as all children are on the same monitor as parent. But left-most monitor (bottom left) positions child too far right. Right-most monitor (bottom right) positions child too far left.

The following shows child window positioning after this patch is applied. Each child positioned correctly in relation to parent no matter which monitor.

This problem is caused by wm_window_check_position() which has flawed logic in order to constrain the new window to monitor bounds as it does not take monitor origins into account. Without origin it can constrain width and height correctly, but cannot constrain positioning. This is because my monitor that is to the left of my main monitor has a horizontal axis that runs from -1919 to -1, and my right-most monitor is 1920 to 3840. Without considering origins, this wm_window_check_position() can only clamp the positions to values inside the monitor dimensions (0-1919).

This patch takes out the positioning constraint and therefore renames the function to wm_window_check_size().

This works perfectly on the Windows platform because the new window is properly constrained for location and size in that ghost code, so no need to do so here. This will have to be tested on Linux and Mac though, to make sure that they they are unable to create windows that are bisected by multiple monitors. If so we will have to create a platform-varying fix.

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Feb 19 2021, 12:39 AM
Harley Acheson (harley) created this revision.

Seems to behave fine on Linux with Gnome 3. It may be different for other window managers, but I think it's reasonable to commit this and get users to test it.

This code was added initially by Ton on macOS, so that case needs to be tested.

Seems to behave fine on Linux with Gnome 3. It may be different for other window managers, but I think it's reasonable to commit this and get users to test it.

Eventually it would be nice to get a monitor bounds rect from ghost, rather that current dimensions. Then some OSs can use 0,0 as origin, while others (like windows) can be offset.

This code was added initially by Ton on macOS, so that case needs to be tested.

Will Find someone to test that first, no worries.

Updated to current state of master.

Works fine on macOS, also clamps to the screen boundaries.

This revision is now accepted and ready to land.Feb 22 2021, 10:28 PM