[mutter] monitor: Allow vendor/product/serial to return NULL
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor: Allow vendor/product/serial to return NULL
- Date: Thu, 1 Sep 2022 14:52:10 +0000 (UTC)
commit ccb6a7e84fa371d8ec8e90eccb1693af8a52dee6
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Thu Oct 28 15:25:58 2021 +0200
monitor: Allow vendor/product/serial to return NULL
Same applies to MetaOutput. The reason for this is to make it possible
to more reliably know when there was EDID telling us about these
details. This will be used for colord integration.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
src/backends/meta-input-mapper.c | 32 +++++++++++++++++++++-----------
src/backends/meta-monitor-manager.c | 12 +++++++++---
src/backends/meta-monitor.c | 16 +++++++++++-----
src/backends/meta-output.c | 11 +----------
src/backends/native/meta-output-kms.c | 3 ++-
src/backends/x11/meta-output-xrandr.c | 7 +++++--
src/core/meta-pad-action-mapper.c | 12 +++++++++---
src/wayland/meta-wayland-outputs.c | 4 ++--
8 files changed, 60 insertions(+), 37 deletions(-)
---
diff --git a/src/backends/meta-input-mapper.c b/src/backends/meta-input-mapper.c
index 03a29f1a83..ab0e848b4f 100644
--- a/src/backends/meta-input-mapper.c
+++ b/src/backends/meta-input-mapper.c
@@ -306,32 +306,42 @@ match_edid (MetaMapperInputInfo *input,
MetaMonitor *monitor,
MetaOutputMatchType *match_type)
{
- const gchar *dev_name;
+ const char *dev_name;
+ const char *vendor;
+ const char *serial;
dev_name = clutter_input_device_get_device_name (input->device);
- if (strcasestr (dev_name, meta_monitor_get_vendor (monitor)) == NULL)
+ vendor = meta_monitor_get_vendor (monitor);
+ if (!vendor || strcasestr (dev_name, vendor) == NULL)
return FALSE;
*match_type = META_MATCH_EDID_VENDOR;
- if (strcasestr (dev_name, meta_monitor_get_product (monitor)) != NULL)
+ serial = meta_monitor_get_serial (monitor);
+ if (!serial || strcasestr (dev_name, serial) != NULL)
{
*match_type = META_MATCH_EDID_FULL;
}
else
{
- int i;
- g_auto (GStrv) split = NULL;
+ const char *product;
- split = g_strsplit (meta_monitor_get_product (monitor), " ", -1);
-
- for (i = 0; split[i]; i++)
+ product = meta_monitor_get_product (monitor);
+ if (product)
{
- if (strcasestr (dev_name, split[i]) != NULL)
+ g_auto (GStrv) split = NULL;
+ int i;
+
+ split = g_strsplit (product, " ", -1);
+
+ for (i = 0; split[i]; i++)
{
- *match_type = META_MATCH_EDID_PARTIAL;
- break;
+ if (strcasestr (dev_name, split[i]) != NULL)
+ {
+ *match_type = META_MATCH_EDID_PARTIAL;
+ break;
+ }
}
}
}
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index 6bdd72be17..c4853ff7b0 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -1688,6 +1688,9 @@ meta_monitor_manager_handle_get_resources (MetaDBusDisplayConfig *skeleton,
gboolean is_underscanning;
gboolean supports_underscanning;
gboolean supports_color_transform;
+ const char *vendor;
+ const char *product;
+ const char *serial;
g_variant_builder_init (&crtcs, G_VARIANT_TYPE ("au"));
for (j = 0; j < output_info->n_possible_crtcs; j++)
@@ -1729,14 +1732,17 @@ meta_monitor_manager_handle_get_resources (MetaDBusDisplayConfig *skeleton,
connector_type_name = get_connector_type_name (output_info->connector_type);
supports_underscanning = output_info->supports_underscanning;
supports_color_transform = output_info->supports_color_transform;
+ vendor = output_info->vendor;
+ product = output_info->product;;
+ serial = output_info->serial;
g_variant_builder_init (&properties, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&properties, "{sv}", "vendor",
- g_variant_new_string (output_info->vendor));
+ g_variant_new_string (vendor ? vendor : "unknown"));
g_variant_builder_add (&properties, "{sv}", "product",
- g_variant_new_string (output_info->product));
+ g_variant_new_string (product ? product : "unknown"));
g_variant_builder_add (&properties, "{sv}", "serial",
- g_variant_new_string (output_info->serial));
+ g_variant_new_string (serial ? serial : "unknown"));
g_variant_builder_add (&properties, "{sv}", "width-mm",
g_variant_new_int32 (output_info->width_mm));
g_variant_builder_add (&properties, "{sv}", "height-mm",
diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c
index 96e2b1aa61..72e3c9e772 100644
--- a/src/backends/meta-monitor.c
+++ b/src/backends/meta-monitor.c
@@ -194,13 +194,20 @@ meta_monitor_generate_spec (MetaMonitor *monitor)
const MetaOutputInfo *output_info =
meta_monitor_get_main_output_info (monitor);
MetaMonitorSpec *monitor_spec;
+ const char *vendor;
+ const char *product;
+ const char *serial;
+
+ vendor = output_info->vendor;
+ product = output_info->product;
+ serial = output_info->serial;
monitor_spec = g_new0 (MetaMonitorSpec, 1);
*monitor_spec = (MetaMonitorSpec) {
.connector = g_strdup (output_info->name),
- .vendor = g_strdup (output_info->vendor),
- .product = g_strdup (output_info->product),
- .serial = g_strdup (output_info->serial),
+ .vendor = g_strdup (vendor ? vendor : "unknown"),
+ .product = g_strdup (product ? product : "unknown"),
+ .serial = g_strdup (serial ? serial : "unknown"),
};
priv->spec = monitor_spec;
@@ -260,8 +267,7 @@ meta_monitor_make_display_name (MetaMonitor *monitor,
}
vendor = meta_monitor_get_vendor (monitor);
-
- if (g_strcmp0 (vendor, "unknown") != 0)
+ if (vendor)
{
vendor_name = meta_monitor_manager_get_vendor_name (monitor_manager,
vendor);
diff --git a/src/backends/meta-output.c b/src/backends/meta-output.c
index 551be67e8e..3573b69fdf 100644
--- a/src/backends/meta-output.c
+++ b/src/backends/meta-output.c
@@ -313,8 +313,7 @@ meta_output_info_parse_edid (MetaOutputInfo *output_info,
size_t len;
gconstpointer data;
- if (!edid)
- goto out;
+ g_return_if_fail (edid);
data = g_bytes_get_data (edid, &len);
parsed_edid = meta_edid_info_new_parse (data);
@@ -346,14 +345,6 @@ meta_output_info_parse_edid (MetaOutputInfo *output_info,
g_free (parsed_edid);
}
-
- out:
- if (!output_info->vendor)
- output_info->vendor = g_strdup ("unknown");
- if (!output_info->product)
- output_info->product = g_strdup ("unknown");
- if (!output_info->serial)
- output_info->serial = g_strdup ("unknown");
}
gboolean
diff --git a/src/backends/native/meta-output-kms.c b/src/backends/native/meta-output-kms.c
index 709590ed48..d002f1098a 100644
--- a/src/backends/native/meta-output-kms.c
+++ b/src/backends/native/meta-output-kms.c
@@ -483,7 +483,8 @@ meta_output_kms_new (MetaGpuKms *gpu_kms,
output_info->max_bpc_max = max_bpc_range->max_value;
}
- meta_output_info_parse_edid (output_info, connector_state->edid_data);
+ if (connector_state->edid_data)
+ meta_output_info_parse_edid (output_info, connector_state->edid_data);
output_info->tile_info = connector_state->tile_info;
diff --git a/src/backends/x11/meta-output-xrandr.c b/src/backends/x11/meta-output-xrandr.c
index 37a377e48c..bc54bb119f 100644
--- a/src/backends/x11/meta-output-xrandr.c
+++ b/src/backends/x11/meta-output-xrandr.c
@@ -970,8 +970,11 @@ meta_output_xrandr_new (MetaGpuXrandr *gpu_xrandr,
output_info->name = g_strdup (xrandr_output->name);
edid = read_xrandr_edid (xdisplay, output_id);
- meta_output_info_parse_edid (output_info, edid);
- g_bytes_unref (edid);
+ if (edid)
+ {
+ meta_output_info_parse_edid (output_info, edid);
+ g_bytes_unref (edid);
+ }
output_info->subpixel_order = COGL_SUBPIXEL_ORDER_UNKNOWN;
output_info->hotplug_mode_update = output_get_hotplug_mode_update (xdisplay,
diff --git a/src/core/meta-pad-action-mapper.c b/src/core/meta-pad-action-mapper.c
index dc43924b55..1a9408e6e4 100644
--- a/src/core/meta-pad-action-mapper.c
+++ b/src/core/meta-pad-action-mapper.c
@@ -415,12 +415,18 @@ meta_pad_action_mapper_cycle_tablet_output (MetaPadActionMapper *mapper,
if (logical_monitor)
{
MetaMonitor *monitor;
+ const char *vendor;
+ const char *product;
+ const char *serial;
/* Pick an arbitrary monitor in the logical monitor to represent it. */
monitor = meta_logical_monitor_get_monitors (logical_monitor)->data;
- edid[0] = meta_monitor_get_vendor (monitor);
- edid[1] = meta_monitor_get_product (monitor);
- edid[2] = meta_monitor_get_serial (monitor);
+ vendor = meta_monitor_get_vendor (monitor);
+ product = meta_monitor_get_product (monitor);
+ serial = meta_monitor_get_serial (monitor);
+ edid[0] = vendor ? vendor : "";
+ edid[1] = product ? product : "";
+ edid[2] = serial ? serial : "";
}
else
{
diff --git a/src/wayland/meta-wayland-outputs.c b/src/wayland/meta-wayland-outputs.c
index 665b2e73fe..a8fe21c856 100644
--- a/src/wayland/meta-wayland-outputs.c
+++ b/src/wayland/meta-wayland-outputs.c
@@ -238,8 +238,8 @@ send_output_events (struct wl_resource *resource,
width_mm,
height_mm,
subpixel_order,
- vendor,
- product,
+ vendor ? vendor : "unknown",
+ product ? product : "unknown",
wl_transform);
need_done = TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]