[gnome-battery-bench] SystemInfo: only optionally depend on 3.22 API
- From: Christian Kellner <gicmo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-battery-bench] SystemInfo: only optionally depend on 3.22 API
- Date: Wed, 10 May 2017 14:58:29 +0000 (UTC)
commit acb29649e68604469c651b61d00bfefbfd8f8197
Author: Christian Kellner <gicmo gnome org>
Date: Wed May 10 14:07:30 2017 +0200
SystemInfo: only optionally depend on 3.22 API
The gdk_monitor_xxx API is 3.22 only, so guard these.
src/system-info.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/system-info.c b/src/system-info.c
index 3b40c78..3146043 100644
--- a/src/system-info.c
+++ b/src/system-info.c
@@ -697,12 +697,8 @@ get_renderer_info (void)
}
static gboolean
-monitor_is_builtin(GdkMonitor *monitor)
+monitor_is_builtin(const char *model)
{
- const char *model;
-
- model = gdk_monitor_get_model(monitor);
-
if (model == NULL)
return FALSE;
@@ -725,6 +721,7 @@ static void
load_monitor_info(GbbSystemInfo *info,
GdkDisplay *display)
{
+#if (GDK_MAJOR_VERSION >= 3 && GDK_MINOR_VERSION >= 22)
GdkMonitor *builtin = NULL;
GdkRectangle geo;
int i, n;
@@ -733,8 +730,9 @@ load_monitor_info(GbbSystemInfo *info,
for (i = 0; i < n; i++) {
GdkMonitor *moni = gdk_display_get_monitor(display, i);
+ const char *model = gdk_monitor_get_model(moni);
- if (monitor_is_builtin(moni)) {
+ if (monitor_is_builtin(model)) {
builtin = moni;
break;
}
@@ -763,6 +761,9 @@ load_monitor_info(GbbSystemInfo *info,
gdk_monitor_get_geometry(builtin, &geo);
info->monitor_x = geo.width * info->monitor_scale;
info->monitor_y = geo.height * info->monitor_scale;
+#else /* GDK version check */
+ info->monitor_valid = FALSE;
+#endif
}
static void gbb_system_info_init (GbbSystemInfo *info)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]