monitor-transform: Invert the behaviour of transform_point
Previously it transformed a physical CRTC coordinate to a logical desktop coordinate. But current and future users of the function all require conversion from logical coordinates to physical coordinates. We would have had to always invert the transform parameter which is a waste of time when we can instead just invert the function behaviour. We also simplify the parameters to show both the point coordinate and the area dimensions are potentially transformed. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3180>
This commit is contained in:
parent
7a4c98438a
commit
5a05b1a901
@ -110,48 +110,76 @@ meta_monitor_transform_transform (MetaMonitorTransform 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)
|
||||
int *area_width,
|
||||
int *area_height,
|
||||
int *point_x,
|
||||
int *point_y)
|
||||
{
|
||||
int old_x = *point_x;
|
||||
int old_y = *point_y;
|
||||
int old_width = *area_width;
|
||||
int old_height = *area_height;
|
||||
int new_x = 0;
|
||||
int new_y = 0;
|
||||
int new_width = 0;
|
||||
int new_height = 0;
|
||||
|
||||
switch (transform)
|
||||
{
|
||||
case META_MONITOR_TRANSFORM_NORMAL:
|
||||
*out_x = x;
|
||||
*out_y = y;
|
||||
new_x = old_x;
|
||||
new_y = old_y;
|
||||
new_width = old_width;
|
||||
new_height = old_height;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_90:
|
||||
*out_x = area_width - y;
|
||||
*out_y = x;
|
||||
new_x = old_y;
|
||||
new_y = old_width - old_x;
|
||||
new_width = old_height;
|
||||
new_height = old_width;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_180:
|
||||
*out_x = area_width - x;
|
||||
*out_y = area_height - y;
|
||||
new_x = old_width - old_x;
|
||||
new_y = old_height - old_y;
|
||||
new_width = old_width;
|
||||
new_height = old_height;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_270:
|
||||
*out_x = y,
|
||||
*out_y = area_height - x;
|
||||
new_x = old_height - old_y;
|
||||
new_y = old_x;
|
||||
new_width = old_height;
|
||||
new_height = old_width;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_FLIPPED:
|
||||
*out_x = area_width - x;
|
||||
*out_y = y;
|
||||
new_x = old_width - old_x;
|
||||
new_y = old_y;
|
||||
new_width = old_width;
|
||||
new_height = old_height;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_FLIPPED_90:
|
||||
*out_x = area_width - y;
|
||||
*out_y = area_height - x;
|
||||
new_x = old_y;
|
||||
new_y = old_x;
|
||||
new_width = old_height;
|
||||
new_height = old_width;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_FLIPPED_180:
|
||||
*out_x = x;
|
||||
*out_y = area_height - y;
|
||||
new_x = old_x;
|
||||
new_y = old_height - old_y;
|
||||
new_width = old_width;
|
||||
new_height = old_height;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_FLIPPED_270:
|
||||
*out_x = y;
|
||||
*out_y = x;
|
||||
new_x = old_height - old_y;
|
||||
new_y = old_width - old_x;
|
||||
new_width = old_height;
|
||||
new_height = old_width;
|
||||
break;
|
||||
}
|
||||
|
||||
*point_x = new_x;
|
||||
*point_y = new_y;
|
||||
*area_width = new_width;
|
||||
*area_height = new_height;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -64,12 +64,10 @@ MetaMonitorTransform meta_monitor_transform_transform (MetaMonitorTransform tran
|
||||
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);
|
||||
int *area_width,
|
||||
int *area_height,
|
||||
int *point_x,
|
||||
int *point_y);
|
||||
|
||||
void meta_monitor_transform_transform_matrix (MetaMonitorTransform transform,
|
||||
graphene_matrix_t *matrix);
|
||||
|
@ -575,8 +575,7 @@ calculate_crtc_cursor_hotspot (MetaCursorSprite *cursor_sprite,
|
||||
width = meta_cursor_sprite_get_width (cursor_sprite);
|
||||
height = meta_cursor_sprite_get_height (cursor_sprite);
|
||||
meta_monitor_transform_transform_point (transform,
|
||||
width, height,
|
||||
hot_x, hot_y,
|
||||
&width, &height,
|
||||
&hot_x, &hot_y);
|
||||
*hotspot = GRAPHENE_POINT_INIT (hot_x * scale, hot_y * scale);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user