GNOME Bugzilla – Bug 715163
Toolbar style "border-width" is always zero after gtk_widget_realize
Last modified: 2013-11-26 21:12:15 UTC
From https://bugzilla.gnome.org/show_bug.cgi?id=690236 Calling gtk_widget_realize to get the window allocation size, is resulting in a size allocated as if the toolbar style property "border-width" is always zero. Tested with a custom gtk.css, only toolbar property appears to be affected. * { border-width: 5px; border-color: blue; } GtkToolbar { border-width: 5px; border-top-width: 11px; } The style is correct with: 1. After calling gtk_widget_show (window); 2. Calling gtk_style_context_invalidate(gtk_widget_get_style_context (toolbar)); before gtk_widget_realize. 3. Patching gtk/gtkwidget.c:gtk_widget_realize to include GtkBitmask *empty; empty = _gtk_bitmask_new (); _gtk_style_context_validate (gtk_widget_get_style_context (widget), g_get_monotonic_time (), 0, empty); _gtk_bitmask_free (empty);
Created attachment 261439 [details] Testcase for toolbar's border-width. A simples test case that shows this problem.
I think you fail to set "border-style: solid;" in your CSS so the border-style is none and then the CSS spec from http://www.w3.org/TR/CSS2/box.html#border-width-properties kicks in and that one says: > Computed value: absolute length; '0' if the border style is 'none' or 'hidden' So I guess this is NOTABUG ? (And yes, sorry for CSS being so confusing sometimes that it resets your border width).
Yes i confirm, just checked awhile ago by debugging. border-style is "none", and then by CSS specification is set to zero, as you said. But there is something strange going around, at the call of: gtk_widget_realize(top_level_window) border-style is "none" gtk_widget_show(top_level_window) border-style is "outset" _gtk_css_provider_load_named loads Raleigh as fall-back, i think this is were "outset" is comming from. Then why at gtk_widget_realize border-style is none? Raleigh is loaded well before that. I will look a this deeper to understand what is happening.
This happens because for performance reasons GTK does not refresh styles until they are needed for a repaint. In the size request, size allocate and draw functions the border should be correctly set.