Skip to content

Commit

Permalink
testoverlay: Add new input stacking test
Browse files Browse the repository at this point in the history
In this case we have a bunch of interactive main children
of the overlay, and then a centered overlay that contains both
non-interactive (labels) and interactive (entry) widgets.

This shows off a problem where the non-interactive parts (the labels)
steals input from the overlay main children (breaks button click and
hover effects).

https://bugzilla.gnome.org/show_bug.cgi?id=750568

https://bugs.freedesktop.org/show_bug.cgi?id=90917
  • Loading branch information
alexlarsson committed Jun 15, 2015
1 parent 3271eb2 commit ccc4b19
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/testoverlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,55 @@ G_GNUC_END_IGNORE_DEPRECATIONS
return win;
}

static GtkWidget *
test_input_stacking (void)
{
GtkWidget *win;
GtkWidget *overlay;
GtkWidget *label, *entry;
GtkWidget *grid;
GtkWidget *button;
GtkWidget *vbox;
int i,j;

win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (win), "Input Stacking");

overlay = gtk_overlay_new ();
grid = gtk_grid_new ();
gtk_container_add (GTK_CONTAINER (overlay), grid);

for (j = 0; j < 5; j++)
{
for (i = 0; i < 5; i++)
{
button = gtk_button_new_with_label (" ");
gtk_widget_set_hexpand (button, TRUE);
gtk_widget_set_vexpand (button, TRUE);
gtk_grid_attach (GTK_GRID (grid), button, i, j, 1, 1);
}
}

vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), vbox);
gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER);
gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER);

label = gtk_label_new ("This is some overlaid text\n"
"It does not get input\n"
"But the entry does");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 8);

entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 8);


gtk_container_add (GTK_CONTAINER (win), overlay);

return win;
}


int
main (int argc, char *argv[])
{
Expand All @@ -420,6 +469,7 @@ main (int argc, char *argv[])
GtkWidget *win5;
GtkWidget *win6;
GtkWidget *win7;
GtkWidget *win8;

gtk_init (&argc, &argv);

Expand Down Expand Up @@ -447,6 +497,9 @@ main (int argc, char *argv[])
win7 = test_stacking ();
gtk_widget_show_all (win7);

win8 = test_input_stacking ();
gtk_widget_show_all (win8);

gtk_main ();

return 0;
Expand Down

0 comments on commit ccc4b19

Please sign in to comment.