Ensure to move the view when configured

This commit is contained in:
emersion 2017-11-17 23:52:42 +01:00
parent 27937add76
commit e2843d87c8
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
4 changed files with 40 additions and 36 deletions

View File

@ -30,7 +30,7 @@ struct roots_xdg_surface_v6 {
struct wl_listener request_maximize;
struct {
bool needs_move;
uint32_t configure_serial;
double x, y;
uint32_t width, height;
} move_resize;

View File

@ -107,7 +107,9 @@ struct wlr_xdg_surface_v6 {
bool configured;
bool added;
uint32_t configure_serial;
struct wl_event_source *configure_idle;
uint32_t configure_next_serial;
struct wl_list configure_list;
char *title;
@ -171,37 +173,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);
/**
* 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);
/**
* 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);
/**
* 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);
/**
* 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);
/**
* 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);
/**
@ -223,4 +226,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 *surface, double sx, double sy,
double *popup_sx, double *popup_sy);
#endif

View File

@ -83,14 +83,13 @@ static void move_resize(struct roots_view *view, double x, double y,
x = x + width - constrained_width;
y = y + height - constrained_height;
roots_surface->move_resize.needs_move = true;
roots_surface->move_resize.x = x;
roots_surface->move_resize.y = y;
roots_surface->move_resize.width = constrained_width;
roots_surface->move_resize.height = constrained_height;
wlr_xdg_toplevel_v6_set_size(surface, constrained_width,
constrained_height);
roots_surface->move_resize.configure_serial = wlr_xdg_toplevel_v6_set_size(
surface, constrained_width, constrained_height);
}
static void maximize(struct roots_view *view, bool maximized) {
@ -159,12 +158,13 @@ static void handle_commit(struct wl_listener *listener, void *data) {
struct roots_view *view = roots_surface->view;
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
if (roots_surface->move_resize.needs_move) {
if (roots_surface->move_resize.configure_serial ==
surface->configure_serial) {
view->x = roots_surface->move_resize.x +
roots_surface->move_resize.width - surface->geometry->width;
view->y = roots_surface->move_resize.y +
roots_surface->move_resize.height - surface->geometry->height;
roots_surface->move_resize.needs_move = false;
roots_surface->move_resize.configure_serial = 0;
}
}

View File

@ -812,6 +812,7 @@ static void xdg_surface_ack_configure(struct wl_client *client,
}
surface->configured = true;
surface->configure_serial = serial;
wl_signal_emit(&surface->events.ack_configure, surface);
@ -941,7 +942,6 @@ static void wlr_xdg_toplevel_v6_send_configure(
static void wlr_xdg_surface_send_configure(void *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;
@ -953,7 +953,7 @@ static void wlr_xdg_surface_send_configure(void *user_data) {
}
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) {
case WLR_XDG_SURFACE_V6_ROLE_NONE:
@ -974,7 +974,7 @@ static void wlr_xdg_surface_send_configure(void *user_data) {
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 wl_display *display = wl_client_get_display(surface->client->client);
struct wl_event_loop *loop = wl_display_get_event_loop(display);
@ -995,23 +995,23 @@ static void wlr_xdg_surface_v6_schedule_configure(
if (surface->configure_idle != NULL) {
if (!pending_same) {
// configure request already scheduled
return;
return surface->configure_next_serial;
}
// configure request not necessary anymore
wl_event_source_remove(surface->configure_idle);
surface->configure_idle = NULL;
return 0;
} else {
if (pending_same) {
// configure request not necessary
return;
return 0;
}
surface->configure_idle =
wl_event_loop_add_idle(
loop,
wlr_xdg_surface_send_configure,
surface);
surface->configure_next_serial = wl_display_next_serial(display);
surface->configure_idle = wl_event_loop_add_idle(loop,
wlr_xdg_surface_send_configure, surface);
return surface->configure_next_serial;
}
}
@ -1304,45 +1304,45 @@ void wlr_xdg_surface_v6_ping(struct wlr_xdg_surface_v6 *surface) {
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) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
surface->toplevel_state->pending.width = width;
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) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
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) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
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) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
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) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
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) {