Toqozz / wired-notify

Lightweight notification daemon with highly customizable layout blocks, written in Rust.
MIT License
587 stars 27 forks source link

wayland support? #47

Open jokeyrhyme opened 2 years ago

jokeyrhyme commented 2 years ago

Howdie, thanks so much for sharing your work here, wired is working terrifically for me! <3

I thought I'd create a dedicated issue for this conversation ( although there are mentions https://github.com/Toqozz/wired-notify/issues/34#issuecomment-1003533590 and https://github.com/Toqozz/wired-notify/issues/34#issuecomment-1003534300 )

I've been using wired with both sway and river compositors (wayland) and I'd like to report that it's working very well

I do see fuzzy font issues when running it on a high-density display with scale=2.0 , which is typical when running an X11 application via xwayland within a wayland compositor

That said, for my use case, I read a notification quickly and then it goes away, I'm not reading this fuzzy text for very long so it doesn't seem super important to me

So, yeah, I thought maybe it would be good to track a decision/reports/progress on wayland, if only to address the fuzzy fonts at scale=2.0 (might become more of a problem as more distributions go wayland-by-default)

Thanks again!

Edit: adding this checklist (to help summarise items from comments)

minimum required to start without crashing and to display something

feature parity for wayland

jokeyrhyme commented 2 years ago

I'm sure there's much more to it than this, but it looks like winit::event_loop::EventLoop::new() will automatically work for either wayland or X11 :shrug:

Toqozz commented 2 years ago

So glad to hear that Wired is working on Wayland! Thanks for the report.

I thought that notifications would need to be handled by the WM or something in Wayland, but this seems silly now thinking about how dbus works.

Indeed winit does support Wayland, but we're using a few X11 things to make stuff work properly, which we'd have to find equivalents for on Wayland.

The main ones I can think of are creating our cairo surface (I believe this was to support transparency): https://github.com/Toqozz/wired-notify/blob/549e595d755abf696b4bf54c385d56f8bb3cce20/src/rendering/window.rs#L132-L153

And setting the X11 window types (there must be alternatives for these): https://github.com/Toqozz/wired-notify/blob/549e595d755abf696b4bf54c385d56f8bb3cce20/src/rendering/window.rs#L113-L116

I'll get around to looking for how to get around those eventually.

jokeyrhyme commented 2 years ago

Ah, I hadn't even looked into transparency at all, but I assume others on wayland will probably want this :)

The other thing I can think of is the idle-behaviour, I'm not sure if this is already being done in a systemd/logind/dbus way or if that's being done in an X11/XSS-specific way? :shrug:

Toqozz commented 2 years ago

Idle behavior is currently done using XSS, bah!

LukasDoesDev commented 2 years ago

Is there any way to have monitor following in Wayland?

tdpeuter commented 2 years ago

Please note that 'it works on Wayland' is probably only because Xwayland is also running. If you start Sway with xwayland disable configured, Wired does not work.

Transparency is trippy indeed, I suspect (based on what I've tried) that only either completely transparent or completely opaque is supported at the moment, using the Color(hex) or Color(rgba) format.

Also I notice that notifications that are configured to anchor anywhere other than top-left, are first displayed TL before being moved somewhere else (at least, that's my assumption, I can only report a flash of the notification at TL).

Toqozz commented 2 years ago

Yeah, XWayland is definitely doing some heavy lifting. I'm not quite in a position to properly support Wayland yet, as I think it would require a lot of research to get it there. I'm open to PRs getting us most of the way there or similar.

Regarding the top left thing, this should be fixed on master (see #71). I've been slow at getting releases out, apologies. I'll try to release one tonight.

tdpeuter commented 2 years ago

No problem at all!

I thought the 'top left thing' would also be caused by Wayland, didn't see that issue there, sorry for that.

TornaxO7 commented 2 years ago

May I ask what the current state is?

Toqozz commented 2 years ago

No progress. I'm not really working on this anytime soon. I'm open to any pull requests in this area.

What are the actual issues at the moment? Monitor following doesn't work, and transparency?

ribosomerocker commented 2 years ago

Yes, and it looks like one of the actual issues is that it runs on XWayland instead of native Wayland, because of the 2 pieces of code you posted above I believe. You might need to replace them with an X/Wayland agnostic call, maybe by using winit.

jokeyrhyme commented 2 years ago

I think our options are:

Toqozz commented 2 years ago

Thanks for the research!

Option 1 is ideal, and I think it's doable.

It definitely should be possible to get a cairo context from a wayland window -- well, it is possible since dunst does it.

Cairo does seem to support EGL, I think it's just not documented well. I also can't find anything about it in the cairo_sys package though, so not sure here. But there should be a way forward -- we can make the bindings ourselves if we have to.

Assuming we can find a way to call cairo_gl_surface_create_for_egl, then we just needa figure out how to get the raw device stuff from rust, probably with the wayland_surface() and wayland_display() methods.

wayland_egl is probably a piece of the puzzle (https://docs.rs/wayland-egl/latest/wayland_egl/)

I'll update if I find anything more regarding cairo EGL.

Toqozz commented 2 years ago

It looks like we could maybe also just use a regular cairo image surface and upload it to the window somehow (https://www.cairographics.org/OpenGL/). But this sounds like much more hassle than just having an actual surface.

jokeyrhyme commented 2 years ago

This could be promising (however C, not Rust): https://cairo.cairographics.narkive.com/sz0ZifFB/to-wayland

jirutka commented 2 years ago

This project intrigued me, especially after seeing that it’s flexible enough to display this https://github.com/Toqozz/wired-notify/issues/63#issuecomment-1100855910. Unfortunately, no native Wayland support is a deal breaker. :( This is not a criticism, I just wanted to let you know that this feature is really wanted.

hnorkowski commented 1 year ago

Any updates on this?

jokeyrhyme commented 1 year ago

I was hoping the new release of cairo would unblock us in an obvious way, but it doesn't look like it:

That said, I'm not familiar enough with cairo to really know either way

It does look like GTK itself wants to stop using cairo, which rules out a previous idea I had about us adopting GTK here as a path to getting a wayland-compatible cairo setup: https://blog.gtk.org/2023/09/19/paths-in-gtk/

TornaxO7 commented 11 months ago

hm.. would it be worth to maybe switch to another gui-framework like iced?

Toqozz commented 11 months ago

I think if we want to use wayland we should just bite the bullet and render to a surface in memory, then blit the result to whatever context wayland/x11 gives us. It's an extra copy, but it's probably worth it. I'm also unsure if transparency will work properly.

Worth mentioning that there may be a way to draw to the wayland context directly like how we do now with xlib, if we wrote some bindings or something, but I'm not familiar enough with how things plug together here to make it work (if it can).