[Xfce4-commits] [xfce/xfwm4] 03/04: common: There might be no primary monitor

noreply at xfce.org noreply at xfce.org
Wed Aug 28 18:46:20 CEST 2019


This is an automated email from the git hooks/post-receive script.

o   l   i   v   i   e   r       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfwm4.

commit 699c0aeb782cb36181d2cd6fe39804363c23fb8c
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Wed Aug 28 10:35:36 2019 -0600

    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 at xfce.org>
---
 common/xfwm-common.c | 13 ++++++++++++-
 common/xfwm-common.h |  2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/common/xfwm-common.c b/common/xfwm-common.c
index f187e42..fffe3db 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 693ad84..28ab6bf 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);
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list