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
319 stars 16 forks source link

gtk_layer_set_keyboard_mode function does nothing #172

Closed hikamaree closed 8 months ago

hikamaree commented 8 months ago

I'm trying to make an audio visualizer for games that will show me the direction the sound is coming from. The layer on which it is drawn should be above all windows and should ignore any input. By default, layer passing trought only input from the keyboard, but not from the mouse. I tried setting the keyboard mode to NONE, but it still behaved the same. Later I tried setting every possible keyboard mode, but each one behaved the same.

Here is part of the code from my program that initializes the layer:

    GtkWidget* win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_set_app_paintable(win, TRUE);
    g_signal_connect(G_OBJECT(win), "draw", G_CALLBACK(draw_visualizer), data);

    gtk_layer_init_for_window(GTK_WINDOW(win));
    //gtk_layer_set_keyboard_interactivity (GTK_WINDOW(win), TRUE);
    gtk_layer_set_keyboard_mode(GTK_WINDOW(win), GTK_LAYER_SHELL_KEYBOARD_MODE_NONE);
    gtk_layer_set_layer(GTK_WINDOW(win), GTK_LAYER_SHELL_LAYER_OVERLAY);

    const gboolean anchors[] = {TRUE, TRUE, TRUE, TRUE};
    for (int i = 0; i < GTK_LAYER_SHELL_EDGE_ENTRY_NUMBER; i++) {
        gtk_layer_set_anchor(GTK_WINDOW(win), i, anchors[i]);
    }

    gtk_widget_show_all(win);

I'm using Hyprland window manager and I'm not sure if that's the problem, but I haven't been able to find any settings that prevent mouse input

wmww commented 8 months ago

Seems to be a Hyprland bug. the demo app works correctly in Sway but on Hyprland keyboard input is not ignored as it should be. Report to Hyprland, and feel free to reopen/request me to reopen if it turns out this library is the problem somehow.

hikamaree commented 8 months ago

I tried the demo app and my program in sway and hyprland and both behave the same everywhere, so I think we misunderstood each other.

My layer is drawn over the entire screen above all windows, and the windows below the layer normally receive input from the keyboard, but not from the mouse. Is there any function that would allow the windows below to receive mouse input.

Consolatis commented 8 months ago

audio visualizer for games that will show me the direction the sound is coming from

Although I would prefer not to help game cheat devs I'll consider your project as leveling the playing field for hearing impaired people unless I know better. All wl_surfaces have an input region that can be set to allow clicks going through the surface.

As for how that is mapped / available in GTK I have no clue.

hikamaree commented 8 months ago

Thanks a lot, I fixed it. All I had to do was connect the widget input region to the empty region.

I'm not a game cheat dev 😃, I'm making a program with a friend who can only hear in one ear