mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
shell/workspace-dot: Avoid excess marshalling
No need for the overhead of via properties when we can just have a method to call in the tight loop in update_expansion
This commit is contained in:
parent
e1763f630a
commit
26f15db928
3 changed files with 72 additions and 42 deletions
|
|
@ -64,32 +64,6 @@ shell_workspace_dot_dispose (GObject *object)
|
|||
G_OBJECT_CLASS (shell_workspace_dot_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
|
||||
static inline gboolean
|
||||
value_changed (float old_value, float new_value)
|
||||
{
|
||||
return !G_APPROX_VALUE (old_value, new_value, FLT_EPSILON);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
set_if_changed (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
float *target,
|
||||
const GValue *value)
|
||||
{
|
||||
float new_value = g_value_get_double (value);
|
||||
|
||||
if (G_LIKELY (value_changed (*target, new_value)))
|
||||
{
|
||||
*target = new_value;
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static inline float
|
||||
lerp (float start, float end, float progress)
|
||||
{
|
||||
|
|
@ -121,17 +95,14 @@ shell_workspace_dot_set_property (GObject *object,
|
|||
switch (property_id)
|
||||
{
|
||||
case PROP_WIDTH_MULTIPLIER:
|
||||
if (set_if_changed (object, pspec, &priv->width_multiplier, value))
|
||||
{
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (object));
|
||||
}
|
||||
shell_workspace_dot_set_state (self,
|
||||
priv->expansion,
|
||||
g_value_get_double (value));
|
||||
break;
|
||||
case PROP_EXPANSION:
|
||||
if (set_if_changed (object, pspec, &priv->expansion, value))
|
||||
{
|
||||
update_visuals (self);
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (object));
|
||||
}
|
||||
shell_workspace_dot_set_state (self,
|
||||
g_value_get_double (value),
|
||||
priv->width_multiplier);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
|
@ -268,6 +239,63 @@ shell_workspace_dot_init (ShellWorkspaceDot *self)
|
|||
update_visuals (self);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
value_changed (float old_value, float new_value)
|
||||
{
|
||||
return !G_APPROX_VALUE (old_value, new_value, FLT_EPSILON);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
set_if_changed (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
float *target,
|
||||
float new_value)
|
||||
{
|
||||
if (G_LIKELY (value_changed (*target, new_value)))
|
||||
{
|
||||
*target = new_value;
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
shell_workspace_dot_set_state (ShellWorkspaceDot *self,
|
||||
float expansion,
|
||||
float width_multiplier)
|
||||
{
|
||||
ShellWorkspaceDotPrivate *priv;
|
||||
GObject *object = G_OBJECT (self);
|
||||
gboolean trigger_layout = FALSE;
|
||||
|
||||
g_return_if_fail (SHELL_IS_WORKSPACE_DOT (self));
|
||||
|
||||
priv = shell_workspace_dot_get_instance_private (self);
|
||||
|
||||
g_object_freeze_notify (object);
|
||||
|
||||
trigger_layout = set_if_changed (object,
|
||||
obj_props[PROP_WIDTH_MULTIPLIER],
|
||||
&priv->width_multiplier,
|
||||
width_multiplier);
|
||||
|
||||
if (set_if_changed (object,
|
||||
obj_props[PROP_EXPANSION],
|
||||
&priv->expansion,
|
||||
expansion))
|
||||
{
|
||||
update_visuals (self);
|
||||
trigger_layout = TRUE;
|
||||
}
|
||||
|
||||
g_object_thaw_notify (object);
|
||||
|
||||
if (G_LIKELY (trigger_layout))
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (self));
|
||||
}
|
||||
|
||||
gboolean
|
||||
shell_workspace_dot_is_destroying (ShellWorkspaceDot *self)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ struct _ShellWorkspaceDotClass
|
|||
void (*scale_out_and_destroy) (ShellWorkspaceDot *dot);
|
||||
};
|
||||
|
||||
void shell_workspace_dot_set_state (ShellWorkspaceDot *self,
|
||||
float expansion,
|
||||
float width_multiplier);
|
||||
gboolean shell_workspace_dot_is_destroying (ShellWorkspaceDot *self);
|
||||
void shell_workspace_dot_scale_in (ShellWorkspaceDot *self);
|
||||
void shell_workspace_dot_scale_out_and_destroy (ShellWorkspaceDot *self);
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ update_expansion (ShellWorkspaceIndicators *self)
|
|||
ShellWorkspaceIndicatorsPrivate *priv;
|
||||
g_autoptr (GPtrArray) active_dots = NULL;
|
||||
size_t n_indicators;
|
||||
double active_workspace, width_multiplier;
|
||||
float active_workspace, width_multiplier;
|
||||
size_t index = 0;
|
||||
|
||||
g_return_if_fail (SHELL_IS_WORKSPACE_INDICATORS (self));
|
||||
|
|
@ -102,12 +102,11 @@ update_expansion (ShellWorkspaceIndicators *self)
|
|||
child != NULL;
|
||||
index++, child = clutter_actor_get_next_sibling (child))
|
||||
{
|
||||
double distance = fabs (((double) index) - active_workspace);
|
||||
|
||||
g_object_set (child,
|
||||
"expansion", CLAMP (1.0 - distance, 0.0, 1.0),
|
||||
"width-multiplier", width_multiplier,
|
||||
NULL);
|
||||
float distance = fabsf (((float) index) - active_workspace);
|
||||
|
||||
shell_workspace_dot_set_state (SHELL_WORKSPACE_DOT (child),
|
||||
CLAMP (1.0 - distance, 0.0, 1.0),
|
||||
width_multiplier);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue