Fixed a bug with move-resize, removed xdg-shell ack_configure event

Fixed move-resizing a view when only one coordinate changes.
This commit is contained in:
emersion 2017-11-18 09:09:23 +01:00
parent e2843d87c8
commit a3a8b7bfd8
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
6 changed files with 31 additions and 18 deletions

View file

@ -32,6 +32,7 @@ struct roots_xdg_surface_v6 {
struct { struct {
uint32_t configure_serial; uint32_t configure_serial;
double x, y; double x, y;
bool update_x, update_y;
uint32_t width, height; uint32_t width, height;
} move_resize; } move_resize;
}; };

View file

@ -125,7 +125,6 @@ struct wlr_xdg_surface_v6 {
struct { struct {
struct wl_signal commit; struct wl_signal commit;
struct wl_signal destroy; struct wl_signal destroy;
struct wl_signal ack_configure;
struct wl_signal ping_timeout; struct wl_signal ping_timeout;
struct wl_signal request_maximize; struct wl_signal request_maximize;

View file

@ -98,13 +98,7 @@ static void roots_cursor_update_position(struct roots_cursor *cursor, uint32_t t
height = 0; height = 0;
} }
if (active_x != seat->focus->x || view_move_resize(seat->focus, active_x, active_y, width, height);
active_y != seat->focus->y) {
view_move_resize(seat->focus, active_x, active_y,
width, height);
} else {
view_resize(seat->focus, width, height);
}
} }
break; break;
case ROOTS_CURSOR_ROTATE: case ROOTS_CURSOR_ROTATE:

View file

@ -103,6 +103,11 @@ void view_resize(struct roots_view *view, uint32_t width, uint32_t height) {
void view_move_resize(struct roots_view *view, double x, double y, void view_move_resize(struct roots_view *view, double x, double y,
uint32_t width, uint32_t height) { uint32_t width, uint32_t height) {
if (x == view->x == x && y == view->y) {
view_resize(view, width, height);
return;
}
if (view->move_resize) { if (view->move_resize) {
view->move_resize(view, x, y, width, height); view->move_resize(view, x, y, width, height);
return; return;

View file

@ -76,15 +76,24 @@ static void move_resize(struct roots_view *view, double x, double y,
return; return;
} }
bool update_x = x != view->x;
bool update_y = y != view->y;
uint32_t constrained_width, constrained_height; uint32_t constrained_width, constrained_height;
apply_size_constraints(surface, width, height, &constrained_width, apply_size_constraints(surface, width, height, &constrained_width,
&constrained_height); &constrained_height);
if (update_x) {
x = x + width - constrained_width; x = x + width - constrained_width;
}
if (update_y) {
y = y + height - constrained_height; y = y + height - constrained_height;
}
roots_surface->move_resize.x = x; roots_surface->move_resize.x = x;
roots_surface->move_resize.y = y; roots_surface->move_resize.y = y;
roots_surface->move_resize.update_x = update_x;
roots_surface->move_resize.update_y = update_y;
roots_surface->move_resize.width = constrained_width; roots_surface->move_resize.width = constrained_width;
roots_surface->move_resize.height = constrained_height; roots_surface->move_resize.height = constrained_height;
@ -158,12 +167,20 @@ static void handle_commit(struct wl_listener *listener, void *data) {
struct roots_view *view = roots_surface->view; struct roots_view *view = roots_surface->view;
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
if (roots_surface->move_resize.configure_serial == if (roots_surface->move_resize.configure_serial > 0 &&
roots_surface->move_resize.configure_serial ==
surface->configure_serial) { surface->configure_serial) {
struct wlr_box size;
get_size(view, &size);
if (roots_surface->move_resize.update_x) {
view->x = roots_surface->move_resize.x + view->x = roots_surface->move_resize.x +
roots_surface->move_resize.width - surface->geometry->width; roots_surface->move_resize.width - size.width;
}
if (roots_surface->move_resize.update_y) {
view->y = roots_surface->move_resize.y + view->y = roots_surface->move_resize.y +
roots_surface->move_resize.height - surface->geometry->height; roots_surface->move_resize.height - size.height;
}
roots_surface->move_resize.configure_serial = 0; roots_surface->move_resize.configure_serial = 0;
} }
} }

View file

@ -814,8 +814,6 @@ static void xdg_surface_ack_configure(struct wl_client *client,
surface->configured = true; surface->configured = true;
surface->configure_serial = serial; surface->configure_serial = serial;
wl_signal_emit(&surface->events.ack_configure, surface);
free(configure); free(configure);
} }
@ -1155,7 +1153,6 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
wl_signal_init(&surface->events.request_show_window_menu); wl_signal_init(&surface->events.request_show_window_menu);
wl_signal_init(&surface->events.commit); wl_signal_init(&surface->events.commit);
wl_signal_init(&surface->events.destroy); wl_signal_init(&surface->events.destroy);
wl_signal_init(&surface->events.ack_configure);
wl_signal_init(&surface->events.ping_timeout); wl_signal_init(&surface->events.ping_timeout);
wl_signal_add(&surface->surface->events.destroy, wl_signal_add(&surface->surface->events.destroy,