Merge pull request #387 from emersion/laggy-move-resize

Fix laggy move-resize
master
Drew DeVault 7 years ago committed by GitHub
commit 1228d0da19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,6 +26,8 @@ struct roots_xdg_surface_v6 {
struct wl_listener request_move; struct wl_listener request_move;
struct wl_listener request_resize; struct wl_listener request_resize;
struct wl_listener request_maximize; struct wl_listener request_maximize;
uint32_t pending_move_resize_configure_serial;
}; };
struct roots_xwayland_surface { struct roots_xwayland_surface {
@ -38,6 +40,8 @@ struct roots_xwayland_surface {
struct wl_listener request_maximize; struct wl_listener request_maximize;
struct wl_listener map_notify; struct wl_listener map_notify;
struct wl_listener unmap_notify; struct wl_listener unmap_notify;
struct wl_listener surface_commit;
}; };
enum roots_view_type { enum roots_view_type {
@ -60,6 +64,12 @@ struct roots_view {
float rotation; float rotation;
} saved; } saved;
struct {
bool update_x, update_y;
double x, y;
uint32_t width, height;
} pending_move_resize;
// TODO: Something for roots-enforced width/height // TODO: Something for roots-enforced width/height
enum roots_view_type type; enum roots_view_type type;
union { union {

@ -107,7 +107,9 @@ struct wlr_xdg_surface_v6 {
bool configured; bool configured;
bool added; bool added;
uint32_t configure_serial;
struct wl_event_source *configure_idle; struct wl_event_source *configure_idle;
uint32_t configure_next_serial;
struct wl_list configure_list; struct wl_list configure_list;
char *title; char *title;
@ -123,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;
@ -171,37 +172,38 @@ void wlr_xdg_shell_v6_destroy(struct wlr_xdg_shell_v6 *xdg_shell);
void wlr_xdg_surface_v6_ping(struct wlr_xdg_surface_v6 *surface); void wlr_xdg_surface_v6_ping(struct wlr_xdg_surface_v6 *surface);
/** /**
* Request that this toplevel surface be the given size. * Request that this toplevel surface be the given size. Returns the associated
* configure serial.
*/ */
void wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface,
uint32_t width, uint32_t height); uint32_t width, uint32_t height);
/** /**
* Request that this toplevel surface show itself in an activated or deactivated * Request that this toplevel surface show itself in an activated or deactivated
* state. * state. Returns the associated configure serial.
*/ */
void wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface,
bool activated); bool activated);
/** /**
* Request that this toplevel surface consider itself maximized or not * Request that this toplevel surface consider itself maximized or not
* maximized. * maximized. Returns the associated configure serial.
*/ */
void wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface,
bool maximized); bool maximized);
/** /**
* Request that this toplevel surface consider itself fullscreen or not * Request that this toplevel surface consider itself fullscreen or not
* fullscreen. * fullscreen. Returns the associated configure serial.
*/ */
void wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface,
bool fullscreen); bool fullscreen);
/** /**
* Request that this toplevel surface consider itself to be resizing or not * Request that this toplevel surface consider itself to be resizing or not
* resizing. * resizing. Returns the associated configure serial.
*/ */
void wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface,
bool resizing); bool resizing);
/** /**
@ -223,4 +225,5 @@ void wlr_xdg_surface_v6_popup_get_position(struct wlr_xdg_surface_v6 *surface,
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6_popup_at( struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6_popup_at(
struct wlr_xdg_surface_v6 *surface, double sx, double sy, struct wlr_xdg_surface_v6 *surface, double sx, double sy,
double *popup_sx, double *popup_sy); double *popup_sx, double *popup_sy);
#endif #endif

@ -71,43 +71,37 @@ static void roots_cursor_update_position(struct roots_cursor *cursor,
if (view != NULL) { if (view != NULL) {
double dx = cursor->cursor->x - cursor->offs_x; double dx = cursor->cursor->x - cursor->offs_x;
double dy = cursor->cursor->y - cursor->offs_y; double dy = cursor->cursor->y - cursor->offs_y;
double active_x = view->x; double x = view->x;
double active_y = view->y; double y = view->y;
int width = cursor->view_width; int width = cursor->view_width;
int height = cursor->view_height; int height = cursor->view_height;
if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) { if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) {
active_y = cursor->view_y + dy; y = cursor->view_y + dy;
height -= dy; height -= dy;
if (height < 0) { if (height < 1) {
active_y += height; y += height;
} }
} else if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_BOTTOM) { } else if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_BOTTOM) {
height += dy; height += dy;
} }
if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) {
active_x = cursor->view_x + dx; x = cursor->view_x + dx;
width -= dx; width -= dx;
if (width < 0) { if (width < 1) {
active_x += width; x += width;
} }
} else if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { } else if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) {
width += dx; width += dx;
} }
if (width < 0) { if (width < 1) {
width = 0; width = 1;
} }
if (height < 0) { if (height < 1) {
height = 0; height = 1;
} }
if (active_x != view->x || view_move_resize(view, x, y, width, height);
active_y != view->y) {
view_move_resize(view, active_x, active_y,
width, height);
} else {
view_resize(view, width, height);
}
} }
break; break;
case ROOTS_CURSOR_ROTATE: case ROOTS_CURSOR_ROTATE:

@ -80,12 +80,25 @@ 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) {
bool update_x = x != view->x;
bool update_y = y != view->y;
if (!update_x && !update_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_move(view, x, y); view->pending_move_resize.update_x = update_x;
view->pending_move_resize.update_y = update_y;
view->pending_move_resize.x = x;
view->pending_move_resize.y = y;
view->pending_move_resize.width = width;
view->pending_move_resize.height = height;
view_resize(view, width, height); view_resize(view, width, height);
} }

@ -71,7 +71,24 @@ static void handle_set_state(struct wl_listener *listener, void *data) {
} }
static void handle_surface_commit(struct wl_listener *listener, void *data) { static void handle_surface_commit(struct wl_listener *listener, void *data) {
// TODO do we need to do anything here? struct roots_wl_shell_surface *roots_surface =
wl_container_of(listener, roots_surface, surface_commit);
struct roots_view *view = roots_surface->view;
struct wlr_surface *wlr_surface = view->wlr_surface;
int width = wlr_surface->current->width;
int height = wlr_surface->current->height;
if (view->pending_move_resize.update_x) {
view->x = view->pending_move_resize.x +
view->pending_move_resize.width - width;
view->pending_move_resize.update_x = false;
}
if (view->pending_move_resize.update_y) {
view->y = view->pending_move_resize.y +
view->pending_move_resize.height - height;
view->pending_move_resize.update_y = false;
}
} }
static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) {

@ -12,11 +12,11 @@
static void get_size(const struct roots_view *view, struct wlr_box *box) { static void get_size(const struct roots_view *view, struct wlr_box *box) {
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
if (surf->geometry->width > 0 && surf->geometry->height > 0) { if (surface->geometry->width > 0 && surface->geometry->height > 0) {
box->width = surf->geometry->width; box->width = surface->geometry->width;
box->height = surf->geometry->height; box->height = surface->geometry->height;
} else { } else {
box->width = view->wlr_surface->current->width; box->width = view->wlr_surface->current->width;
box->height = view->wlr_surface->current->height; box->height = view->wlr_surface->current->height;
@ -25,20 +25,19 @@ static void get_size(const struct roots_view *view, struct wlr_box *box) {
static void activate(struct roots_view *view, bool active) { static void activate(struct roots_view *view, bool active) {
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
if (surf->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { if (surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
wlr_xdg_toplevel_v6_set_activated(surf, active); wlr_xdg_toplevel_v6_set_activated(surface, active);
} }
} }
static void apply_size_constraints(struct wlr_xdg_surface_v6 *surf, static void apply_size_constraints(struct wlr_xdg_surface_v6 *surface,
uint32_t width, uint32_t height, uint32_t *dest_width, uint32_t width, uint32_t height, uint32_t *dest_width,
uint32_t *dest_height) { uint32_t *dest_height) {
*dest_width = width; *dest_width = width;
*dest_height = height; *dest_height = height;
struct wlr_xdg_toplevel_v6_state *state = struct wlr_xdg_toplevel_v6_state *state = &surface->toplevel_state->current;
&surf->toplevel_state->current;
if (width < state->min_width) { if (width < state->min_width) {
*dest_width = state->min_width; *dest_width = state->min_width;
} else if (state->max_width > 0 && } else if (state->max_width > 0 &&
@ -55,39 +54,57 @@ static void apply_size_constraints(struct wlr_xdg_surface_v6 *surf,
static void resize(struct roots_view *view, uint32_t width, uint32_t height) { static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
if (surf->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
return; return;
} }
uint32_t contrained_width, contrained_height; uint32_t constrained_width, constrained_height;
apply_size_constraints(surf, width, height, &contrained_width, apply_size_constraints(surface, width, height, &constrained_width,
&contrained_height); &constrained_height);
wlr_xdg_toplevel_v6_set_size(surf, contrained_width, contrained_height); wlr_xdg_toplevel_v6_set_size(surface, constrained_width,
constrained_height);
} }
static void move_resize(struct roots_view *view, double x, double y, static void move_resize(struct roots_view *view, double x, double y,
uint32_t width, uint32_t height) { uint32_t width, uint32_t height) {
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; struct roots_xdg_surface_v6 *roots_surface = view->roots_xdg_surface_v6;
if (surf->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
return; return;
} }
uint32_t contrained_width, contrained_height; bool update_x = x != view->x;
apply_size_constraints(surf, width, height, &contrained_width, bool update_y = y != view->y;
&contrained_height);
uint32_t constrained_width, constrained_height;
apply_size_constraints(surface, width, height, &constrained_width,
&constrained_height);
x = x + width - contrained_width; if (update_x) {
y = y + height - contrained_height; x = x + width - constrained_width;
}
if (update_y) {
y = y + height - constrained_height;
}
// TODO: we should wait for an ack_configure event before updating the view->pending_move_resize.update_x = update_x;
// position view->pending_move_resize.update_y = update_y;
view->x = x; view->pending_move_resize.x = x;
view->y = y; view->pending_move_resize.y = y;
view->pending_move_resize.width = constrained_width;
view->pending_move_resize.height = constrained_height;
wlr_xdg_toplevel_v6_set_size(surf, contrained_width, contrained_height); uint32_t serial = wlr_xdg_toplevel_v6_set_size(surface, constrained_width,
constrained_height);
if (serial > 0) {
roots_surface->pending_move_resize_configure_serial = serial;
} else {
view->x = x;
view->y = y;
}
} }
static void maximize(struct roots_view *view, bool maximized) { static void maximize(struct roots_view *view, bool maximized) {
@ -102,9 +119,9 @@ static void maximize(struct roots_view *view, bool maximized) {
static void close(struct roots_view *view) { static void close(struct roots_view *view) {
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
if (surf->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { if (surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
wlr_xdg_toplevel_v6_send_close(surf); wlr_xdg_toplevel_v6_send_close(surface);
} }
} }
@ -151,11 +168,30 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) {
} }
static void handle_commit(struct wl_listener *listener, void *data) { static void handle_commit(struct wl_listener *listener, void *data) {
//struct roots_xdg_surface_v6 *roots_xdg_surface = struct roots_xdg_surface_v6 *roots_surface =
// wl_container_of(listener, roots_xdg_surface, commit); wl_container_of(listener, roots_surface, commit);
//struct roots_view *view = roots_xdg_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;
// TODO
uint32_t pending_serial =
roots_surface->pending_move_resize_configure_serial;
if (pending_serial > 0 && pending_serial >= surface->configure_serial) {
struct wlr_box size;
get_size(view, &size);
if (view->pending_move_resize.update_x) {
view->x = view->pending_move_resize.x +
view->pending_move_resize.width - size.width;
}
if (view->pending_move_resize.update_y) {
view->y = view->pending_move_resize.y +
view->pending_move_resize.height - size.height;
}
if (pending_serial == surface->configure_serial) {
roots_surface->pending_move_resize_configure_serial = 0;
}
}
} }
static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) {

@ -52,13 +52,13 @@ static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
assert(view->type == ROOTS_XWAYLAND_VIEW); assert(view->type == ROOTS_XWAYLAND_VIEW);
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
uint32_t contrained_width, contrained_height; uint32_t constrained_width, constrained_height;
apply_size_constraints(xwayland_surface, width, height, &contrained_width, apply_size_constraints(xwayland_surface, width, height, &constrained_width,
&contrained_height); &constrained_height);
wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface, wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface,
xwayland_surface->x, xwayland_surface->y, contrained_width, xwayland_surface->x, xwayland_surface->y, constrained_width,
contrained_height); constrained_height);
} }
static void move_resize(struct roots_view *view, double x, double y, static void move_resize(struct roots_view *view, double x, double y,
@ -66,18 +66,29 @@ static void move_resize(struct roots_view *view, double x, double y,
assert(view->type == ROOTS_XWAYLAND_VIEW); assert(view->type == ROOTS_XWAYLAND_VIEW);
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
uint32_t contrained_width, contrained_height; bool update_x = x != view->x;
apply_size_constraints(xwayland_surface, width, height, &contrained_width, bool update_y = y != view->y;
&contrained_height);
x = x + width - contrained_width; uint32_t constrained_width, constrained_height;
y = y + height - contrained_height; apply_size_constraints(xwayland_surface, width, height, &constrained_width,
&constrained_height);
view->x = x; if (update_x) {
view->y = y; x = x + width - constrained_width;
}
if (update_y) {
y = y + height - constrained_height;
}
view->pending_move_resize.update_x = update_x;
view->pending_move_resize.update_y = update_y;
view->pending_move_resize.x = x;
view->pending_move_resize.y = y;
view->pending_move_resize.width = constrained_width;
view->pending_move_resize.height = constrained_height;
wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface, wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface,
x, y, contrained_width, contrained_height); x, y, constrained_width, constrained_height);
} }
static void close(struct roots_view *view) { static void close(struct roots_view *view) {
@ -175,6 +186,27 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) {
view_maximize(view, maximized); view_maximize(view, maximized);
} }
static void handle_surface_commit(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface =
wl_container_of(listener, roots_surface, surface_commit);
struct roots_view *view = roots_surface->view;
struct wlr_surface *wlr_surface = view->wlr_surface;
int width = wlr_surface->current->width;
int height = wlr_surface->current->height;
if (view->pending_move_resize.update_x) {
view->x = view->pending_move_resize.x +
view->pending_move_resize.width - width;
view->pending_move_resize.update_x = false;
}
if (view->pending_move_resize.update_y) {
view->y = view->pending_move_resize.y +
view->pending_move_resize.height - height;
view->pending_move_resize.update_y = false;
}
}
static void handle_map_notify(struct wl_listener *listener, void *data) { static void handle_map_notify(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface = struct roots_xwayland_surface *roots_surface =
wl_container_of(listener, roots_surface, map_notify); wl_container_of(listener, roots_surface, map_notify);
@ -186,6 +218,10 @@ static void handle_map_notify(struct wl_listener *listener, void *data) {
view->x = (double)xsurface->x; view->x = (double)xsurface->x;
view->y = (double)xsurface->y; view->y = (double)xsurface->y;
roots_surface->surface_commit.notify = handle_surface_commit;
wl_signal_add(&xsurface->surface->events.commit,
&roots_surface->surface_commit);
wl_list_insert(&desktop->views, &view->link); wl_list_insert(&desktop->views, &view->link);
} }
@ -194,6 +230,8 @@ static void handle_unmap_notify(struct wl_listener *listener, void *data) {
wl_container_of(listener, roots_surface, unmap_notify); wl_container_of(listener, roots_surface, unmap_notify);
roots_surface->view->wlr_surface = NULL; roots_surface->view->wlr_surface = NULL;
wl_list_remove(&roots_surface->surface_commit.link);
wl_list_remove(&roots_surface->view->link); wl_list_remove(&roots_surface->view->link);
} }
@ -229,6 +267,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
wl_signal_add(&surface->events.request_maximize, wl_signal_add(&surface->events.request_maximize,
&roots_surface->request_maximize); &roots_surface->request_maximize);
roots_surface->surface_commit.notify = handle_surface_commit;
wl_signal_add(&surface->surface->events.commit,
&roots_surface->surface_commit);
struct roots_view *view = calloc(1, sizeof(struct roots_view)); struct roots_view *view = calloc(1, sizeof(struct roots_view));
if (view == NULL) { if (view == NULL) {
free(roots_surface); free(roots_surface);

@ -812,8 +812,7 @@ static void xdg_surface_ack_configure(struct wl_client *client,
} }
surface->configured = true; surface->configured = true;
surface->configure_serial = serial;
wl_signal_emit(&surface->events.ack_configure, surface);
free(configure); free(configure);
} }
@ -941,7 +940,6 @@ static void wlr_xdg_toplevel_v6_send_configure(
static void wlr_xdg_surface_send_configure(void *user_data) { static void wlr_xdg_surface_send_configure(void *user_data) {
struct wlr_xdg_surface_v6 *surface = user_data; struct wlr_xdg_surface_v6 *surface = user_data;
struct wl_display *display = wl_client_get_display(surface->client->client);
surface->configure_idle = NULL; surface->configure_idle = NULL;
@ -953,7 +951,7 @@ static void wlr_xdg_surface_send_configure(void *user_data) {
} }
wl_list_insert(surface->configure_list.prev, &configure->link); wl_list_insert(surface->configure_list.prev, &configure->link);
configure->serial = wl_display_next_serial(display); configure->serial = surface->configure_next_serial;
switch (surface->role) { switch (surface->role) {
case WLR_XDG_SURFACE_V6_ROLE_NONE: case WLR_XDG_SURFACE_V6_ROLE_NONE:
@ -974,7 +972,7 @@ static void wlr_xdg_surface_send_configure(void *user_data) {
zxdg_surface_v6_send_configure(surface->resource, configure->serial); zxdg_surface_v6_send_configure(surface->resource, configure->serial);
} }
static void wlr_xdg_surface_v6_schedule_configure( static uint32_t wlr_xdg_surface_v6_schedule_configure(
struct wlr_xdg_surface_v6 *surface) { struct wlr_xdg_surface_v6 *surface) {
struct wl_display *display = wl_client_get_display(surface->client->client); struct wl_display *display = wl_client_get_display(surface->client->client);
struct wl_event_loop *loop = wl_display_get_event_loop(display); struct wl_event_loop *loop = wl_display_get_event_loop(display);
@ -995,23 +993,23 @@ static void wlr_xdg_surface_v6_schedule_configure(
if (surface->configure_idle != NULL) { if (surface->configure_idle != NULL) {
if (!pending_same) { if (!pending_same) {
// configure request already scheduled // configure request already scheduled
return; return surface->configure_next_serial;
} }
// configure request not necessary anymore // configure request not necessary anymore
wl_event_source_remove(surface->configure_idle); wl_event_source_remove(surface->configure_idle);
surface->configure_idle = NULL; surface->configure_idle = NULL;
return 0;
} else { } else {
if (pending_same) { if (pending_same) {
// configure request not necessary // configure request not necessary
return; return 0;
} }
surface->configure_idle = surface->configure_next_serial = wl_display_next_serial(display);
wl_event_loop_add_idle( surface->configure_idle = wl_event_loop_add_idle(loop,
loop, wlr_xdg_surface_send_configure, surface);
wlr_xdg_surface_send_configure, return surface->configure_next_serial;
surface);
} }
} }
@ -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,
@ -1304,45 +1301,45 @@ void wlr_xdg_surface_v6_ping(struct wlr_xdg_surface_v6 *surface) {
surface->client->ping_serial); surface->client->ping_serial);
} }
void wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface,
uint32_t width, uint32_t height) { uint32_t width, uint32_t height) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
surface->toplevel_state->pending.width = width; surface->toplevel_state->pending.width = width;
surface->toplevel_state->pending.height = height; surface->toplevel_state->pending.height = height;
wlr_xdg_surface_v6_schedule_configure(surface); return wlr_xdg_surface_v6_schedule_configure(surface);
} }
void wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface,
bool activated) { bool activated) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
surface->toplevel_state->pending.activated = activated; surface->toplevel_state->pending.activated = activated;
wlr_xdg_surface_v6_schedule_configure(surface); return wlr_xdg_surface_v6_schedule_configure(surface);
} }
void wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface,
bool maximized) { bool maximized) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
surface->toplevel_state->pending.maximized = maximized; surface->toplevel_state->pending.maximized = maximized;
wlr_xdg_surface_v6_schedule_configure(surface); return wlr_xdg_surface_v6_schedule_configure(surface);
} }
void wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface,
bool fullscreen) { bool fullscreen) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
surface->toplevel_state->pending.fullscreen = fullscreen; surface->toplevel_state->pending.fullscreen = fullscreen;
wlr_xdg_surface_v6_schedule_configure(surface); return wlr_xdg_surface_v6_schedule_configure(surface);
} }
void wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface,
bool resizing) { bool resizing) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
surface->toplevel_state->pending.resizing = resizing; surface->toplevel_state->pending.resizing = resizing;
wlr_xdg_surface_v6_schedule_configure(surface); return wlr_xdg_surface_v6_schedule_configure(surface);
} }
void wlr_xdg_toplevel_v6_send_close(struct wlr_xdg_surface_v6 *surface) { void wlr_xdg_toplevel_v6_send_close(struct wlr_xdg_surface_v6 *surface) {

Loading…
Cancel
Save