Skip to content

x11: More robust geometry calculations#438

Merged
august64 merged 1 commit intorust-windowing:masterfrom
august64:x11-geometry
Apr 7, 2018
Merged

x11: More robust geometry calculations#438
august64 merged 1 commit intorust-windowing:masterfrom
august64:x11-geometry

Conversation

@august64
Copy link
Copy Markdown
Member

It was brought to my attention via #430 that there are presently issues with how window geometry is calculated, and I soon found myself in a rather deep rabbit hole.

After testing on Xfwm4, Mutter, Muffin, Budgie, Marco, Compiz, KWin, Enlightenment, FVWM, Awesome, i3, xmonad, dwm, Openbox, Fluxbox, Blackbox, and IceWM, I believe I've arrived at a complete and correct solution.

Normally, this is where I'd explain in depth what this PR does and why it exists, but I wrote some rather extensive comments throughout the source, so I'll just outline the consequences of these changes.

I've verified on all of the WMs tested that get_position, get_inner_position, get_inner_size, get_outer_size, and set_position all work correctly, both with and without decorations enabled. The only caveat to this is that I wasn't able to figure out how to test positioning on i3, but i3 isn't on the list of WMs that return different values after this change anyway.

The WMs that return different positions after this change are Mutter/Muffin/Budgie, Compiz, and Enlightenment. Fortunately, from my measurements, these are improvements rather than regressions. Explanations for why these values are different are included in the comments.

Enightenment and FVWM now have set_position behavior consistent with other WMs. Once again, explanation in comments.

Prior to this, get_outer_size was reliably wrong, as frame extents were being estimated using the border return of XGetGeometry. On all WMs tested other than xmonad and dwm, that value is always 0. Since the proposed get_inner_position method relies on the same value, it would also be reliably wrong. This PR provides us with accurate frame extents, enabling both of these methods to work correctly.

Most of these changes are centered around the _NET_FRAME_EXTENTS window property, which is supported on all widely used WMs. On all WMs tested that don't support it, it's correctly estimated using other values. This PR was inspired by an SFML PR of similar scope.

@august64 august64 force-pushed the x11-geometry branch 3 times, most recently from a0d841e to 1cf8862 Compare April 5, 2018 20:29
Tested on the following window managers:
* Xfwm4 4.12.4
* Mutter 3.26.2
* Muffin 3.6.0
* Budgie 10.4
* Marco 1.20.0
* Compiz 0.9.13.1
* KWin 5.12.3
* Enlightenment 0.22.2
* FVWM 2.6.7
* Awesome 4.2
* i3 4.15
* xmonad 0.13
* dwm 6.1
* Openbox 3.6.1
* Fluxbox 1.3.7
* Blackbox 0.70.1
* IceWM 1.3.8
* IceWM 1.4.2
@august64 august64 merged commit 4005bf1 into rust-windowing:master Apr 7, 2018
@august64 august64 mentioned this pull request Apr 22, 2018
@august64 august64 mentioned this pull request Jun 7, 2018
4 tasks
tmfink pushed a commit to tmfink/winit that referenced this pull request Jan 5, 2022
bugfix rust-windowing#436 which endless loop in clip::clip_line_segment_to_rect method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant