You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.0 KiB
91 lines
3.0 KiB
From 36594e191980d84ca77ba09faddf3f160a9839cf Mon Sep 17 00:00:00 2001
|
|
From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
|
Date: Tue, 28 Sep 2021 21:00:35 -0300
|
|
Subject: [PATCH] displaystatetracker: Add match string
|
|
|
|
The monitor's match string is a unique string that can be used to compare
|
|
monitors and check for equality. It's composed of the product, vendor, and
|
|
serial numbers. It'll be used by the next commit to restore sessions.
|
|
---
|
|
src/displaystatetracker.c | 18 +++++++++++++++---
|
|
src/displaystatetracker.h | 2 ++
|
|
2 files changed, 17 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/displaystatetracker.c b/src/displaystatetracker.c
|
|
index 6affd8a..fc9109e 100644
|
|
--- a/src/displaystatetracker.c
|
|
+++ b/src/displaystatetracker.c
|
|
@@ -35,6 +35,7 @@ static guint signals[N_SIGNALS];
|
|
typedef struct _Monitor
|
|
{
|
|
char *connector;
|
|
+ char *match_string;
|
|
char *display_name;
|
|
} Monitor;
|
|
|
|
@@ -65,6 +66,7 @@ static void
|
|
monitor_free (Monitor *monitor)
|
|
{
|
|
g_free (monitor->connector);
|
|
+ g_free (monitor->match_string);
|
|
g_free (monitor->display_name);
|
|
g_free (monitor);
|
|
}
|
|
@@ -75,6 +77,12 @@ monitor_get_connector (Monitor *monitor)
|
|
return monitor->connector;
|
|
}
|
|
|
|
+const char *
|
|
+monitor_get_match_string (Monitor *monitor)
|
|
+{
|
|
+ return monitor->match_string;
|
|
+}
|
|
+
|
|
const char *
|
|
monitor_get_display_name (Monitor *monitor)
|
|
{
|
|
@@ -109,6 +117,9 @@ generate_monitors (DisplayStateTracker *tracker,
|
|
g_variant_iter_init (&monitors_iter, monitors);
|
|
while ((monitor_variant = g_variant_iter_next_value (&monitors_iter)))
|
|
{
|
|
+ g_autofree char *vendor = NULL;
|
|
+ g_autofree char *product = NULL;
|
|
+ g_autofree char *serial = NULL;
|
|
Monitor *monitor;
|
|
char *connector;
|
|
char *display_name;
|
|
@@ -116,9 +127,9 @@ generate_monitors (DisplayStateTracker *tracker,
|
|
|
|
g_variant_get (monitor_variant, "((ssss)a(siiddada{sv})@a{sv})",
|
|
&connector,
|
|
- NULL /* vendor */,
|
|
- NULL /* product */,
|
|
- NULL /* serial */,
|
|
+ &vendor,
|
|
+ &product,
|
|
+ &serial,
|
|
NULL /* modes */,
|
|
&properties);
|
|
|
|
@@ -128,6 +139,7 @@ generate_monitors (DisplayStateTracker *tracker,
|
|
monitor = g_new0 (Monitor, 1);
|
|
*monitor = (Monitor) {
|
|
.connector = connector,
|
|
+ .match_string = g_strdup_printf ("%s:%s:%s", vendor, product, serial),
|
|
.display_name = display_name
|
|
};
|
|
|
|
diff --git a/src/displaystatetracker.h b/src/displaystatetracker.h
|
|
index 54c63fa..1c3a7dc 100644
|
|
--- a/src/displaystatetracker.h
|
|
+++ b/src/displaystatetracker.h
|
|
@@ -28,6 +28,8 @@ G_DECLARE_FINAL_TYPE (DisplayStateTracker, display_state_tracker,
|
|
|
|
const char * monitor_get_connector (Monitor *monitor);
|
|
|
|
+const char * monitor_get_match_string (Monitor *monitor);
|
|
+
|
|
const char * monitor_get_display_name (Monitor *monitor);
|
|
|
|
GList * logical_monitor_get_monitors (LogicalMonitor *logical_monitor);
|