wayland/surface: Add get_width() and get_height() helper functions

With viewporter / transformations it get's more complicated to
figure out the dimensions of a surface. Bundle it in this helper-
functions.
This commit is contained in:
Robert Mader 2018-06-29 17:45:28 +02:00 committed by Jonas Ådahl
parent 5f99eeb926
commit ad864083f9
2 changed files with 37 additions and 0 deletions

View File

@ -1747,3 +1747,37 @@ meta_wayland_surface_notify_geometry_changed (MetaWaylandSurface *surface)
{
g_signal_emit (surface, surface_signals[SURFACE_GEOMETRY_CHANGED], 0);
}
int
meta_wayland_surface_get_width (MetaWaylandSurface *surface)
{
MetaWaylandBuffer *buffer;
buffer = surface->buffer_ref.buffer;
if (buffer)
{
CoglTexture *texture = meta_wayland_buffer_get_texture (buffer);
return cogl_texture_get_width (texture) / surface->scale;
}
else
{
return 0;
}
}
int
meta_wayland_surface_get_height (MetaWaylandSurface *surface)
{
MetaWaylandBuffer *buffer;
buffer = surface->buffer_ref.buffer;
if (buffer)
{
CoglTexture *texture = meta_wayland_buffer_get_texture (buffer);
return cogl_texture_get_height (texture) / surface->scale;
}
else
{
return 0;
}
}

View File

@ -302,4 +302,7 @@ MetaSurfaceActor * meta_wayland_surface_get_actor (MetaWaylandSurface *surface)
void meta_wayland_surface_notify_geometry_changed (MetaWaylandSurface *surface);
int meta_wayland_surface_get_width (MetaWaylandSurface *surface);
int meta_wayland_surface_get_height (MetaWaylandSurface *surface);
#endif