Skip to content

Commit ecd36df

Browse files
committed
wobbly: Fix resizing for wobbly surfaces
This problem was due to the fact that rotate changed the surface position when rotating to offset the fact that resize didn't keep the position updated as expected, that is, position.p + 0.5 * size.p = center.p. Wobbly must also make this assumption to sync correctly but the position must be adjusted during resize, not on rotate motion. As a side note, shell_surface_adjust_for_transform should end up in the rotate plugin resize handler, if/when it is ported to a standalone version.
1 parent 746f1d7 commit ecd36df

3 files changed

Lines changed: 46 additions & 17 deletions

File tree

desktop-shell/shell.c

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4343,7 +4343,7 @@ rotate_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
43434343
container_of(grab, struct rotate_grab, base.grab);
43444344
struct weston_pointer *pointer = grab->pointer;
43454345
struct shell_surface *shsurf = rotate->base.shsurf;
4346-
float cx, cy, dx, dy, cposx, cposy, dposx, dposy, r;
4346+
float cx, cy, dx, dy, r;
43474347

43484348
weston_pointer_move(pointer, x, y);
43494349

@@ -4382,18 +4382,6 @@ rotate_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
43824382
weston_matrix_init(&rotate->rotation);
43834383
}
43844384

4385-
/* We need to adjust the position of the surface
4386-
* in case it was resized in a rotated state before */
4387-
cposx = shsurf->view->geometry.x + cx;
4388-
cposy = shsurf->view->geometry.y + cy;
4389-
dposx = rotate->center.x - cposx;
4390-
dposy = rotate->center.y - cposy;
4391-
if (dposx != 0.0f || dposy != 0.0f) {
4392-
weston_view_set_position(shsurf->view,
4393-
shsurf->view->geometry.x + dposx,
4394-
shsurf->view->geometry.y + dposy);
4395-
}
4396-
43974385
/* Repaint implies weston_surface_update_transform(), which
43984386
* lazily applies the damage due to rotation update.
43994387
*/
@@ -5063,6 +5051,44 @@ map(struct desktop_shell *shell, struct shell_surface *shsurf,
50635051
}
50645052
}
50655053

5054+
static void
5055+
shell_surface_adjust_for_transform(struct shell_surface *shsurf)
5056+
{
5057+
struct weston_matrix *matrix;
5058+
float cx, cy, cposx, cposy, dposx, dposy, rcx, rcy;
5059+
5060+
/* Adjust for rotation transformation */
5061+
cx = 0.5f * shsurf->surface->width;
5062+
cy = 0.5f * shsurf->surface->height;
5063+
5064+
wl_list_remove(&shsurf->rotation.transform.link);
5065+
weston_view_geometry_dirty(shsurf->view);
5066+
5067+
matrix = &shsurf->rotation.transform.matrix;
5068+
5069+
weston_matrix_init(matrix);
5070+
weston_matrix_translate(matrix, -cx, -cy, 0.0f);
5071+
weston_matrix_multiply(matrix, &shsurf->rotation.rotation);
5072+
weston_matrix_translate(matrix, cx, cy, 0.0f);
5073+
5074+
wl_list_insert(
5075+
&shsurf->view->geometry.transformation_list,
5076+
&shsurf->rotation.transform.link);
5077+
5078+
weston_view_to_global_float(shsurf->view, cx, cy, &rcx, &rcy);
5079+
5080+
/* Position surface to maintain expected center coordinates */
5081+
cposx = shsurf->view->geometry.x + cx;
5082+
cposy = shsurf->view->geometry.y + cy;
5083+
dposx = rcx - cposx;
5084+
dposy = rcy - cposy;
5085+
if (dposx != 0.0f || dposy != 0.0f) {
5086+
weston_view_set_position(shsurf->view,
5087+
shsurf->view->geometry.x + dposx,
5088+
shsurf->view->geometry.y + dposy);
5089+
}
5090+
}
5091+
50665092
static void
50675093
configure(struct desktop_shell *shell, struct weston_surface *surface,
50685094
float x, float y)
@@ -5097,6 +5123,9 @@ configure(struct desktop_shell *shell, struct weston_surface *surface,
50975123
if (shsurf->state.maximized)
50985124
surface->output = shsurf->output;
50995125
}
5126+
5127+
if (!wl_list_empty(&shsurf->rotation.transform.link))
5128+
shell_surface_adjust_for_transform(shsurf);
51005129
}
51015130

51025131
static void

src/compositor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ struct weston_compositor {
628628
};
629629

630630
/* WESTON_PLUGIN_CALL_SINGLE(compositor, weston_plugin, function, arguments to function)
631-
* Call a function for a specific plugin */
631+
* Call a function for a weston_plugin */
632632
#define WESTON_PLUGIN_CALL_SINGLE(p, f, ...) ({ \
633633
if (p->interface->f) \
634634
p->interface->f(__VA_ARGS__); \
@@ -640,7 +640,7 @@ struct weston_compositor {
640640
struct weston_plugin *p; \
641641
\
642642
wl_list_for_each(p, &(c)->plugin_list, link) \
643-
WESTON_PLUGIN_CALL_SINGLE(p, f, __VA_ARGS__); \
643+
WESTON_PLUGIN_CALL_SINGLE(p, f, __VA_ARGS__); \
644644
})
645645

646646
struct weston_plugin;

src/wobbly.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,8 @@ wobbly_resize_notify(struct weston_view *view)
827827

828828
ww = ws->ww;
829829

830-
x = view->geometry.x;
831-
y = view->geometry.y;
830+
x = ws->x = view->geometry.x;
831+
y = ws->y = view->geometry.y;
832832
w = ws->width = surface->width;
833833
h = ws->height = surface->height;
834834

0 commit comments

Comments
 (0)