widget: Don't assume opacity is 100%
... just because there is no style context instantiated yet. Instead, instantiate a style context during realize() and ask it. Fixes problems with dim labels not being dimmed on first show. Testcase included. https://bugzilla.gnome.org/show_bug.cgi?id=735240
This commit is contained in:
parent
95959ef470
commit
9a8a4a8b14
@ -5527,9 +5527,7 @@ gtk_widget_realize (GtkWidget *widget)
|
|||||||
_gtk_widget_enable_device_events (widget);
|
_gtk_widget_enable_device_events (widget);
|
||||||
gtk_widget_update_devices_mask (widget, TRUE);
|
gtk_widget_update_devices_mask (widget, TRUE);
|
||||||
|
|
||||||
if (gtk_widget_is_toplevel (widget))
|
gtk_widget_update_alpha (widget);
|
||||||
gdk_window_set_opacity (priv->window,
|
|
||||||
priv->alpha / 255.0);
|
|
||||||
|
|
||||||
if (priv->context)
|
if (priv->context)
|
||||||
gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
|
gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
|
||||||
@ -15913,6 +15911,7 @@ static void
|
|||||||
gtk_widget_update_alpha (GtkWidget *widget)
|
gtk_widget_update_alpha (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
GtkWidgetPrivate *priv;
|
GtkWidgetPrivate *priv;
|
||||||
|
GtkStyleContext *context;
|
||||||
gdouble opacity;
|
gdouble opacity;
|
||||||
guint8 alpha;
|
guint8 alpha;
|
||||||
|
|
||||||
@ -15920,15 +15919,13 @@ gtk_widget_update_alpha (GtkWidget *widget)
|
|||||||
|
|
||||||
alpha = priv->user_alpha;
|
alpha = priv->user_alpha;
|
||||||
|
|
||||||
if (priv->context)
|
context = gtk_widget_get_style_context (widget);
|
||||||
{
|
|
||||||
opacity =
|
opacity =
|
||||||
_gtk_css_number_value_get (_gtk_style_context_peek_property (priv->context,
|
_gtk_css_number_value_get (_gtk_style_context_peek_property (context,
|
||||||
GTK_CSS_PROPERTY_OPACITY),
|
GTK_CSS_PROPERTY_OPACITY),
|
||||||
100);
|
100);
|
||||||
opacity = CLAMP (opacity, 0.0, 1.0);
|
opacity = CLAMP (opacity, 0.0, 1.0);
|
||||||
alpha = round (priv->user_alpha * opacity);
|
alpha = round (priv->user_alpha * opacity);
|
||||||
}
|
|
||||||
|
|
||||||
if (alpha == priv->alpha)
|
if (alpha == priv->alpha)
|
||||||
return;
|
return;
|
||||||
|
@ -314,6 +314,9 @@ testdata = \
|
|||||||
opacity.css \
|
opacity.css \
|
||||||
opacity.ui \
|
opacity.ui \
|
||||||
opacity.ref.ui \
|
opacity.ref.ui \
|
||||||
|
opacity-initial.css \
|
||||||
|
opacity-initial.ref.ui \
|
||||||
|
opacity-initial.ui \
|
||||||
overlay-no-main-widget.ref.ui \
|
overlay-no-main-widget.ref.ui \
|
||||||
overlay-no-main-widget.ui \
|
overlay-no-main-widget.ui \
|
||||||
paned-undersized.css \
|
paned-undersized.css \
|
||||||
|
3
testsuite/reftests/opacity-initial.css
Normal file
3
testsuite/reftests/opacity-initial.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
GtkLabel {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
11
testsuite/reftests/opacity-initial.ref.ui
Normal file
11
testsuite/reftests/opacity-initial.ref.ui
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.18.1 -->
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk+" version="3.12"/>
|
||||||
|
<object class="GtkWindow" id="window1">
|
||||||
|
<property name="width_request">200</property>
|
||||||
|
<property name="height_request">100</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="type">popup</property>
|
||||||
|
</object>
|
||||||
|
</interface>
|
29
testsuite/reftests/opacity-initial.ui
Normal file
29
testsuite/reftests/opacity-initial.ui
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.18.1 -->
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk+" version="3.12"/>
|
||||||
|
<object class="GtkWindow" id="window1">
|
||||||
|
<property name="width_request">200</property>
|
||||||
|
<property name="height_request">100</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="type">popup</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkOverlay" id="overlay1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child type="overlay">
|
||||||
|
<object class="GtkLabel" id="label1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">I'm the invisible label.
|
||||||
|
Incredible how you can
|
||||||
|
see right through me.</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
Loading…
Reference in New Issue
Block a user