gtk4-layer-shell icon indicating copy to clipboard operation
gtk4-layer-shell copied to clipboard

Keyboard focus does not work when using zink

Open LaserEyess opened this issue 2 years ago • 3 comments

I'm running into a strange issue that I can't really figure out how to debug. Admittedly, this is probably (by definition) a zink bug, but I'm not sure where to begin debugging it. I'm also going to report this to mesa.

Using this code:

Minimal reproducible code
#include <gtk/gtk.h>
#include "gtk4-layer-shell.h"

// modified from gtk4-layer-shell/examples/simple-example.c
static void
activate (GtkApplication* app, void *_data)
{
    (void)_data;

    // Create a normal GTK window however you like
    GtkWindow *gtk_window = GTK_WINDOW (gtk_application_window_new (app));

    // Before the window is first realized, set it up to be a layer surface
    gtk_layer_init_for_window (gtk_window);
    gtk_layer_set_layer (gtk_window, GTK_LAYER_SHELL_LAYER_TOP);
    gtk_layer_set_keyboard_mode (gtk_window, GTK_LAYER_SHELL_KEYBOARD_MODE_ON_DEMAND); // NONE is default

    // Set up a widget
    GtkWidget *entry = gtk_entry_new();
    gtk_window_set_child (gtk_window, entry);
    gtk_window_present (gtk_window);
    gtk_window_set_default_size(gtk_window, 200, 200);
}

int
main (int argc, char **argv)
{
    GtkApplication * app = gtk_application_new ("com.github.wmww.gtk4-layer-shell.example", G_APPLICATION_DEFAULT_FLAGS);
    const char* accels[] = {"Escape", NULL};
    gtk_application_set_accels_for_action(app, "window.close", accels);
    g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
    int status = g_application_run (G_APPLICATION (app), argc, argv);
    g_object_unref (app);
    return status;
}

and MESA_LOADER_DRIVER_OVERRIDE=zink, keyboard focus does not work properly. With either MODE_ON_DEMAND or MODE_EXCLUSIVE. I tested this on sway master as of today. My normal driver is radeonsi.

Some logs:

  • WAYLAND_DEBUG=1 MESA_LOADER_DRIVER_OVERRIDE=zink ./reproduce: https://0x0.st/HtSw.log
  • WAYLAND_DEBUG=1 ./reproduce: https://0x0.st/HtSx.log

LaserEyess avatar Nov 05 '23 22:11 LaserEyess

Mesa issue: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10102

LaserEyess avatar Nov 05 '23 22:11 LaserEyess

If you were using a released version of this library it had a nasty use-after-free bug that could have been causing lots of weird problems (see https://github.com/wmww/gtk4-layer-shell/pull/27 for details). I've just released v1.0.2 which includes a fix. Please re-open if this crash persists on v1.0.2, thanks.

wmww avatar Nov 07 '23 08:11 wmww

I tested this on 14b5bf95734b9fb33270e5ef55c127ef519089ac, but even at git master it didn't work.

@wmww I can't reopen the issue but it very much still is an issue

LaserEyess avatar Nov 08 '23 01:11 LaserEyess