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

Better decorations in wayland #4970

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tmccombs
Copy link
Contributor

@tmccombs tmccombs commented Feb 6, 2024

This is an attempt to improve window decorations on wayland. It waits to create the window decorations until we get a configure event from the compositor, so that we can know whether the compositor wants us to use CSD or not.

@wez
Copy link
Member

wez commented Feb 10, 2025

How do you feel about also rebasing/revising this one? I think it will help with a couple of outstanding issues!

@tmccombs tmccombs force-pushed the wayland-decoration-fix branch from f581278 to 8a608ea Compare February 11, 2025 09:22
Copy link
Member

@wez wez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

FWIW, under KDE Plasma I experience this with this pr; the window briefly appears and then we immediately terminate:

$ ./target/debug/wezterm -n --config 'window_decorations="RESIZE"'
Io error: Broken pipe (os error 32)
07:24:04.792  ERROR  wezterm_gui > running message loop: Io error: Broken pipe (os error 32); terminating

@@ -2,6 +2,8 @@
//! in smithay_client_toolkit 0.11 which is Copyright (c) 2018 Victor Berger
//! and provided under the terms of the MIT license.

// TODO: update this for SCTK 0.18 and use this instead of the FallbackFrame
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we need to do here now that we're on SCTK 0.19? Does it need to be part of this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it doesn't need to be, and probably shouldn't be part of this PR.

Basically it would need to be re-written to implement the DecorationsFrame trait.

Alternatively, just delete this and use the adwaita implementation instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda like the idea of adwaita: feels like less of a chore for us to maintain over here

@tmccombs
Copy link
Contributor Author

tmccombs commented Feb 12, 2025

the window briefly appears and then we immediately terminate:

huh. not sure why my changes would result in a pipe error. I might be able to look into it later.

@tmccombs tmccombs force-pushed the wayland-decoration-fix branch from 363f55c to ac6dbe1 Compare February 13, 2025 07:01
let outer_size = frame.add_borders(w, h);
let (x, y) = frame.location();
window.set_window_geometry(
x.try_into().unwrap(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still experience the broken pipe error with the latest version of this PR. Sometimes though, I see a panic trigger here; I think this is a secondary symptom during teardown, but I'd like to see it handled better. I put a dbg! around x and in the case of the panic its value is -4, but set_window_geometry wants unsigned values, which is the cause of this particular panic.

Probably to do something like x.max(0).try_into().unwrap() here instead? to ensure that we don't have a negative value, same for y?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, so the x and y values are actually expected to be negative.

As far as I understand, the way this works is the origin (0,0) is the top left of the inner surface. But you set the window geometry to have a negative x and y, to tell the compositor that the outer window should have space for the decorations.

Looking at examples of using the wayland_csd_decorations crate, it looks like it can be worked around by using window.xdg_surface().set_window_geometry instead of the set_window_geometry on the sctk XdgSurface.

I just pushed a fix for that panic. I might get a chance to test it more this weekend.

@tmccombs
Copy link
Contributor Author

Well. On Sway, I don't get the pipe error, but it is extremely buggy. Resizing doesn't seem to work at all.

Possibly I messed something when resolving conflicts.

I'm not sure when I'll have the time to dig deeper into this. I wouldn't object if someone else wanted to pick this up, otherwise, I'll put this on my todo list to fix.

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

Successfully merging this pull request may close these issues.

2 participants