[Xfce4-commits] [xfce/libxfce4ui] 01/01: Add xfce_gdk_screen_get_geometry
noreply at xfce.org
noreply at xfce.org
Sun Apr 21 23:05:42 CEST 2019
This is an automated email from the git hooks/post-receive script.
a n d r e 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/libxfce4ui.
commit 0e121db6f9ccb4ceb2a53f6d63b01da8a8b16f90
Author: Andre Miranda <andreldm at xfce.org>
Date: Sun Apr 21 18:04:34 2019 -0300
Add xfce_gdk_screen_get_geometry
---
docs/libxfce4ui-sections.txt | 1 +
libxfce4ui/libxfce4ui.symbols | 1 +
libxfce4ui/xfce-gdk-extensions.c | 46 ++++++++++++++++++++++++++++++++++++++++
libxfce4ui/xfce-gdk-extensions.h | 4 +++-
4 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/docs/libxfce4ui-sections.txt b/docs/libxfce4ui-sections.txt
index f59e8b7..74871fb 100644
--- a/docs/libxfce4ui-sections.txt
+++ b/docs/libxfce4ui-sections.txt
@@ -23,6 +23,7 @@ xfce_spawn_command_line_on_screen
<SECTION>
<FILE>xfce-gdk-extensions</FILE>
xfce_gdk_screen_get_active
+xfce_gdk_screen_get_geometry
</SECTION>
<SECTION>
diff --git a/libxfce4ui/libxfce4ui.symbols b/libxfce4ui/libxfce4ui.symbols
index bd87d5f..df86081 100644
--- a/libxfce4ui/libxfce4ui.symbols
+++ b/libxfce4ui/libxfce4ui.symbols
@@ -73,6 +73,7 @@ xfce_message_dialog G_GNUC_NULL_TERMINATED
#if IN_HEADER(__XFCE_GDK_EXTENSIONS_H__)
#if IN_SOURCE(__XFCE_GDK_EXTENSIONS_C__)
xfce_gdk_screen_get_active
+xfce_gdk_screen_get_geometry
#endif
#endif
diff --git a/libxfce4ui/xfce-gdk-extensions.c b/libxfce4ui/xfce-gdk-extensions.c
index 69dc7bf..d60aa8d 100644
--- a/libxfce4ui/xfce-gdk-extensions.c
+++ b/libxfce4ui/xfce-gdk-extensions.c
@@ -98,6 +98,52 @@ xfce_gdk_screen_get_active (gint *monitor_return)
}
+/**
+ * xfce_gdk_screen_get_geometry:
+ * @geometry : (out): Address to store the monitor number to or %NULL.
+ *
+ * Sets the width and height of the default #GdkScreen into @geometry.
+ * This is a replacement for gdk_screen_width/gdk_screen_height.
+ **/
+void
+xfce_gdk_screen_get_geometry (GdkRectangle *geometry)
+{
+#if GTK_CHECK_VERSION (3, 22, 0)
+ gint x, y, w, h;
+ int num_monitors;
+ GdkDisplay *display;
+ GdkRectangle rect;
+ GdkMonitor *monitor;
+
+ g_return_if_fail (geometry != NULL);
+
+ display = gdk_display_get_default ();
+ num_monitors = gdk_display_get_n_monitors (display);
+
+ x = y = G_MAXINT;
+ w = h = G_MININT;
+
+ for (int i = 0; i < num_monitors; i++)
+ {
+ monitor = gdk_display_get_monitor (display, i);
+ gdk_monitor_get_geometry (monitor, &rect);
+
+ x = MIN (x, rect.x);
+ y = MIN (y, rect.y);
+ w = MAX (w, rect.x + rect.width);
+ h = MAX (h, rect.y + rect.height);
+ }
+
+ geometry->width = w - x;
+ geometry->height = h - y;
+#else
+ g_return_if_fail (geometry != NULL);
+
+ geometry->width = gdk_screen_width ();
+ geometry->height = gdk_screen_height ();
+#endif
+}
+
#define __XFCE_GDK_EXTENSIONS_C__
#include <libxfce4ui/libxfce4ui-aliasdef.c>
diff --git a/libxfce4ui/xfce-gdk-extensions.h b/libxfce4ui/xfce-gdk-extensions.h
index df336e4..07e4b1f 100644
--- a/libxfce4ui/xfce-gdk-extensions.h
+++ b/libxfce4ui/xfce-gdk-extensions.h
@@ -29,7 +29,9 @@
G_BEGIN_DECLS
-GdkScreen *xfce_gdk_screen_get_active (gint *monitor_return);
+GdkScreen *xfce_gdk_screen_get_active (gint *monitor_return);
+
+void xfce_gdk_screen_get_geometry (GdkRectangle *geometry);
G_END_DECLS
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list