#include <stdarg.h>
#include <string.h>
#include <locale.h>
+#include <math.h>
#include <gobject/gvaluecollector.h>
#include <gobject/gobjectnotifyqueue.c>
#include "gtkaccelmapprivate.h"
#include "gtkclipboard.h"
#include "gtkcssstylepropertyprivate.h"
+#include "gtkcssnumbervalueprivate.h"
#include "gtkiconfactory.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
* </accessibility>
* <child internal-child="accessible">
* <object class="AtkObject" id="a11y-button1">
- * <property name="AtkObject::name">Clickable Button</property>
+ * <property name="accessible-name">Clickable Button</property>
* </object>
* </child>
* </object>
* all flags will be set on children (think prelight or active), but we
* might want to not do this for some.
*/
-#define GTK_STATE_FLAGS_DONT_PROPAGATE (GTK_STATE_FLAG_FOCUSED)
+#define GTK_STATE_FLAGS_DONT_PROPAGATE (GTK_STATE_FLAG_FOCUSED | GTK_STATE_FLAG_DIR_LTR | GTK_STATE_FLAG_DIR_RTL)
#define GTK_STATE_FLAGS_DO_PROPAGATE (~GTK_STATE_FLAGS_DONT_PROPAGATE)
#define WIDGET_CLASS(w) GTK_WIDGET_GET_CLASS (w)
-#define GTK_STATE_FLAGS_BITS 7
+#define GTK_STATE_FLAGS_BITS 9
struct _GtkWidgetPrivate
{
/* SizeGroup related flags */
guint have_size_groups : 1;
+ guint norender_children : 1;
+ guint norender : 1; /* Don't expose windows, instead recurse via draw */
+
+ guint8 alpha;
+ guint8 user_alpha;
+
/* The widget's name. If the widget does not have a name
* (the name is NULL), then its name (as returned by
* "gtk_widget_get_name") is its class's name.
* GTK_NO_WINDOW flag being set).
*/
GdkWindow *window;
+ GList *registered_windows;
/* The widget's parent */
GtkWidget *parent;
PROP_TOOLTIP_MARKUP,
PROP_TOOLTIP_TEXT,
PROP_WINDOW,
+ PROP_OPACITY,
PROP_DOUBLE_BUFFERED,
PROP_HALIGN,
PROP_VALIGN,
typedef struct _GtkStateData GtkStateData;
-enum {
- STATE_CHANGE_REPLACE,
- STATE_CHANGE_SET,
- STATE_CHANGE_UNSET
-};
-
struct _GtkStateData
{
- guint flags : GTK_STATE_FLAGS_BITS;
- guint operation : 2;
+ guint flags_to_set;
+ guint flags_to_unset;
};
/* --- prototypes --- */
static void gtk_widget_update_pango_context (GtkWidget *widget);
static void gtk_widget_propagate_state (GtkWidget *widget,
GtkStateData *data);
-;
+static void gtk_widget_update_alpha (GtkWidget *widget);
+
static gint gtk_widget_event_internal (GtkWidget *widget,
GdkEvent *event);
static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget,
gboolean recurse,
gboolean enabled);
static gboolean event_window_is_still_viewable (GdkEvent *event);
+static void gtk_cairo_set_event (cairo_t *cr,
+ GdkEventExpose *event);
+static void gtk_widget_propagate_alpha (GtkWidget *widget);
/* --- variables --- */
static gpointer gtk_widget_parent_class = NULL;
gpointer invocation_hint,
gpointer marshal_data)
{
+ GtkWidget *widget = g_value_get_object (¶m_values[0]);
+ GdkEventExpose *tmp_event;
+ gboolean push_group;
cairo_t *cr = g_value_get_boxed (¶m_values[1]);
cairo_save (cr);
+ tmp_event = _gtk_cairo_get_event (cr);
+
+ push_group =
+ widget->priv->alpha != 255 &&
+ (!gtk_widget_get_has_window (widget) || tmp_event == NULL);
+
+ if (push_group)
+ {
+ cairo_push_group (cr);
+ gtk_cairo_set_event (cr, NULL);
+ }
_gtk_marshal_BOOLEAN__BOXED (closure,
return_value,
invocation_hint,
marshal_data);
+
+ if (push_group)
+ {
+ cairo_pop_group_to_source (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_paint_with_alpha (cr, widget->priv->alpha / 255.0);
+ }
+
+ gtk_cairo_set_event (cr, tmp_event);
cairo_restore (cr);
}
int n_params,
GType *param_types)
{
+ GtkWidget *widget = GTK_WIDGET (instance);
+ GdkEventExpose *tmp_event;
+ gboolean push_group;
cairo_t *cr;
va_list args_copy;
cr = va_arg (args_copy, gpointer);
cairo_save (cr);
+ tmp_event = _gtk_cairo_get_event (cr);
+
+ push_group =
+ widget->priv->alpha != 255 &&
+ (!gtk_widget_get_has_window (widget) || tmp_event == NULL);
+
+ if (push_group)
+ {
+ cairo_push_group (cr);
+ gtk_cairo_set_event (cr, NULL);
+ }
_gtk_marshal_BOOLEAN__BOXEDv (closure,
return_value,
n_params,
param_types);
+
+ if (push_group)
+ {
+ cairo_pop_group_to_source (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_paint_with_alpha (cr, widget->priv->alpha / 255.0);
+ }
+
+ gtk_cairo_set_event (cr, tmp_event);
cairo_restore (cr);
va_end (args_copy);
FALSE,
GTK_PARAM_READWRITE));
+ /**
+ * GtkWidget:opacity:
+ *
+ * The requested opacity of the widget. See gtk_widget_set_opacity() for
+ * more details about window opacity.
+ *
+ * Before 3.8 this was only availible in GtkWindow
+ *
+ * Since: 3.8
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_OPACITY,
+ g_param_spec_double ("opacity",
+ P_("Opacity for Widget"),
+ P_("The opacity of the widget, from 0 to 1"),
+ 0.0,
+ 1.0,
+ 1.0,
+ GTK_PARAM_READWRITE));
/**
* GtkWidget::show:
* @widget: the object which received the signal.
gtk_widget_set_vexpand (widget, g_value_get_boolean (value));
g_object_thaw_notify (G_OBJECT (widget));
break;
+ case PROP_OPACITY:
+ gtk_widget_set_opacity (widget, g_value_get_double (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
gtk_widget_get_hexpand (widget) &&
gtk_widget_get_vexpand (widget));
break;
+ case PROP_OPACITY:
+ g_value_set_double (value, gtk_widget_get_opacity (widget));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
priv->allocation.y = -1;
priv->allocation.width = 1;
priv->allocation.height = 1;
+ priv->user_alpha = 255;
+ priv->alpha = 255;
priv->window = NULL;
priv->parent = NULL;
priv->double_buffered = TRUE;
priv->redraw_on_alloc = TRUE;
priv->alloc_needed = TRUE;
+
+ switch (gtk_widget_get_direction (widget))
+ {
+ case GTK_TEXT_DIR_LTR:
+ priv->state_flags = GTK_STATE_FLAG_DIR_LTR;
+ break;
+
+ case GTK_TEXT_DIR_RTL:
+ priv->state_flags = GTK_STATE_FLAG_DIR_RTL;
+ break;
+
+ case GTK_TEXT_DIR_NONE:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
/* this will be set to TRUE if the widget gets a child or if the
* expand flag is set on the widget, but until one of those happen
g_object_notify_queue_clear (G_OBJECT (widget), nqueue);
g_object_notify_queue_thaw (G_OBJECT (widget), nqueue);
+ gtk_widget_propagate_alpha (widget);
+
gtk_widget_pop_verify_invariants (widget);
g_object_unref (widget);
}
g_return_if_fail (GTK_IS_WIDGET (widget));
+ if (!priv->visible && !gtk_widget_is_toplevel (widget))
+ return;
+
gtk_widget_push_verify_invariants (widget);
#ifdef G_ENABLE_DEBUG
GtkWidgetPrivate *priv = widget->priv;
gtk_widget_update_pango_context (widget);
+ gtk_widget_update_alpha (widget);
if (priv->style != NULL &&
priv->style != gtk_widget_get_default_style ())
}
static void
-_gtk_widget_update_state_flags (GtkWidget *widget,
- GtkStateFlags flags,
- guint operation)
+gtk_widget_update_state_flags (GtkWidget *widget,
+ GtkStateFlags flags_to_set,
+ GtkStateFlags flags_to_unset)
{
GtkWidgetPrivate *priv;
/* Handle insensitive first, since it is propagated
* differently throughout the widget hierarchy.
*/
- if ((priv->state_flags & GTK_STATE_FLAG_INSENSITIVE) && (flags & GTK_STATE_FLAG_INSENSITIVE) && (operation == STATE_CHANGE_UNSET))
+ if ((priv->state_flags & GTK_STATE_FLAG_INSENSITIVE) && (flags_to_unset & GTK_STATE_FLAG_INSENSITIVE))
gtk_widget_set_sensitive (widget, TRUE);
- else if (!(priv->state_flags & GTK_STATE_FLAG_INSENSITIVE) && (flags & GTK_STATE_FLAG_INSENSITIVE) && (operation != STATE_CHANGE_UNSET))
+ else if (!(priv->state_flags & GTK_STATE_FLAG_INSENSITIVE) && (flags_to_set & GTK_STATE_FLAG_INSENSITIVE))
gtk_widget_set_sensitive (widget, FALSE);
- else if ((priv->state_flags & GTK_STATE_FLAG_INSENSITIVE) && !(flags & GTK_STATE_FLAG_INSENSITIVE) && (operation == STATE_CHANGE_REPLACE))
- gtk_widget_set_sensitive (widget, TRUE);
- if (operation != STATE_CHANGE_REPLACE)
- flags &= ~(GTK_STATE_FLAG_INSENSITIVE);
+ flags_to_set &= ~(GTK_STATE_FLAG_INSENSITIVE);
+ flags_to_unset &= ~(GTK_STATE_FLAG_INSENSITIVE);
- if (flags != 0 ||
- operation == STATE_CHANGE_REPLACE)
+ if (flags_to_set != 0 || flags_to_unset != 0)
{
GtkStateData data;
- data.flags = flags;
- data.operation = operation;
+ data.flags_to_set = flags_to_set;
+ data.flags_to_unset = flags_to_unset;
gtk_widget_propagate_state (widget, &data);
}
return;
if (clear)
- _gtk_widget_update_state_flags (widget, flags, STATE_CHANGE_REPLACE);
+ gtk_widget_update_state_flags (widget, flags, ~(flags ^ (GTK_STATE_FLAG_DIR_LTR | GTK_STATE_FLAG_DIR_RTL)));
else
- _gtk_widget_update_state_flags (widget, flags, STATE_CHANGE_SET);
+ gtk_widget_update_state_flags (widget, flags, 0);
}
/**
if ((widget->priv->state_flags & flags) == 0)
return;
- _gtk_widget_update_state_flags (widget, flags, STATE_CHANGE_UNSET);
+ gtk_widget_update_state_flags (widget, 0, flags);
}
/**
break;
}
- _gtk_widget_update_state_flags (widget, flags, STATE_CHANGE_REPLACE);
+ gtk_widget_update_state_flags (widget,
+ flags,
+ (GTK_STATE_FLAG_ACTIVE | GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED
+ | GTK_STATE_FLAG_INSENSITIVE | GTK_STATE_FLAG_INCONSISTENT | GTK_STATE_FLAG_FOCUSED) ^ flags);
}
/**
_gtk_widget_set_visible_flag (GtkWidget *widget,
gboolean visible)
{
- widget->priv->visible = visible;
+ GtkWidgetPrivate *priv = widget->priv;
+
+ priv->visible = visible;
+
+ if (!visible)
+ {
+ priv->allocation.x = -1;
+ priv->allocation.y = -1;
+ priv->allocation.width = 1;
+ priv->allocation.height = 1;
+ }
}
/**
{
GtkStateData data;
- data.flags = GTK_STATE_FLAG_INSENSITIVE;
-
if (sensitive)
- data.operation = STATE_CHANGE_UNSET;
+ {
+ data.flags_to_set = 0;
+ data.flags_to_unset = GTK_STATE_FLAG_INSENSITIVE;
+ }
else
- data.operation = STATE_CHANGE_SET;
+ {
+ data.flags_to_set = GTK_STATE_FLAG_INSENSITIVE;
+ data.flags_to_unset = 0;
+ }
gtk_widget_propagate_state (widget, &data);
/* Merge both old state and current parent state,
* making sure to only propagate the right states */
- data.flags = parent_flags & GTK_STATE_FLAGS_DO_PROPAGATE;
- data.flags |= priv->state_flags;
-
- data.operation = STATE_CHANGE_REPLACE;
+ data.flags_to_set = parent_flags & GTK_STATE_FLAGS_DO_PROPAGATE;
+ data.flags_to_unset = 0;
gtk_widget_propagate_state (widget, &data);
if (priv->context)
gtk_widget_queue_compute_expand (parent);
}
+ gtk_widget_propagate_alpha (widget);
+
gtk_widget_pop_verify_invariants (widget);
}
gtk_widget_emit_direction_changed (GtkWidget *widget,
GtkTextDirection old_dir)
{
+ GtkTextDirection direction;
+ GtkStateFlags state;
+
gtk_widget_update_pango_context (widget);
- if (widget->priv->context)
- gtk_style_context_set_direction (widget->priv->context,
- gtk_widget_get_direction (widget));
+ direction = gtk_widget_get_direction (widget);
+ state = widget->priv->state_flags;
+ state &= GTK_STATE_FLAG_DIR_LTR | GTK_STATE_FLAG_DIR_RTL;
+
+ switch (direction)
+ {
+ case GTK_TEXT_DIR_LTR:
+ state |= GTK_STATE_FLAG_DIR_LTR;
+ break;
+
+ case GTK_TEXT_DIR_RTL:
+ state |= GTK_STATE_FLAG_DIR_RTL;
+ break;
+
+ case GTK_TEXT_DIR_NONE:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ gtk_widget_set_state_flags (widget, state, TRUE);
g_signal_emit (widget, widget_signals[DIRECTION_CHANGED], 0, old_dir);
}
if (gtk_widget_get_has_window (widget))
{
- gdk_window_set_user_data (priv->window, NULL);
+ gtk_widget_unregister_window (widget, priv->window);
gdk_window_destroy (priv->window);
priv->window = NULL;
}
old_state = gtk_widget_get_state (widget);
- switch (data->operation)
- {
- case STATE_CHANGE_REPLACE:
- priv->state_flags = data->flags;
- break;
- case STATE_CHANGE_SET:
- priv->state_flags |= data->flags;
- break;
- case STATE_CHANGE_UNSET:
- priv->state_flags &= ~(data->flags);
- break;
- }
+ priv->state_flags |= data->flags_to_set;
+ priv->state_flags &= ~(data->flags_to_unset);
/* make insensitivity unoverridable */
if (!priv->sensitive)
if (GTK_IS_CONTAINER (widget))
{
- GtkStateData child_data = *data;
+ GtkStateData child_data;
/* Make sure to only propate the right states further */
- child_data.flags &= GTK_STATE_FLAGS_DO_PROPAGATE;
+ child_data.flags_to_set = data->flags_to_set & GTK_STATE_FLAGS_DO_PROPAGATE;
+ child_data.flags_to_unset = data->flags_to_unset & GTK_STATE_FLAGS_DO_PROPAGATE;
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback) gtk_widget_propagate_state,
/**
* gtk_widget_set_tooltip_text:
* @widget: a #GtkWidget
- * @text: the contents of the tooltip for @widget
+ * @text: (allow-none): the contents of the tooltip for @widget
*
* Sets @text as the contents of the tooltip. This function will take
* care of setting #GtkWidget:has-tooltip to %TRUE and of the default
GtkWidgetPrivate *priv;
g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (gtk_widget_get_visible (widget) || gtk_widget_is_toplevel (widget));
g_return_if_fail (allocation != NULL);
priv = widget->priv;
if (priv->window != window)
{
priv->window = window;
+
+ if (gtk_widget_get_has_window (widget) && window != NULL && !gdk_window_has_native (window))
+ gdk_window_set_opacity (window,
+ priv->norender ? 0 : priv->alpha / 255.0);
+
g_object_notify (G_OBJECT (widget), "window");
}
}
+/**
+ * gtk_widget_register_window:
+ * @widget: a #GtkWidget
+ * @window: a #GdkWindow
+ *
+ * Registers a #GdkWindow with the widget and sets it up so that
+ * the widget recieves events for it. Call gtk_widget_unregister_window()
+ * when destroying the window.
+ *
+ * Before 3.8 you needed to call gdk_window_set_user_data() directly to set
+ * this up. This is now deprecated and you should use gtk_widget_register_window()
+ * instead. Old code will keep working as is, although some new features like
+ * transparency might not work perfectly.
+ *
+ * Since: 3.8
+ */
+void
+gtk_widget_register_window (GtkWidget *widget,
+ GdkWindow *window)
+{
+ GtkWidgetPrivate *priv;
+ gpointer user_data;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ gdk_window_get_user_data (window, &user_data);
+ g_assert (user_data == NULL);
+
+ priv = widget->priv;
+
+ gdk_window_set_user_data (window, widget);
+ priv->registered_windows = g_list_prepend (priv->registered_windows, window);
+
+ if (!gtk_widget_get_has_window (widget) && !gdk_window_has_native (window))
+ gdk_window_set_opacity (window,
+ priv->norender_children ? 0.0 : 1.0);
+}
+
+/**
+ * gtk_widget_unregister_window:
+ * @widget: a #GtkWidget
+ * @window: a #GdkWindow
+ *
+ * Unregisters a #GdkWindow from the widget that was previously set up with
+ * gtk_widget_register_window(). You need to call this when the window is
+ * no longer used by the widget, such as when you destroy it.
+ *
+ * Since: 3.8
+ */
+void
+gtk_widget_unregister_window (GtkWidget *widget,
+ GdkWindow *window)
+{
+ GtkWidgetPrivate *priv;
+ gpointer user_data;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ priv = widget->priv;
+
+ gdk_window_get_user_data (window, &user_data);
+ g_assert (user_data == widget);
+ gdk_window_set_user_data (window, NULL);
+ priv->registered_windows = g_list_remove (priv->registered_windows, window);
+}
+
/**
* gtk_widget_get_window:
* @widget: a #GtkWidget
gdk_window_set_support_multidevice (priv->window, support_multidevice);
}
+/* There are multiple alpha related sources, the user can specify alpha
+ * in gtk_widget_set_opacity, secondly we can get it from the css opacity. These two
+ * are multiplied together to form the total alpha.
+ *
+ * We handle opacity in two ways. For a windowed widget, with opacity set but no opacity
+ * group we directly set the opacity of widget->window. This will cause gdk to properly
+ * redirect drawing inside the window to a buffer and do OVER paint_with_alpha.
+ *
+ * However, if the widget is not windowed,
+ * we do the opacity handling in the ::draw marshaller for the widget. A naive
+ * implementation of this would break for windowed widgets or descendant widgets with
+ * windows, as these would not be handled by the ::draw signal. To handle this we set
+ * all such gdkwindows as fully transparent and then override gtk_cairo_should_draw_window()
+ * to make the draw signal propagate to *all* child widgets/windows.
+ *
+ * Note: We don't make all child windows fully transparent, we stop at the first one
+ * in each branch when propagating down the hierarchy.
+ */
+
+
+/* This is called when priv->alpha changes, and should
+ * update priv->norender and GdkWindow opacity for this widget and any children that
+ * needs changing. It is also called whenver the parent changes, the parents
+ * norender_children state changes, or the has_window state of the widget changes.
+ */
+static void
+gtk_widget_propagate_alpha (GtkWidget *widget)
+{
+ GtkWidgetPrivate *priv = widget->priv;
+ GtkWidget *parent;
+ gboolean norender, norender_children;
+ GList *l;
+
+ parent = priv->parent;
+
+ norender =
+ /* If the parent has norender_children, propagate that here */
+ (parent != NULL && parent->priv->norender_children);
+
+ /* Windowed widget children should norender if: */
+ norender_children =
+ /* The widget is no_window (otherwise its enought to mark it norender/alpha), and */
+ !gtk_widget_get_has_window (widget) &&
+ ( /* norender is set, or */
+ norender ||
+ /* widget has an alpha */
+ priv->alpha != 255
+ );
+
+ if (gtk_widget_get_has_window (widget))
+ {
+ if (priv->window != NULL && !gdk_window_has_native (priv->window))
+ gdk_window_set_opacity (priv->window,
+ norender ? 0 : priv->alpha / 255.0);
+ }
+ else /* !has_window */
+ {
+ for (l = priv->registered_windows; l != NULL; l = l->next)
+ {
+ GdkWindow *w = l->data;
+ if (!gdk_window_has_native (w))
+ gdk_window_set_opacity (w, norender_children ? 0.0 : 1.0);
+ }
+ }
+
+ priv->norender = norender;
+ if (priv->norender_children != norender_children)
+ {
+ priv->norender_children = norender_children;
+
+ if (GTK_IS_CONTAINER (widget))
+ gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback)gtk_widget_propagate_alpha, NULL);
+ }
+
+ if (gtk_widget_get_realized (widget))
+ gtk_widget_queue_draw (widget);
+}
+
+static void
+gtk_widget_update_alpha (GtkWidget *widget)
+{
+ GtkWidgetPrivate *priv;
+ double opacity;
+ guint8 alpha;
+
+ priv = widget->priv;
+
+ alpha = priv->user_alpha;
+
+ if (priv->context)
+ {
+ opacity =
+ _gtk_css_number_value_get (_gtk_style_context_peek_property (priv->context,
+ GTK_CSS_PROPERTY_OPACITY),
+ 100);
+ opacity = CLAMP (opacity, 0.0, 1.0);
+ alpha = round (priv->user_alpha * opacity);
+ }
+
+ if (alpha == priv->alpha)
+ return;
+
+ priv->alpha = alpha;
+
+ gtk_widget_propagate_alpha (widget);
+
+}
+
+/**
+ * gtk_widget_set_opacity:
+ * @widget: a #GtkWidget
+ * @opacity: desired opacity, between 0 and 1
+ *
+ * Request the @widget to be rendered partially transparent,
+ * with opacity 0 being fully transparent and 1 fully opaque. (Opacity values
+ * are clamped to the [0,1] range.).
+ * This works on both toplevel widget, and child widgets, although there
+ * are some limitations:
+ *
+ * For toplevel widgets this depends on the capabilities of the windowing
+ * system. On X11 this has any effect only on X screens with a compositing manager
+ * running. See gtk_widget_is_composited(). On Windows it should work
+ * always, although setting a window's opacity after the window has been
+ * shown causes it to flicker once on Windows.
+ *
+ * For child widgets it doesn't work if any affected widget has a native window, or
+ * disables double buffering.
+ *
+ * Since: 3.8
+ **/
+void
+gtk_widget_set_opacity (GtkWidget *widget,
+ gdouble opacity)
+{
+ GtkWidgetPrivate *priv;
+ guint8 alpha;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ priv = widget->priv;
+
+ opacity = CLAMP (opacity, 0.0, 1.0);
+
+ alpha = round (opacity * 255);
+ if (alpha == priv->user_alpha)
+ return;
+
+ priv->user_alpha = alpha;
+
+ gtk_widget_update_alpha (widget);
+}
+
+/**
+ * gtk_widget_get_opacity:
+ * @widget: a #GtkWidget
+ *
+ * Fetches the requested opacity for this widget. See
+ * gtk_widget_set_opacity().
+ *
+ * Return value: the requested opacity for this widget.
+ *
+ * Since: 3.8
+ **/
+gdouble
+gtk_widget_get_opacity (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), 0.0);
+
+ return widget->priv->alpha / 255.0;
+}
+
static void
_gtk_widget_set_has_focus (GtkWidget *widget,
gboolean has_focus)
priv->context = gtk_style_context_new ();
- gtk_style_context_set_direction (priv->context, gtk_widget_get_direction (widget));
+ gtk_style_context_set_state (priv->context, priv->state_flags);
screen = gtk_widget_get_screen (widget);
if (screen)