summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-11-01 14:02:08 -0400
committerMatthias Clasen <mclasen@redhat.com>2017-11-01 14:17:20 -0400
commitf2655b055d6d1e7b81293aad7ecbcc0956857164 (patch)
tree5e63f04c8d8db2b2bef12545341a9d8cd89d3e51
parent2d31a5499a5484e72dc30fe573d5934d8560361f (diff)
downloadgtk+-f2655b055d6d1e7b81293aad7ecbcc0956857164.tar.gz
monitor: Add a ::valid property
This is slightly more useful than the existing ::invalidate signal, since it can be queried at any time.
-rw-r--r--docs/reference/gdk/gdk4-sections.txt1
-rw-r--r--gdk/gdkmonitor.c34
-rw-r--r--gdk/gdkmonitor.h2
-rw-r--r--gdk/gdkmonitorprivate.h1
4 files changed, 38 insertions, 0 deletions
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt
index a39abe6136..797bb27290 100644
--- a/docs/reference/gdk/gdk4-sections.txt
+++ b/docs/reference/gdk/gdk4-sections.txt
@@ -1271,6 +1271,7 @@ gdk_monitor_get_refresh_rate
GdkSubpixelLayout
gdk_monitor_get_subpixel_layout
gdk_monitor_is_primary
+gdk_monitor_is_valid
<SUBSECTION Standard>
gdk_monitor_get_type
diff --git a/gdk/gdkmonitor.c b/gdk/gdkmonitor.c
index fb721481db..3e8ec272b5 100644
--- a/gdk/gdkmonitor.c
+++ b/gdk/gdkmonitor.c
@@ -49,6 +49,7 @@ enum {
PROP_HEIGHT_MM,
PROP_REFRESH_RATE,
PROP_SUBPIXEL_LAYOUT,
+ PROP_VALID,
LAST_PROP
};
@@ -67,6 +68,7 @@ static void
gdk_monitor_init (GdkMonitor *monitor)
{
monitor->scale_factor = 1;
+ monitor->valid = TRUE;
}
static void
@@ -123,6 +125,10 @@ gdk_monitor_get_property (GObject *object,
g_value_set_enum (value, monitor->subpixel_layout);
break;
+ case PROP_VALID:
+ g_value_set_boolean (value, monitor->valid);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -232,6 +238,12 @@ gdk_monitor_class_init (GdkMonitorClass *class)
GDK_TYPE_SUBPIXEL_LAYOUT,
GDK_SUBPIXEL_LAYOUT_UNKNOWN,
G_PARAM_READABLE);
+ props[PROP_VALID] =
+ g_param_spec_boolean ("valid",
+ "Valid",
+ "Whether the monitor is still valid",
+ TRUE,
+ G_PARAM_READABLE);
g_object_class_install_properties (object_class, LAST_PROP, props);
@@ -595,5 +607,27 @@ gdk_monitor_set_subpixel_layout (GdkMonitor *monitor,
void
gdk_monitor_invalidate (GdkMonitor *monitor)
{
+ monitor->valid = FALSE;
+ g_object_notify (G_OBJECT (monitor), "valid");
g_signal_emit (monitor, signals[INVALIDATE], 0);
}
+
+/**
+ * gdk_monitor_is_valid:
+ * @monitor: a #GdkMonitor
+ *
+ * Returns %TRUE if the @monitor object corresponds to a
+ * physical monitor. The @monitor becomes invalid when the
+ * physical monitor is unplugged or removed.
+ *
+ * Returns: %TRUE if the object corresponds to a physical monitor
+ *
+ * Since: 3.94
+ */
+gboolean
+gdk_monitor_is_valid (GdkMonitor *monitor)
+{
+ g_return_val_if_fail (GDK_IS_MONITOR (monitor), FALSE);
+
+ return monitor->valid;
+}
diff --git a/gdk/gdkmonitor.h b/gdk/gdkmonitor.h
index a12bfa8ac0..887bbbd40c 100644
--- a/gdk/gdkmonitor.h
+++ b/gdk/gdkmonitor.h
@@ -89,6 +89,8 @@ GDK_AVAILABLE_IN_3_22
GdkSubpixelLayout gdk_monitor_get_subpixel_layout (GdkMonitor *monitor);
GDK_AVAILABLE_IN_3_22
gboolean gdk_monitor_is_primary (GdkMonitor *monitor);
+GDK_AVAILABLE_IN_3_94
+gboolean gdk_monitor_is_valid (GdkMonitor *monitor);
G_END_DECLS
diff --git a/gdk/gdkmonitorprivate.h b/gdk/gdkmonitorprivate.h
index c76b59ce90..a2c7b5c86b 100644
--- a/gdk/gdkmonitorprivate.h
+++ b/gdk/gdkmonitorprivate.h
@@ -42,6 +42,7 @@ struct _GdkMonitor {
int scale_factor;
int refresh_rate;
GdkSubpixelLayout subpixel_layout;
+ gboolean valid;
};
struct _GdkMonitorClass {