screen-cast-stream: Add API to transform relative coordinates

Will be used to translate stream local coordinates to stage coordinates.
This commit is contained in:
Jonas Ådahl 2018-01-29 14:46:13 +08:00
parent f3203f0330
commit 4d5e1f690d
3 changed files with 44 additions and 0 deletions

View File

@ -176,6 +176,24 @@ meta_screen_cast_monitor_stream_set_parameters (MetaScreenCastStream *stream,
logical_monitor_layout.height));
}
static void
meta_screen_cast_monitor_stream_transform_position (MetaScreenCastStream *stream,
double stream_x,
double stream_y,
double *x,
double *y)
{
MetaScreenCastMonitorStream *monitor_stream =
META_SCREEN_CAST_MONITOR_STREAM (stream);
MetaRectangle logical_monitor_layout;
logical_monitor_layout =
meta_logical_monitor_get_layout (monitor_stream->logical_monitor);
*x = logical_monitor_layout.x + stream_x;
*y = logical_monitor_layout.y + stream_y;
}
static void
meta_screen_cast_monitor_stream_set_property (GObject *object,
guint prop_id,
@ -247,6 +265,7 @@ meta_screen_cast_monitor_stream_class_init (MetaScreenCastMonitorStreamClass *kl
stream_class->create_src = meta_screen_cast_monitor_stream_create_src;
stream_class->set_parameters = meta_screen_cast_monitor_stream_set_parameters;
stream_class->transform_position = meta_screen_cast_monitor_stream_transform_position;
g_object_class_install_property (object_class,
PROP_MONITOR,

View File

@ -136,6 +136,20 @@ meta_screen_cast_stream_get_object_path (MetaScreenCastStream *stream)
return priv->object_path;
}
void
meta_screen_cast_stream_transform_position (MetaScreenCastStream *stream,
double stream_x,
double stream_y,
double *x,
double *y)
{
META_SCREEN_CAST_STREAM_GET_CLASS (stream)->transform_position (stream,
stream_x,
stream_y,
x,
y);
}
static void
meta_screen_cast_stream_set_property (GObject *object,
guint prop_id,

View File

@ -41,6 +41,11 @@ struct _MetaScreenCastStreamClass
GError **error);
void (* set_parameters) (MetaScreenCastStream *stream,
GVariantBuilder *parameters_builder);
void (* transform_position) (MetaScreenCastStream *stream,
double stream_x,
double stream_y,
double *x,
double *y);
};
gboolean meta_screen_cast_stream_start (MetaScreenCastStream *stream,
@ -50,4 +55,10 @@ void meta_screen_cast_stream_close (MetaScreenCastStream *stream);
char * meta_screen_cast_stream_get_object_path (MetaScreenCastStream *stream);
void meta_screen_cast_stream_transform_position (MetaScreenCastStream *stream,
double stream_x,
double stream_y,
double *x,
double *y);
#endif /* META_SCREEN_CAST_STREAM_H */