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

Wayland backend #535

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Wayland backend #535

wants to merge 13 commits into from

Conversation

bolphen
Copy link
Contributor

@bolphen bolphen commented Feb 28, 2025

We now have

  • Cursor shape / hide and grab (the cursor shape protocol is not supported under gnome for now but apparently it will be there in the next version)
  • Key repeat
  • Clipboard and drag-n-drop
  • Blocking event loop
  • High-dpi support
  • Client-side window decorations under gnome using libdecor, which is what xwayland uses (I removed the old fallback decorations: it looks bad but more importantly it also messes up the cursor positioning, and I don't want to manually fix the offset)

Probably some tests are needed before merging, especially under different compositors and on different machines (I tested on mutter, hyprland, and sway, and I've had the same code working under one but not another...)

Also I did modify the code structure quite a bit. Probably gonna be bad for others who worked/are working on it (@narodnik maybe? btw I rebased upon your clipboard implementation; it got me started so your work is not in vain :)

There's still some code that's a bit messy; also it'd probably be nice for the X11 and Wayland implementations to share more common patterns, which I didn't pay enough attention. But at least it works now :)

jkds and others added 9 commits March 1, 2025 05:12
…, but there's a segfault when the text is replaced (cancelled). Reading the clipboard data just hangs so it's commented out for now.
- Implement Wayland key repeat
- Implement Wayland clipboard and drag_n_drop
- Rename `Platform::linux_x11_wm_class` to `linux_wm_class` for both X11
  and Wayland usage
- Use `eglSwapInterval`
Remove `event_handler` from the payload and add `EVENTS` to the payload.
Essentially we now maintain our own event queue.
- Make the event handlers of listeners not `Option` anymore.
- Let `wl_listener` macro write all the dummy event handlers
- High-dpi support
- Construct all the `wl_proxy` in `registry_add_object` (except the
  `wl_data_device`)
- Add new struct `PointerContext`
- Support cursor shape and cursor grab
- Move the `wl_request` macros to `libwayland_client.rs`
- Make `wayland_use_fallback_decorations` deprecated
- There is no reason to normalize the mouse wheel value to {-1,0,1}:
  it's not done on other platforms, and this just makes the input
  very imprecise
/// When using Wayland, this controls whether to draw the default window decorations.
/// On Wayland, the decorations are either drawn by the server or via `libdecor`. If neither is
/// available then no decorations will be drawn.
#[deprecated]
pub wayland_use_fallback_decorations: bool,
Copy link
Owner

Choose a reason for hiding this comment

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

I would keep this configurable. Maybe as an enum with options for no csd, ugly csd and libdecor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK I restored the old fallback decorations so this flag still applies if libdecor is not found.

@not-fl3
Copy link
Owner

not-fl3 commented Mar 1, 2025

Wow, what a PR, great work! I do not have much to add, looks super good to me.

This is correct, this code was basically maintained by @narodnik, so I would wait for their feedback too.

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.

2 participants