shell-global: Add 'force-animations' property

Set via a command line argument to gnome-shell. Will allow enabling
animations despite e.g. lack of hardware acceleration otherwise
inhibiting it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2560>
This commit is contained in:
Jonas Ådahl 2022-11-29 16:26:46 +01:00
parent 5bb9843217
commit 08d4addeef
2 changed files with 26 additions and 1 deletions

View File

@ -39,6 +39,7 @@ extern GType gnome_shell_plugin_get_type (void);
static gboolean is_gdm_mode = FALSE; static gboolean is_gdm_mode = FALSE;
static char *session_mode = NULL; static char *session_mode = NULL;
static int caught_signal = 0; static int caught_signal = 0;
static gboolean force_animations = FALSE;
#define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1 #define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1
#define DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4 #define DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4
@ -530,6 +531,12 @@ GOptionEntry gnome_shell_options[] = {
N_("List possible modes"), N_("List possible modes"),
NULL NULL
}, },
{
"force-animations", 0, G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE,
&force_animations,
N_("Force animations to be enabled"),
NULL
},
{ NULL } { NULL }
}; };
@ -632,7 +639,9 @@ main (int argc, char **argv)
if (session_mode == NULL) if (session_mode == NULL)
session_mode = is_gdm_mode ? (char *)"gdm" : (char *)"user"; session_mode = is_gdm_mode ? (char *)"gdm" : (char *)"user";
_shell_global_init ("session-mode", session_mode, NULL); _shell_global_init ("session-mode", session_mode,
"force-animations", force_animations,
NULL);
dump_gjs_stack_on_signal (SIGABRT); dump_gjs_stack_on_signal (SIGABRT);
dump_gjs_stack_on_signal (SIGFPE); dump_gjs_stack_on_signal (SIGFPE);

View File

@ -85,6 +85,8 @@ struct _ShellGlobal {
GDBusProxy *switcheroo_control; GDBusProxy *switcheroo_control;
GCancellable *switcheroo_cancellable; GCancellable *switcheroo_cancellable;
gboolean force_animations;
}; };
enum { enum {
@ -109,6 +111,7 @@ enum {
PROP_FRAME_TIMESTAMPS, PROP_FRAME_TIMESTAMPS,
PROP_FRAME_FINISH_TIMESTAMP, PROP_FRAME_FINISH_TIMESTAMP,
PROP_SWITCHEROO_CONTROL, PROP_SWITCHEROO_CONTROL,
PROP_FORCE_ANIMATIONS,
N_PROPS N_PROPS
}; };
@ -235,6 +238,9 @@ shell_global_set_property(GObject *object,
} }
} }
break; break;
case PROP_FORCE_ANIMATIONS:
global->force_animations = g_value_get_boolean (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -318,6 +324,9 @@ shell_global_get_property(GObject *object,
case PROP_SWITCHEROO_CONTROL: case PROP_SWITCHEROO_CONTROL:
g_value_set_object (value, global->switcheroo_control); g_value_set_object (value, global->switcheroo_control);
break; break;
case PROP_FORCE_ANIMATIONS:
g_value_set_boolean (value, global->force_animations);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -649,6 +658,13 @@ shell_global_class_init (ShellGlobalClass *klass)
G_TYPE_DBUS_PROXY, G_TYPE_DBUS_PROXY,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
props[PROP_FORCE_ANIMATIONS] =
g_param_spec_boolean ("force-animations",
"force-animations",
"Force animations to be enabled",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT| G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, N_PROPS, props); g_object_class_install_properties (gobject_class, N_PROPS, props);
} }