wmww / gtk4-layer-shell

A library to create panels and other desktop components for Wayland using the Layer Shell protocol and GTK4
MIT License
128 stars 4 forks source link

Clicking a markup link within a layer-shell window results in crash with wayland protocol error #38

Open pdf opened 2 months ago

pdf commented 2 months ago

Clicking a markup link withing a layer-shell window results in the following error and crash:

[3340928.178]  -> zxdg_exporter_v2@20.export_toplevel(new id zxdg_exported_v2@51, wl_surface@39)
[3340928.237] wl_display@1.error(zxdg_exporter_v2@20, 0, "surface must be an xdg_toplevel")
Gdk-Message: 00:14:48.507: Error 71 (Protocol error) dispatching to Wayland display.

The same application works fine without layer-shell, and correctly pops the clicked link via xdg-open.

Minimal example without layer-shell (WAYLAND_DEBUG log):

https://gist.github.com/pdf/73c0bfc6034adb3bc3ae862208888574#file-gtkanchor-c

#include <gtk/gtk.h>

static void
activate (GtkApplication *app,
          gpointer        user_data)
{
  GtkWidget *window;
  GtkWidget *label;

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Hello");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

  label = gtk_label_new (NULL);
  gtk_label_set_markup(GTK_LABEL (label), "<a href=\"https://github.com/wmww/gtk4-layer-shell\">gtk4-layer-shell</a>");
  gtk_window_set_child (GTK_WINDOW (window), label);

  gtk_window_present (GTK_WINDOW (window));
}

int
main (int    argc,
      char **argv)
{
  GtkApplication *app;
  int status;

  app = gtk_application_new ("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
  status = g_application_run (G_APPLICATION (app), argc, argv);
  g_object_unref (app);

  return status;
}

Minimal example with layer-shell (WAYLAND_DEBUG log):

https://gist.github.com/pdf/73c0bfc6034adb3bc3ae862208888574#file-gtkanchorshell-c

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

static void
activate (GtkApplication *app,
          gpointer        user_data)
{
  GtkWidget *window;
  GtkWidget *label;

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Hello");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

  label = gtk_label_new (NULL);
  gtk_label_set_markup(GTK_LABEL (label), "<a href=\"https://github.com/wmww/gtk4-layer-shell\">gtk4-layer-shell</a>");
  gtk_window_set_child (GTK_WINDOW (window), label);

  gtk_layer_init_for_window(GTK_WINDOW (window));

  gtk_window_present (GTK_WINDOW (window));
}

int
main (int    argc,
      char **argv)
{
  GtkApplication *app;
  int status;

  app = gtk_application_new ("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
  status = g_application_run (G_APPLICATION (app), argc, argv);
  g_object_unref (app);

  return status;
}

I'm not entirely certain where the fault lies - it's certainly possible that this is a GTK/GDK or compositor problem that is just exercised by gtk4-layer-shell.