From 8fd6a3dc1ca2cf4c728ba61a86055320c1257383 Mon Sep 17 00:00:00 2001
From: songchuanfei <songchuanfei@kylinos.com.cn>
Date: Tue, 7 Apr 2020 17:13:46 +0800
Subject: [PATCH] KYOS-F: Add api to check hotplug_mode_update property for
 outputs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- 添加检查给定输出的hotplug_mode_update属性的接口，该属性标记了虚拟屏幕(Virtural Screen)

Signed-off-by: songchuanfei <songchuanfei@kylinos.com.cn>
---
 libmate-desktop/mate-rr-config.c      |  1 +
 libmate-desktop/mate-rr-config.h      |  2 ++
 libmate-desktop/mate-rr-output-info.c |  5 +++++
 libmate-desktop/mate-rr-private.h     |  1 +
 libmate-desktop/mate-rr.c             | 16 ++++++++++++++++
 libmate-desktop/mate-rr.h             |  1 +
 6 files changed, 26 insertions(+)

diff --git a/libmate-desktop/mate-rr-config.c b/libmate-desktop/mate-rr-config.c
index 09d2b8f..3609292 100644
--- a/libmate-desktop/mate-rr-config.c
+++ b/libmate-desktop/mate-rr-config.c
@@ -518,6 +518,7 @@ mate_rr_config_load_current (MateRRConfig *config, GError **error)
 
 	output->priv->name = g_strdup (mate_rr_output_get_name (rr_output));
 	output->priv->connected = mate_rr_output_is_connected (rr_output);
+	output->priv->hotplug_mode_update = mate_rr_output_has_hotplug_mode_update (rr_output);
 
 	if (!output->priv->connected)
 	{
diff --git a/libmate-desktop/mate-rr-config.h b/libmate-desktop/mate-rr-config.h
index 85c8c9f..2f16d52 100644
--- a/libmate-desktop/mate-rr-config.h
+++ b/libmate-desktop/mate-rr-config.h
@@ -87,6 +87,8 @@ void     mate_rr_output_info_set_primary (MateRROutputInfo *self, gboolean prima
 int mate_rr_output_info_get_preferred_width  (MateRROutputInfo *self);
 int mate_rr_output_info_get_preferred_height (MateRROutputInfo *self);
 
+gboolean mate_rr_output_info_has_hotplug_mode_update (MateRROutputInfo *self);
+
 typedef struct
 {
     GObject parent;
diff --git a/libmate-desktop/mate-rr-output-info.c b/libmate-desktop/mate-rr-output-info.c
index 9761e9c..85ee50b 100644
--- a/libmate-desktop/mate-rr-output-info.c
+++ b/libmate-desktop/mate-rr-output-info.c
@@ -250,3 +250,8 @@ int mate_rr_output_info_get_preferred_height (MateRROutputInfo *self)
 
     return self->priv->pref_height;
 }
+
+gboolean mate_rr_output_info_has_hotplug_mode_update (MateRROutputInfo *self)
+{
+    return self->priv->hotplug_mode_update;
+}
diff --git a/libmate-desktop/mate-rr-private.h b/libmate-desktop/mate-rr-private.h
index d5410ca..fa14368 100644
--- a/libmate-desktop/mate-rr-private.h
+++ b/libmate-desktop/mate-rr-private.h
@@ -70,6 +70,7 @@ struct MateRROutputInfoPrivate
     int			pref_height;
     char *		display_name;
     gboolean            primary;
+    gboolean		hotplug_mode_update;
 };
 
 struct MateRRConfigPrivate
diff --git a/libmate-desktop/mate-rr.c b/libmate-desktop/mate-rr.c
index 04ffd0d..a9bdf79 100644
--- a/libmate-desktop/mate-rr.c
+++ b/libmate-desktop/mate-rr.c
@@ -89,6 +89,7 @@ struct MateRROutput
     int			n_preferred;
     guint8 *		edid_data;
     int         edid_size;
+    gboolean		hotplug_mode_update;
     char *              connector_type;
 };
 
@@ -1202,6 +1203,19 @@ read_edid_data (MateRROutput *output, int *len)
     return NULL;
 }
 
+static gboolean check_hotplug_mode_update(MateRROutput *output)
+{
+	Atom atom;
+
+	atom = XInternAtom(DISPLAY(output), "hotplug_mode_update", FALSE);
+	return (XRRQueryOutputProperty(DISPLAY(output), output->id, atom) != NULL);
+}
+
+gboolean mate_rr_output_has_hotplug_mode_update(MateRROutput *output)
+{
+	return output->hotplug_mode_update;
+}
+
 static char *
 get_connector_type_string (MateRROutput *output)
 {
@@ -1315,6 +1329,8 @@ output_initialize (MateRROutput *output, XRRScreenResources *res, GError **error
     
     /* Edid data */
     output->edid_data = read_edid_data (output, &output->edid_size);
+
+    output->hotplug_mode_update = check_hotplug_mode_update(output);
     
     XRRFreeOutputInfo (info);
 
diff --git a/libmate-desktop/mate-rr.h b/libmate-desktop/mate-rr.h
index cc7e427..be3e7e8 100644
--- a/libmate-desktop/mate-rr.h
+++ b/libmate-desktop/mate-rr.h
@@ -146,6 +146,7 @@ MateRRMode *   mate_rr_output_get_preferred_mode (MateRROutput         *output);
 gboolean        mate_rr_output_supports_mode      (MateRROutput         *output,
 						    MateRRMode           *mode);
 gboolean        mate_rr_output_get_is_primary     (MateRROutput         *output);
+gboolean	mate_rr_output_has_hotplug_mode_update (MateRROutput *output);
 
 /* MateRRMode */
 guint32         mate_rr_mode_get_id               (MateRRMode           *mode);
-- 
2.18.1

