[gnome-control-center/wip/rtcm/new-display-config: 1/3] display: Introduce an abstract API for display configuration
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/rtcm/new-display-config: 1/3] display: Introduce an abstract API for display configuration
- Date: Wed, 18 Jan 2017 13:56:07 +0000 (UTC)
commit b63d4f9644ef13f83be089d7b22a7146694b6ec4
Author: Rui Matos <tiagomatos gmail com>
Date: Mon Jan 2 18:10:34 2017 +0000
display: Introduce an abstract API for display configuration
This will allow us to switch the display panel away from using the
GnomeRR api directly in order to gracefully move to a new DBus display
configuration API to be provided by mutter while still keeping the
existing functionality on top of the GnomeRR api while the new one
is developed.
panels/display/Makefile.am | 4 +
panels/display/cc-display-config-manager.c | 67 ++++++++
panels/display/cc-display-config-manager.h | 49 ++++++
panels/display/cc-display-config.c | 237 ++++++++++++++++++++++++++++
panels/display/cc-display-config.h | 188 ++++++++++++++++++++++
5 files changed, 545 insertions(+), 0 deletions(-)
---
diff --git a/panels/display/Makefile.am b/panels/display/Makefile.am
index 9402044..4f71efe 100644
--- a/panels/display/Makefile.am
+++ b/panels/display/Makefile.am
@@ -4,6 +4,10 @@ cappletname = display
noinst_LTLIBRARIES = libdisplay.la
libdisplay_la_SOURCES = \
+ cc-display-config.c \
+ cc-display-config.h \
+ cc-display-config-manager.c \
+ cc-display-config-manager.h \
cc-display-panel.c \
cc-display-panel.h \
scrollarea.c \
diff --git a/panels/display/cc-display-config-manager.c b/panels/display/cc-display-config-manager.c
new file mode 100644
index 0000000..8b89591
--- /dev/null
+++ b/panels/display/cc-display-config-manager.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2016 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include "cc-display-config-manager.h"
+
+G_DEFINE_TYPE (CcDisplayConfigManager,
+ cc_display_config_manager,
+ G_TYPE_OBJECT)
+
+enum
+{
+ CONFIG_MANAGER_CHANGED,
+ N_CONFIG_MANAGER_SIGNALS,
+};
+
+static guint config_manager_signals[N_CONFIG_MANAGER_SIGNALS] = { 0 };
+
+static void
+cc_display_config_manager_init (CcDisplayConfigManager *self)
+{
+}
+
+static void
+cc_display_config_manager_class_init (CcDisplayConfigManagerClass *klass)
+{
+ config_manager_signals[CONFIG_MANAGER_CHANGED] =
+ g_signal_new ("changed",
+ CC_TYPE_DISPLAY_CONFIG_MANAGER,
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
+
+void
+_cc_display_config_manager_emit_changed (CcDisplayConfigManager *self)
+{
+ g_signal_emit (self, config_manager_signals[CONFIG_MANAGER_CHANGED], 0);
+}
+
+CcDisplayConfig *
+cc_display_config_manager_get_current (CcDisplayConfigManager *self)
+{
+ return CC_DISPLAY_CONFIG_MANAGER_GET_CLASS (self)->get_current (self);
+}
+
+gboolean
+cc_display_config_manager_apply (CcDisplayConfigManager *self)
+{
+ return CC_DISPLAY_CONFIG_MANAGER_GET_CLASS (self)->apply (self);
+}
diff --git a/panels/display/cc-display-config-manager.h b/panels/display/cc-display-config-manager.h
new file mode 100644
index 0000000..c42c742
--- /dev/null
+++ b/panels/display/cc-display-config-manager.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2016 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#ifndef _CC_DISPLAY_CONFIG_MANAGER_H
+#define _CC_DISPLAY_CONFIG_MANAGER_H
+
+#include <glib-object.h>
+
+#include "cc-display-config.h"
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_DISPLAY_CONFIG_MANAGER (cc_display_config_manager_get_type ())
+G_DECLARE_DERIVABLE_TYPE (CcDisplayConfigManager, cc_display_config_manager,
+ CC, DISPLAY_CONFIG_MANAGER, GObject)
+
+struct _CcDisplayConfigManagerClass
+{
+ GObjectClass parent_class;
+
+ CcDisplayConfig * (*get_current) (CcDisplayConfigManager *self);
+ gboolean (*apply) (CcDisplayConfigManager *self);
+};
+
+CcDisplayConfig * cc_display_config_manager_get_current (CcDisplayConfigManager *self);
+
+gboolean cc_display_config_manager_apply (CcDisplayConfigManager *self);
+
+void _cc_display_config_manager_emit_changed (CcDisplayConfigManager *self);
+
+G_END_DECLS
+
+#endif /* _CC_DISPLAY_CONFIG_MANAGER_H */
diff --git a/panels/display/cc-display-config.c b/panels/display/cc-display-config.c
new file mode 100644
index 0000000..a479c7a
--- /dev/null
+++ b/panels/display/cc-display-config.c
@@ -0,0 +1,237 @@
+/*
+ * Copyright (C) 2016 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include "cc-display-config.h"
+
+G_DEFINE_TYPE (CcDisplayMode,
+ cc_display_mode,
+ G_TYPE_OBJECT)
+
+static void
+cc_display_mode_init (CcDisplayMode *self)
+{
+}
+
+static void
+cc_display_mode_class_init (CcDisplayModeClass *klass)
+{
+}
+
+void
+cc_display_mode_get_resolution (CcDisplayMode *self, int *w, int *h)
+{
+ return CC_DISPLAY_MODE_GET_CLASS (self)->get_resolution (self, w, h);
+}
+
+gboolean
+cc_display_mode_is_interlaced (CcDisplayMode *self)
+{
+ return CC_DISPLAY_MODE_GET_CLASS (self)->is_interlaced (self);
+}
+
+int
+cc_display_mode_get_freq (CcDisplayMode *self)
+{
+ return CC_DISPLAY_MODE_GET_CLASS (self)->get_freq (self);
+}
+
+double
+cc_display_mode_get_freq_f (CcDisplayMode *self)
+{
+ return CC_DISPLAY_MODE_GET_CLASS (self)->get_freq_f (self);
+}
+
+
+G_DEFINE_TYPE (CcDisplayMonitor,
+ cc_display_monitor,
+ G_TYPE_OBJECT)
+
+static void
+cc_display_monitor_init (CcDisplayMonitor *self)
+{
+}
+
+static void
+cc_display_monitor_class_init (CcDisplayMonitorClass *klass)
+{
+}
+
+const char *
+cc_display_monitor_get_display_name (CcDisplayMonitor *self)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->get_display_name (self);
+}
+
+gboolean
+cc_display_monitor_is_builtin (CcDisplayMonitor *self)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->is_builtin (self);
+}
+
+gboolean
+cc_display_monitor_is_primary (CcDisplayMonitor *self)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->is_primary (self);
+}
+
+gboolean
+cc_display_monitor_is_active (CcDisplayMonitor *self)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->is_active (self);
+}
+
+void
+cc_display_monitor_set_active (CcDisplayMonitor *self, gboolean active)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->set_active (self, active);
+}
+
+CcDisplayRotation
+cc_display_monitor_get_rotation (CcDisplayMonitor *self)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->get_rotation (self);
+}
+
+void
+cc_display_monitor_set_rotation (CcDisplayMonitor *self,
+ CcDisplayRotation rotation)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->set_rotation (self, rotation);
+}
+
+gboolean
+cc_display_monitor_supports_rotation (CcDisplayMonitor *self, CcDisplayRotation r)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->supports_rotation (self, r);
+}
+
+void
+cc_display_monitor_get_physical_size (CcDisplayMonitor *self, int *w, int *h)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->get_physical_size (self, w, h);
+}
+
+void
+cc_display_monitor_get_geometry (CcDisplayMonitor *self, int *x, int *y, int *w, int *h)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->get_geometry (self, x, y, w, h);
+}
+
+CcDisplayMode *
+cc_display_monitor_get_mode (CcDisplayMonitor *self)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->get_mode (self);
+}
+
+CcDisplayMode *
+cc_display_monitor_get_preferred_mode (CcDisplayMonitor *self)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->get_preferred_mode (self);
+}
+
+guint32
+cc_display_monitor_get_id (CcDisplayMonitor *self)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->get_id (self);
+}
+
+GList *
+cc_display_monitor_get_modes (CcDisplayMonitor *self)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->get_modes (self);
+}
+
+gboolean
+cc_display_monitor_supports_underscanning (CcDisplayMonitor *self)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->supports_underscanning (self);
+}
+
+gboolean
+cc_display_monitor_get_underscanning (CcDisplayMonitor *self)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->get_underscanning (self);
+}
+
+void
+cc_display_monitor_set_underscanning (CcDisplayMonitor *self,
+ gboolean underscanning)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->set_underscanning (self, underscanning);
+}
+
+void
+cc_display_monitor_set_mode (CcDisplayMonitor *self, CcDisplayMode *m)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->set_mode (self, m);
+}
+
+void
+cc_display_monitor_set_position (CcDisplayMonitor *self, int x, int y)
+{
+ return CC_DISPLAY_MONITOR_GET_CLASS (self)->set_position (self, x, y);
+}
+
+
+G_DEFINE_TYPE (CcDisplayConfig,
+ cc_display_config,
+ G_TYPE_OBJECT)
+
+static void
+cc_display_config_init (CcDisplayConfig *self)
+{
+}
+
+static void
+cc_display_config_class_init (CcDisplayConfigClass *klass)
+{
+}
+
+GList *
+cc_display_config_get_monitors (CcDisplayConfig *self)
+{
+ return CC_DISPLAY_CONFIG_GET_CLASS (self)->get_monitors (self);
+}
+
+gboolean
+cc_display_config_is_applicable (CcDisplayConfig *self)
+{
+ return CC_DISPLAY_CONFIG_GET_CLASS (self)->is_applicable (self);
+}
+
+gboolean
+cc_display_config_equal (CcDisplayConfig *self,
+ CcDisplayConfig *other)
+{
+ return CC_DISPLAY_CONFIG_GET_CLASS (self)->equal (self, other);
+}
+
+void
+cc_display_config_set_primary (CcDisplayConfig *self,
+ CcDisplayMonitor *monitor)
+{
+ return CC_DISPLAY_CONFIG_GET_CLASS (self)->set_primary (self, monitor);
+}
+
+gboolean
+cc_display_config_apply (CcDisplayConfig *self,
+ GError **error)
+{
+ return CC_DISPLAY_CONFIG_GET_CLASS (self)->apply (self, error);
+}
diff --git a/panels/display/cc-display-config.h b/panels/display/cc-display-config.h
new file mode 100644
index 0000000..b520c1b
--- /dev/null
+++ b/panels/display/cc-display-config.h
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2016 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#ifndef _CC_DISPLAY_CONFIG_H
+#define _CC_DISPLAY_CONFIG_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*
+ * GNOME Control Center display configuration system:
+ *
+ * The display configuration system consists of multiple concepts:
+ *
+ * CcDisplayConfig:
+ *
+ * Configuration instance, read from mutter using the
+ * org.gnome.Mutter.DisplayConfig D-Bus API. Contains information about the
+ * current configuration. Can be copied, to create a representation of a
+ * configuration at a given time, and applied, applying any changes that has
+ * been made to the objects associated with the configuration.
+ *
+ * CcDisplayConfig provides a list of all known "monitors" known to the
+ * compositor. It does not know about ports without any monitors connected,
+ * nor low level details about monitors, such as tiling etc.
+ *
+ * CcDisplayMonitor:
+ *
+ * A high level representation of a connected monitor. A monitor have details
+ * associated with it, some which can be altered. Each CcDisplayMonitor
+ * instance is associated with a single CcDisplayConfig instance. All
+ * alteration to a monitor is cached and not applied until
+ * cc_display_config_apply() is called on the corresponding CcDisplayConfig
+ * object.
+ *
+ * CcDisplayMode:
+ *
+ * A monitor mode, including resolution, refresh rate, and scale. Each monitor
+ * will have a list of possible modes.
+ *
+ */
+
+typedef enum _CcDisplayRotation
+{
+ CC_DISPLAY_ROTATION_NONE = 1 << 0,
+ CC_DISPLAY_ROTATION_90 = 1 << 1,
+ CC_DISPLAY_ROTATION_180 = 1 << 2,
+ CC_DISPLAY_ROTATION_270 = 1 << 3
+} CcDisplayRotation;
+
+
+#define CC_TYPE_DISPLAY_MODE (cc_display_mode_get_type ())
+G_DECLARE_DERIVABLE_TYPE (CcDisplayMode, cc_display_mode,
+ CC, DISPLAY_MODE, GObject)
+
+struct _CcDisplayModeClass
+{
+ GObjectClass parent_class;
+
+ void (*get_resolution) (CcDisplayMode *self, int *w, int *h);
+ gboolean (*is_interlaced) (CcDisplayMode *self);
+ int (*get_freq) (CcDisplayMode *self);
+ double (*get_freq_f) (CcDisplayMode *self);
+};
+
+
+#define CC_TYPE_DISPLAY_MONITOR (cc_display_monitor_get_type ())
+G_DECLARE_DERIVABLE_TYPE (CcDisplayMonitor, cc_display_monitor,
+ CC, DISPLAY_MONITOR, GObject)
+
+struct _CcDisplayMonitorClass
+{
+ GObjectClass parent_class;
+
+ guint32 (*get_id) (CcDisplayMonitor *self);
+ const char * (*get_display_name) (CcDisplayMonitor *self);
+ gboolean (*is_builtin) (CcDisplayMonitor *self);
+ gboolean (*is_primary) (CcDisplayMonitor *self);
+ gboolean (*is_active) (CcDisplayMonitor *self);
+ void (*set_active) (CcDisplayMonitor *self, gboolean a);
+ CcDisplayRotation (*get_rotation) (CcDisplayMonitor *self);
+ void (*set_rotation) (CcDisplayMonitor *self, CcDisplayRotation r);
+ gboolean (*supports_rotation) (CcDisplayMonitor *self, CcDisplayRotation r);
+ void (*get_physical_size) (CcDisplayMonitor *self, int *w, int *h);
+ void (*get_geometry) (CcDisplayMonitor *self, int *x, int *y, int *w, int *h);
+ gboolean (*supports_underscanning) (CcDisplayMonitor *self);
+ gboolean (*get_underscanning) (CcDisplayMonitor *self);
+ void (*set_underscanning) (CcDisplayMonitor *self, gboolean u);
+ CcDisplayMode * (*get_mode) (CcDisplayMonitor *self);
+ CcDisplayMode * (*get_preferred_mode) (CcDisplayMonitor *self);
+ GList * (*get_modes) (CcDisplayMonitor *self);
+ void (*set_mode) (CcDisplayMonitor *self, CcDisplayMode *m);
+ void (*set_position) (CcDisplayMonitor *self, int x, int y);
+};
+
+
+#define CC_TYPE_DISPLAY_CONFIG (cc_display_config_get_type ())
+G_DECLARE_DERIVABLE_TYPE (CcDisplayConfig, cc_display_config,
+ CC, DISPLAY_CONFIG, GObject)
+
+struct _CcDisplayConfigClass
+{
+ GObjectClass parent_class;
+
+ GList * (*get_monitors) (CcDisplayConfig *self);
+ gboolean (*is_applicable) (CcDisplayConfig *self);
+ gboolean (*equal) (CcDisplayConfig *self, CcDisplayConfig *other);
+ void (*set_primary) (CcDisplayConfig *self, CcDisplayMonitor *monitor);
+ gboolean (*apply) (CcDisplayConfig *self, GError **error);
+};
+
+
+GList *cc_display_config_get_monitors (CcDisplayConfig *config);
+gboolean cc_display_config_is_applicable (CcDisplayConfig *config);
+gboolean cc_display_config_equal (CcDisplayConfig *config,
+ CcDisplayConfig *other);
+void cc_display_config_set_primary (CcDisplayConfig *config,
+ CcDisplayMonitor *monitor);
+gboolean cc_display_config_apply (CcDisplayConfig *config, GError **error);
+
+const char * cc_display_monitor_get_display_name (CcDisplayMonitor *monitor);
+gboolean cc_display_monitor_is_active (CcDisplayMonitor *monitor);
+void cc_display_monitor_set_active (CcDisplayMonitor *monitor, gboolean active);
+const char * cc_display_monitor_get_connector_name (CcDisplayMonitor *monitor);
+CcDisplayRotation cc_display_monitor_get_rotation (CcDisplayMonitor *monitor);
+void cc_display_monitor_set_rotation (CcDisplayMonitor *monitor, CcDisplayRotation r);
+gboolean cc_display_monitor_supports_rotation (CcDisplayMonitor *monitor,
+ CcDisplayRotation rotation);
+void cc_display_monitor_get_physical_size (CcDisplayMonitor *monitor, int *w, int *h);
+gboolean cc_display_monitor_is_builtin (CcDisplayMonitor *monitor);
+gboolean cc_display_monitor_is_primary (CcDisplayMonitor *monitor);
+guint32 cc_display_monitor_get_id (CcDisplayMonitor *monitor);
+
+GList * cc_display_monitor_get_clones (CcDisplayMonitor *monitor);
+CcDisplayMonitor * cc_display_monitor_get_cloned_of (CcDisplayMonitor *monitor);
+void cc_display_monitor_set_clone_of (CcDisplayMonitor *monitor,
+ CcDisplayMonitor *primary);
+
+gboolean cc_display_monitor_supports_underscanning (CcDisplayMonitor *monitor);
+gboolean cc_display_monitor_get_underscanning (CcDisplayMonitor *monitor);
+void cc_display_monitor_set_underscanning (CcDisplayMonitor *monitor,
+ gboolean underscanning);
+
+CcDisplayMode * cc_display_monitor_get_mode (CcDisplayMonitor *monitor);
+void cc_display_monitor_get_geometry (CcDisplayMonitor *monitor,
+ int *x,
+ int *y,
+ int *width,
+ int *height);
+GList * cc_display_monitor_get_modes (CcDisplayMonitor *monitor);
+CcDisplayMode * cc_display_monitor_get_preferred_mode (CcDisplayMonitor *monitor);
+
+void cc_display_monitor_set_mode (CcDisplayMonitor *monitor,
+ CcDisplayMode *mode);
+void cc_display_monitor_set_position (CcDisplayMonitor *monitor,
+ int x, int y);
+
+void cc_display_mode_get_resolution (CcDisplayMode *mode,
+ int *width,
+ int *height);
+void cc_display_mode_get_dimensions (CcDisplayMode *mode,
+ int *width,
+ int *hegiht);
+int cc_display_mode_get_scale (CcDisplayMode *mode);
+gboolean cc_display_mode_is_interlaced (CcDisplayMode *mode);
+int cc_display_mode_get_freq (CcDisplayMode *mode);
+double cc_display_mode_get_freq_f (CcDisplayMode *mode);
+
+G_END_DECLS
+
+#endif /* _CC_DISPLAY_CONFIG_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]