|
|
79df40 |
From 4020cddaf71e8868c03f0136964a6429af313b54 Mon Sep 17 00:00:00 2001
|
|
|
79df40 |
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
|
|
|
79df40 |
Date: Wed, 24 Jul 2019 15:40:06 +0200
|
|
|
79df40 |
Subject: [PATCH 20/28] monitor: Free the existing mode if replacing it
|
|
|
79df40 |
|
|
|
79df40 |
When adding a mode and replacing it, we need to free it after that we've added
|
|
|
79df40 |
it to the table. Since the mode_ids table has not ownership on the mode id or
|
|
|
79df40 |
on the mode itself, we need to free it once replaced.
|
|
|
79df40 |
|
|
|
79df40 |
https://gitlab.gnome.org/GNOME/mutter/merge_requests/682
|
|
|
79df40 |
---
|
|
|
79df40 |
src/backends/meta-monitor.c | 3 +++
|
|
|
79df40 |
1 file changed, 3 insertions(+)
|
|
|
79df40 |
|
|
|
79df40 |
diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c
|
|
|
79df40 |
index 9a412a612..ec583aa13 100644
|
|
|
79df40 |
--- a/src/backends/meta-monitor.c
|
|
|
79df40 |
+++ b/src/backends/meta-monitor.c
|
|
|
79df40 |
@@ -437,60 +437,63 @@ generate_mode_id (MetaMonitorModeSpec *monitor_mode_spec)
|
|
|
79df40 |
is_interlaced = !!(monitor_mode_spec->flags & META_CRTC_MODE_FLAG_INTERLACE);
|
|
|
79df40 |
g_ascii_dtostr (refresh_rate_str, G_ASCII_DTOSTR_BUF_SIZE,
|
|
|
79df40 |
monitor_mode_spec->refresh_rate);
|
|
|
79df40 |
|
|
|
79df40 |
return g_strdup_printf ("%dx%d%s@%s",
|
|
|
79df40 |
monitor_mode_spec->width,
|
|
|
79df40 |
monitor_mode_spec->height,
|
|
|
79df40 |
is_interlaced ? "i" : "",
|
|
|
79df40 |
refresh_rate_str);
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
static gboolean
|
|
|
79df40 |
meta_monitor_add_mode (MetaMonitor *monitor,
|
|
|
79df40 |
MetaMonitorMode *monitor_mode,
|
|
|
79df40 |
gboolean replace)
|
|
|
79df40 |
{
|
|
|
79df40 |
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
79df40 |
MetaMonitorMode *existing_mode;
|
|
|
79df40 |
|
|
|
79df40 |
existing_mode = g_hash_table_lookup (priv->mode_ids,
|
|
|
79df40 |
meta_monitor_mode_get_id (monitor_mode));
|
|
|
79df40 |
if (existing_mode && !replace)
|
|
|
79df40 |
return FALSE;
|
|
|
79df40 |
|
|
|
79df40 |
if (existing_mode)
|
|
|
79df40 |
priv->modes = g_list_remove (priv->modes, existing_mode);
|
|
|
79df40 |
|
|
|
79df40 |
priv->modes = g_list_append (priv->modes, monitor_mode);
|
|
|
79df40 |
g_hash_table_replace (priv->mode_ids, monitor_mode->id, monitor_mode);
|
|
|
79df40 |
|
|
|
79df40 |
+ if (existing_mode)
|
|
|
79df40 |
+ meta_monitor_mode_free (existing_mode);
|
|
|
79df40 |
+
|
|
|
79df40 |
return TRUE;
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
static MetaMonitorModeSpec
|
|
|
79df40 |
meta_monitor_create_spec (MetaMonitor *monitor,
|
|
|
79df40 |
int width,
|
|
|
79df40 |
int height,
|
|
|
79df40 |
MetaCrtcMode *crtc_mode)
|
|
|
79df40 |
{
|
|
|
79df40 |
MetaOutput *output = meta_monitor_get_main_output (monitor);
|
|
|
79df40 |
|
|
|
79df40 |
if (meta_monitor_transform_is_rotated (output->panel_orientation_transform))
|
|
|
79df40 |
{
|
|
|
79df40 |
int temp = width;
|
|
|
79df40 |
width = height;
|
|
|
79df40 |
height = temp;
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
return (MetaMonitorModeSpec) {
|
|
|
79df40 |
.width = width,
|
|
|
79df40 |
.height = height,
|
|
|
79df40 |
.refresh_rate = crtc_mode->refresh_rate,
|
|
|
79df40 |
.flags = crtc_mode->flags & HANDLED_CRTC_MODE_FLAGS
|
|
|
79df40 |
};
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
static void
|
|
|
79df40 |
meta_monitor_normal_generate_modes (MetaMonitorNormal *monitor_normal)
|
|
|
79df40 |
{
|
|
|
79df40 |
MetaMonitor *monitor = META_MONITOR (monitor_normal);
|
|
|
79df40 |
--
|
|
|
79df40 |
2.26.2
|
|
|
79df40 |
|