window: Save the buffer_rect internally

Rather than calculate it speculatively with the current properties
which may be too new or too out of date, make sure it always fits
with the proper definition. We update it when we update the toplevel
window for X11, and when a Wayland surface is committed with a newly
attached buffer.
This commit is contained in:
Jasper St. Pierre 2014-06-17 11:03:29 -04:00
parent 188e4e1b92
commit b0b8f37240
4 changed files with 19 additions and 18 deletions

View File

@ -421,6 +421,15 @@ struct _MetaWindow
*/
MetaRectangle unconstrained_rect;
/* The rectangle of the "server-side" geometry of the buffer,
* in root coordinates.
*
* For X11 windows, this matches XGetGeometry of the toplevel.
*
* For Wayland windows, this matches the buffer size and where
* the surface actor is positioned. */
MetaRectangle buffer_rect;
/* Cached net_wm_icon_geometry */
MetaRectangle icon_geometry;

View File

@ -4052,24 +4052,7 @@ void
meta_window_get_buffer_rect (const MetaWindow *window,
MetaRectangle *rect)
{
if (window->frame)
*rect = window->frame->rect;
else if (window->xwindow != None)
{
XWindowAttributes xwa;
XGetWindowAttributes (window->display->xdisplay, window->xwindow, &xwa);
rect->x = xwa.x;
rect->y = xwa.y;
rect->width = xwa.width;
rect->height = xwa.height;
}
else
{
*rect = window->rect;
meta_window_frame_rect_to_client_rect ((MetaWindow *) window, rect, rect);
}
*rect = window->buffer_rect;
}
/**

View File

@ -361,6 +361,8 @@ meta_window_wayland_move_resize (MetaWindow *window,
rect.width = width;
rect.height = height;
window->buffer_rect = rect;
if (rect.width != window->rect.width || rect.height != window->rect.height)
flags |= META_IS_RESIZE_ACTION;

View File

@ -550,6 +550,7 @@ meta_window_x11_manage (MetaWindow *window)
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
priv->client_rect = window->rect;
window->buffer_rect = window->rect;
}
else
{
@ -1257,6 +1258,11 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
gravity,
need_move_frame, need_resize_frame);
if (window->frame)
window->buffer_rect = window->frame->rect;
else
window->buffer_rect = client_rect;
if (need_configure_notify)
send_configure_notify (window);
@ -3265,6 +3271,7 @@ meta_window_x11_configure_notify (MetaWindow *window,
window->rect.height = event->height;
priv->client_rect = window->rect;
window->buffer_rect = window->rect;
meta_window_update_monitor (window);