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



commit ad864083f97ba33ecd4e8074a46ab3379f30a6cb
Author: Robert Mader <robert mader posteo de>
Date:   Fri Jun 29 17:45:28 2018 +0200

    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.

 src/wayland/meta-wayland-surface.c | 34 ++++++++++++++++++++++++++++++++++
 src/wayland/meta-wayland-surface.h |  3 +++
 2 files changed, 37 insertions(+)
---
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 4e0f0d33d..2646476f3 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -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;
+    }
+}
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index 9921ee24e..6fd19bf41 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]