Remove monitor migration support from v1 monitors.xml format

We'll introduce some new migration code with the next few commits to introduce
a layout_mode property in monitors.xml. This will be significantly easier
without keeping around the old monitor migration code, so drop it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
This commit is contained in:
Jonas Dreßler
2024-02-15 23:33:12 +01:00
committed by Marge Bot
parent 4105827254
commit de56634fd0
27 changed files with 10 additions and 1298 deletions

View File

@ -23,7 +23,6 @@
#include "backends/meta-monitor-config-manager.h"
#include "backends/meta-backend-private.h"
#include "backends/meta-monitor-config-migration.h"
#include "backends/meta-monitor-config-store.h"
#include "backends/meta-monitor-manager-private.h"
#include "backends/meta-output.h"
@ -506,7 +505,6 @@ meta_monitor_config_manager_get_stored (MetaMonitorConfigManager *config_manager
MetaMonitorManager *monitor_manager = config_manager->monitor_manager;
MetaMonitorsConfigKey *config_key;
MetaMonitorsConfig *config;
GError *error = NULL;
config_key =
meta_create_monitors_config_key_for_current_state (monitor_manager);
@ -517,22 +515,6 @@ meta_monitor_config_manager_get_stored (MetaMonitorConfigManager *config_manager
config_key);
meta_monitors_config_key_free (config_key);
if (!config)
return NULL;
if (config->flags & META_MONITORS_CONFIG_FLAG_MIGRATED)
{
if (!meta_finish_monitors_config_migration (monitor_manager, config,
&error))
{
g_warning ("Failed to finish monitors config migration: %s",
error->message);
g_error_free (error);
meta_monitor_config_store_remove (config_manager->config_store, config);
return NULL;
}
}
return config;
}

View File

@ -54,8 +54,7 @@ typedef struct _MetaMonitorsConfigKey
enum _MetaMonitorsConfigFlag
{
META_MONITORS_CONFIG_FLAG_NONE = 0,
META_MONITORS_CONFIG_FLAG_MIGRATED = (1 << 0),
META_MONITORS_CONFIG_FLAG_SYSTEM_CONFIG = (1 << 1),
META_MONITORS_CONFIG_FLAG_SYSTEM_CONFIG = (1 << 0),
};
struct _MetaMonitorsConfig

View File

@ -1,36 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2017 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 "backends/meta-monitor-manager-private.h"
META_EXPORT_TEST
gboolean meta_migrate_old_monitors_config (MetaMonitorConfigStore *config_store,
GFile *in_file,
GError **error);
META_EXPORT_TEST
gboolean meta_migrate_old_user_monitors_config (MetaMonitorConfigStore *config_store,
GError **error);
META_EXPORT_TEST
gboolean meta_finish_monitors_config_migration (MetaMonitorManager *monitor_manager,
MetaMonitorsConfig *config,
GError **error);

View File

