Expander: Don’t set event_window over whole widget
authorDaniel Boles <dboles@src.gnome.org>
Tue, 29 Aug 2017 10:24:19 +0000 (11:24 +0100)
committerDaniel Boles <dboles@src.gnome.org>
Tue, 29 Aug 2017 17:47:33 +0000 (18:47 +0100)
realize() gave the event_window the allocation of the whole widget. This
was wrong; it should be that of the title_gadget, as in size_allocate().

This broke expanders in which :expanded is TRUE before showing: Input
over the entire widget was sent to the title, making the child unable to
receive it. Clicking the child unexpectedly collapsed it. Once expanded
again, things fixed themselves as size_allocate() fixed the event_window
alloc. So, queuing a reallocate or resize after show() was a workaround.

Fix by giving event_window the allocation of the title_gadget, to match
what size_allocate() does. That is symmetrical and just plain correct.

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

gtk/gtkexpander.c

index 89f7582bdc542b25e8ea5003fd9dba6364bb8acd..609899d84cd6a5c9fa4838210dcec91e45054cf3 100644 (file)
@@ -602,7 +602,7 @@ gtk_expander_destroy (GtkWidget *widget)
 static void
 gtk_expander_realize (GtkWidget *widget)
 {
-  GtkAllocation allocation;
+  GtkAllocation title_allocation;
   GtkExpanderPrivate *priv;
   GdkWindow *window;
   GdkWindowAttr attributes;
@@ -610,13 +610,13 @@ gtk_expander_realize (GtkWidget *widget)
 
   priv = GTK_EXPANDER (widget)->priv;
 
-  gtk_widget_get_allocation (widget, &allocation);
+  gtk_css_gadget_get_border_allocation (priv->title_gadget, &title_allocation, NULL);
 
   attributes.window_type = GDK_WINDOW_CHILD;
-  attributes.x = allocation.x;
-  attributes.y = allocation.y;
-  attributes.width = allocation.width;
-  attributes.height = allocation.height;
+  attributes.x = title_allocation.x;
+  attributes.y = title_allocation.y;
+  attributes.width = title_allocation.width;
+  attributes.height = title_allocation.height;
   attributes.wclass = GDK_INPUT_ONLY;
   attributes.event_mask = gtk_widget_get_events (widget)
                           | GDK_BUTTON_PRESS_MASK