summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2019-06-20 14:52:41 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2019-06-24 15:38:36 +0100
commit03840fb68778a5278652d338697153a4dc9e87a8 (patch)
treeafe58280be45201768fc43391b9e855035d20ab0 /gdk
parent6e65c16b60b192d60f1e9b9ff6fe39e8bdda72a8 (diff)
downloadgtk+-03840fb68778a5278652d338697153a4dc9e87a8.tar.gz
Add getter for a monitor connector
The migration from GdkScreen's monitor API to GdkMonitor left out a way to get the connector's name of a monitor. While there's no real guarantee coming from the underlying graphics system that the connector's name is stable, some system components may use it to uniquely identify a monitor until the next plug in/out event.
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdkmonitor.c38
-rw-r--r--gdk/gdkmonitor.h2
-rw-r--r--gdk/gdkmonitorprivate.h3
3 files changed, 43 insertions, 0 deletions
diff --git a/gdk/gdkmonitor.c b/gdk/gdkmonitor.c
index 18730d3df2..2d27c29972 100644
--- a/gdk/gdkmonitor.c
+++ b/gdk/gdkmonitor.c
@@ -49,6 +49,7 @@ enum {
PROP_DISPLAY,
PROP_MANUFACTURER,
PROP_MODEL,
+ PROP_CONNECTOR,
PROP_SCALE_FACTOR,
PROP_GEOMETRY,
PROP_WORKAREA,
@@ -100,6 +101,10 @@ gdk_monitor_get_property (GObject *object,
g_value_set_string (value, monitor->model);
break;
+ case PROP_CONNECTOR:
+ g_value_set_string (value, monitor->connector);
+ break;
+
case PROP_SCALE_FACTOR:
g_value_set_int (value, monitor->scale_factor);
break;
@@ -165,6 +170,7 @@ gdk_monitor_finalize (GObject *object)
{
GdkMonitor *monitor = GDK_MONITOR (object);
+ g_free (monitor->connector);
g_free (monitor->manufacturer);
g_free (monitor->model);
@@ -198,6 +204,12 @@ gdk_monitor_class_init (GdkMonitorClass *class)
"The model name",
NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ props[PROP_CONNECTOR] =
+ g_param_spec_string ("connector",
+ "Connector",
+ "The connector name",
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
props[PROP_SCALE_FACTOR] =
g_param_spec_int ("scale-factor",
"Scale factor",
@@ -370,6 +382,22 @@ gdk_monitor_get_height_mm (GdkMonitor *monitor)
}
/**
+ * gdk_monitor_get_connector:
+ * @monitor: a #GdkMonitor
+ *
+ * Gets the name of the monitor's connector, if available.
+ *
+ * Returns: (transfer none) (nullable): the name of the connector
+ */
+const char *
+gdk_monitor_get_connector (GdkMonitor *monitor)
+{
+ g_return_val_if_fail (GDK_IS_MONITOR (monitor), NULL);
+
+ return monitor->connector;
+}
+
+/**
* gdk_monitor_get_manufacturer:
* @monitor: a #GdkMonitor
*
@@ -505,6 +533,16 @@ gdk_monitor_set_model (GdkMonitor *monitor,
}
void
+gdk_monitor_set_connector (GdkMonitor *monitor,
+ const char *connector)
+{
+ g_free (monitor->connector);
+ monitor->connector = g_strdup (connector);
+
+ g_object_notify (G_OBJECT (monitor), "connector");
+}
+
+void
gdk_monitor_set_position (GdkMonitor *monitor,
int x,
int y)
diff --git a/gdk/gdkmonitor.h b/gdk/gdkmonitor.h
index 79fd434660..b711195e31 100644
--- a/gdk/gdkmonitor.h
+++ b/gdk/gdkmonitor.h
@@ -80,6 +80,8 @@ const char * gdk_monitor_get_manufacturer (GdkMonitor *monitor);
GDK_AVAILABLE_IN_ALL
const char * gdk_monitor_get_model (GdkMonitor *monitor);
GDK_AVAILABLE_IN_ALL
+const char * gdk_monitor_get_connector (GdkMonitor *monitor);
+GDK_AVAILABLE_IN_ALL
int gdk_monitor_get_scale_factor (GdkMonitor *monitor);
GDK_AVAILABLE_IN_ALL
int gdk_monitor_get_refresh_rate (GdkMonitor *monitor);
diff --git a/gdk/gdkmonitorprivate.h b/gdk/gdkmonitorprivate.h
index a2c7b5c86b..f7331376e7 100644
--- a/gdk/gdkmonitorprivate.h
+++ b/gdk/gdkmonitorprivate.h
@@ -36,6 +36,7 @@ struct _GdkMonitor {
GdkDisplay *display;
char *manufacturer;
char *model;
+ char *connector;
GdkRectangle geometry;
int width_mm;
int height_mm;
@@ -58,6 +59,8 @@ void gdk_monitor_set_manufacturer (GdkMonitor *monitor,
const char *manufacturer);
void gdk_monitor_set_model (GdkMonitor *monitor,
const char *model);
+void gdk_monitor_set_connector (GdkMonitor *monitor,
+ const char *connector);
void gdk_monitor_set_position (GdkMonitor *monitor,
int x,
int y);