mirror of
https://github.com/brl/mutter.git
synced 2025-08-10 18:34:42 +00:00
monitor-config-store: Add way to define config store loading policy
This adds a way to define a way, at the system level, to define a policy of how monitor configuration files are loaded. The intended use case is to e.g. either prefer system level monitor configurations before user levels, or only allow system level configurations. Examples: Prefer system over user level configurations: <monitors version="2"> <policy> <stores> <store>system</store> <store>user</store> </stores> </policy> <configuration> ... </configuration> </monitors> Only allow system level configurations: <monitors version="2"> <policy> <stores> <store>system</store> </stores> </policy> <configuration> ... </configuration> </monitors> Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
This commit is contained in:
@@ -594,8 +594,9 @@ meta_test_get_plugin_name (void)
|
||||
}
|
||||
|
||||
void
|
||||
meta_set_custom_monitor_config (MetaBackend *backend,
|
||||
const char *filename)
|
||||
meta_set_custom_monitor_config (MetaBackend *backend,
|
||||
const char *filename,
|
||||
MetaMonitorsConfigFlag configs_flags)
|
||||
{
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
@@ -611,8 +612,9 @@ meta_set_custom_monitor_config (MetaBackend *backend,
|
||||
path = g_test_get_filename (G_TEST_DIST, "tests", "monitor-configs",
|
||||
filename, NULL);
|
||||
if (!meta_monitor_config_store_set_custom (config_store, path, NULL,
|
||||
configs_flags,
|
||||
&error))
|
||||
g_error ("Failed to set custom config: %s", error->message);
|
||||
g_warning ("Failed to set custom config: %s", error->message);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/sync.h>
|
||||
|
||||
#include "backends/meta-backend-types.h"
|
||||
#include "meta/window.h"
|
||||
|
||||
#define META_TEST_CLIENT_ERROR meta_test_client_error_quark ()
|
||||
@@ -109,8 +110,9 @@ META_EXPORT
|
||||
const char * meta_test_get_plugin_name (void);
|
||||
|
||||
META_EXPORT
|
||||
void meta_set_custom_monitor_config (MetaBackend *backend,
|
||||
const char *filename);
|
||||
void meta_set_custom_monitor_config (MetaBackend *backend,
|
||||
const char *filename,
|
||||
MetaMonitorsConfigFlag configs_flags);
|
||||
|
||||
META_EXPORT
|
||||
void meta_wait_for_paint (MetaContext *context);
|
||||
|
@@ -55,6 +55,7 @@ test_migration (const char *old_config,
|
||||
NULL);
|
||||
if (!meta_monitor_config_store_set_custom (config_store, "/dev/null",
|
||||
migrated_path,
|
||||
META_MONITORS_CONFIG_FLAG_NONE,
|
||||
&error))
|
||||
g_error ("Failed to set custom config store: %s", error->message);
|
||||
|
||||
|
27
src/tests/monitor-configs/policy.xml
Normal file
27
src/tests/monitor-configs/policy.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<monitors version="2">
|
||||
<policy>
|
||||
<stores>
|
||||
<store>system</store>
|
||||
</stores>
|
||||
</policy>
|
||||
<configuration>
|
||||
<logicalmonitor>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<primary>yes</primary>
|
||||
<monitor>
|
||||
<monitorspec>
|
||||
<connector>DP-1</connector>
|
||||
<vendor>MetaProduct's Inc.</vendor>
|
||||
<product>MetaMonitor</product>
|
||||
<serial>0x123456</serial>
|
||||
</monitorspec>
|
||||
<mode>
|
||||
<width>1920</width>
|
||||
<height>1080</height>
|
||||
<rate>60</rate>
|
||||
</mode>
|
||||
</monitor>
|
||||
</logicalmonitor>
|
||||
</configuration>
|
||||
</monitors>
|
@@ -890,6 +890,35 @@ meta_test_monitor_store_unknown_elements (void)
|
||||
check_monitor_store_configurations (&expect);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_test_monitor_store_policy_not_allowed (void)
|
||||
{
|
||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||
"*Policy can only be defined in system level "
|
||||
"configurations*");
|
||||
set_custom_monitor_config ("policy.xml");
|
||||
g_test_assert_expected_messages ();
|
||||
}
|
||||
|
||||
static void
|
||||
meta_test_monitor_store_policy (void)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
|
||||
MetaMonitorConfigStore *config_store =
|
||||
meta_monitor_config_manager_get_store (config_manager);
|
||||
GList *stores_policy;
|
||||
|
||||
set_custom_monitor_system_config ("policy.xml");
|
||||
stores_policy = meta_monitor_config_store_get_stores_policy (config_store);
|
||||
g_assert_cmpuint (g_list_length (stores_policy), ==, 1);
|
||||
g_assert_cmpint (GPOINTER_TO_INT (stores_policy->data),
|
||||
==,
|
||||
META_CONFIG_STORE_SYSTEM);
|
||||
}
|
||||
|
||||
void
|
||||
init_monitor_store_tests (void)
|
||||
{
|
||||
@@ -917,4 +946,8 @@ init_monitor_store_tests (void)
|
||||
meta_test_monitor_store_interlaced);
|
||||
g_test_add_func ("/backends/monitor-store/unknown-elements",
|
||||
meta_test_monitor_store_unknown_elements);
|
||||
g_test_add_func ("/backends/monitor-store/policy-not-allowed",
|
||||
meta_test_monitor_store_policy_not_allowed);
|
||||
g_test_add_func ("/backends/monitor-store/policy",
|
||||
meta_test_monitor_store_policy);
|
||||
}
|
||||
|
@@ -38,10 +38,24 @@ test_get_gpu (void)
|
||||
return META_GPU (meta_backend_get_gpus (meta_get_backend ())->data);
|
||||
}
|
||||
|
||||
static void
|
||||
set_custom_monitor_config_common (const char *filename,
|
||||
MetaMonitorsConfigFlag configs_flags)
|
||||
{
|
||||
meta_set_custom_monitor_config (meta_get_backend (), filename, configs_flags);
|
||||
}
|
||||
|
||||
void
|
||||
set_custom_monitor_config (const char *filename)
|
||||
{
|
||||
meta_set_custom_monitor_config (meta_get_backend (), filename);
|
||||
set_custom_monitor_config_common (filename, META_MONITORS_CONFIG_FLAG_NONE);
|
||||
}
|
||||
|
||||
void
|
||||
set_custom_monitor_system_config (const char *filename)
|
||||
{
|
||||
set_custom_monitor_config_common (filename,
|
||||
META_MONITORS_CONFIG_FLAG_SYSTEM_CONFIG);
|
||||
}
|
||||
|
||||
char *
|
||||
|
@@ -201,6 +201,8 @@ MetaGpu * test_get_gpu (void);
|
||||
|
||||
void set_custom_monitor_config (const char *filename);
|
||||
|
||||
void set_custom_monitor_system_config (const char *filename);
|
||||
|
||||
char * read_file (const char *file_path);
|
||||
|
||||
void check_monitor_configuration (MonitorTestCaseExpect *expect);
|
||||
|
@@ -7690,6 +7690,7 @@ meta_test_monitor_migrated_rotated (void)
|
||||
if (!meta_monitor_config_store_set_custom (config_store,
|
||||
"/dev/null",
|
||||
migrated_path,
|
||||
META_MONITORS_CONFIG_FLAG_NONE,
|
||||
&error))
|
||||
g_error ("Failed to set custom config store files: %s", error->message);
|
||||
|
||||
@@ -7832,6 +7833,7 @@ meta_test_monitor_migrated_wiggle_discard (void)
|
||||
if (!meta_monitor_config_store_set_custom (config_store,
|
||||
"/dev/null",
|
||||
migrated_path,
|
||||
META_MONITORS_CONFIG_FLAG_NONE,
|
||||
&error))
|
||||
g_error ("Failed to set custom config store files: %s", error->message);
|
||||
|
||||
@@ -8103,6 +8105,7 @@ meta_test_monitor_migrated_wiggle (void)
|
||||
if (!meta_monitor_config_store_set_custom (config_store,
|
||||
"/dev/null",
|
||||
migrated_path,
|
||||
META_MONITORS_CONFIG_FLAG_NONE,
|
||||
&error))
|
||||
g_error ("Failed to set custom config store files: %s", error->message);
|
||||
|
||||
|
@@ -66,7 +66,8 @@ meta_test_warp_on_hotplug (void)
|
||||
virtual_pointer = clutter_seat_create_virtual_device (seat,
|
||||
CLUTTER_POINTER_DEVICE);
|
||||
|
||||
meta_set_custom_monitor_config (backend, "pointer-constraint.xml");
|
||||
meta_set_custom_monitor_config (backend, "pointer-constraint.xml",
|
||||
META_MONITORS_CONFIG_FLAG_NONE);
|
||||
|
||||
monitor_info1 = meta_virtual_monitor_info_new (100, 100, 60.0,
|
||||
"MetaTestVendor",
|
||||
|
Reference in New Issue
Block a user