Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set _NET_FRAME_EXTENTS according to the actual decoration size #5944

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

sigprof
Copy link

@sigprof sigprof commented Mar 9, 2024

Inspired by #5384, but instead of just using the border width, this PR reports the actual frame extents for the window, which may also include the title bar (for floating windows and tiled windows in plain split containers, but not for tiled windows in stacked/tabbed containers).

The existing con_border_style_rect() function should already handle all configuration options which can affect the decoration sizes (if it does not, that would also show up in other places); its result just needs to be converted into the format used by the _NET_FRAME_EXTENTS property.

This PR fixes #4292 probably in the best way possible (the reported _NET_FRAME_EXTENTS values should always match the actual sizes of window frame elements which are actually drawn into the X11 frame window into which the client window is reparented). The only really problematic case is with the stacked/tabbed containers, for which the title bar is actually drawn into a completely separate window, therefore the title bar size cannot be reported in _NET_FRAME_EXTENTS (actually I tried to calculate the size of those decorations and add it to the top decoration size, but that did not change the behavior of picom).

Large screenshots here (3840×2160)

Example of configuration with hide_edge_borders smart — a single window does not have borders, so only the top frame size is non-zero:
2024-03-09_21-41

but multiple windows have borders:
2024-03-09_21-44

Changing border width works too (although with border normal 8 you can see that the top border overlaps the title text, because on the i3 side that border does not really exists, and picom just draws it over; also the pixel sizes reported by xprop and xwininfo are not identical to what is specified in i3, because I use 168 dpi on this system, therefore 4 px in the i3 config = 7 dpx):
2024-03-09_21-48

Handling of tabbed containers is less perfect though. Here is a single tabbed container with hide_edge_borders smart, so it does not really have a border — note that all frame extents are zero, and the titlebar is rounded separately (although it could easily be excluded from rounding, that does not really help much):
2024-03-09_22-02

Once the border actually appears, you may notice that the top part of the picom border actually gets drawn over the top part of the window, partially obscuring the top line in this terminal (picom does not mind that the top frame size is reported as 0):
2024-03-09_22-04

Some examples of floating windows (no major problems there):
2024-03-09_22-09

Options like hide_edge_borders both work too when gaps are removed (although the resulting behavior with picom is probably not very useful — the rounded border gets drawn only if all of the left, bottom and right borders are present):
2024-03-09_22-15

The same with border pixel 8 (note that windows with only the top border hidden still get the rounded border treatment by picom, but the border overlaps the top part of the window):
2024-03-09_22-21

Use `con_border_style_rect(con)` to retrieve the decoration size (that
function takes lots of special cases due to `hide_edge_borders`, border
style and width customizations, etc. into account), then massage the
result into the form suitable for `_NET_FRAME_EXTENTS`.

Signed-off-by: Sergey Vlasov <sigprof@gmail.com>
Signed-off-by: Sergey Vlasov <sigprof@gmail.com>
@SolsticeSpectrum
Copy link

Can we accept this? This is actually perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set _NET_FRAME_EXTENTS
2 participants