summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorOlivier Fourdan <fourdan@xfce.org>2019-08-28 10:35:36 -0600
committerOlivier Fourdan <fourdan@xfce.org>2019-08-28 10:46:14 -0600
commit699c0aeb782cb36181d2cd6fe39804363c23fb8c (patch)
treec9dca26b16b2e8e6aef0c711a95176ef7829c998 /common
parent3925109d09614f95a5ef96b35db686d889457af0 (diff)
downloadxfwm4-699c0aeb782cb36181d2cd6fe39804363c23fb8c.tar.gz
common: There might be no primary monitor
Bug: 15852 The function `xfwm_get_primary_monitor_geometry()` assumes there is always a primary monitor, which is not true if no monitor is connected, in which case the size is not meaningful. Make `xfwm_get_primary_monitor_geometry()` return a boolean value that can be used by the caller to determine if the reported size is meaningless. Signed-off-by: Olivier Fourdan <fourdan@xfce.org>
Diffstat (limited to 'common')
-rw-r--r--common/xfwm-common.c13
-rw-r--r--common/xfwm-common.h2
2 files changed, 13 insertions, 2 deletions
diff --git a/common/xfwm-common.c b/common/xfwm-common.c
index f187e4277..fffe3db5e 100644
--- a/common/xfwm-common.c
+++ b/common/xfwm-common.c
@@ -116,7 +116,7 @@ xfwm_get_monitor_geometry (GdkScreen *screen,
-void
+gboolean
xfwm_get_primary_monitor_geometry (GdkScreen *screen,
GdkRectangle *geometry,
gboolean scaled)
@@ -128,6 +128,15 @@ xfwm_get_primary_monitor_geometry (GdkScreen *screen,
display = gdk_screen_get_display (screen);
monitor = gdk_display_get_primary_monitor (display);
+
+ if (!monitor)
+ {
+ geometry->width = 0;
+ geometry->height = 0;
+
+ return FALSE;
+ }
+
scale = gdk_monitor_get_scale_factor (monitor);
gdk_monitor_get_geometry (monitor, geometry);
#else
@@ -140,6 +149,8 @@ xfwm_get_primary_monitor_geometry (GdkScreen *screen,
if (scaled && scale != 1)
xfwm_geometry_convert_to_device_pixels (geometry, scale);
+
+ return TRUE;
}
diff --git a/common/xfwm-common.h b/common/xfwm-common.h
index 693ad8476..28ab6bf15 100644
--- a/common/xfwm-common.h
+++ b/common/xfwm-common.h
@@ -34,7 +34,7 @@ void xfwm_get_monitor_geometry (GdkScreen *screen,
GdkRectangle *geometry,
gboolean scaled);
-void xfwm_get_primary_monitor_geometry (GdkScreen *screen,
+gboolean xfwm_get_primary_monitor_geometry (GdkScreen *screen,
GdkRectangle *geometry,
gboolean scaled);