mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
monitor-transform: Add API to transform point
Transforms a point in a rectangle with the origin (0, 0). To be used to transform cursor hotspots within a cursor sprite. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1136
This commit is contained in:
parent
3c157242fa
commit
343de21af5
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user