Commit 676fea75 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

prefs: add new compositor setting

And deprecate old compositing-manager setting.
parent 21876407
Pipeline #210876 passed with stages
in 18 minutes and 30 seconds
NULL =
gsettings_ENUM_NAMESPACE = org.gnome.metacity
gsettings_ENUM_FILES = \
$(top_srcdir)/src/include/meta-compositor.h \
$(NULL)
gsettings_SCHEMAS = \
org.gnome.metacity.gschema.xml \
org.gnome.metacity.keybindings.gschema.xml \
......@@ -14,6 +19,7 @@ EXTRA_DIST = \
CLEANFILES = \
*.gschema.valid \
$(gsettings__enum_file) \
$(NULL)
-include $(top_srcdir)/git.mk
......@@ -23,6 +23,17 @@
<summary>Compositing Manager</summary>
<description>
Determines whether Metacity is a compositing manager.
DEPRECATED: This key is deprecated, use the “compositor” instead.
</description>
</key>
<key name="compositor" enum="org.gnome.metacity.MetaCompositorType">
<default>'xrender'</default>
<summary>Compositor</summary>
<description>
Compositor that Metacity will use for compositing. Possible values
are “none” and “xrender”.
</description>
</key>
......
......@@ -1187,13 +1187,32 @@ static gboolean
not_implemented_cb (MetaCompositorVulkan *vulkan)
{
MetaDisplay *display;
gboolean cm;
MetaCompositorType type;
const char *compositor;
display = meta_compositor_get_display (META_COMPOSITOR (vulkan));
cm = meta_prefs_get_compositing_manager ();
type = meta_prefs_get_compositor ();
compositor = "";
g_warning ("MetaCompositorVulkan is not implemented, switching to %s...",
cm ? "MetaCompositorXRender" : "MetaCompositorNone");
switch (type)
{
case META_COMPOSITOR_TYPE_NONE:
compositor = "none";
break;
case META_COMPOSITOR_TYPE_XRENDER:
compositor = "xrender";
break;
case META_COMPOSITOR_TYPE_EXTERNAL:
case META_COMPOSITOR_TYPE_VULKAN:
default:
g_assert_not_reached ();
break;
}
g_warning ("“vulkan” compositor is not implemented, switching to “%s”...",
compositor);
g_unsetenv ("META_COMPOSITOR");
meta_display_update_compositor (display);
......
......@@ -285,10 +285,7 @@ get_compositor_type (MetaDisplay *display)
}
else
{
if (meta_prefs_get_compositing_manager ())
type = META_COMPOSITOR_TYPE_XRENDER;
else
type = META_COMPOSITOR_TYPE_NONE;
type = meta_prefs_get_compositor ();
}
return type;
......@@ -5118,7 +5115,7 @@ prefs_changed_callback (MetaPreference pref,
{
meta_bell_set_audible (display, meta_prefs_bell_is_audible ());
}
else if (pref == META_PREF_COMPOSITING_MANAGER)
else if (pref == META_PREF_COMPOSITOR)
{
meta_display_update_compositor (display);
}
......
......@@ -178,8 +178,79 @@ typedef struct
gboolean composite;
gboolean no_composite;
gboolean no_force_fullscreen;
MetaCompositorType compositor;
gboolean compositor_set;
} MetaArguments;
static gboolean
option_composite_cb (const char *option_name,
const char *value,
gpointer data,
GError **error)
{
MetaArguments *args;
args = data;
args->composite = TRUE;
g_warning (_("Option “%s” is deprecated, use the “--compositor” instead."),
option_name);
return TRUE;
}
static gboolean
option_no_composite_cb (const char *option_name,
const char *value,
gpointer data,
GError **error)
{
MetaArguments *args;
args = data;
args->no_composite = TRUE;
g_warning (_("Option “%s” is deprecated, use the “--compositor” instead."),
option_name);
return TRUE;
}
static gboolean
option_compositior_cb (const char *option_name,
const char *value,
gpointer data,
GError **error)
{
MetaArguments *args;
args = data;
if (g_strcmp0 (value, "none") == 0)
{
args->compositor = META_COMPOSITOR_TYPE_NONE;
}
else if (g_strcmp0 (value, "xrender") == 0)
{
args->compositor = META_COMPOSITOR_TYPE_XRENDER;
}
else
{
g_set_error (error,
G_OPTION_ERROR,
G_OPTION_ERROR_FAILED,
_("“%s” is not a valid compositor"),
value);
return FALSE;
}
args->compositor_set = TRUE;
return TRUE;
}
/**
* Parses argc and argv and returns the
* arguments that Metacity understands in meta_args.
......@@ -196,8 +267,7 @@ static void
meta_parse_options (int *argc, char ***argv,
MetaArguments *meta_args)
{
MetaArguments my_args = {NULL, NULL, NULL,
FALSE, FALSE, FALSE, FALSE, FALSE};
MetaArguments my_args = { 0 };
GOptionEntry options[] = {
{
"sm-disable", 0, 0, G_OPTION_ARG_NONE,
......@@ -241,17 +311,32 @@ meta_parse_options (int *argc, char ***argv,
NULL
},
{
"composite", 'c', G_OPTION_ARG_NONE, G_OPTION_ARG_NONE,
&my_args.composite,
"composite",
'c',
G_OPTION_FLAG_NO_ARG,
G_OPTION_ARG_CALLBACK,
option_composite_cb,
N_("Turn compositing on"),
NULL
},
{
"no-composite", 0, G_OPTION_ARG_NONE, G_OPTION_ARG_NONE,
&my_args.no_composite,
"no-composite",
0,
G_OPTION_FLAG_NO_ARG,
G_OPTION_ARG_CALLBACK,
option_no_composite_cb,
N_("Turn compositing off"),
NULL
},
{
"compositor",
0,
G_OPTION_FLAG_NONE,
G_OPTION_ARG_CALLBACK,
option_compositior_cb,
N_("Compositor to use"),
"COMPOSITOR"
},
{
"no-force-fullscreen", 0, G_OPTION_ARG_NONE, G_OPTION_ARG_NONE,
&my_args.no_force_fullscreen,
......@@ -261,9 +346,12 @@ meta_parse_options (int *argc, char ***argv,
{NULL}
};
GOptionContext *ctx;
GOptionGroup *group;
GError *error = NULL;
ctx = g_option_context_new (NULL);
group = g_option_group_new (NULL, NULL, NULL, &my_args, NULL);
g_option_context_set_main_group (ctx, group);
g_option_context_add_main_entries (ctx, options, "metacity");
if (!g_option_context_parse (ctx, argc, argv, &error))
{
......@@ -455,8 +543,17 @@ main (int argc, char **argv)
g_free (meta_args.display_name);
g_free (meta_args.client_id);
if (meta_args.composite || meta_args.no_composite)
meta_prefs_set_compositing_manager (meta_args.composite);
if (meta_args.compositor_set)
{
meta_prefs_set_compositor (meta_args.compositor);
}
else if (meta_args.composite || meta_args.no_composite)
{
if (meta_args.composite)
meta_prefs_set_compositor (META_COMPOSITOR_TYPE_XRENDER);
else
meta_prefs_set_compositor (META_COMPOSITOR_TYPE_NONE);
}
if (meta_args.no_force_fullscreen)
meta_prefs_set_force_fullscreen (FALSE);
......
......@@ -42,7 +42,7 @@
#define KEY_TITLEBAR_FONT "titlebar-font"
#define KEY_NUM_WORKSPACES "num-workspaces"
#define KEY_WORKSPACE_NAMES "workspace-names"
#define KEY_COMPOSITOR "compositing-manager"
#define KEY_COMPOSITING_MANAGER "compositing-manager"
#define KEY_PLACEMENT_MODE "placement-mode"
/* Keys from "foreign" schemas */
......@@ -86,7 +86,7 @@ static gboolean gnome_accessibility = FALSE;
static gboolean gnome_animations = TRUE;
static char *cursor_theme = NULL;
static int cursor_size = 24;
static gboolean compositing_manager = TRUE;
static MetaCompositorType compositor = META_COMPOSITOR_TYPE_XRENDER;
static gboolean resize_with_right_button = FALSE;
static gboolean edge_tiling = FALSE;
static gboolean force_fullscreen = TRUE;
......@@ -260,6 +260,13 @@ static MetaEnumPreference preferences_enum[] =
},
&current_theme_type,
},
{
{ "compositor",
SCHEMA_METACITY,
META_PREF_COMPOSITOR,
},
&compositor,
},
{ { NULL, 0, 0 }, NULL },
};
......@@ -329,14 +336,6 @@ static MetaBoolPreference preferences_bool[] =
&gnome_animations,
TRUE,
},
{
{ "compositing-manager",
SCHEMA_METACITY,
META_PREF_COMPOSITING_MANAGER,
},
&compositing_manager,
FALSE,
},
{
{ "resize-with-right-button",
SCHEMA_GENERAL,
......@@ -802,6 +801,35 @@ init_gtk_theme_name (void)
G_CALLBACK (gtk_theme_name_changed), NULL);
}
static void
update_compositing_manager (void)
{
GVariant *user_value;
gboolean compositing_manager;
user_value = g_settings_get_user_value (SETTINGS (SCHEMA_METACITY),
KEY_COMPOSITING_MANAGER);
if (user_value == NULL)
return;
compositing_manager = g_variant_get_boolean (user_value);
g_variant_unref (user_value);
if (compositing_manager)
meta_prefs_set_compositor (META_COMPOSITOR_TYPE_XRENDER);
else
meta_prefs_set_compositor (META_COMPOSITOR_TYPE_NONE);
g_settings_reset (SETTINGS (SCHEMA_METACITY), KEY_COMPOSITING_MANAGER);
}
static void
init_compositing_manager (void)
{
update_compositing_manager ();
}
/****************************************************************************/
/* Initialisation. */
/****************************************************************************/
......@@ -844,6 +872,7 @@ meta_prefs_init (void)
init_bindings ();
init_workspace_names ();
init_compositing_manager ();
init_gtk_cursor_theme_size ();
init_gtk_theme_name ();
......@@ -871,6 +900,14 @@ settings_changed (GSettings *settings,
return;
}
else if (strcmp (key, KEY_COMPOSITING_MANAGER) == 0)
{
g_warning (_("Setting “" KEY_COMPOSITING_MANAGER "” is deprecated, "
"use the “compositor” instead."));
Please register or sign in to reply
update_compositing_manager ();
return;
}
value = g_settings_get_value (settings, key);
type = g_variant_get_type (value);
......@@ -1216,8 +1253,8 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_CURSOR_SIZE:
return "CURSOR_SIZE";
case META_PREF_COMPOSITING_MANAGER:
return "COMPOSITING_MANAGER";
case META_PREF_COMPOSITOR:
return "META_PREF_COMPOSITOR";
case META_PREF_RESIZE_WITH_RIGHT_BUTTON:
return "RESIZE_WITH_RIGHT_BUTTON";
......@@ -1635,12 +1672,6 @@ meta_prefs_get_window_binding (const char *name,
g_assert_not_reached ();
}
gboolean
meta_prefs_get_compositing_manager (void)
{
return compositing_manager;
}
guint
meta_prefs_get_mouse_button_resize (void)
{
......@@ -1671,10 +1702,16 @@ meta_prefs_get_alt_tab_thumbnails (void)
return alt_tab_thumbnails;
}
MetaCompositorType
meta_prefs_get_compositor (void)
{
return compositor;
}
void
meta_prefs_set_compositing_manager (gboolean whether)
meta_prefs_set_compositor (MetaCompositorType type)
{
g_settings_set_boolean (SETTINGS (SCHEMA_METACITY), KEY_COMPOSITOR, whether);
g_settings_set_enum (SETTINGS (SCHEMA_METACITY), "compositor", type);
}
void
......
......@@ -35,11 +35,11 @@ typedef enum
{
META_COMPOSITOR_TYPE_NONE,
META_COMPOSITOR_TYPE_XRENDER,
META_COMPOSITOR_TYPE_EXTERNAL,
META_COMPOSITOR_TYPE_VULKAN
META_COMPOSITOR_TYPE_EXTERNAL, /*< skip >*/
META_COMPOSITOR_TYPE_VULKAN /*< skip >*/
} MetaCompositorType;
typedef enum
typedef enum /*< skip >*/
{
META_EFFECT_TYPE_NONE,
META_EFFECT_TYPE_CREATE,
......
......@@ -25,6 +25,7 @@
/* This header is a "common" one between the UI and core side */
#include "common.h"
#include "meta-compositor.h"
#include "types.h"
#include <libmetacity/meta-theme.h>
#include <pango/pango-font.h>
......@@ -58,7 +59,7 @@ typedef enum
META_PREF_GNOME_ANIMATIONS,
META_PREF_CURSOR_THEME,
META_PREF_CURSOR_SIZE,
META_PREF_COMPOSITING_MANAGER,
META_PREF_COMPOSITOR,
META_PREF_RESIZE_WITH_RIGHT_BUTTON,
META_PREF_EDGE_TILING,
META_PREF_FORCE_FULLSCREEN,
......@@ -128,19 +129,15 @@ void meta_prefs_change_workspace_name (int i,
const char* meta_prefs_get_cursor_theme (void);
int meta_prefs_get_cursor_size (void);
gboolean meta_prefs_get_compositing_manager (void);
gboolean meta_prefs_get_force_fullscreen (void);
MetaPlacementMode meta_prefs_get_placement_mode (void);
gboolean meta_prefs_get_alt_tab_thumbnails (void);
/**
* Sets whether the compositor is turned on.
*
* \param whether TRUE to turn on, FALSE to turn off
*/
void meta_prefs_set_compositing_manager (gboolean whether);
MetaCompositorType meta_prefs_get_compositor (void);
void meta_prefs_set_compositor (MetaCompositorType compositor);
void meta_prefs_set_force_fullscreen (gboolean whether);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment