wayland: Calculate the window geometry based on all subsurfaces

Not just the main surface.
This commit is contained in:
Jasper St. Pierre 2014-07-17 15:24:06 -04:00
parent 166b8c042c
commit b5f46c9171
3 changed files with 49 additions and 17 deletions

View File

@ -162,6 +162,38 @@ cursor_surface_commit (MetaWaylandSurface *surface,
meta_wayland_seat_update_cursor_surface (surface->compositor->seat);
}
static void
calculate_surface_window_geometry (MetaWaylandSurface *surface,
MetaRectangle *total_geometry,
float parent_x,
float parent_y)
{
ClutterActor *surface_actor = CLUTTER_ACTOR (surface->surface_actor);
MetaRectangle geom;
float x, y;
GList *l;
/* Unmapped surfaces don't count. */
if (!CLUTTER_ACTOR_IS_VISIBLE (surface_actor))
return;
/* XXX: Is there a better way to do this using Clutter APIs? */
clutter_actor_get_position (surface_actor, &x, &y);
geom.x = parent_x + x;
geom.y = parent_x + y;
geom.width = cogl_texture_get_width (surface->buffer->texture);
geom.height = cogl_texture_get_height (surface->buffer->texture);
meta_rectangle_union (total_geometry, &geom, total_geometry);
for (l = surface->subsurfaces; l != NULL; l = l->next)
{
MetaWaylandSurface *subsurface = l->data;
calculate_surface_window_geometry (subsurface, total_geometry, x, y);
}
}
static void
toplevel_surface_commit (MetaWaylandSurface *surface,
MetaWaylandPendingState *pending)
@ -183,12 +215,10 @@ toplevel_surface_commit (MetaWaylandSurface *surface,
/* We resize X based surfaces according to X events */
if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
{
int new_width, new_height;
MetaRectangle geom;
new_width = cogl_texture_get_width (surface->buffer->texture);
new_height = cogl_texture_get_height (surface->buffer->texture);
meta_window_wayland_move_resize (window, new_width, new_height, pending->dx, pending->dy);
calculate_surface_window_geometry (surface, &geom, 0, 0);
meta_window_wayland_move_resize (window, geom, pending->dx, pending->dy);
}
}

View File

@ -337,17 +337,20 @@ meta_window_wayland_new (MetaDisplay *display,
* Complete a resize operation from a wayland client.
*/
void
meta_window_wayland_move_resize (MetaWindow *window,
int width,
int height,
int dx,
int dy)
meta_window_wayland_move_resize (MetaWindow *window,
MetaRectangle new_geom,
int dx,
int dy)
{
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
int gravity;
MetaRectangle rect;
MetaMoveResizeFlags flags;
/* XXX: Find a better place to store the window geometry offsets. */
window->custom_frame_extents.left = -new_geom.x;
window->custom_frame_extents.top = -new_geom.y;
flags = META_IS_WAYLAND_RESIZE;
/* x/y are ignored when we're doing interactive resizing */
@ -373,8 +376,8 @@ meta_window_wayland_move_resize (MetaWindow *window,
}
}
rect.width = width;
rect.height = height;
rect.width = new_geom.width;
rect.height = new_geom.height;
if (rect.width != window->rect.width || rect.height != window->rect.height)
flags |= META_IS_RESIZE_ACTION;

View File

@ -45,10 +45,9 @@ typedef struct _MetaWindowWaylandClass MetaWindowWaylandClass;
MetaWindow * meta_window_wayland_new (MetaDisplay *display,
MetaWaylandSurface *surface);
void meta_window_wayland_move_resize (MetaWindow *window,
int width,
int height,
int dx,
int dy);
void meta_window_wayland_move_resize (MetaWindow *window,
MetaRectangle new_geom,
int dx,
int dy);
#endif