diff options
author | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2018-03-17 05:03:12 -0300 |
---|---|---|
committer | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2018-04-25 17:00:26 -0300 |
commit | 53d6d5a2db0a478116d72e3debc2afb800fdf20d (patch) | |
tree | 5c19ec5f8ddcc57630db1716fb29be398126d6f4 | |
parent | 930d62ad65842764e68cfb0c0e4c73dc4a1f5e5b (diff) | |
download | mutter-gbsneto/wayland-animations.tar.gz |
wayland: Check if state and size changed before calling move_resize()gbsneto/wayland-animations
The current implementation of the XdgSurface v6 protocol does not check
if the window changed before calling meta_window_wayland_move_resize().
The problem with this approach is that calling this function is a costly
operation since we enter the compositor side. In GNOME Shell case, it is
in JavaScript, which triggers a GJS trampoline. Calling this function on
every mouse movement is naturally as terrible as it could be - and is
exactly what happens now.
This commit adds the necessary checks to only call move_resize() when
the window actually changed, or when it needs to be updated.
https://bugzilla.gnome.org/show_bug.cgi?id=780292
Issue: #78
-rw-r--r-- | src/wayland/meta-wayland-legacy-xdg-shell.c | 14 | ||||
-rw-r--r-- | src/wayland/meta-wayland-xdg-shell.c | 14 |
2 files changed, 26 insertions, 2 deletions
diff --git a/src/wayland/meta-wayland-legacy-xdg-shell.c b/src/wayland/meta-wayland-legacy-xdg-shell.c index c43bcff3e..39cd64e22 100644 --- a/src/wayland/meta-wayland-legacy-xdg-shell.c +++ b/src/wayland/meta-wayland-legacy-xdg-shell.c @@ -618,7 +618,7 @@ meta_wayland_zxdg_toplevel_v6_commit (MetaWaylandSurfaceRole *surface_role, if (!window) return; - if (pending->has_new_geometry) + if (pending->has_new_geometry || meta_window_wayland_needs_move_resize (window)) { window_geometry = meta_wayland_zxdg_surface_v6_get_window_geometry (xdg_surface); @@ -1206,8 +1206,20 @@ zxdg_surface_v6_set_window_geometry (struct wl_client *client, int32_t width, int32_t height) { + MetaWaylandZxdgSurfaceV6 *xdg_surface = wl_resource_get_user_data (resource); + MetaWaylandZxdgSurfaceV6Private *priv = + meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); MetaWaylandSurface *surface = surface_from_xdg_surface_resource (resource); + if (priv->geometry.x == x && + priv->geometry.y == y && + priv->geometry.width == width && + priv->geometry.height == height) + { + surface->pending->has_new_geometry = FALSE; + return; + } + surface->pending->has_new_geometry = TRUE; surface->pending->new_geometry.x = x; surface->pending->new_geometry.y = y; diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c index c750d3f66..145bec31f 100644 --- a/src/wayland/meta-wayland-xdg-shell.c +++ b/src/wayland/meta-wayland-xdg-shell.c @@ -643,7 +643,7 @@ meta_wayland_xdg_toplevel_commit (MetaWaylandSurfaceRole *surface_role, if (!pending->newly_attached) return; - if (pending->has_new_geometry) + if (pending->has_new_geometry || meta_window_wayland_needs_move_resize (window)) { window_geometry = meta_wayland_xdg_surface_get_window_geometry (xdg_surface); meta_window_wayland_move_resize (window, @@ -1278,8 +1278,20 @@ xdg_surface_set_window_geometry (struct wl_client *client, int32_t width, int32_t height) { + MetaWaylandXdgSurface *xdg_surface = wl_resource_get_user_data (resource); + MetaWaylandXdgSurfacePrivate *priv = + meta_wayland_xdg_surface_get_instance_private (xdg_surface); MetaWaylandSurface *surface = surface_from_xdg_surface_resource (resource); + if (priv->geometry.x == x && + priv->geometry.y == y && + priv->geometry.width == width && + priv->geometry.height == height) + { + surface->pending->has_new_geometry = FALSE; + return; + } + surface->pending->has_new_geometry = TRUE; surface->pending->new_geometry.x = x; surface->pending->new_geometry.y = y; |