@ -25,7 +25,6 @@
#include <string.h>
#include "backends/meta-monitor-config-manager.h"
#include "backends/meta-monitor-config-migration.h"
#define MONITORS_CONFIG_XML_FORMAT_VERSION 2
@ -126,24 +125,12 @@ struct _MetaMonitorConfigStore
MetaMonitorConfigPolicy policy;
};
#define META_MONITOR_CONFIG_STORE_ERROR (meta_monitor_config_store_error_quark ())
static GQuark meta_monitor_config_store_error_quark (void);
enum
{
META_MONITOR_CONFIG_STORE_ERROR_NEEDS_MIGRATION
};
G_DEFINE_QUARK (meta-monitor-config-store-error-quark,
meta_monitor_config_store_error)
typedef enum
{
STATE_INITIAL,
STATE_UNKNOWN,
STATE_MONITORS,
STATE_CONFIGURATION,
STATE_MIGRATED,
STATE_LOGICAL_MONITOR,
STATE_LOGICAL_MONITOR_X,
STATE_LOGICAL_MONITOR_Y,
@ -185,7 +172,6 @@ typedef struct
ParserState monitor_spec_parent_state;
gboolean current_was_migrated;
GList *current_logical_monitor_configs;
MetaMonitorSpec *current_monitor_spec;
gboolean current_transform_flipped;
@ -277,15 +263,6 @@ handle_start_element (GMarkupParseContext *context,
"Missing config file format version");
}
if (g_str_equal (version, "1"))
{
g_set_error_literal (error,
META_MONITOR_CONFIG_STORE_ERROR,
META_MONITOR_CONFIG_STORE_ERROR_NEEDS_MIGRATION,
"monitors.xml has the old format");
return;
}
if (!g_str_equal (version, QUOTE (MONITORS_CONFIG_XML_FORMAT_VERSION)))
{
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
@ -302,7 +279,6 @@ handle_start_element (GMarkupParseContext *context,
if (g_str_equal (element_name, "configuration"))
{
parser->state = STATE_CONFIGURATION;
parser->current_was_migrated = FALSE;
}
else if (g_str_equal (element_name, "policy"))
{
@ -343,12 +319,6 @@ handle_start_element (GMarkupParseContext *context,
parser->state = STATE_LOGICAL_MONITOR;
}
else if (g_str_equal (element_name, "migrated"))
{
parser->current_was_migrated = TRUE;
parser->state = STATE_MIGRATED;
}
else if (g_str_equal (element_name, "disabled"))
{
parser->state = STATE_DISABLED;
@ -362,13 +332,6 @@ handle_start_element (GMarkupParseContext *context,
return;
}
case STATE_MIGRATED:
{
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT,
"Unexpected element '%s'", element_name);
return;
}
case STATE_LOGICAL_MONITOR:
{
if (g_str_equal (element_name, "x"))
@ -909,9 +872,7 @@ handle_end_element (GMarkupParseContext *context,
g_assert (g_str_equal (element_name, "logicalmonitor"));
if (parser->current_was_migrated)
logical_monitor_config->scale = -1;
else if (logical_monitor_config->scale == 0)
if (logical_monitor_config->scale == 0)
logical_monitor_config->scale = 1;
parser->current_logical_monitor_configs =
@ -923,14 +884,6 @@ handle_end_element (GMarkupParseContext *context,
return;
}
case STATE_MIGRATED:
{
g_assert (g_str_equal (element_name, "migrated"));
parser->state = STATE_CONFIGURATION;
return;
}
case STATE_DISABLED:
{
g_assert (g_str_equal (element_name, "disabled"));
@ -949,11 +902,7 @@ handle_end_element (GMarkupParseContext *context,
g_assert (g_str_equal (element_name, "configuration"));
if (parser->current_was_migrated)
layout_mode = META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL;
else
layout_mode =
meta_monitor_manager_get_default_layout_mode (store->monitor_manager);
layout_mode = meta_monitor_manager_get_default_layout_mode (store->monitor_manager);
for (l = parser->current_logical_monitor_configs; l; l = l->next)
{
@ -971,9 +920,6 @@ handle_end_element (GMarkupParseContext *context,
return;
}
if (parser->current_was_migrated)
config_flags |= META_MONITORS_CONFIG_FLAG_MIGRATED;
config_flags |= parser->extra_config_flags;
config =
@ -1213,7 +1159,6 @@ handle_text (GMarkupParseContext *context,
case STATE_INITIAL:
case STATE_MONITORS:
case STATE_CONFIGURATION:
case STATE_MIGRATED:
case STATE_LOGICAL_MONITOR:
case STATE_MONITOR:
case STATE_MONITOR_SPEC:
@ -1711,7 +1656,6 @@ append_logical_monitor_xml (GString *buffer,
logical_monitor_config->layout.y);
g_ascii_dtostr (scale_str, G_ASCII_DTOSTR_BUF_SIZE,
logical_monitor_config->scale);
if ((config->flags & META_MONITORS_CONFIG_FLAG_MIGRATED) == 0)
g_string_append_printf (buffer, " <scale>%s</scale>\n",
scale_str);
if (logical_monitor_config->is_primary)
@ -1744,9 +1688,6 @@ generate_config_xml (MetaMonitorConfigStore *config_store)
g_string_append (buffer, " <configuration>\n");
if (config->flags & META_MONITORS_CONFIG_FLAG_MIGRATED)
g_string_append (buffer, " <migrated/>\n");
for (l = config->logical_monitor_configs; l; l = l->next)
{
MetaLogicalMonitorConfig *logical_monitor_config = l->data;
@ -2133,14 +2074,6 @@ meta_monitor_config_store_reset (MetaMonitorConfigStore *config_store)
&system_configs,
&error))
{
if (g_error_matches (error,
META_MONITOR_CONFIG_STORE_ERROR,
META_MONITOR_CONFIG_STORE_ERROR_NEEDS_MIGRATION))
g_warning ("System monitor configuration file (%s) is "
"incompatible; ask your administrator to migrate "
"the system monitor configuration.",
system_file_path);
else
g_warning ("Failed to read monitors config file '%s': %s",
system_file_path, error->message);
g_clear_error (&error);
@ -2160,26 +2093,12 @@ meta_monitor_config_store_reset (MetaMonitorConfigStore *config_store)
META_MONITORS_CONFIG_FLAG_NONE,
&user_configs,
&error))
{
if (error->domain == META_MONITOR_CONFIG_STORE_ERROR &&
error->code == META_MONITOR_CONFIG_STORE_ERROR_NEEDS_MIGRATION)
{
g_clear_error (&error);
if (!meta_migrate_old_user_monitors_config (config_store, &error))
{
g_warning ("Failed to migrate old monitors config file: %s",
error->message);
g_error_free (error);
}
}
else
{
g_warning ("Failed to read monitors config file '%s': %s",
user_file_path, error->message);
g_error_free (error);
}
}
}
if (config_store->has_stores_policy)
{

View File

@ -646,9 +646,6 @@ meta_monitor_manager_apply_monitors_config (MetaMonitorManager *manager,
MetaMonitorManagerClass *manager_class =
META_MONITOR_MANAGER_GET_CLASS (manager);
g_assert (!config ||
!(config->flags & META_MONITORS_CONFIG_FLAG_MIGRATED));
if (!manager_class->apply_monitors_config (manager, config, method, error))
return FALSE;

View File

@ -250,8 +250,6 @@ mutter_sources = [
'backends/meta-monitor.c',
'backends/meta-monitor-config-manager.c',
'backends/meta-monitor-config-manager.h',
'backends/meta-monitor-config-migration.c',
'backends/meta-monitor-config-migration.h',
'backends/meta-monitor-config-store.c',
'backends/meta-monitor-config-store.h',
'backends/meta-monitor.h',

View File

@ -247,8 +247,6 @@ test_cases += [
'unit-tests.c',
'boxes-tests.c',
'boxes-tests.h',
'monitor-config-migration-unit-tests.c',
'monitor-config-migration-unit-tests.h',
'monitor-store-unit-tests.c',
'monitor-store-unit-tests.h',
'monitor-transform-tests.c',

View File

@ -1,78 +0,0 @@
<monitors version="2">
<configuration>
<migrated/>
<logicalmonitor>
<x>0</x>
<y>0</y>
<monitor>
<monitorspec>
<connector>HDMI-1</connector>
<vendor>DEL</vendor>
<product>DELL P2415Q</product>
<serial>GTTPW67P0WFB</serial>
</monitorspec>
<mode>
<width>3840</width>
<height>2160</height>
<rate>29.981</rate>
</mode>
</monitor>
</logicalmonitor>
<logicalmonitor>
<x>3840</x>
<y>0</y>
<primary>yes</primary>
<monitor>
<monitorspec>
<connector>eDP-1</connector>
<vendor>AUO</vendor>
<product>0x123d</product>
<serial>0x00000000</serial>
</monitorspec>
<mode>
<width>1920</width>
<height>1080</height>
<rate>60.050</rate>
</mode>
</monitor>
</logicalmonitor>
</configuration>
<configuration>
<migrated/>
<logicalmonitor>
<x>1920</x>
<y>0</y>
<monitor>
<monitorspec>
<connector>DP-2</connector>
<vendor>ACI</vendor>
<product>VX239</product>
<serial>ECLMRS004144</serial>
</monitorspec>
<mode>
<width>1920</width>
<height>1080</height>
<rate>60.000</rate>
</mode>
</monitor>
</logicalmonitor>
<logicalmonitor>
<x>0</x>
<y>0</y>
<primary>yes</primary>
<monitor>
<monitorspec>
<connector>eDP-1</connector>
<vendor>AUO</vendor>
<product>0x123d</product>
<serial>0x00000000</serial>
</monitorspec>
<mode>
<width>1920</width>
<height>1080</height>
<rate>60.049</rate>
</mode>
</monitor>
</logicalmonitor>
</configuration>
</monitors>

View File

@ -1,72 +0,0 @@
<monitors version="1">
<configuration>
<clone>no</clone>
<output name="HDMI-1">
<vendor>DEL</vendor>
<product>DELL P2415Q</product>
<serial>GTTPW67P0WFB</serial>
<width>3840</width>
<height>2160</height>
<rate>29.981103897094727</rate>
<x>0</x>
<y>0</y>
<rotation>normal</rotation>
<reflect_x>no</reflect_x>
<reflect_y>no</reflect_y>
<primary>no</primary>
<presentation>no</presentation>
<underscanning>no</underscanning>
</output>
<output name="eDP-1">
<vendor>AUO</vendor>
<product>0x123d</product>
<serial>0x00000000</serial>
<width>1920</width>
<height>1080</height>
<rate>60.049972534179688</rate>
<x>3840</x>
<y>0</y>
<rotation>normal</rotation>
<reflect_x>no</reflect_x>
<reflect_y>no</reflect_y>
<primary>yes</primary>
<presentation>no</presentation>
<underscanning>no</underscanning>
</output>
</configuration>
<configuration>
<clone>no</clone>
<output name="DP-2">
<vendor>ACI</vendor>
<product>VX239</product>
<serial>ECLMRS004144</serial>
<width>1920</width>
<height>1080</height>
<rate>60</rate>
<x>1920</x>
<y>0</y>
<rotation>normal</rotation>
<reflect_x>no</reflect_x>
<reflect_y>no</reflect_y>
<primary>no</primary>
<presentation>no</presentation>
<underscanning>no</underscanning>
</output>
<output name="eDP-1">
<vendor>AUO</vendor>
<product>0x123d</product>
<serial>0x00000000</serial>
<width>1920</width>
<height>1080</height>
<rate>60.049468994140625</rate>
<x>0</x>
<y>0</y>
<rotation>normal</rotation>
<reflect_x>no</reflect_x>
<reflect_y>no</reflect_y>
<primary>yes</primary>
<presentation>no</presentation>
<underscanning>no</underscanning>
</output>
</configuration>
</monitors>

View File

@ -1,44 +0,0 @@
<monitors version="2">
<configuration>
<migrated/>
<logicalmonitor>
<x>0</x>
<y>0</y>
<transform>
<rotation>left</rotation>
<flipped>no</flipped>
</transform>
<monitor>
<monitorspec>
<connector>HDMI-1</connector>
<vendor>DEL</vendor>
<product>DELL P2415Q</product>
<serial>GTTPW67P0WFB</serial>
</monitorspec>
<mode>
<width>3840</width>
<height>2160</height>
<rate>29.981</rate>
</mode>
</monitor>
</logicalmonitor>
<logicalmonitor>
<x>2160</x>
<y>0</y>
<primary>yes</primary>
<monitor>
<monitorspec>
<connector>eDP-1</connector>
<vendor>AUO</vendor>
<product>0x123d</product>
<serial>0x00000000</serial>
</monitorspec>
<mode>
<width>1920</width>
<height>1080</height>
<rate>60.050</rate>
</mode>
</monitor>
</logicalmonitor>
</configuration>
</monitors>

View File

@ -1,37 +0,0 @@
<monitors version="1">
<configuration>
<clone>no</clone>
<output name="HDMI-1">
<vendor>DEL</vendor>
<product>DELL P2415Q</product>
<serial>GTTPW67P0WFB</serial>
<width>2160</width>
<height>3840</height>
<rate>29.981103897094727</rate>
<x>0</x>
<y>0</y>
<rotation>left</rotation>
<reflect_x>no</reflect_x>
<reflect_y>no</reflect_y>
<primary>no</primary>
<presentation>no</presentation>
<underscanning>no</underscanning>
</output>
<output name="eDP-1">
<vendor>AUO</vendor>
<product>0x123d</product>
<serial>0x00000000</serial>
<width>1920</width>
<height>1080</height>
<rate>60.049972534179688</rate>
<x>2160</x>
<y>0</y>
<rotation>normal</rotation>
<reflect_x>no</reflect_x>
<reflect_y>no</reflect_y>
<primary>yes</primary>
<presentation>no</presentation>
<underscanning>no</underscanning>
</output>
</configuration>
</monitors>

View File

@ -1,31 +0,0 @@
<monitors version="2">
<configuration>
<logicalmonitor>
<x>0</x>
<y>0</y>
<scale>1</scale>
<primary>yes</primary>
<monitor>
<monitorspec>
<connector>DP-1</connector>
<vendor>MetaProduct&apos;s Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
<mode>
<width>800</width>
<height>600</height>
<rate>60</rate>
</mode>
</monitor>
</logicalmonitor>
<disabled>
<monitorspec>
<connector>DP-2</connector>
<vendor>MetaProduct&apos;s Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x654321</serial>
</monitorspec>
</disabled>
</configuration>
</monitors>

View File

@ -1,31 +0,0 @@
<monitors version="2">
<configuration>
<migrated/>
<logicalmonitor>
<x>0</x>
<y>0</y>
<primary>yes</primary>
<monitor>
<monitorspec>
<connector>DP-1</connector>
<vendor>MetaProduct&apos;s Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
<mode>
<width>800</width>
<height>600</height>
<rate>60.000</rate>
</mode>
</monitor>
</logicalmonitor>
<disabled>
<monitorspec>
<connector>DP-2</connector>
<vendor>MetaProduct&apos;s Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x654321</serial>
</monitorspec>
</disabled>
</configuration>
</monitors>

View File

@ -1,26 +0,0 @@
<monitors version="1">
<configuration>
<clone>no</clone>
<output name="DP-1">
<vendor>MetaProduct&apos;s Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
<width>800</width>
<height>600</height>
<rate>60</rate>
<x>0</x>
<y>0</y>
<rotation>normal</rotation>
<reflect_x>no</reflect_x>
<reflect_y>no</reflect_y>
<primary>yes</primary>
<presentation>no</presentation>
<underscanning>no</underscanning>
</output>
<output name="DP-2">
<vendor>MetaProduct&apos;s Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x654321</serial>
</output>
</configuration>
</monitors>

View File

@ -1,27 +0,0 @@
<monitors version="2">
<configuration>
<logicalmonitor>
<x>0</x>
<y>0</y>
<scale>1</scale>
<primary>yes</primary>
<transform>
<rotation>right</rotation>
<flipped>no</flipped>
</transform>
<monitor>
<monitorspec>
<connector>DP-1</connector>
<vendor>MetaProduct&apos;s Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
<mode>
<width>800</width>
<height>600</height>
<rate>60.000</rate>
</mode>
</monitor>
</logicalmonitor>
</configuration>
</monitors>

View File

@ -1,27 +0,0 @@
<monitors version="2">
<configuration>
<migrated/>
<logicalmonitor>
<x>0</x>
<y>0</y>
<primary>yes</primary>
<transform>
<rotation>right</rotation>
<flipped>no</flipped>
</transform>
<monitor>
<monitorspec>
<connector>DP-1</connector>
<vendor>MetaProduct&apos;s Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
<mode>
<width>800</width>
<height>600</height>
<rate>60.000</rate>
</mode>
</monitor>
</logicalmonitor>
</configuration>
</monitors>

View File

@ -1,21 +0,0 @@
<monitors version="1">
<configuration>
<clone>no</clone>
<output name="DP-1">
<vendor>MetaProduct&apos;s Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
<width>600</width>
<height>800</height>
<rate>60</rate>
<x>0</x>
<y>0</y>
<rotation>right</rotation>
<reflect_x>no</reflect_x>
<reflect_y>no</reflect_y>
<primary>yes</primary>
<presentation>no</presentation>
<underscanning>no</underscanning>
</output>
</configuration>
</monitors>

View File

@ -1,23 +0,0 @@
<monitors version="2">
<configuration>
<migrated/>
<logicalmonitor>
<x>0</x>
<y>0</y>
<primary>yes</primary>
<monitor>
<monitorspec>
<connector>DP-1</connector>
<vendor>DEL</vendor>
<product>DELL P2415Q</product>
<serial>GTTPW67P0WFB</serial>
</monitorspec>
<mode>
<width>3840</width>
<height>2160</height>
<rate>60.000</rate>
</mode>
</monitor>
</logicalmonitor>
</configuration>
</monitors>

View File

@ -1,37 +0,0 @@
<monitors version="1">
<configuration>
<clone>no</clone>
<output name="DP-1">
<vendor>DEL</vendor>
<product>DELL P2415Q</product>
<serial>GTTPW67P0WFB</serial>
<width>1920</width>
<height>2160</height>
<rate>60</rate>
<x>0</x>
<y>0</y>
<rotation>normal</rotation>
<reflect_x>no</reflect_x>
<reflect_y>no</reflect_y>
<primary>yes</primary>
<presentation>no</presentation>
<underscanning>no</underscanning>
</output>
<output name="DP-2">
<vendor>DEL</vendor>
<product>DELL P2415Q</product>
<serial>GTTPW67P0WFB</serial>
<width>1920</width>
<height>2160</height>
<rate>60</rate>
<x>1920</x>
<y>0</y>
<rotation>normal</rotation>
<reflect_x>no</reflect_x>
<reflect_y>no</reflect_y>
<primary>yes</primary>
<presentation>no</presentation>
<underscanning>no</underscanning>
</output>
</configuration>
</monitors>

View File

@ -1,2 +0,0 @@
<monitors version="2">
</monitors>

View File

@ -1,27 +0,0 @@
<monitors version="2">
<configuration>
<logicalmonitor>
<x>0</x>
<y>0</y>
<scale>1</scale>
<primary>yes</primary>
<transform>
<rotation>left</rotation>
<flipped>no</flipped>
</transform>
<monitor>
<monitorspec>
<connector>DP-1</connector>
<vendor>MetaProduct&apos;s Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
<mode>
<width>800</width>
<height>600</height>
<rate>60.001</rate>
</mode>
</monitor>
</logicalmonitor>
</configuration>
</monitors>

View File

@ -1,27 +0,0 @@
<monitors version="2">
<configuration>
<migrated/>
<logicalmonitor>
<x>0</x>
<y>0</y>
<primary>yes</primary>
<transform>
<rotation>left</rotation>
<flipped>no</flipped>
</transform>
<monitor>
<monitorspec>
<connector>DP-1</connector>
<vendor>MetaProduct&apos;s Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
<mode>
<width>800</width>
<height>600</height>
<rate>60.001</rate>
</mode>
</monitor>
</logicalmonitor>
</configuration>
</monitors>

View File

@ -1,21 +0,0 @@
<monitors version="1">
<configuration>
<clone>no</clone>
<output name="DP-1">
<vendor>MetaProduct&apos;s Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
<width>600</width>
<height>800</height>
<rate>60.000801086425781</rate>
<x>0</x>
<y>0</y>
<rotation>left</rotation>
<reflect_x>no</reflect_x>
<reflect_y>no</reflect_y>
<primary>yes</primary>
<presentation>no</presentation>
<underscanning>no</underscanning>
</output>
</configuration>
</monitors>

View File

@ -1,138 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2017 Red Hat, Inc.
*
* 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 "tests/monitor-config-migration-unit-tests.h"
#include <glib.h>
#include <gio/gio.h>
#include "backends/meta-backend-private.h"
#include "backends/meta-monitor-config-manager.h"
#include "backends/meta-monitor-config-store.h"
#include "backends/meta-monitor-manager-private.h"
#include "backends/meta-monitor-config-migration.h"
#include "tests/meta-monitor-test-utils.h"
#include "tests/unit-tests.h"
static void
test_migration (const char *old_config,
const char *new_config)
{
MetaBackend *backend = meta_context_get_backend (test_context);
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);
GError *error = NULL;
const char *old_config_path;
g_autoptr (GFile) old_config_file = NULL;
g_autofree char *migrated_path = NULL;
const char *expected_path;
g_autofree char *migrated_data = NULL;
g_autofree char *expected_data = NULL;
g_autoptr (GFile) migrated_file = NULL;
migrated_path = g_build_filename (g_get_tmp_dir (),
"test-migrated-monitors.xml",
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);
old_config_path = g_test_get_filename (G_TEST_DIST, "tests", "migration",
old_config, NULL);
old_config_file = g_file_new_for_path (old_config_path);
if (!meta_migrate_old_monitors_config (config_store,
old_config_file,
&error))
g_error ("Failed to migrate config: %s", error->message);
expected_path = g_test_get_filename (G_TEST_DIST, "tests", "migration",
new_config, NULL);
expected_data = meta_read_file (expected_path);
migrated_data = meta_read_file (migrated_path);
g_assert_nonnull (expected_data);
g_assert_nonnull (migrated_data);
g_assert_cmpstr (expected_data, ==, migrated_data);
migrated_file = g_file_new_for_path (migrated_path);
if (!g_file_delete (migrated_file, NULL, &error))
g_error ("Failed to remove test data output file: %s", error->message);
}
static void
meta_test_monitor_config_migration_basic (void)
{
test_migration ("basic-old.xml", "basic-new.xml");
}
static void
meta_test_monitor_config_migration_rotated (void)
{
test_migration ("rotated-old.xml", "rotated-new.xml");
}
static void
meta_test_monitor_config_migration_tiled (void)
{
test_migration ("tiled-old.xml", "tiled-new.xml");
}
static void
meta_test_monitor_config_migration_first_rotated (void)
{
test_migration ("first-rotated-old.xml", "first-rotated-new.xml");
}
static void
meta_test_monitor_config_migration_oneoff (void)
{
test_migration ("oneoff-old.xml", "oneoff-new.xml");
}
static void
meta_test_monitor_config_migration_wiggle (void)
{
test_migration ("wiggle-old.xml", "wiggle-new.xml");
}
void
init_monitor_config_migration_tests (void)
{
g_test_add_func ("/backends/monitor-config-migration/basic",
meta_test_monitor_config_migration_basic);
g_test_add_func ("/backends/monitor-config-migration/rotated",
meta_test_monitor_config_migration_rotated);
g_test_add_func ("/backends/monitor-config-migration/tiled",
meta_test_monitor_config_migration_tiled);
g_test_add_func ("/backends/monitor-config-migration/first-rotated",
meta_test_monitor_config_migration_first_rotated);
g_test_add_func ("/backends/monitor-config-migration/oneoff",
meta_test_monitor_config_migration_oneoff);
g_test_add_func ("/backends/monitor-config-migration/wiggle",
meta_test_monitor_config_migration_wiggle);
}

View File

@ -1,22 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2017 Red Hat, Inc.
*
* 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
void init_monitor_config_migration_tests (void);

View File

@ -23,7 +23,6 @@
#include "backends/meta-crtc.h"
#include "backends/meta-logical-monitor.h"
#include "backends/meta-monitor.h"
#include "backends/meta-monitor-config-migration.h"
#include "backends/meta-monitor-config-store.h"
#include "backends/meta-output.h"
#include "core/window-private.h"
@ -8418,303 +8417,6 @@ meta_test_monitor_custom_lid_switch_config (void)
check_monitor_test_clients_state ();
}
static void
meta_test_monitor_migrated_rotated (void)
{
MonitorTestCase test_case = {
.setup = {
.modes = {
{
.width = 800,
.height = 600,
.refresh_rate = 60.0
}
},
.n_modes = 1,
.outputs = {
{
.crtc = -1,
.modes = { 0 },
.n_modes = 1,
.preferred_mode = 0,
.possible_crtcs = { 0 },
.n_possible_crtcs = 1,
.width_mm = 222,
.height_mm = 125,
.serial = "0x123456",
}
},
.n_outputs = 1,
.crtcs = {
{
.current_mode = -1
}
},
.n_crtcs = 1
},
.expect = {
.monitors = {
{
.outputs = { 0 },
.n_outputs = 1,
.modes = {
{
.width = 800,
.height = 600,
.refresh_rate = 60.0,
.crtc_modes = {
{
.output = 0,
.crtc_mode = 0
}
}
}
},
.n_modes = 1,
.current_mode = 0,
.width_mm = 222,
.height_mm = 125
}
},
.n_monitors = 1,
.logical_monitors = {
{
.monitors = { 0 },
.n_monitors = 1,
.layout = { .x = 0, .y = 0, .width = 600, .height = 800 },
.scale = 1,
.transform = MTK_MONITOR_TRANSFORM_270
},
},
.n_logical_monitors = 1,
.primary_logical_monitor = 0,
.n_outputs = 1,
.crtcs = {
{
.current_mode = 0,
.transform = MTK_MONITOR_TRANSFORM_270
}
},
.n_crtcs = 1,
.screen_width = 600,
.screen_height = 800,
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_context_get_backend (test_context);
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);
g_autofree char *migrated_path = NULL;
const char *old_config_path;
g_autoptr (GFile) old_config_file = NULL;
GError *error = NULL;
const char *expected_path;
g_autofree char *migrated_data = NULL;
g_autofree char *expected_data = NULL;
g_autoptr (GFile) migrated_file = NULL;
test_setup = meta_create_monitor_test_setup (test_backend,
&test_case.setup,
MONITOR_TEST_FLAG_NONE);
migrated_path = g_build_filename (g_get_tmp_dir (),
"test-finished-migrated-monitors.xml",
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 files: %s", error->message);
old_config_path = g_test_get_filename (G_TEST_DIST,
"tests", "migration",
"rotated-old.xml",
NULL);
old_config_file = g_file_new_for_path (old_config_path);
if (!meta_migrate_old_monitors_config (config_store,
old_config_file,
&error))
g_error ("Failed to migrate config: %s", error->message);
emulate_hotplug (test_setup);
META_TEST_LOG_CALL ("Checking monitor configuration",
meta_check_monitor_configuration (test_context,
&test_case.expect));
check_monitor_test_clients_state ();
expected_path = g_test_get_filename (G_TEST_DIST,
"tests", "migration",
"rotated-new-finished.xml",
NULL);
expected_data = meta_read_file (expected_path);
migrated_data = meta_read_file (migrated_path);
g_assert_nonnull (expected_data);
g_assert_nonnull (migrated_data);
g_assert (strcmp (expected_data, migrated_data) == 0);
migrated_file = g_file_new_for_path (migrated_path);
if (!g_file_delete (migrated_file, NULL, &error))
g_error ("Failed to remove test data output file: %s", error->message);
}
static void
meta_test_monitor_migrated_wiggle_discard (void)
{
MonitorTestCase test_case = {
.setup = {
.modes = {
{
.width = 800,
.height = 600,
.refresh_rate = 59.0
}
},
.n_modes = 1,
.outputs = {
{
.crtc = -1,
.modes = { 0 },
.n_modes = 1,
.preferred_mode = 0,
.possible_crtcs = { 0 },
.n_possible_crtcs = 1,
.width_mm = 222,
.height_mm = 125,
.serial = "0x123456",
}
},
.n_outputs = 1,
.crtcs = {
{
.current_mode = -1
}
},
.n_crtcs = 1
},
.expect = {
.monitors = {
{
.outputs = { 0 },
.n_outputs = 1,
.modes = {
{
.width = 800,
.height = 600,
.refresh_rate = 59.0,
.crtc_modes = {
{
.output = 0,
.crtc_mode = 0
}
}
}
},
.n_modes = 1,
.current_mode = 0,
.width_mm = 222,
.height_mm = 125
}
},
.n_monitors = 1,
.logical_monitors = {
{
.monitors = { 0 },
.n_monitors = 1,
.layout = { .x = 0, .y = 0, .width = 800, .height = 600 },
.scale = 1,
.transform = MTK_MONITOR_TRANSFORM_NORMAL
},
},
.n_logical_monitors = 1,
.primary_logical_monitor = 0,
.n_outputs = 1,
.crtcs = {
{
.current_mode = 0,
}
},
.n_crtcs = 1,
.screen_width = 800,
.screen_height = 600,
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_context_get_backend (test_context);
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);
g_autofree char *migrated_path = NULL;
const char *old_config_path;
g_autoptr (GFile) old_config_file = NULL;
GError *error = NULL;
const char *expected_path;
g_autofree char *migrated_data = NULL;
g_autofree char *expected_data = NULL;
g_autoptr (GFile) migrated_file = NULL;
test_setup = meta_create_monitor_test_setup (test_backend,
&test_case.setup,
MONITOR_TEST_FLAG_NONE);
migrated_path = g_build_filename (g_get_tmp_dir (),
"test-finished-migrated-monitors.xml",
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 files: %s", error->message);
old_config_path = g_test_get_filename (G_TEST_DIST,
"tests", "migration",
"wiggle-old.xml",
NULL);
old_config_file = g_file_new_for_path (old_config_path);
if (!meta_migrate_old_monitors_config (config_store,
old_config_file,
&error))
g_error ("Failed to migrate config: %s", error->message);
g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
"Failed to finish monitors config migration: "
"Mode not available on monitor");
emulate_hotplug (test_setup);
g_test_assert_expected_messages ();
META_TEST_LOG_CALL ("Checking monitor configuration",
meta_check_monitor_configuration (test_context,
&test_case.expect));
check_monitor_test_clients_state ();
expected_path = g_test_get_filename (G_TEST_DIST,
"tests", "migration",
"wiggle-new-discarded.xml",
NULL);
expected_data = meta_read_file (expected_path);
migrated_data = meta_read_file (migrated_path);
g_assert_nonnull (expected_data);
g_assert_nonnull (migrated_data);
g_assert (strcmp (expected_data, migrated_data) == 0);
migrated_file = g_file_new_for_path (migrated_path);
if (!g_file_delete (migrated_file, NULL, &error))
g_error ("Failed to remove test data output file: %s", error->message);
}
static void
meta_test_monitor_custom_detached_groups (void)
{
@ -8868,153 +8570,6 @@ meta_test_monitor_wm_tiling (void)
meta_test_client_destroy (test_client);
}
static void
meta_test_monitor_migrated_wiggle (void)
{
MonitorTestCase test_case = {
.setup = {
.modes = {
{
.width = 800,
.height = 600,
.refresh_rate = 60.0
}
},
.n_modes = 1,
.outputs = {
{
.crtc = -1,
.modes = { 0 },
.n_modes = 1,
.preferred_mode = 0,
.possible_crtcs = { 0 },
.n_possible_crtcs = 1,
.width_mm = 222,
.height_mm = 125,
.serial = "0x123456",
}
},
.n_outputs = 1,
.crtcs = {
{
.current_mode = -1
}
},
.n_crtcs = 1
},
.expect = {
.monitors = {
{
.outputs = { 0 },
.n_outputs = 1,
.modes = {
{
.width = 800,
.height = 600,
.refresh_rate = 60.0,
.crtc_modes = {
{
.output = 0,
.crtc_mode = 0
}
}
}
},
.n_modes = 1,
.current_mode = 0,
.width_mm = 222,
.height_mm = 125
}
},
.n_monitors = 1,
.logical_monitors = {
{
.monitors = { 0 },
.n_monitors = 1,
.layout = { .x = 0, .y = 0, .width = 600, .height = 800 },
.scale = 1,
.transform = MTK_MONITOR_TRANSFORM_90
},
},
.n_logical_monitors = 1,
.primary_logical_monitor = 0,
.n_outputs = 1,
.crtcs = {
{
.current_mode = 0,
.transform = MTK_MONITOR_TRANSFORM_90
}
},
.n_crtcs = 1,
.screen_width = 600,
.screen_height = 800,
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_context_get_backend (test_context);
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);
g_autofree char *migrated_path = NULL;
const char *old_config_path;
g_autoptr (GFile) old_config_file = NULL;
GError *error = NULL;
const char *expected_path;
g_autofree char *migrated_data = NULL;
g_autofree char *expected_data = NULL;
g_autoptr (GFile) migrated_file = NULL;
test_setup = meta_create_monitor_test_setup (test_backend,
&test_case.setup,
MONITOR_TEST_FLAG_NONE);
migrated_path = g_build_filename (g_get_tmp_dir (),
"test-finished-migrated-monitors.xml",
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 files: %s", error->message);
old_config_path = g_test_get_filename (G_TEST_DIST,
"tests", "migration",
"wiggle-old.xml",
NULL);
old_config_file = g_file_new_for_path (old_config_path);
if (!meta_migrate_old_monitors_config (config_store,
old_config_file,
&error))
g_error ("Failed to migrate config: %s", error->message);
emulate_hotplug (test_setup);
META_TEST_LOG_CALL ("Checking monitor configuration",
meta_check_monitor_configuration (test_context,
&test_case.expect));
check_monitor_test_clients_state ();
expected_path = g_test_get_filename (G_TEST_DIST,
"tests", "migration",
"wiggle-new-finished.xml",
NULL);
expected_data = meta_read_file (expected_path);
migrated_data = meta_read_file (migrated_path);
g_assert_nonnull (expected_data);
g_assert_nonnull (migrated_data);
g_assert (strcmp (expected_data, migrated_data) == 0);
migrated_file = g_file_new_for_path (migrated_path);
if (!g_file_delete (migrated_file, NULL, &error))
g_error ("Failed to remove test data output file: %s", error->message);
}
static void
meta_test_monitor_supported_integer_scales (void)
{
@ -10105,13 +9660,6 @@ init_monitor_tests (void)
add_monitor_test ("/backends/monitor/custom/detached-groups",
meta_test_monitor_custom_detached_groups);
add_monitor_test ("/backends/monitor/migrated/rotated",
meta_test_monitor_migrated_rotated);
add_monitor_test ("/backends/monitor/migrated/wiggle",
meta_test_monitor_migrated_wiggle);
add_monitor_test ("/backends/monitor/migrated/wiggle-discard",
meta_test_monitor_migrated_wiggle_discard);
add_monitor_test ("/backends/monitor/wm/tiling",
meta_test_monitor_wm_tiling);

View File

@ -33,7 +33,6 @@
#include "meta/compositor.h"
#include "meta/meta-context.h"
#include "tests/boxes-tests.h"
#include "tests/monitor-config-migration-unit-tests.h"
#include "tests/monitor-store-unit-tests.h"
#include "tests/monitor-transform-tests.h"
#include "tests/meta-test-utils.h"
@ -208,7 +207,6 @@ init_tests (void)
meta_test_util_later_schedule_from_later);
init_monitor_store_tests ();
init_monitor_config_migration_tests ();
init_boxes_tests ();
init_monitor_transform_tests ();
init_orientation_manager_tests ();