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

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

Open
doggge77 opened this issue Dec 21, 2020 · 5 comments
Open

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

doggge77 opened this issue Dec 21, 2020 · 5 comments

Comments

@doggge77
Copy link

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

@doggge77
Copy link
Author

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

@doggge77
Copy link
Author

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

@antoyo
Copy link
Owner

antoyo commented Dec 21, 2020

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?

@doggge77
Copy link
Author

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?

@antoyo
Copy link
Owner

antoyo commented Dec 21, 2020

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.

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

No branches or pull requests

2 participants