wmww / gtk-layer-shell

A library to create panels and other desktop components for Wayland using the Layer Shell protocol
GNU General Public License v3.0
324 stars 16 forks source link

layer shell window not shown with this example #181

Closed dgod closed 2 months ago

dgod commented 6 months ago

Fedora 40 wlroots 0.17.3 labwc 0.7.2 gtk-layer-shell 0.8.2

#include <gtk/gtk.h>
#include <gtk-layer-shell.h>

int main(int argc,char **argv)
{
    gtk_init(&argc,&argv);
    GtkWindow *w = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_layer_init_for_window(w);
    gtk_layer_set_layer (w, GTK_LAYER_SHELL_LAYER_TOP);
    gtk_layer_set_anchor(w,GTK_LAYER_SHELL_EDGE_LEFT,TRUE);
    gtk_layer_set_anchor(w,GTK_LAYER_SHELL_EDGE_RIGHT,FALSE);
    gtk_layer_set_anchor(w,GTK_LAYER_SHELL_EDGE_TOP,TRUE);
    gtk_layer_set_anchor(w,GTK_LAYER_SHELL_EDGE_BOTTOM,FALSE);

    gtk_window_resize(w,400,400);
    gtk_widget_show_all(GTK_WIDGET(w));
    gtk_main();
    return 0;
}
wmww commented 2 months ago

If the window doesn't have any content (and so is naturally 0-sized) you need to call gtk_widget_set_size_request(), as per the docs.