[mutter] monitor-transform: Add helper function transform_invert()



commit b7a9c7e7d384a08f7106e00b7089e197cc27d945
Author: Robert Mader <robert mader posteo de>
Date:   Sat Jan 5 14:18:02 2019 +0100

    monitor-transform: Add helper function transform_invert()
    
    It returns the inverted transform, which is always the same as the
    input, besides for TRANSFORM_90 and TRANSFORM_270.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/366

 src/Makefile.am                       |  1 +
 src/backends/meta-monitor-transform.c | 40 +++++++++++++++++++++++++++++++++++
 src/backends/meta-monitor-transform.h |  2 ++
 src/meson.build                       |  1 +
 4 files changed, 44 insertions(+)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index f37d095c2..8e5d03bce 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -160,6 +160,7 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES =      \
        backends/meta-monitor-manager-private.h \
        backends/meta-monitor-manager-dummy.c   \
        backends/meta-monitor-manager-dummy.h   \
+       backends/meta-monitor-transform.c       \
        backends/meta-monitor-transform.h       \
        backends/meta-orientation-manager.c     \
        backends/meta-orientation-manager.h     \
diff --git a/src/backends/meta-monitor-transform.c b/src/backends/meta-monitor-transform.c
new file mode 100644
index 000000000..1ecf341cc
--- /dev/null
+++ b/src/backends/meta-monitor-transform.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2018 Robert Mader
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "backends/meta-monitor-transform.h"
+
+MetaMonitorTransform
+meta_monitor_transform_invert (MetaMonitorTransform transform)
+{
+  switch (transform)
+    {
+    case META_MONITOR_TRANSFORM_90:
+      return META_MONITOR_TRANSFORM_270;
+    case META_MONITOR_TRANSFORM_270:
+      return META_MONITOR_TRANSFORM_90;
+    case META_MONITOR_TRANSFORM_NORMAL:
+    case META_MONITOR_TRANSFORM_180:
+    case META_MONITOR_TRANSFORM_FLIPPED:
+    case META_MONITOR_TRANSFORM_FLIPPED_90:
+    case META_MONITOR_TRANSFORM_FLIPPED_180:
+    case META_MONITOR_TRANSFORM_FLIPPED_270:
+      return transform;
+    }
+  g_assert_not_reached ();
+}
diff --git a/src/backends/meta-monitor-transform.h b/src/backends/meta-monitor-transform.h
index 87aa9c761..b2cf9ea53 100644
--- a/src/backends/meta-monitor-transform.h
+++ b/src/backends/meta-monitor-transform.h
@@ -50,4 +50,6 @@ meta_monitor_transform_is_flipped (MetaMonitorTransform transform)
   return (transform >= META_MONITOR_TRANSFORM_FLIPPED);
 }
 
+MetaMonitorTransform meta_monitor_transform_invert (MetaMonitorTransform transform);
+
 #endif /* META_MONITOR_TRANSFORM_H */
diff --git a/src/meson.build b/src/meson.build
index c0db00bb8..3fad9eda7 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -202,6 +202,7 @@ mutter_sources = [
   'backends/meta-monitor-manager-dummy.c',
   'backends/meta-monitor-manager-dummy.h',
   'backends/meta-monitor-manager-private.h',
+  'backends/meta-monitor-transform.c',
   'backends/meta-monitor-transform.h',
   'backends/meta-orientation-manager.c',
   'backends/meta-orientation-manager.h',


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