wayland-surface: Make get_relative_coordinates() accurate for X apps

Using clutter API to transform coordinates is only accurate right
after a clutter layout pass but this function is used e.g. to deliver
pointer motion events which can happen at any time. This isn't a
problem for wayland clients since they don't control their position,
but X clients do and we'd be sending outdated coordinates if a client
is moving a window in response to motion events.

https://bugzilla.gnome.org/show_bug.cgi?id=768039
This commit is contained in:
Rui Matos 2016-07-14 14:39:26 +02:00
parent 5ee0f24ab9
commit b281f9566d

View File

@ -1772,6 +1772,25 @@ meta_wayland_surface_get_relative_coordinates (MetaWaylandSurface *surface,
float abs_y, float abs_y,
float *sx, float *sx,
float *sy) float *sy)
{
/* Using clutter API to transform coordinates is only accurate right
* after a clutter layout pass but this function is used e.g. to
* deliver pointer motion events which can happen at any time. This
* isn't a problem for wayland clients since they don't control
* their position, but X clients do and we'd be sending outdated
* coordinates if a client is moving a window in response to motion
* events.
*/
if (surface->window &&
surface->window->client_type == META_WINDOW_CLIENT_TYPE_X11)
{
MetaRectangle window_rect;
meta_window_get_buffer_rect (surface->window, &window_rect);
*sx = abs_x - window_rect.x;
*sy = abs_y - window_rect.y;
}
else
{ {
ClutterActor *actor = ClutterActor *actor =
CLUTTER_ACTOR (meta_surface_actor_get_texture (surface->surface_actor)); CLUTTER_ACTOR (meta_surface_actor_get_texture (surface->surface_actor));
@ -1780,6 +1799,7 @@ meta_wayland_surface_get_relative_coordinates (MetaWaylandSurface *surface,
*sx /= surface->scale; *sx /= surface->scale;
*sy /= surface->scale; *sy /= surface->scale;
} }
}
void void
meta_wayland_surface_get_absolute_coordinates (MetaWaylandSurface *surface, meta_wayland_surface_get_absolute_coordinates (MetaWaylandSurface *surface,