waycrate / exwlshelleventloop

winit like binding for layershell and sessionlock
MIT License
47 stars 10 forks source link

Listen Wayland events #82

Open MalpenZibo opened 3 weeks ago

MalpenZibo commented 3 weeks ago

It would be possibile to receive Wayland events? Like for example when a new wl_output appears? Currently the pop_os iced fork has these kind of event but maybe without forking iced it's impossible to obtain the same results.

My use case would be to create a new surface when a new monitor is attached

Decodetalkers commented 3 weeks ago

Emm. in layershellev, I will mark the manually created window..

If you want to follow the new screen, I think you can use StartMode::AllScreens, then a new layershell surface will becreated..

But iced_layershell does not support to pass wl_output to create surface.. so maybe it will be useless?

But if you want to listen to the event, maybe we need to make a pr to origin iced to let it allow use to add custom events to the iced::event

by the way, I have seen your pr in ashell, you set the startMode to active, that means the main layershells will only created on the activated screen, but if you set to AllScreens, the new layershell will be created follow the outputs

https://github.com/waycrate/lala-bar/blob/master/lala_bar/src/main.rs#L75

MalpenZibo commented 3 weeks ago

Sadly I think the same, we have to request a change to iced.

I will try to avoid the necessity to get this information but for example in some situation I need to destroy the surface on the main monitor when an external one is connected and recreate the surface there

Decodetalkers commented 3 weeks ago

Sadly I think the same, we have to request a change to iced.

I will try to avoid the necessity to get this information but for example in some situation I need to destroy the surface on the main monitor when an external one is connected and recreate the surface there

but the main layershell is not designed to be breaked.. Emm, and in iced, the renderer is binding to the first connected wl_surface, if it is brokened, it will panic

Decodetalkers commented 2 weeks ago

I have an idea, I will create a new crate to listen to these events and pass to iced

Decodetalkers commented 2 weeks ago

I add a new crate, and add a new feature, can you take a try? I think this will solve your problem

MalpenZibo commented 2 weeks ago

I tried, but if I understand correctly, I should subscribe to the wayland event using the subscribe method in my application's subscription method. But the subscribe method is async, and the subscription method cannot be declared async because the MultiApplication trait doesn't declare that method async.

Decodetalkers commented 2 weeks ago

I tried, but if I understand correctly, I should subscribe to the wayland event using the subscribe method in my application's subscription method. But the subscribe method is async, and the subscription method cannot be declared async because the MultiApplication trait doesn't declare that method async.

A, sorry, that is a mistake, I will fix it

Decodetalkers commented 2 weeks ago

Ok. I have fix it, you can try it again.

Now you can use the repo of that branch, and may you please take a try with the iced_layershell and that new crate of that branch?

MalpenZibo commented 2 weeks ago

Ok, I tried. I added a subscription and I tried to log the event but nothing happens if I attach/detach an external monitor

image image

Decodetalkers commented 2 weeks ago

I don't know what is happened... I try to send the message in subscription(now I have changed it to listen), but after it successfully send the message, I cannot receive it . Can you help me resolve this problem?

MalpenZibo commented 2 weeks ago

The problem is related to the subscription::channel loop being constantly busy. You can spot the problem by the fact that the CPU constantly runs. Everything works if you add a sleep(3000).await after the for event in current_events {. I think that the problem is that the poll_connection.await; in my case is resolved instantly every time.

Decodetalkers commented 2 weeks ago

ok, seems solved, thank you

MalpenZibo commented 2 weeks ago

I see the changes, in this way every 10 ms we make a check, it would be nice to have the poll_connection work as intended. Anyway if it's impossible this change should resolve the issue!

Decodetalkers commented 1 week ago

I have met some problems... I write an example to use the wloutput from the subscriber, but then it panic at the process of getting layer surface, can you help take a look?

Decodetalkers commented 1 week ago

seems usable.. can you take a look?

MalpenZibo commented 1 week ago

In the next few days I will be quite busy, I will try as soon as I can

MalpenZibo commented 1 week ago

I tried to open a layer (using LayerOutputSetting::ChosenOutput(event) where event is what I receive in the iced_wayland_subscriber::WaylandEvents::OutputInsert) when a monitor is attached but the app crashed with this error

wl_display#1: error 1: invalid arguments for zwlr_layer_shell_v1#427.get_layer_surface
Io error: Invalid argument (os error 22)
Error trying to flush the wayland display: Invalid argument (os error 22)
Io error: Invalid argument (os error 22)
ERROR [ashell] Panic: panicked at /home/zibo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/blocking/shutdown.rs:51:21:
Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.
 disabled backtrace
Decodetalkers commented 1 week ago

I tried to open a layer (using LayerOutputSetting::ChosenOutput(event) where event is what I receive in the iced_wayland_subscriber::WaylandEvents::OutputInsert) when a monitor is attached but the app crashed with this error

wl_display#1: error 1: invalid arguments for zwlr_layer_shell_v1#427.get_layer_surface
Io error: Invalid argument (os error 22)
Error trying to flush the wayland display: Invalid argument (os error 22)
Io error: Invalid argument (os error 22)
ERROR [ashell] Panic: panicked at /home/zibo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/blocking/shutdown.rs:51:21:
Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.
 disabled backtrace

Update to the latest, I have made some changes. I have already noticed this issue, so now I have fixed it. Seems the wl_output by another eventloop cannot be used, so instead I pass the name of xdg_output

MalpenZibo commented 5 days ago

I tried the example. Now doesn't crash but on my laptop when I connect an external monitor I get the event but the topbar is rendered on the main screen two time and not on the external one.

Decodetalkers commented 5 days ago

I tried the example. Now doesn't crash but on my laptop when I connect an external monitor I get the event but the topbar is rendered on the main screen two time and not on the external one.

Now I do not have external monitor, sorry, if you can help me fix it , I will be glad