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

Upgrade smithay-client-toolkit 0.17 #4777

Closed
wants to merge 55 commits into from
Closed

Upgrade smithay-client-toolkit 0.17 #4777

wants to merge 55 commits into from

Conversation

tzx
Copy link
Contributor

@tzx tzx commented Jan 11, 2024

Saw #4504, when I was looking into #4483.

Understand that this requires a large refactor, so I am attempting it here. Currently, typing works, but there are a lot of missing features that I am noting down, possibly more...:

  • Mouse input doesn't work at all
  • rendering cursor icons
  • window decorations (It currently uses the Fallback one from SCTK, but not wezterm's own custom one)
  • clipboard support
  • primary clipboard support (seems like I rather update to 0.18 to make this easier, I did it in 0.17 but 0.18 has an abstraction)
  • drag and drop support
  • ime support
  • wlr-output-management-unstable
  • all rendering frontends supported (egl seems weird because I hardcoded stuff so I need to fix that)

tzx added 30 commits January 3, 2024 20:22
- wgpu gives segfault so move to EGL
- implement terminating message loop to match prev implementation
- still gives error but no segfault or panic right now
Without this change, the event dispatch would go on forever and cause a
stack overflow
@wez
Copy link
Owner

wez commented Jan 28, 2024

@tzx many thanks for doing this work! I appreciate it a great deal! I'll see if I can persuade one or two people to run with this and we can figure out where to go from there!

@jokeyrhyme
Copy link
Contributor

@tzx amazing, Herculean effort :D

I'll check the todo!() macros and compare some window and settings behaviours across the compositors I use (GNOME, sway, COSMIC) and report back

In terms of continuing this work, if I were up to actually contributing code, should we fork the fork and raise PRs against it, fork the fork and submit a new PR here, or add more people as collaborators to the fork to preserve this PR?

@wez
Copy link
Owner

wez commented Jan 28, 2024

Since we just cut a release, which gives folks an up to date stable build to target, I'm conceptually ok with merging this and making nightly a bit wonky for wayland users while we quickly try to close any gaps that might cause work to be lost, and then we can take a bit longer to polish up the rest.

@jokeyrhyme
Copy link
Contributor

jokeyrhyme commented Jan 28, 2024

I'll update this comment with results from other configurations, but to start with...

I'm running cargo run --bin wezterm-gui --release -- --config '...' for each scenario, and my machine has both an AMD iGPU and AMD dGPU (no nVidia in the mix), with 1.25 scale on my single monitor (no multi-monitor)

Compositors with server-side decorations here are:

Compositors with only client-side decorations here are:

COSMIC (tiling disabled), GNOME sway (tiling), COSMIC (tiling)
window_decorations="NONE" SCTK panic "trying to resize hidden frame" SCTK panic "trying to resize hidden frame"
window_decorations="RESIZE" todo!() panic works 👍
window_decorations="TITLE" todo!() panic works 👍
window_decorations="INTEGRATED_BUTTONS|RESIZE" todo!() panic works 👍
window_decorations="TITLE|RESIZE" SCTK panic "trying to resize hidden frame" SCTK panic "trying to resize hidden frame"

@tzx
Copy link
Contributor Author

tzx commented Jan 28, 2024

Ahh, I forgot about turning off window_decorations in my config when working on frame decorations when I was trying wezterm on weston... Hope it's an easy fix.

@jokeyrhyme
Copy link
Contributor

@tzx don't worry about it
If there are other settings you think I ought to be interested in, let me know
But, I will eventually dive in and figure out what to look at based on your comment ( #4777 (comment) ) and the todo!() s
So don't stress about it :)

@jokeyrhyme
Copy link
Contributor

Okay, I've had a chance to play with this

I'm no expert in Wayland or SCTK, although learning a lot just reading through the code

What I'd like to do is prepare a PR that can be merged soon after this PR, and my approach is to hard code CSD via SCTK Fallback Frame, ignoring user and compositor preference, with the user able to move/resize/maximise the window without hitting any todo!()

Then separate future PRs can look at updating to SCTK 0.18, and restoring user control over decorations

@jokeyrhyme
Copy link
Contributor

jokeyrhyme commented Jan 29, 2024

I've created a branch here: https://github.com/jokeyrhyme/wezterm/tree/smithay-0-17-conflicts-after-4824-and-4866

I figured it was worth tackling the git conflicts separately before trying to do much else

This incorporates the changes to resize_increment behaviour from #4824 and #4866

Otherwise, this doesn't change the observed results: #4777 (comment)

@wez
Copy link
Owner

wez commented Jan 30, 2024

FWIW, a valid outcome for client-side decorations is to default to lean on the https://wezfurlong.org/wezterm/config/lua/config/integrated_title_button_style.html feature to render most/all of that UI. I think that would reduce the problem space in the wayland specific code to handling resize "handles" around the window borders, which can be done with transparent surfaces. The benefit of that is that no custom drawing would be necessary at the wayland layer.

@tmccombs
Copy link
Contributor

tmccombs commented Feb 3, 2024

I tested this branch on Hyprland and found the following issues:

  1. For every key press, I see an error that looks like: "ERROR window::os::wayland::window > set_cursor: Cursor not found" on stderr
  2. With window_decorations of NONE, or "TITLE | RESIZE" I get the "trying to resize hidden frame" panic
  3. With window_decorations of "TITLE" or "RESIZE" It opens, but there are strange gray lines to the bottom and left:
    image
  4. The text of the terminal seems offset, possibly due to decorations, but the decorations aren't actually rendered. This is most obvious if I open a TUI with a background color, like vim:
    image
  5. Probably related to 4, If I go down to the bottom of the window, then the last line oveflows past the end of the window:
    image

@tmccombs
Copy link
Contributor

tmccombs commented Feb 3, 2024

Actually... If I make the window floating, it makes a little more sense:
image

It looks like it is trying to draw the whole window offset from the frame Hyprland is using for the window. Maybe there is a problem between the reference frame of the window including the client decorations and without.

Although, ideally I'd use window_decorations="NONE" on hyprland. But that currently panics.

@tmccombs
Copy link
Contributor

tmccombs commented Feb 3, 2024

A few thoughts on this:

  1. We should be passing in the appropraite decorations mode to xdg_shell::new_window (second argument) instead of always using Decorations::FollowServer.
  2. If we are suing server-side decorations (which I don't think we know until after getting a configure back from the server, I'm not entirely sure where the code that handles that is), then we shouldn't create the window_frame for the decorations at all. I think that panic is happening because we are trying to resize the frame after hiding it.

@tmccombs
Copy link
Contributor

tmccombs commented Feb 3, 2024

if someone else doesn't get to it, I think I know what needs to be done to fix this, and a general idea of how to fix this at least using the fallback frame.

Although using https://github.com/PolyMeilex/sctk-adwaita might look nicer.

@jokeyrhyme
Copy link
Contributor

@tmccombs thanks!

I believe this PR is effectively frozen, so I've created some follow-up PRs that address some of the panics by using the fallback frame in all cases (for now) as a temporary stop-gap

@wez wez closed this in a435606 Feb 3, 2024
@wez
Copy link
Owner

wez commented Feb 3, 2024

I've rebased this and pushed it to main, for (mostly) better and (ideally temporarily) slightly worse!
Thanks again @tzx!

@catdevnull
Copy link

Hi, just wondering, would this somewhat improve the fractional scaling situation in Wayland?

@catdevnull catdevnull mentioned this pull request Feb 3, 2024
@tmccombs
Copy link
Contributor

tmccombs commented Feb 6, 2024

Here's my draft at attempting to improve this:

#4970

MartinNowak added a commit to MartinNowak/wezterm that referenced this pull request Mar 9, 2024
- was dropped with wayland reimplementation (wez#4777, 3eaba4e)
- get appearance from xdg desktop portal
- advise all windows of appearance changes and reload config
MartinNowak added a commit to MartinNowak/wezterm that referenced this pull request Mar 9, 2024
- was dropped with wayland reimplementation (wez#4777, 3eaba4e)
- get appearance from xdg desktop portal
- advise all windows of appearance changes to reload config
@dedguy21
Copy link

dedguy21 commented Mar 22, 2024

start if i enter:
env WAYLAND_DISPLAY=1 wezterm

added that to the .desktop app script, and opens everytime now on hyprland.

also added it to hotkey obviously, just verify your wayland display number.

wez pushed a commit that referenced this pull request May 5, 2024
- was dropped with wayland reimplementation (#4777, 3eaba4e)
- get appearance from xdg desktop portal
- advise all windows of appearance changes to reload config
HidemaruOwO added a commit to HidemaruOwO/dotfiles that referenced this pull request May 18, 2024
saep pushed a commit to saep/wezterm that referenced this pull request Jul 14, 2024
- was dropped with wayland reimplementation (wez#4777, 3eaba4e)
- get appearance from xdg desktop portal
- advise all windows of appearance changes to reload config
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.

7 participants