[mutter] monitor-transform: Add generic function to get relative transform
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-transform: Add generic function to get relative transform
- Date: Fri, 28 Feb 2020 10:37:28 +0000 (UTC)
commit d600cd9aeef5206787c60e8ba93fd82e1f17a971
Author: Robert Mader <robert mader posteo de>
Date: Mon Jun 24 21:26:31 2019 +0200
monitor-transform: Add generic function to get relative transform
It takes transforms A and B and returns the transform to get from
A to B.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/526
src/backends/meta-monitor-transform.c | 27 +++++++++++++++++++++++++++
src/backends/meta-monitor-transform.h | 3 +++
2 files changed, 30 insertions(+)
---
diff --git a/src/backends/meta-monitor-transform.c b/src/backends/meta-monitor-transform.c
index e8672d151..f0d3fd52e 100644
--- a/src/backends/meta-monitor-transform.c
+++ b/src/backends/meta-monitor-transform.c
@@ -53,3 +53,30 @@ meta_monitor_transform_transform (MetaMonitorTransform transform,
return new_transform;
}
+
+/**
+ * meta_monitor_transform_relative_transform:
+ * @transform: The transform to start from
+ * @other: The transform to go to
+ *
+ * Return value: a transform to get from @transform to @other
+ */
+MetaMonitorTransform
+meta_monitor_transform_relative_transform (MetaMonitorTransform transform,
+ MetaMonitorTransform other)
+{
+ MetaMonitorTransform relative_transform;
+
+ relative_transform = ((other % META_MONITOR_TRANSFORM_FLIPPED -
+ transform % META_MONITOR_TRANSFORM_FLIPPED) %
+ META_MONITOR_TRANSFORM_FLIPPED);
+
+ if (meta_monitor_transform_is_flipped (transform) !=
+ meta_monitor_transform_is_flipped (other))
+ {
+ relative_transform = (meta_monitor_transform_invert (relative_transform) +
+ META_MONITOR_TRANSFORM_FLIPPED);
+ }
+
+ return relative_transform;
+}
diff --git a/src/backends/meta-monitor-transform.h b/src/backends/meta-monitor-transform.h
index 86dc9692d..f73abe79a 100644
--- a/src/backends/meta-monitor-transform.h
+++ b/src/backends/meta-monitor-transform.h
@@ -58,4 +58,7 @@ META_EXPORT_TEST
MetaMonitorTransform meta_monitor_transform_transform (MetaMonitorTransform transform,
MetaMonitorTransform other);
+MetaMonitorTransform meta_monitor_transform_relative_transform (MetaMonitorTransform transform,
+ MetaMonitorTransform other);
+
#endif /* META_MONITOR_TRANSFORM_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]