relm icon indicating copy to clipboard operation
relm copied to clipboard

Trying to use relm with gtk-layer-shell-rs

Open catpreneur opened this issue 4 years ago • 7 comments

Trying to build a an application using https://github.com/subgraph/gtk-layer-shell-rs

If you're not familiar with, it's basically a library to allow GTK to use a Wayland protocol known as layer shell protocol, which will allow windows to be anchored to corners of the screen.

The code for the app is simple: https://gist.github.com/oofdog/4625c3dad79736a638209c8f31e266f2 However, I'm getting these errors when the app boots image and the app does not render correctly (i'm expecting to see margins of 10px from all sides from these lines) image

Did some digging and found here that after init_view, relm will clone the app? Could this be the cause of the problems? Btw this is what the gtk-layer-shell init function does

catpreneur avatar Dec 21 '20 00:12 catpreneur

Btw here's a code example for gtk-layer-shell-rs https://github.com/subgraph/gtk-layer-shell-rs/blob/master/examples/example.rs

catpreneur avatar Dec 21 '20 02:12 catpreneur

And as a reference, this is what it should look like. Notice I'm setting sway background to light blue, and the empty GTK box has 10 margin all around image

catpreneur avatar Dec 21 '20 05:12 catpreneur

I'm not sure, but my guess is that it doesn't work because the window is already shown (by the view macro) when init_layer_shell() is called. You'll probably have to not use the #[widget] attribute.

Now that I think of it, maybe it would be useful to have an attribute to specify to not show the widget immediately in the view! macro. What do you think?

antoyo avatar Dec 21 '20 13:12 antoyo

Now that I think of it, maybe it would be useful to have an attribute to specify to not show the widget immediately in the view! macro. What do you think?

If that would solve this issue then sure. it would be nice to have a hook called before_view (just like init_view) but it is called before it is shown, so I can call init_layer_shell(). It shouldn't be too much code right? If you could provide a small snippet, I can try it out locally and let you know if it worked.

Also, is there a IRC channel or discord to chat about relm?

catpreneur avatar Dec 21 '20 20:12 catpreneur

I'm not sure about the before_view() idea. As I understand, you would need the widgets in that method, right? But the widgets are currently created in the view! macro (view() function under the hood). If we were to have a useful before_view(), that would probably require separating the widget creation from widget show, thus adding two methods: before_show() and show(). I think that would work but it's more involved than what you suggest.

There's a gitter to chat about relm and I'm often on #rust on irc.gnome.org.

antoyo avatar Dec 21 '20 20:12 antoyo

Hi, has this been implemented ?

LucaCoduriV avatar Aug 14 '24 18:08 LucaCoduriV

There was no progress made on this issue.

antoyo avatar Aug 14 '24 18:08 antoyo