Fix maximize delay in xdg-shell

This commit is contained in:
emersion 2017-11-09 21:41:11 +01:00
parent 0204f811b4
commit bf1b12a725
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
4 changed files with 23 additions and 5 deletions

View File

@ -27,6 +27,7 @@ struct roots_xdg_surface_v6 {
struct wl_listener destroy; struct wl_listener destroy;
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 roots_xwayland_surface { struct roots_xwayland_surface {

View File

@ -126,6 +126,8 @@ struct wlr_xdg_surface_v6 {
struct wl_signal ack_configure; struct wl_signal ack_configure;
struct wl_signal ping_timeout; struct wl_signal ping_timeout;
struct wl_signal request_maximize;
struct wl_signal request_fullscreen;
struct wl_signal request_minimize; struct wl_signal request_minimize;
struct wl_signal request_move; struct wl_signal request_move;
struct wl_signal request_resize; struct wl_signal request_resize;

View File

@ -128,9 +128,9 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
view_begin_resize(input, event->cursor, view, e->edges); view_begin_resize(input, event->cursor, view, e->edges);
} }
static void handle_commit(struct wl_listener *listener, void *data) { static void handle_request_maximize(struct wl_listener *listener, void *data) {
struct roots_xdg_surface_v6 *roots_xdg_surface = struct roots_xdg_surface_v6 *roots_xdg_surface =
wl_container_of(listener, roots_xdg_surface, commit); wl_container_of(listener, roots_xdg_surface, request_maximize);
struct roots_view *view = roots_xdg_surface->view; struct roots_view *view = roots_xdg_surface->view;
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
@ -138,9 +138,15 @@ static void handle_commit(struct wl_listener *listener, void *data) {
return; return;
} }
if (view->maximized != surface->toplevel_state->current.maximized) { view_maximize(view, surface->toplevel_state->next.maximized);
view_maximize(view, surface->toplevel_state->current.maximized); }
}
static void handle_commit(struct wl_listener *listener, void *data) {
//struct roots_xdg_surface_v6 *roots_xdg_surface =
// wl_container_of(listener, roots_xdg_surface, commit);
//struct roots_view *view = roots_xdg_surface->view;
//struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
// TODO
} }
static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) {
@ -185,6 +191,9 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
roots_surface->request_resize.notify = handle_request_resize; roots_surface->request_resize.notify = handle_request_resize;
wl_signal_add(&surface->events.request_resize, wl_signal_add(&surface->events.request_resize,
&roots_surface->request_resize); &roots_surface->request_resize);
roots_surface->request_maximize.notify = handle_request_maximize;
wl_signal_add(&surface->events.request_maximize,
&roots_surface->request_maximize);
struct roots_view *view = calloc(1, sizeof(struct roots_view)); struct roots_view *view = calloc(1, sizeof(struct roots_view));
if (!view) { if (!view) {

View File

@ -667,24 +667,28 @@ static void xdg_toplevel_protocol_set_maximized(struct wl_client *client,
struct wl_resource *resource) { struct wl_resource *resource) {
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
surface->toplevel_state->next.maximized = true; surface->toplevel_state->next.maximized = true;
wl_signal_emit(&surface->events.request_maximize, surface);
} }
static void xdg_toplevel_protocol_unset_maximized(struct wl_client *client, static void xdg_toplevel_protocol_unset_maximized(struct wl_client *client,
struct wl_resource *resource) { struct wl_resource *resource) {
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
surface->toplevel_state->next.maximized = false; surface->toplevel_state->next.maximized = false;
wl_signal_emit(&surface->events.request_maximize, surface);
} }
static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client, static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *output_resource) { struct wl_resource *resource, struct wl_resource *output_resource) {
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
surface->toplevel_state->next.fullscreen = true; surface->toplevel_state->next.fullscreen = true;
wl_signal_emit(&surface->events.request_fullscreen, surface);
} }
static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client, static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client,
struct wl_resource *resource) { struct wl_resource *resource) {
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
surface->toplevel_state->next.fullscreen = false; surface->toplevel_state->next.fullscreen = false;
wl_signal_emit(&surface->events.request_fullscreen, surface);
} }
static void xdg_toplevel_protocol_set_minimized(struct wl_client *client, static void xdg_toplevel_protocol_set_minimized(struct wl_client *client,
@ -1146,6 +1150,8 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
wl_list_init(&surface->configure_list); wl_list_init(&surface->configure_list);
wl_list_init(&surface->popups); wl_list_init(&surface->popups);
wl_signal_init(&surface->events.request_maximize);
wl_signal_init(&surface->events.request_fullscreen);
wl_signal_init(&surface->events.request_minimize); wl_signal_init(&surface->events.request_minimize);
wl_signal_init(&surface->events.request_move); wl_signal_init(&surface->events.request_move);
wl_signal_init(&surface->events.request_resize); wl_signal_init(&surface->events.request_resize);