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

Setting a layer-shell window as parent of a dialog breaks positioning of combo box lists #177

Open Tamaranch opened 8 months ago

Tamaranch commented 8 months ago

I've just noticed this with the preferences dialogs of some xfce4-panel plugins that contain combo boxes, and which for a long time on X11 have set the panel as dialog parent.

It's reproducible on Wayland, independent of the compositor as far as I can see, with this piece of code:

gint main (gint argc, gchar **argv)
{
  gtk_init (&argc, &argv);

  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_layer_init_for_window (GTK_WINDOW (window));
  gtk_layer_set_anchor (GTK_WINDOW (window), GTK_LAYER_SHELL_EDGE_BOTTOM, TRUE);
  gtk_widget_set_size_request (window, 200, 40);
  gtk_widget_show (window);

  GtkWidget *dialog = gtk_dialog_new_with_buttons ("dialog", GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, NULL, NULL);
  GtkWidget *area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
  GtkWidget *combo = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "text1");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "text2");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "text3");
  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
  gtk_container_add (GTK_CONTAINER (area), combo);
  gtk_widget_set_size_request (dialog, 200, -1);
  gtk_widget_show_all (dialog);

  GMainLoop *loop = g_main_loop_new (NULL, FALSE);
  g_signal_connect_swapped (dialog, "destroy", G_CALLBACK (g_main_loop_quit), loop);
  g_main_loop_run (loop);
  g_main_loop_unref (loop);
}

When the combo box is clicked, the list of entries is displayed in the layer-shell window instead of in the combo box.

I don't think there's much point, or sense, in setting the panel as parent of these dialogs (perhaps it was done at the time to avoid a GTK warning). So I could certainly modify the code of these plugins, but I'd like to know if it wouldn't be a bug in gtk-layer-shell before doing that.

gtk-layer-shell 0.8.2 gtk 3.24.41