[gnome-battery-bench] SystemInfo: include display-protocol information



commit 4b8c7e3af5440c34856a3d3916924fb3065f4a55
Author: Christian Kellner <gicmo gnome org>
Date:   Thu May 4 21:16:06 2017 +0200

    SystemInfo: include display-protocol information
    
    This will enable us to distinguish between X11 and Wayland, which
    might reveal important differences in power consumption in those
    too.

 src/system-info.c |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/src/system-info.c b/src/system-info.c
index bfdbef7..76a081a 100644
--- a/src/system-info.c
+++ b/src/system-info.c
@@ -7,6 +7,13 @@
 
 #include <gdk/gdk.h>
 
+#ifdef GDK_WINDOWING_WAYLAND
+#include <gdk/gdkwayland.h>
+#endif
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
 #include "power-supply.h"
 
 #include "config.h"
@@ -51,6 +58,8 @@ struct _GbbSystemInfo {
     char *os_type;
     char *os_kernel;
 
+    char *display_proto;
+
     /*  GNOME */
     char *gnome_version;
     char *gnome_distributor;
@@ -86,6 +95,8 @@ enum {
     PROP_OS_TYPE,
     PROP_OS_KERNEL,
 
+    PROP_DISPLAY_PROTO,
+
     PROP_GNOME_VERSION,
     PROP_GNOME_DISTRIBUTOR,
     PROP_GNOME_DATE,
@@ -123,6 +134,8 @@ gbb_system_info_finalize(GbbSystemInfo *info)
     g_free(info->os_type);
     g_free(info->os_kernel);
 
+    g_free(info->display_proto);
+
     g_free(info->gnome_version);
     g_free(info->gnome_distributor);
     g_free(info->gnome_date);
@@ -214,6 +227,10 @@ gbb_system_info_get_property (GObject *object, guint prop_id, GValue *value, GPa
         g_value_set_string(value, info->os_kernel);
         break;
 
+    case PROP_DISPLAY_PROTO:
+        g_value_set_string(value, info->display_proto);
+        break;
+
     case PROP_GNOME_VERSION:
         g_value_set_string(value, info->gnome_version);
         break;
@@ -348,6 +365,12 @@ gbb_system_info_class_init (GbbSystemInfoClass *klass)
                             NULL,
                             G_PARAM_READABLE);
 
+    props[PROP_DISPLAY_PROTO] =
+        g_param_spec_string("display-proto",
+                            NULL, NULL,
+                            NULL,
+                            G_PARAM_READABLE);
+
     props[PROP_GNOME_VERSION] =
         g_param_spec_string("gnome-version",
                             NULL, NULL,
@@ -752,6 +775,20 @@ static void gbb_system_info_init (GbbSystemInfo *info)
     }
 
     load_monitor_info(info, display);
+
+#ifdef GDK_WINDOWING_WAYLAND
+    if (GDK_IS_WAYLAND_DISPLAY(display)) {
+        info->display_proto = g_strdup("Wayland");
+    }
+#endif
+#ifdef GDK_WINDOWING_X11
+    if (info->display_proto == NULL && GDK_IS_X11_DISPLAY (display)) {
+        info->display_proto = g_strdup("X11");
+    }
+#endif
+    if (info->display_proto == NULL) {
+        info->display_proto = g_strdup("Unknown");
+    }
 }
 
 GbbSystemInfo *
@@ -898,6 +935,10 @@ gbb_system_info_to_json (const GbbSystemInfo *info, JsonBuilder *builder)
             json_builder_add_string_value(builder, info->os_kernel);
             json_builder_end_object(builder);
         }
+
+        json_builder_set_member_name(builder, "display-protocol");
+        json_builder_add_string_value(builder, info->display_proto);
+
         json_builder_set_member_name(builder, "gnome");
         {
             json_builder_begin_object(builder);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]