st: Move slow-down-factor into settings
Now that we have a Settings singleton, we have a better place for the slow-down-factor than an awkward extern variable. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/656
This commit is contained in:
parent
5295866eff
commit
12b8fb15b1
@ -107,6 +107,12 @@ function init() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
St.set_slow_down_factor = function(factor) {
|
||||||
|
let { stack } = new Error();
|
||||||
|
log(`St.set_slow_down_factor() is deprecated, use St.Settings.slow_down_factor\n${stack}`);
|
||||||
|
St.Settings.get().slow_down_factor = factor;
|
||||||
|
};
|
||||||
|
|
||||||
let origToString = Object.prototype.toString;
|
let origToString = Object.prototype.toString;
|
||||||
Object.prototype.toString = function() {
|
Object.prototype.toString = function() {
|
||||||
let base = origToString.call(this);
|
let base = origToString.call(this);
|
||||||
@ -129,7 +135,7 @@ function init() {
|
|||||||
if (slowdownEnv) {
|
if (slowdownEnv) {
|
||||||
let factor = parseFloat(slowdownEnv);
|
let factor = parseFloat(slowdownEnv);
|
||||||
if (!isNaN(factor) && factor > 0.0)
|
if (!isNaN(factor) && factor > 0.0)
|
||||||
St.set_slow_down_factor(factor);
|
St.Settings.get().slow_down_factor = factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OK, now things are initialized enough that we can import shell JS
|
// OK, now things are initialized enough that we can import shell JS
|
||||||
|
@ -949,9 +949,10 @@ var LookingGlass = class LookingGlass {
|
|||||||
if (this._completionActor.visible) {
|
if (this._completionActor.visible) {
|
||||||
this._completionActor.height = naturalHeight;
|
this._completionActor.height = naturalHeight;
|
||||||
} else {
|
} else {
|
||||||
|
let settings = St.Settings.get();
|
||||||
this._completionActor.show();
|
this._completionActor.show();
|
||||||
Tweener.removeTweens(this._completionActor);
|
Tweener.removeTweens(this._completionActor);
|
||||||
Tweener.addTween(this._completionActor, { time: AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION / St.get_slow_down_factor(),
|
Tweener.addTween(this._completionActor, { time: AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION / settings.slow_down_factor,
|
||||||
transition: 'easeOutQuad',
|
transition: 'easeOutQuad',
|
||||||
height: naturalHeight,
|
height: naturalHeight,
|
||||||
opacity: 255
|
opacity: 255
|
||||||
@ -961,8 +962,9 @@ var LookingGlass = class LookingGlass {
|
|||||||
|
|
||||||
_hideCompletions() {
|
_hideCompletions() {
|
||||||
if (this._completionActor) {
|
if (this._completionActor) {
|
||||||
|
let settings = St.Settings.get();
|
||||||
Tweener.removeTweens(this._completionActor);
|
Tweener.removeTweens(this._completionActor);
|
||||||
Tweener.addTween(this._completionActor, { time: AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION / St.get_slow_down_factor(),
|
Tweener.addTween(this._completionActor, { time: AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION / settings.slow_down_factor,
|
||||||
transition: 'easeOutQuad',
|
transition: 'easeOutQuad',
|
||||||
height: 0,
|
height: 0,
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
@ -1082,7 +1084,8 @@ var LookingGlass = class LookingGlass {
|
|||||||
|
|
||||||
// We inverse compensate for the slow-down so you can change the factor
|
// We inverse compensate for the slow-down so you can change the factor
|
||||||
// through LookingGlass without long waits.
|
// through LookingGlass without long waits.
|
||||||
Tweener.addTween(this.actor, { time: 0.5 / St.get_slow_down_factor(),
|
let settings = St.Settings.get();
|
||||||
|
Tweener.addTween(this.actor, { time: 0.5 / settings.slow_down_factor,
|
||||||
transition: 'easeOutQuad',
|
transition: 'easeOutQuad',
|
||||||
y: this._targetY
|
y: this._targetY
|
||||||
});
|
});
|
||||||
@ -1101,7 +1104,8 @@ var LookingGlass = class LookingGlass {
|
|||||||
|
|
||||||
Main.popModal(this._entry);
|
Main.popModal(this._entry);
|
||||||
|
|
||||||
Tweener.addTween(this.actor, { time: Math.min(0.5 / St.get_slow_down_factor(), 0.5),
|
let settings = St.Settings.get();
|
||||||
|
Tweener.addTween(this.actor, { time: Math.min(0.5 / settings.slow_down_factor, 0.5),
|
||||||
transition: 'easeOutQuad',
|
transition: 'easeOutQuad',
|
||||||
y: this._hiddenY,
|
y: this._hiddenY,
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
|
@ -211,8 +211,9 @@ var ClutterFrameTicker = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
if (St.get_slow_down_factor() > 0)
|
let settings = St.Settings.get();
|
||||||
Tweener.setTimeScale(1 / St.get_slow_down_factor());
|
if (settings.slow_down_factor > 0)
|
||||||
|
Tweener.setTimeScale(1 / settings.slow_down_factor);
|
||||||
this._timeline.start();
|
this._timeline.start();
|
||||||
global.begin_work();
|
global.begin_work();
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "st-enum-types.h"
|
#include "st-enum-types.h"
|
||||||
#include "st-private.h"
|
#include "st-private.h"
|
||||||
#include "st-button.h"
|
#include "st-button.h"
|
||||||
|
#include "st-settings.h"
|
||||||
|
|
||||||
#define PAGING_INITIAL_REPEAT_TIMEOUT 500
|
#define PAGING_INITIAL_REPEAT_TIMEOUT 500
|
||||||
#define PAGING_SUBSEQUENT_REPEAT_TIMEOUT 200
|
#define PAGING_SUBSEQUENT_REPEAT_TIMEOUT 200
|
||||||
@ -96,8 +97,6 @@ enum
|
|||||||
|
|
||||||
static guint signals[LAST_SIGNAL] = { 0, };
|
static guint signals[LAST_SIGNAL] = { 0, };
|
||||||
|
|
||||||
extern gfloat st_slow_down_factor;
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_button_press_event_cb (ClutterActor *actor,
|
handle_button_press_event_cb (ClutterActor *actor,
|
||||||
ClutterButtonEvent *event,
|
ClutterButtonEvent *event,
|
||||||
@ -683,9 +682,11 @@ static gboolean
|
|||||||
trough_paging_cb (StScrollBar *self)
|
trough_paging_cb (StScrollBar *self)
|
||||||
{
|
{
|
||||||
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (self);
|
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (self);
|
||||||
|
StSettings *settings;
|
||||||
gfloat handle_pos, event_pos, tx, ty;
|
gfloat handle_pos, event_pos, tx, ty;
|
||||||
gdouble value, new_value;
|
gdouble value, new_value;
|
||||||
gdouble page_increment;
|
gdouble page_increment;
|
||||||
|
gdouble slow_down_factor;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
gulong mode;
|
gulong mode;
|
||||||
@ -776,13 +777,16 @@ trough_paging_cb (StScrollBar *self)
|
|||||||
clutter_timeline_stop (CLUTTER_TIMELINE (priv->paging_animation));
|
clutter_timeline_stop (CLUTTER_TIMELINE (priv->paging_animation));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings = st_settings_get ();
|
||||||
|
g_object_get (settings, "slow-down-factor", &slow_down_factor, NULL);
|
||||||
|
|
||||||
/* FIXME: Creating a new transition for each scroll is probably not the best
|
/* FIXME: Creating a new transition for each scroll is probably not the best
|
||||||
* idea, but it's a lot less involved than extending the current animation */
|
* idea, but it's a lot less involved than extending the current animation */
|
||||||
priv->paging_animation = g_object_new (CLUTTER_TYPE_PROPERTY_TRANSITION,
|
priv->paging_animation = g_object_new (CLUTTER_TYPE_PROPERTY_TRANSITION,
|
||||||
"animatable", priv->adjustment,
|
"animatable", priv->adjustment,
|
||||||
"property-name", "value",
|
"property-name", "value",
|
||||||
"interval", clutter_interval_new (G_TYPE_DOUBLE, value, new_value),
|
"interval", clutter_interval_new (G_TYPE_DOUBLE, value, new_value),
|
||||||
"duration", (guint)(PAGING_SUBSEQUENT_REPEAT_TIMEOUT * st_slow_down_factor),
|
"duration", (guint)(PAGING_SUBSEQUENT_REPEAT_TIMEOUT * slow_down_factor),
|
||||||
"progress-mode", mode,
|
"progress-mode", mode,
|
||||||
NULL);
|
NULL);
|
||||||
g_signal_connect (priv->paging_animation, "stopped",
|
g_signal_connect (priv->paging_animation, "stopped",
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
#include "st-private.h"
|
#include "st-private.h"
|
||||||
@ -41,6 +42,7 @@ enum {
|
|||||||
PROP_GTK_THEME,
|
PROP_GTK_THEME,
|
||||||
PROP_GTK_ICON_THEME,
|
PROP_GTK_ICON_THEME,
|
||||||
PROP_MAGNIFIER_ACTIVE,
|
PROP_MAGNIFIER_ACTIVE,
|
||||||
|
PROP_SLOW_DOWN_FACTOR,
|
||||||
N_PROPS
|
N_PROPS
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -59,10 +61,24 @@ struct _StSettings
|
|||||||
gboolean primary_paste;
|
gboolean primary_paste;
|
||||||
gboolean magnifier_active;
|
gboolean magnifier_active;
|
||||||
gint drag_threshold;
|
gint drag_threshold;
|
||||||
|
double slow_down_factor;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (StSettings, st_settings, G_TYPE_OBJECT)
|
G_DEFINE_TYPE (StSettings, st_settings, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
#define EPSILON (1e-10)
|
||||||
|
|
||||||
|
static void
|
||||||
|
st_settings_set_slow_down_factor (StSettings *settings,
|
||||||
|
double factor)
|
||||||
|
{
|
||||||
|
if (fabs (settings->slow_down_factor - factor) < EPSILON)
|
||||||
|
return;
|
||||||
|
|
||||||
|
settings->slow_down_factor = factor;
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (settings), props[PROP_SLOW_DOWN_FACTOR]);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
st_settings_finalize (GObject *object)
|
st_settings_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
@ -82,7 +98,16 @@ st_settings_set_property (GObject *object,
|
|||||||
const GValue *value,
|
const GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
StSettings *settings = ST_SETTINGS (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_SLOW_DOWN_FACTOR:
|
||||||
|
st_settings_set_slow_down_factor (settings, g_value_get_double (value));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -113,6 +138,9 @@ st_settings_get_property (GObject *object,
|
|||||||
case PROP_MAGNIFIER_ACTIVE:
|
case PROP_MAGNIFIER_ACTIVE:
|
||||||
g_value_set_boolean (value, settings->magnifier_active);
|
g_value_set_boolean (value, settings->magnifier_active);
|
||||||
break;
|
break;
|
||||||
|
case PROP_SLOW_DOWN_FACTOR:
|
||||||
|
g_value_set_double (value, settings->slow_down_factor);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
}
|
}
|
||||||
@ -157,6 +185,11 @@ st_settings_class_init (StSettingsClass *klass)
|
|||||||
"Weather the a11y magnifier is active",
|
"Weather the a11y magnifier is active",
|
||||||
FALSE,
|
FALSE,
|
||||||
ST_PARAM_READABLE);
|
ST_PARAM_READABLE);
|
||||||
|
props[PROP_SLOW_DOWN_FACTOR] = g_param_spec_double("slow-down-factor",
|
||||||
|
"Slow down factor",
|
||||||
|
"Factor applied to all animation durations",
|
||||||
|
EPSILON, G_MAXDOUBLE, 1.0,
|
||||||
|
ST_PARAM_READWRITE);
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, N_PROPS, props);
|
g_object_class_install_properties (object_class, N_PROPS, props);
|
||||||
}
|
}
|
||||||
@ -242,6 +275,7 @@ st_settings_init (StSettings *settings)
|
|||||||
KEY_DRAG_THRESHOLD);
|
KEY_DRAG_THRESHOLD);
|
||||||
settings->magnifier_active = g_settings_get_boolean (settings->a11y_settings,
|
settings->magnifier_active = g_settings_get_boolean (settings->a11y_settings,
|
||||||
KEY_MAGNIFIER_ACTIVE);
|
KEY_MAGNIFIER_ACTIVE);
|
||||||
|
settings->slow_down_factor = 1.;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "st-settings.h"
|
||||||
#include "st-theme-private.h"
|
#include "st-theme-private.h"
|
||||||
#include "st-theme-context.h"
|
#include "st-theme-context.h"
|
||||||
#include "st-theme-node-private.h"
|
#include "st-theme-node-private.h"
|
||||||
@ -39,8 +40,6 @@ static const ClutterColor DEFAULT_SUCCESS_COLOR = { 0x4e, 0x9a, 0x06, 0xff };
|
|||||||
static const ClutterColor DEFAULT_WARNING_COLOR = { 0xf5, 0x79, 0x3e, 0xff };
|
static const ClutterColor DEFAULT_WARNING_COLOR = { 0xf5, 0x79, 0x3e, 0xff };
|
||||||
static const ClutterColor DEFAULT_ERROR_COLOR = { 0xcc, 0x00, 0x00, 0xff };
|
static const ClutterColor DEFAULT_ERROR_COLOR = { 0xcc, 0x00, 0x00, 0xff };
|
||||||
|
|
||||||
extern gfloat st_slow_down_factor;
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (StThemeNode, st_theme_node, G_TYPE_OBJECT)
|
G_DEFINE_TYPE (StThemeNode, st_theme_node, G_TYPE_OBJECT)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2348,18 +2347,23 @@ st_theme_node_get_margin (StThemeNode *node,
|
|||||||
int
|
int
|
||||||
st_theme_node_get_transition_duration (StThemeNode *node)
|
st_theme_node_get_transition_duration (StThemeNode *node)
|
||||||
{
|
{
|
||||||
|
StSettings *settings;
|
||||||
gdouble value = 0.0;
|
gdouble value = 0.0;
|
||||||
|
gdouble factor;
|
||||||
|
|
||||||
g_return_val_if_fail (ST_IS_THEME_NODE (node), 0);
|
g_return_val_if_fail (ST_IS_THEME_NODE (node), 0);
|
||||||
|
|
||||||
|
settings = st_settings_get ();
|
||||||
|
g_object_get (settings, "slow-down-factor", &factor, NULL);
|
||||||
|
|
||||||
if (node->transition_duration > -1)
|
if (node->transition_duration > -1)
|
||||||
return st_slow_down_factor * node->transition_duration;
|
return factor * node->transition_duration;
|
||||||
|
|
||||||
st_theme_node_lookup_time (node, "transition-duration", FALSE, &value);
|
st_theme_node_lookup_time (node, "transition-duration", FALSE, &value);
|
||||||
|
|
||||||
node->transition_duration = (int)value;
|
node->transition_duration = (int)value;
|
||||||
|
|
||||||
return st_slow_down_factor * node->transition_duration;
|
return factor * node->transition_duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
StIconStyle
|
StIconStyle
|
||||||
|
@ -133,8 +133,6 @@ enum
|
|||||||
|
|
||||||
static guint signals[LAST_SIGNAL] = { 0, };
|
static guint signals[LAST_SIGNAL] = { 0, };
|
||||||
|
|
||||||
gfloat st_slow_down_factor = 1.0;
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (StWidget, st_widget, CLUTTER_TYPE_ACTOR);
|
G_DEFINE_TYPE_WITH_PRIVATE (StWidget, st_widget, CLUTTER_TYPE_ACTOR);
|
||||||
#define ST_WIDGET_PRIVATE(w) ((StWidgetPrivate *)st_widget_get_instance_private (w))
|
#define ST_WIDGET_PRIVATE(w) ((StWidgetPrivate *)st_widget_get_instance_private (w))
|
||||||
|
|
||||||
@ -2449,30 +2447,6 @@ st_describe_actor (ClutterActor *actor)
|
|||||||
return g_string_free (desc, FALSE);
|
return g_string_free (desc, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* st_set_slow_down_factor:
|
|
||||||
* @factor: new slow-down factor
|
|
||||||
*
|
|
||||||
* Set a global factor applied to all animation durations
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
st_set_slow_down_factor (gfloat factor)
|
|
||||||
{
|
|
||||||
st_slow_down_factor = factor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* st_get_slow_down_factor:
|
|
||||||
*
|
|
||||||
* Returns: the global factor applied to all animation durations
|
|
||||||
*/
|
|
||||||
gfloat
|
|
||||||
st_get_slow_down_factor (void)
|
|
||||||
{
|
|
||||||
return st_slow_down_factor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* st_widget_get_label_actor:
|
* st_widget_get_label_actor:
|
||||||
* @widget: a #StWidget
|
* @widget: a #StWidget
|
||||||
|
@ -143,8 +143,6 @@ gboolean st_widget_get_resource_scale (StWidget *widg
|
|||||||
|
|
||||||
/* debug methods */
|
/* debug methods */
|
||||||
char *st_describe_actor (ClutterActor *actor);
|
char *st_describe_actor (ClutterActor *actor);
|
||||||
void st_set_slow_down_factor (gfloat factor);
|
|
||||||
gfloat st_get_slow_down_factor (void);
|
|
||||||
|
|
||||||
/* accessibility methods */
|
/* accessibility methods */
|
||||||
void st_widget_set_accessible_role (StWidget *widget,
|
void st_widget_set_accessible_role (StWidget *widget,
|
||||||
|
Loading…
Reference in New Issue
Block a user