[gtk+/wip/matthiasc/monitor] Add subpixel layout



commit b224d1df6113fb9e8c940ee4bfbf7ad0adc64b89
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Apr 2 16:02:48 2016 -0400

    Add subpixel layout

 gdk/gdkmonitor.c                |   56 +++++++++++++++++++++-----------------
 gdk/gdkmonitor.h                |   11 +++++++
 gdk/gdkmonitorprivate.h         |    3 ++
 gdk/wayland/gdkscreen-wayland.c |    1 +
 4 files changed, 46 insertions(+), 25 deletions(-)
---
diff --git a/gdk/gdkmonitor.c b/gdk/gdkmonitor.c
index f7717e6..b7a8a28 100644
--- a/gdk/gdkmonitor.c
+++ b/gdk/gdkmonitor.c
@@ -22,13 +22,13 @@
 #include "config.h"
 
 #include "gdkmonitorprivate.h"
+#include "gdkenumtypes.h"
 
 /*
  * TODO:
  * - primary
  * - workarea
  * - monitor type (laptop, projector, ...)
- * - subpixel layout
  * - consider vfuncs instead of baseclass storage
  * - consider array instead of list
  * - provide a persistent id (if the backend allows)
@@ -42,11 +42,8 @@ enum {
   PROP_GEOMETRY,
   PROP_WIDTH_MM,
   PROP_HEIGHT_MM,
-<<<<<<< HEAD
-=======
-  PROP_PRIMARY,
   PROP_REFRESH_RATE,
->>>>>>> 3b15fdf... Add refresh rate
+  PROP_SUBPIXEL_LAYOUT,
   LAST_PROP
 };
 
@@ -98,17 +95,14 @@ 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
+    case PROP_SUBPIXEL_LAYOUT:
+      g_value_set_enum (value, monitor->subpixel_layout);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -205,6 +199,13 @@ gdk_monitor_class_init (GdkMonitorClass *class)
                       0, G_MAXINT,
                       0,
                       G_PARAM_READABLE);
+  props[PROP_SUBPIXEL_LAYOUT] =
+    g_param_spec_enum ("subpixel-layout",
+                       "Subpixel layout",
+                       "The subpixel layout",
+                       GDK_TYPE_SUBPIXEL_LAYOUT,
+                       GDK_SUBPIXEL_LAYOUT_UNKNOWN,
+                       G_PARAM_READABLE);
 
   g_object_class_install_properties (object_class, LAST_PROP, props);
 }
@@ -270,6 +271,14 @@ gdk_monitor_get_refresh_rate (GdkMonitor *monitor)
   return monitor->refresh_rate;
 }
 
+GdkSubpixelLayout
+gdk_monitor_get_subpixel_layout (GdkMonitor *monitor)
+{
+  g_return_val_if_fail (GDK_IS_MONITOR (monitor), GDK_SUBPIXEL_LAYOUT_UNKNOWN);
+
+  return monitor->subpixel_layout;
+}
+
 GdkMonitor *
 gdk_monitor_new (GdkDisplay *display)
 {
@@ -375,30 +384,27 @@ 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)
+gdk_monitor_set_refresh_rate (GdkMonitor *monitor,
+                              int         refresh_rate)
 {
-  if (monitor->primary == primary)
+  if (monitor->refresh_rate == refresh_rate)
     return;
 
-  monitor->primary = primary;
+  monitor->refresh_rate = refresh_rate;
 
-  g_object_notify (G_OBJECT (monitor), "primary");
+  g_object_notify (G_OBJECT (monitor), "refresh-rate");
 }
 
 void
-gdk_monitor_set_refresh_rate (GdkMonitor *monitor,
-                              int         refresh_rate)
+gdk_monitor_set_subpixel_layout (GdkMonitor        *monitor,
+                                 GdkSubpixelLayout  subpixel_layout)
 {
-  if (monitor->refresh_rate == refresh_rate)
+  if (monitor->subpixel_layout == subpixel_layout)
     return;
 
-  monitor->refresh_rate = refresh_rate;
+  monitor->subpixel_layout = subpixel_layout;
 
-  g_object_notify (G_OBJECT (monitor), "refresh-rate");
+  g_object_notify (G_OBJECT (monitor), "subpixel-layout");
 }
->>>>>>> 3b15fdf... Add refresh rate
diff --git a/gdk/gdkmonitor.h b/gdk/gdkmonitor.h
index d837223..5690c98 100644
--- a/gdk/gdkmonitor.h
+++ b/gdk/gdkmonitor.h
@@ -40,6 +40,15 @@ G_BEGIN_DECLS
 typedef struct _GdkMonitor      GdkMonitor;
 typedef struct _GdkMonitorClass GdkMonitorClass;
 
+typedef enum {
+  GDK_SUBPIXEL_LAYOUT_UNKNOWN,
+  GDK_SUBPIXEL_LAYOUT_NONE,
+  GDK_SUBPIXEL_LAYOUT_HORIZONTAL_RGB,
+  GDK_SUBPIXEL_LAYOUT_HORIZONTAL_BGR,
+  GDK_SUBPIXEL_LAYOUT_VERTICAL_RGB,
+  GDK_SUBPIXEL_LAYOUT_VERTICAL_BGR
+} GdkSubpixelLayout;
+
 GDK_AVAILABLE_IN_3_22
 GType        gdk_monitor_get_type             (void) G_GNUC_CONST;
 
@@ -60,6 +69,8 @@ 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);
+GDK_AVAILABLE_IN_3_22
+GdkSubpixelLayout gdk_monitor_get_subpixel_layout (GdkMonitor   *monitor);
 
 G_END_DECLS
 
diff --git a/gdk/gdkmonitorprivate.h b/gdk/gdkmonitorprivate.h
index f0116c5..ae5e86d 100644
--- a/gdk/gdkmonitorprivate.h
+++ b/gdk/gdkmonitorprivate.h
@@ -35,6 +35,7 @@ struct _GdkMonitor {
   int height_mm;
   int scale_factor;
   int refresh_rate;
+  GdkSubpixelLayout subpixel_layout;
 };
 
 struct _GdkMonitorClass {
@@ -62,6 +63,8 @@ void            gdk_monitor_set_scale_factor    (GdkMonitor *monitor,
                                                  int         scale);
 void            gdk_monitor_set_refresh_rate    (GdkMonitor *monitor,
                                                  int         refresh_rate);
+void            gdk_monitor_set_subpixel_layout (GdkMonitor        *monitor,
+                                                 GdkSubpixelLayout  subpixel);
 
 G_END_DECLS
 
diff --git a/gdk/wayland/gdkscreen-wayland.c b/gdk/wayland/gdkscreen-wayland.c
index 8306921..0d839aa 100644
--- a/gdk/wayland/gdkscreen-wayland.c
+++ b/gdk/wayland/gdkscreen-wayland.c
@@ -1081,6 +1081,7 @@ output_handle_geometry (void             *data,
 
   gdk_monitor_set_position (GDK_MONITOR (monitor), x, y);
   gdk_monitor_set_physical_size (GDK_MONITOR (monitor), physical_width, physical_height);
+  gdk_monitor_set_subpixel_layout (GDK_MONITOR (monitor), subpixel);
   gdk_monitor_set_manufacturer (GDK_MONITOR (monitor), make);
   gdk_monitor_set_model (GDK_MONITOR (monitor), model);
 


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