[gnome-flashback] backends: add GfMonitorConfig



commit c1973376ad9d8fa1cf8135008b2e56ad7f53e046
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Wed Sep 20 18:14:51 2017 +0300

    backends: add GfMonitorConfig

 backends/Makefile.am                         |    2 +
 backends/gf-logical-monitor.c                |    1 +
 backends/gf-monitor-config-manager-private.h |    7 ---
 backends/gf-monitor-config-private.h         |   47 +++++++++++++++++
 backends/gf-monitor-config.c                 |   71 ++++++++++++++++++++++++++
 5 files changed, 121 insertions(+), 7 deletions(-)
---
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 7f10f63..cd5621c 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -36,6 +36,8 @@ libbackends_la_SOURCES = \
        gf-logical-monitor-private.h \
        gf-logical-monitor.c \
        gf-monitor-config-manager-private.h \
+       gf-monitor-config-private.h \
+       gf-monitor-config.c \
        gf-monitor-manager-dummy-private.h \
        gf-monitor-manager-dummy.c \
        gf-monitor-manager-enums-private.h \
diff --git a/backends/gf-logical-monitor.c b/backends/gf-logical-monitor.c
index 479d9b9..b5b14df 100644
--- a/backends/gf-logical-monitor.c
+++ b/backends/gf-logical-monitor.c
@@ -22,6 +22,7 @@
 #include "config.h"
 #include "gf-crtc-private.h"
 #include "gf-logical-monitor-private.h"
+#include "gf-monitor-config-private.h"
 #include "gf-output-private.h"
 
 typedef struct
diff --git a/backends/gf-monitor-config-manager-private.h b/backends/gf-monitor-config-manager-private.h
index 1cf5b1d..7385e27 100644
--- a/backends/gf-monitor-config-manager-private.h
+++ b/backends/gf-monitor-config-manager-private.h
@@ -29,13 +29,6 @@ G_BEGIN_DECLS
 
 typedef struct
 {
-  GfMonitorSpec     *monitor_spec;
-  GfMonitorModeSpec *mode_spec;
-  gboolean           enable_underscanning;
-} GfMonitorConfig;
-
-typedef struct
-{
   GfRectangle         layout;
   GList              *monitor_configs;
   GfMonitorTransform  transform;
diff --git a/backends/gf-monitor-config-private.h b/backends/gf-monitor-config-private.h
new file mode 100644
index 0000000..44bd61e
--- /dev/null
+++ b/backends/gf-monitor-config-private.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2016 Red Hat
+ * Copyright (C) 2017 Alberts Muktupāvels
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Adapted from mutter:
+ * - src/backends/meta-monitor-config-manager.h
+ */
+
+#ifndef GF_MONITOR_CONFIG_PRIVATE_H
+#define GF_MONITOR_CONFIG_PRIVATE_H
+
+#include "gf-monitor-private.h"
+
+G_BEGIN_DECLS
+
+typedef struct
+{
+  GfMonitorSpec     *monitor_spec;
+  GfMonitorModeSpec *mode_spec;
+  gboolean           enable_underscanning;
+} GfMonitorConfig;
+
+GfMonitorConfig *gf_monitor_config_new    (GfMonitor        *monitor,
+                                           GfMonitorMode    *mode);
+
+void             gf_monitor_config_free   (GfMonitorConfig  *config);
+
+
+gboolean         gf_verify_monitor_config (GfMonitorConfig  *config,
+                                           GError          **error);
+
+G_END_DECLS
+
+#endif
diff --git a/backends/gf-monitor-config.c b/backends/gf-monitor-config.c
new file mode 100644
index 0000000..aaeda8b
--- /dev/null
+++ b/backends/gf-monitor-config.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2016 Red Hat
+ * Copyright (C) 2017 Alberts Muktupāvels
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Adapted from mutter:
+ * - src/backends/meta-monitor-config-manager.c
+ */
+
+#include "config.h"
+
+#include <gio/gio.h>
+
+#include "gf-monitor-config-private.h"
+#include "gf-monitor-spec-private.h"
+
+GfMonitorConfig *
+gf_monitor_config_new (GfMonitor     *monitor,
+                       GfMonitorMode *mode)
+{
+  GfMonitorSpec *spec;
+  GfMonitorModeSpec *mode_spec;
+  GfMonitorConfig *config;
+
+  spec = gf_monitor_get_spec (monitor);
+  mode_spec = gf_monitor_mode_get_spec (mode);
+
+  config = g_new0 (GfMonitorConfig, 1);
+  config->monitor_spec = gf_monitor_spec_clone (spec);
+  config->mode_spec = g_memdup (mode_spec, sizeof (GfMonitorModeSpec));
+  config->enable_underscanning = gf_monitor_is_underscanning (monitor);
+
+  return config;
+}
+
+void
+gf_monitor_config_free (GfMonitorConfig *config)
+{
+  gf_monitor_spec_free (config->monitor_spec);
+  g_free (config->mode_spec);
+  g_free (config);
+}
+
+gboolean
+gf_verify_monitor_config (GfMonitorConfig  *config,
+                          GError          **error)
+{
+  if (config->monitor_spec && config->mode_spec)
+    {
+      return TRUE;
+    }
+  else
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "Monitor config incomplete");
+
+      return FALSE;
+    }
+}


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