[gtk+/wip/matthiasc/monitor] Add refresh rate



commit ad8483caad685c3bb1a9b3fc3d76c5e441f58b48
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Apr 2 15:50:33 2016 -0400

    Add refresh rate

 gdk/gdkmonitor.c                |   59 ++++++++++++++++++++++++++++++++++++++-
 gdk/gdkmonitor.h                |    2 +
 gdk/gdkmonitorprivate.h         |    1 +
 gdk/wayland/gdkscreen-wayland.c |    5 +--
 4 files changed, 63 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkmonitor.c b/gdk/gdkmonitor.c
index 31fd282..f7717e6 100644
--- a/gdk/gdkmonitor.c
+++ b/gdk/gdkmonitor.c
@@ -28,7 +28,6 @@
  * - primary
  * - workarea
  * - monitor type (laptop, projector, ...)
- * - refresh rate
  * - subpixel layout
  * - consider vfuncs instead of baseclass storage
  * - consider array instead of list
@@ -43,6 +42,11 @@ enum {
   PROP_GEOMETRY,
   PROP_WIDTH_MM,
   PROP_HEIGHT_MM,
+<<<<<<< HEAD
+=======
+  PROP_PRIMARY,
+  PROP_REFRESH_RATE,
+>>>>>>> 3b15fdf... Add refresh rate
   LAST_PROP
 };
 
@@ -94,6 +98,17 @@ gdk_monitor_get_property (GObject    *object,
       g_value_set_int (value, monitor->height_mm);
       break;
 
+<<<<<<< HEAD
+=======
+    case PROP_PRIMARY:
+      g_value_set_boolean (value, monitor->primary);
+      break;
+
+    case PROP_REFRESH_RATE:
+      g_value_set_boolean (value, monitor->refresh_rate);
+      break;
+
+>>>>>>> 3b15fdf... Add refresh rate
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -183,6 +198,13 @@ gdk_monitor_class_init (GdkMonitorClass *class)
                       0, G_MAXINT,
                       0,
                       G_PARAM_READABLE);
+  props[PROP_REFRESH_RATE] =
+    g_param_spec_int ("refresh-rate",
+                      "Refresh rate",
+                      "The refresh rate, in millihertz",
+                      0, G_MAXINT,
+                      0,
+                      G_PARAM_READABLE);
 
   g_object_class_install_properties (object_class, LAST_PROP, props);
 }
@@ -240,6 +262,14 @@ gdk_monitor_get_scale_factor (GdkMonitor *monitor)
   return monitor->scale_factor;
 }
 
+int
+gdk_monitor_get_refresh_rate (GdkMonitor *monitor)
+{
+  g_return_val_if_fail (GDK_IS_MONITOR (monitor), 0);
+
+  return monitor->refresh_rate;
+}
+
 GdkMonitor *
 gdk_monitor_new (GdkDisplay *display)
 {
@@ -345,3 +375,30 @@ gdk_monitor_set_scale_factor (GdkMonitor *monitor,
 
   g_object_notify (G_OBJECT (monitor), "scale-factor");
 }
+<<<<<<< HEAD
+=======
+
+void
+gdk_monitor_set_primary (GdkMonitor *monitor,
+                         gboolean    primary)
+{
+  if (monitor->primary == primary)
+    return;
+
+  monitor->primary = primary;
+
+  g_object_notify (G_OBJECT (monitor), "primary");
+}
+
+void
+gdk_monitor_set_refresh_rate (GdkMonitor *monitor,
+                              int         refresh_rate)
+{
+  if (monitor->refresh_rate == refresh_rate)
+    return;
+
+  monitor->refresh_rate = refresh_rate;
+
+  g_object_notify (G_OBJECT (monitor), "refresh-rate");
+}
+>>>>>>> 3b15fdf... Add refresh rate
diff --git a/gdk/gdkmonitor.h b/gdk/gdkmonitor.h
index 208dcb9..d837223 100644
--- a/gdk/gdkmonitor.h
+++ b/gdk/gdkmonitor.h
@@ -58,6 +58,8 @@ GDK_AVAILABLE_IN_3_22
 const char * gdk_monitor_get_model            (GdkMonitor   *monitor);
 GDK_AVAILABLE_IN_3_22
 int          gdk_monitor_get_scale_factor     (GdkMonitor   *monitor);
+GDK_AVAILABLE_IN_3_22
+int          gdk_monitor_get_refresh_rate     (GdkMonitor   *monitor);
 
 G_END_DECLS
 
diff --git a/gdk/gdkmonitorprivate.h b/gdk/gdkmonitorprivate.h
index bc15c25..f0116c5 100644
--- a/gdk/gdkmonitorprivate.h
+++ b/gdk/gdkmonitorprivate.h
@@ -34,6 +34,7 @@ struct _GdkMonitor {
   int width_mm;
   int height_mm;
   int scale_factor;
+  int refresh_rate;
 };
 
 struct _GdkMonitorClass {
diff --git a/gdk/wayland/gdkscreen-wayland.c b/gdk/wayland/gdkscreen-wayland.c
index 81f96e7..8306921 100644
--- a/gdk/wayland/gdkscreen-wayland.c
+++ b/gdk/wayland/gdkscreen-wayland.c
@@ -59,7 +59,6 @@ struct _GdkWaylandMonitor {
   guint32 id;
   guint32 version;
   struct wl_output *output;
-  int refresh_rate;
   gboolean added;
 };
 
@@ -1153,7 +1152,7 @@ output_handle_mode (void             *data,
     return;
 
   gdk_monitor_set_size (GDK_MONITOR (monitor), width, height);
-  monitor->refresh_rate = refresh;
+  gdk_monitor_set_refresh_rate (GDK_MONITOR (monitor), refresh);
 
   if (width != 0 && monitor->version < OUTPUT_VERSION_WITH_DONE)
     {
@@ -1285,7 +1284,7 @@ _gdk_wayland_screen_get_output_refresh_rate (GdkScreen        *screen,
 
   monitor = get_monitor_for_output (screen, output);
   if (monitor != NULL)
-    return monitor->refresh_rate;
+    return gdk_monitor_get_refresh_rate (GDK_MONITOR (monitor));
 
   return 0;
 }


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