[xdg-desktop-portal-gnome/gbsneto/screencast-session-restore: 22/24] displaystatetracker: Add match string
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [xdg-desktop-portal-gnome/gbsneto/screencast-session-restore: 22/24] displaystatetracker: Add match string
- Date: Thu, 11 Nov 2021 03:16:57 +0000 (UTC)
commit 6670e0693a5d0bbad35d9dcdca8b6c2affa22841
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Sep 28 21:00:35 2021 -0300
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]