diff --git a/src/backends/meta-monitor-transform.c b/src/backends/meta-monitor-transform.c index f0d3fd52e..d6b1f8b45 100644 --- a/src/backends/meta-monitor-transform.c +++ b/src/backends/meta-monitor-transform.c @@ -80,3 +80,49 @@ meta_monitor_transform_relative_transform (MetaMonitorTransform transform, return relative_transform; } + +void +meta_monitor_transform_transform_point (MetaMonitorTransform transform, + int area_width, + int area_height, + int x, + int y, + int *out_x, + int *out_y) +{ + switch (transform) + { + case META_MONITOR_TRANSFORM_NORMAL: + *out_x = x; + *out_y = y; + break; + case META_MONITOR_TRANSFORM_90: + *out_x = area_width - y; + *out_y = x; + break; + case META_MONITOR_TRANSFORM_180: + *out_x = area_width - x; + *out_y = area_height - y; + break; + case META_MONITOR_TRANSFORM_270: + *out_x = y, + *out_y = area_height - x; + break; + case META_MONITOR_TRANSFORM_FLIPPED: + *out_x = area_width - x; + *out_y = y; + break; + case META_MONITOR_TRANSFORM_FLIPPED_90: + *out_x = area_width - y; + *out_y = area_height - x; + break; + case META_MONITOR_TRANSFORM_FLIPPED_180: + *out_x = x; + *out_y = area_height - y; + break; + case META_MONITOR_TRANSFORM_FLIPPED_270: + *out_x = y; + *out_y = x; + break; + } +} diff --git a/src/backends/meta-monitor-transform.h b/src/backends/meta-monitor-transform.h index f73abe79a..6fca0a4e3 100644 --- a/src/backends/meta-monitor-transform.h +++ b/src/backends/meta-monitor-transform.h @@ -61,4 +61,12 @@ MetaMonitorTransform meta_monitor_transform_transform (MetaMonitorTransform tran MetaMonitorTransform meta_monitor_transform_relative_transform (MetaMonitorTransform transform, MetaMonitorTransform other); +void meta_monitor_transform_transform_point (MetaMonitorTransform transform, + int area_width, + int area_height, + int x, + int y, + int *out_x, + int *out_y); + #endif /* META_MONITOR_TRANSFORM_H */