Commit f8bd76c5 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

monitor-manager: use MonitorsConfig to track switch_config

Based on mutter commit:
mutter@6267732b
parent 21594a60
......@@ -994,7 +994,11 @@ GfMonitorsConfig *
gf_monitor_config_manager_create_for_switch_config (GfMonitorConfigManager *config_manager,
GfMonitorSwitchConfigType config_type)
{
GfMonitorManager *monitor_manager = config_manager->monitor_manager;
GfMonitorManager *monitor_manager;
GfMonitorsConfig *config;
monitor_manager = config_manager->monitor_manager;
config = NULL;
if (!gf_monitor_manager_can_switch_config (monitor_manager))
return NULL;
......@@ -1002,16 +1006,20 @@ gf_monitor_config_manager_create_for_switch_config (GfMonitorConfigManager *c
switch (config_type)
{
case GF_MONITOR_SWITCH_CONFIG_ALL_MIRROR:
return create_for_switch_config_all_mirror (config_manager);
config = create_for_switch_config_all_mirror (config_manager);
break;
case GF_MONITOR_SWITCH_CONFIG_ALL_LINEAR:
return gf_monitor_config_manager_create_linear (config_manager);
config = gf_monitor_config_manager_create_linear (config_manager);
break;
case GF_MONITOR_SWITCH_CONFIG_EXTERNAL:
return create_for_switch_config_external (config_manager);
config = create_for_switch_config_external (config_manager);
break;
case GF_MONITOR_SWITCH_CONFIG_BUILTIN:
return create_for_switch_config_builtin (config_manager);
config = create_for_switch_config_builtin (config_manager);
break;
case GF_MONITOR_SWITCH_CONFIG_UNKNOWN:
default:
......@@ -1019,7 +1027,10 @@ gf_monitor_config_manager_create_for_switch_config (GfMonitorConfigManager *c
break;
}
return NULL;
if (config)
gf_monitors_config_set_switch_config (config, config_type);
return config;
}
void
......
......@@ -180,8 +180,6 @@ gf_monitor_manager_notify_monitors_changed (GfMonitorManager *manager)
priv = gf_monitor_manager_get_instance_private (manager);
manager->current_switch_config = GF_MONITOR_SWITCH_CONFIG_UNKNOWN;
gf_backend_monitors_changed (priv->backend);
g_signal_emit_by_name (manager, "monitors-changed");
......@@ -2484,7 +2482,9 @@ gf_monitor_manager_ensure_configured (GfMonitorManager *manager)
g_clear_object (&config);
}
config = gf_monitor_config_manager_create_linear (manager->config_manager);
config = gf_monitor_config_manager_create_for_switch_config (manager->config_manager,
GF_MONITOR_SWITCH_CONFIG_ALL_LINEAR);
if (config)
{
if (!gf_monitor_manager_apply_monitors_config (manager, config,
......@@ -2537,6 +2537,11 @@ void
gf_monitor_manager_update_logical_state_derived (GfMonitorManager *manager,
GfMonitorsConfig *config)
{
if (config)
manager->current_switch_config = gf_monitors_config_get_switch_config (config);
else
manager->current_switch_config = GF_MONITOR_SWITCH_CONFIG_UNKNOWN;
manager->layout_mode = GF_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL;
gf_monitor_manager_rebuild_logical_monitors_derived (manager, config);
......
/*
* Copyright (C) 2016 Red Hat
* Copyright (C) 2017 Alberts Muktupāvels
* Copyright (C) 2017-2019 Alberts Muktupāvels
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -49,32 +49,39 @@ struct _GfMonitorsConfig
GfMonitorsConfigFlag flags;
GfLogicalMonitorLayoutMode layout_mode;
GfMonitorSwitchConfigType switch_config;
};
#define GF_TYPE_MONITORS_CONFIG (gf_monitors_config_get_type ())
G_DECLARE_FINAL_TYPE (GfMonitorsConfig, gf_monitors_config,
GF, MONITORS_CONFIG, GObject)
GfMonitorsConfig *gf_monitors_config_new_full (GList *logical_monitor_configs,
GList *disabled_monitor_specs,
GfLogicalMonitorLayoutMode layout_mode,
GfMonitorsConfigFlag flags);
GfMonitorsConfig *gf_monitors_config_new_full (GList *logical_monitor_configs,
GList *disabled_monitor_specs,
GfLogicalMonitorLayoutMode layout_mode,
GfMonitorsConfigFlag flags);
GfMonitorsConfig *gf_monitors_config_new (GfMonitorManager *monitor_manager,
GList *logical_monitor_configs,
GfLogicalMonitorLayoutMode layout_mode,
GfMonitorsConfigFlag flags);
GfMonitorSwitchConfigType gf_monitors_config_get_switch_config (GfMonitorsConfig *config);
GfMonitorsConfig *gf_monitors_config_new (GfMonitorManager *monitor_manager,
GList *logical_monitor_configs,
GfLogicalMonitorLayoutMode layout_mode,
GfMonitorsConfigFlag flags);
void gf_monitors_config_set_switch_config (GfMonitorsConfig *config,
GfMonitorSwitchConfigType switch_config);
guint gf_monitors_config_key_hash (gconstpointer data);
guint gf_monitors_config_key_hash (gconstpointer data);
gboolean gf_monitors_config_key_equal (gconstpointer data_a,
gconstpointer data_b);
gboolean gf_monitors_config_key_equal (gconstpointer data_a,
gconstpointer data_b);
void gf_monitors_config_key_free (GfMonitorsConfigKey *config_key);
void gf_monitors_config_key_free (GfMonitorsConfigKey *config_key);
gboolean gf_verify_monitors_config (GfMonitorsConfig *config,
GfMonitorManager *monitor_manager,
GError **error);
gboolean gf_verify_monitors_config (GfMonitorsConfig *config,
GfMonitorManager *monitor_manager,
GError **error);
G_END_DECLS
......
/*
* Copyright (C) 2016 Red Hat
* Copyright (C) 2017 Alberts Muktupāvels
* Copyright (C) 2017-2019 Alberts Muktupāvels
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -149,6 +149,7 @@ gf_monitors_config_new_full (GList *logical_monitor_configs
disabled_monitor_specs);
config->layout_mode = layout_mode;
config->flags = flags;
config->switch_config = GF_MONITOR_SWITCH_CONFIG_UNKNOWN;
return config;
}
......@@ -188,6 +189,19 @@ gf_monitors_config_new (GfMonitorManager *monitor_manager,
layout_mode, flags);
}
GfMonitorSwitchConfigType
gf_monitors_config_get_switch_config (GfMonitorsConfig *config)
{
return config->switch_config;
}
void
gf_monitors_config_set_switch_config (GfMonitorsConfig *config,
GfMonitorSwitchConfigType switch_config)
{
config->switch_config = switch_config;
}
guint
gf_monitors_config_key_hash (gconstpointer data)
{
......
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