summaryrefslogtreecommitdiff
path: root/gtk/gtkcsswidgetnode.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-02-19 00:54:14 +0100
committerBenjamin Otte <otte@redhat.com>2015-03-18 15:23:32 +0100
commitdbe5058b86a2e9974b80045ab4b02a4c78e560da (patch)
treef659638f34f0379f82849a19a25d63b91d775de1 /gtk/gtkcsswidgetnode.c
parent5833858abfffa7e31cb9a20fe1c3a8eff078964e (diff)
downloadgtk+-dbe5058b86a2e9974b80045ab4b02a4c78e560da.tar.gz
cssnode: Add API to query the timestamp
... and pass it to the API that computes new styles. A special timestamp of 0 means "please don't animate" and is used when no frame clock is available for a node.
Diffstat (limited to 'gtk/gtkcsswidgetnode.c')
-rw-r--r--gtk/gtkcsswidgetnode.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c
index d3ec5a2043..1bc21244df 100644
--- a/gtk/gtkcsswidgetnode.c
+++ b/gtk/gtkcsswidgetnode.c
@@ -36,14 +36,28 @@ G_DEFINE_TYPE (GtkCssWidgetNode, gtk_css_widget_node, GTK_TYPE_CSS_NODE)
static GtkCssStyle *
gtk_css_widget_node_update_style (GtkCssNode *cssnode,
GtkCssChange pending_change,
+ gint64 timestamp,
GtkCssStyle *old_style)
{
if (old_style == NULL)
- return GTK_CSS_NODE_CLASS (gtk_css_widget_node_parent_class)->update_style (cssnode, pending_change, old_style);
+ return GTK_CSS_NODE_CLASS (gtk_css_widget_node_parent_class)->update_style (cssnode, pending_change, timestamp, old_style);
return NULL;
}
+static gboolean
+gtk_css_widget_node_queue_callback (GtkWidget *widget,
+ GdkFrameClock *frame_clock,
+ gpointer user_data)
+{
+ GtkCssNode *node = user_data;
+
+ gtk_css_node_invalidate_frame_clock (node, TRUE);
+ _gtk_container_queue_restyle (GTK_CONTAINER (widget));
+
+ return G_SOURCE_CONTINUE;
+}
+
static void
gtk_css_widget_node_queue_validate (GtkCssNode *node)
{
@@ -52,8 +66,8 @@ gtk_css_widget_node_queue_validate (GtkCssNode *node)
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (GTK_IS_RESIZE_CONTAINER (widget_node->widget))
widget_node->validate_cb_id = gtk_widget_add_tick_callback (widget_node->widget,
- (GtkTickCallback) _gtk_container_queue_restyle,
- NULL,
+ gtk_css_widget_node_queue_callback,
+ node,
NULL);
G_GNUC_END_IGNORE_DEPRECATIONS
}
@@ -128,7 +142,7 @@ gtk_css_widget_node_validate (GtkCssNode *node,
new_static_style = validate_static_style (node, static_style, change);
- if (new_static_style != static_style)
+ if (new_static_style != static_style || (change & GTK_CSS_CHANGE_ANIMATIONS))
{
GtkCssNode *parent = gtk_css_node_get_parent (node);
new_style = gtk_css_animated_style_new (new_static_style,
@@ -139,7 +153,7 @@ gtk_css_widget_node_validate (GtkCssNode *node,
g_object_unref (new_static_style);
}
- else if (GTK_IS_CSS_ANIMATED_STYLE (style))
+ else if (GTK_IS_CSS_ANIMATED_STYLE (style) && (change & GTK_CSS_CHANGE_TIMESTAMP))
{
new_style = gtk_css_animated_style_new_advance (GTK_CSS_ANIMATED_STYLE (style),
static_style,
@@ -264,6 +278,17 @@ gtk_css_widget_node_get_style_provider (GtkCssNode *node)
return gtk_style_context_get_style_provider (gtk_widget_get_style_context (widget_node->widget));
}
+static GdkFrameClock *
+gtk_css_widget_node_get_frame_clock (GtkCssNode *node)
+{
+ GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
+
+ if (widget_node->widget == NULL)
+ return NULL;
+
+ return gtk_widget_get_frame_clock (widget_node->widget);
+}
+
static void
gtk_css_widget_node_class_init (GtkCssWidgetNodeClass *klass)
{
@@ -277,6 +302,7 @@ gtk_css_widget_node_class_init (GtkCssWidgetNodeClass *klass)
node_class->create_widget_path = gtk_css_widget_node_create_widget_path;
node_class->get_widget_path = gtk_css_widget_node_get_widget_path;
node_class->get_style_provider = gtk_css_widget_node_get_style_provider;
+ node_class->get_frame_clock = gtk_css_widget_node_get_frame_clock;
}
static void