monitor-config-manager: Move some things into common file for config utils
We'll need a few of those things from the monitor config store soon, also it's generally useful to have a prefix which makes it clear where functions are defined. So factor some things out into a new monitor-config-utils.c file. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
This commit is contained in:
parent
076b3664a3
commit
a203020c4b
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "backends/meta-backend-private.h"
|
#include "backends/meta-backend-private.h"
|
||||||
#include "backends/meta-monitor-config-store.h"
|
#include "backends/meta-monitor-config-store.h"
|
||||||
|
#include "backends/meta-monitor-config-utils.h"
|
||||||
#include "backends/meta-monitor-manager-private.h"
|
#include "backends/meta-monitor-manager-private.h"
|
||||||
#include "backends/meta-output.h"
|
#include "backends/meta-output.h"
|
||||||
#include "core/boxes-private.h"
|
#include "core/boxes-private.h"
|
||||||
@ -1008,58 +1009,6 @@ meta_monitor_config_manager_create_suggested (MetaMonitorConfigManager *config_m
|
|||||||
META_MONITORS_CONFIG_FLAG_NONE);
|
META_MONITORS_CONFIG_FLAG_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GList *
|
|
||||||
clone_monitor_config_list (GList *monitor_configs_in)
|
|
||||||
{
|
|
||||||
MetaMonitorConfig *monitor_config_in;
|
|
||||||
MetaMonitorConfig *monitor_config_out;
|
|
||||||
GList *monitor_configs_out = NULL;
|
|
||||||
GList *l;
|
|
||||||
|
|
||||||
for (l = monitor_configs_in; l; l = l->next)
|
|
||||||
{
|
|
||||||
monitor_config_in = l->data;
|
|
||||||
monitor_config_out = g_new0 (MetaMonitorConfig, 1);
|
|
||||||
*monitor_config_out = (MetaMonitorConfig) {
|
|
||||||
.monitor_spec = meta_monitor_spec_clone (monitor_config_in->monitor_spec),
|
|
||||||
.mode_spec = g_memdup2 (monitor_config_in->mode_spec,
|
|
||||||
sizeof (MetaMonitorModeSpec)),
|
|
||||||
.enable_underscanning = monitor_config_in->enable_underscanning,
|
|
||||||
.has_max_bpc = monitor_config_in->has_max_bpc,
|
|
||||||
.max_bpc = monitor_config_in->max_bpc
|
|
||||||
};
|
|
||||||
monitor_configs_out =
|
|
||||||
g_list_append (monitor_configs_out, monitor_config_out);
|
|
||||||
}
|
|
||||||
|
|
||||||
return monitor_configs_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
clone_logical_monitor_config_list (GList *logical_monitor_configs_in)
|
|
||||||
{
|
|
||||||
MetaLogicalMonitorConfig *logical_monitor_config_in;
|
|
||||||
MetaLogicalMonitorConfig *logical_monitor_config_out;
|
|
||||||
GList *logical_monitor_configs_out = NULL;
|
|
||||||
GList *l;
|
|
||||||
|
|
||||||
for (l = logical_monitor_configs_in; l; l = l->next)
|
|
||||||
{
|
|
||||||
logical_monitor_config_in = l->data;
|
|
||||||
|
|
||||||
logical_monitor_config_out =
|
|
||||||
g_memdup2 (logical_monitor_config_in,
|
|
||||||
sizeof (MetaLogicalMonitorConfig));
|
|
||||||
logical_monitor_config_out->monitor_configs =
|
|
||||||
clone_monitor_config_list (logical_monitor_config_in->monitor_configs);
|
|
||||||
|
|
||||||
logical_monitor_configs_out =
|
|
||||||
g_list_append (logical_monitor_configs_out, logical_monitor_config_out);
|
|
||||||
}
|
|
||||||
|
|
||||||
return logical_monitor_configs_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
static MetaLogicalMonitorConfig *
|
static MetaLogicalMonitorConfig *
|
||||||
find_logical_config_for_builtin_monitor (MetaMonitorConfigManager *config_manager,
|
find_logical_config_for_builtin_monitor (MetaMonitorConfigManager *config_manager,
|
||||||
GList *logical_monitor_configs)
|
GList *logical_monitor_configs)
|
||||||
@ -1141,7 +1090,7 @@ create_for_builtin_display_rotation (MetaMonitorConfigManager *config_manager,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
logical_monitor_configs =
|
logical_monitor_configs =
|
||||||
clone_logical_monitor_config_list (base_config->logical_monitor_configs);
|
meta_clone_logical_monitor_config_list (base_config->logical_monitor_configs);
|
||||||
logical_monitor_config =
|
logical_monitor_config =
|
||||||
find_logical_config_for_builtin_monitor (config_manager,
|
find_logical_config_for_builtin_monitor (config_manager,
|
||||||
logical_monitor_configs);
|
logical_monitor_configs);
|
||||||
|
@ -208,7 +208,6 @@ gboolean meta_verify_monitors_config (MetaMonitorsConfig *config,
|
|||||||
MetaMonitorManager *monitor_manager,
|
MetaMonitorManager *monitor_manager,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaMonitorConfig, meta_monitor_config_free)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaMonitorConfig, meta_monitor_config_free)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaLogicalMonitorConfig,
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaLogicalMonitorConfig,
|
||||||
meta_logical_monitor_config_free)
|
meta_logical_monitor_config_free)
|
||||||
|
78
src/backends/meta-monitor-config-utils.c
Normal file
78
src/backends/meta-monitor-config-utils.c
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Red Hat
|
||||||
|
* Copyright (c) 2018 DisplayLink (UK) Ltd.
|
||||||
|
*
|
||||||
|
* 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 the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "backends/meta-monitor-config-utils.h"
|
||||||
|
|
||||||
|
#include "backends/meta-backend-private.h"
|
||||||
|
#include "backends/meta-monitor-config-store.h"
|
||||||
|
#include "backends/meta-monitor-manager-private.h"
|
||||||
|
#include "meta/meta-monitor-manager.h"
|
||||||
|
|
||||||
|
static GList *
|
||||||
|
meta_clone_monitor_config_list (GList *monitor_configs_in)
|
||||||
|
{
|
||||||
|
MetaMonitorConfig *monitor_config_in;
|
||||||
|
MetaMonitorConfig *monitor_config_out;
|
||||||
|
GList *monitor_configs_out = NULL;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
for (l = monitor_configs_in; l; l = l->next)
|
||||||
|
{
|
||||||
|
monitor_config_in = l->data;
|
||||||
|
monitor_config_out = g_new0 (MetaMonitorConfig, 1);
|
||||||
|
*monitor_config_out = (MetaMonitorConfig) {
|
||||||
|
.monitor_spec = meta_monitor_spec_clone (monitor_config_in->monitor_spec),
|
||||||
|
.mode_spec = g_memdup2 (monitor_config_in->mode_spec,
|
||||||
|
sizeof (MetaMonitorModeSpec)),
|
||||||
|
.enable_underscanning = monitor_config_in->enable_underscanning,
|
||||||
|
.has_max_bpc = monitor_config_in->has_max_bpc,
|
||||||
|
.max_bpc = monitor_config_in->max_bpc
|
||||||
|
};
|
||||||
|
monitor_configs_out =
|
||||||
|
g_list_append (monitor_configs_out, monitor_config_out);
|
||||||
|
}
|
||||||
|
|
||||||
|
return monitor_configs_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
GList *
|
||||||
|
meta_clone_logical_monitor_config_list (GList *logical_monitor_configs_in)
|
||||||
|
{
|
||||||
|
MetaLogicalMonitorConfig *logical_monitor_config_in;
|
||||||
|
MetaLogicalMonitorConfig *logical_monitor_config_out;
|
||||||
|
GList *logical_monitor_configs_out = NULL;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
for (l = logical_monitor_configs_in; l; l = l->next)
|
||||||
|
{
|
||||||
|
logical_monitor_config_in = l->data;
|
||||||
|
|
||||||
|
logical_monitor_config_out =
|
||||||
|
g_memdup2 (logical_monitor_config_in,
|
||||||
|
sizeof (MetaLogicalMonitorConfig));
|
||||||
|
logical_monitor_config_out->monitor_configs =
|
||||||
|
meta_clone_monitor_config_list (logical_monitor_config_in->monitor_configs);
|
||||||
|
|
||||||
|
logical_monitor_configs_out =
|
||||||
|
g_list_append (logical_monitor_configs_out, logical_monitor_config_out);
|
||||||
|
}
|
||||||
|
|
||||||
|
return logical_monitor_configs_out;
|
||||||
|
}
|
22
src/backends/meta-monitor-config-utils.h
Normal file
22
src/backends/meta-monitor-config-utils.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Red Hat
|
||||||
|
*
|
||||||
|
* 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 the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
GList * meta_clone_logical_monitor_config_list (GList *logical_monitor_configs_in);
|
@ -252,6 +252,8 @@ mutter_sources = [
|
|||||||
'backends/meta-monitor-config-manager.h',
|
'backends/meta-monitor-config-manager.h',
|
||||||
'backends/meta-monitor-config-store.c',
|
'backends/meta-monitor-config-store.c',
|
||||||
'backends/meta-monitor-config-store.h',
|
'backends/meta-monitor-config-store.h',
|
||||||
|
'backends/meta-monitor-config-utils.c',
|
||||||
|
'backends/meta-monitor-config-utils.h',
|
||||||
'backends/meta-monitor.h',
|
'backends/meta-monitor.h',
|
||||||
'backends/meta-monitor-manager.c',
|
'backends/meta-monitor-manager.c',
|
||||||
'backends/meta-monitor-manager-dummy.c',
|
'backends/meta-monitor-manager-dummy.c',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user