|
|
@ -198,16 +198,15 @@ static void xdg_surface_unmap(struct wlr_xdg_surface *surface) {
|
|
|
|
wlr_signal_emit_safe(&surface->events.unmap, surface);
|
|
|
|
wlr_signal_emit_safe(&surface->events.unmap, surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
|
|
|
switch (surface->role) {
|
|
|
|
wl_resource_set_user_data(surface->toplevel->resource, NULL);
|
|
|
|
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
|
|
|
|
free(surface->toplevel);
|
|
|
|
free(surface->toplevel->title);
|
|
|
|
surface->toplevel = NULL;
|
|
|
|
surface->toplevel->title = NULL;
|
|
|
|
}
|
|
|
|
free(surface->toplevel->app_id);
|
|
|
|
|
|
|
|
surface->toplevel->app_id = NULL;
|
|
|
|
if (surface->role == WLR_XDG_SURFACE_ROLE_POPUP) {
|
|
|
|
break;
|
|
|
|
wl_resource_set_user_data(surface->popup->resource, NULL);
|
|
|
|
case WLR_XDG_SURFACE_ROLE_POPUP:
|
|
|
|
|
|
|
|
if (surface->popup->seat != NULL) {
|
|
|
|
if (surface->popup->seat) {
|
|
|
|
|
|
|
|
struct wlr_xdg_popup_grab *grab =
|
|
|
|
struct wlr_xdg_popup_grab *grab =
|
|
|
|
xdg_shell_popup_grab_from_seat(surface->client->shell,
|
|
|
|
xdg_shell_popup_grab_from_seat(surface->client->shell,
|
|
|
|
surface->popup->seat);
|
|
|
|
surface->popup->seat);
|
|
|
@ -222,11 +221,12 @@ static void xdg_surface_unmap(struct wlr_xdg_surface *surface) {
|
|
|
|
wlr_seat_keyboard_end_grab(grab->seat);
|
|
|
|
wlr_seat_keyboard_end_grab(grab->seat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_list_remove(&surface->popup->link);
|
|
|
|
surface->popup->seat = NULL;
|
|
|
|
free(surface->popup);
|
|
|
|
}
|
|
|
|
surface->popup = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WLR_XDG_SURFACE_ROLE_NONE:
|
|
|
|
|
|
|
|
assert(false && "not reached");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_xdg_surface_configure *configure, *tmp;
|
|
|
|
struct wlr_xdg_surface_configure *configure, *tmp;
|
|
|
@ -234,13 +234,7 @@ static void xdg_surface_unmap(struct wlr_xdg_surface *surface) {
|
|
|
|
xdg_surface_configure_destroy(configure);
|
|
|
|
xdg_surface_configure_destroy(configure);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
surface->role = WLR_XDG_SURFACE_ROLE_NONE;
|
|
|
|
surface->configured = surface->mapped = false;
|
|
|
|
free(surface->title);
|
|
|
|
|
|
|
|
surface->title = NULL;
|
|
|
|
|
|
|
|
free(surface->app_id);
|
|
|
|
|
|
|
|
surface->app_id = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
surface->added = surface->configured = surface->mapped = false;
|
|
|
|
|
|
|
|
surface->configure_serial = 0;
|
|
|
|
surface->configure_serial = 0;
|
|
|
|
if (surface->configure_idle) {
|
|
|
|
if (surface->configure_idle) {
|
|
|
|
wl_event_source_remove(surface->configure_idle);
|
|
|
|
wl_event_source_remove(surface->configure_idle);
|
|
|
@ -253,6 +247,29 @@ static void xdg_surface_unmap(struct wlr_xdg_surface *surface) {
|
|
|
|
memset(&surface->next_geometry, 0, sizeof(struct wlr_box));
|
|
|
|
memset(&surface->next_geometry, 0, sizeof(struct wlr_box));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_destroy(struct wlr_xdg_surface *surface) {
|
|
|
|
|
|
|
|
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
|
|
|
|
|
|
|
|
xdg_surface_unmap(surface);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_resource_set_user_data(surface->toplevel->resource, NULL);
|
|
|
|
|
|
|
|
free(surface->toplevel);
|
|
|
|
|
|
|
|
surface->toplevel = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
surface->role = WLR_XDG_SURFACE_ROLE_NONE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_popup_destroy(struct wlr_xdg_surface *surface) {
|
|
|
|
|
|
|
|
assert(surface->role == WLR_XDG_SURFACE_ROLE_POPUP);
|
|
|
|
|
|
|
|
xdg_surface_unmap(surface);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_resource_set_user_data(surface->popup->resource, NULL);
|
|
|
|
|
|
|
|
wl_list_remove(&surface->popup->link);
|
|
|
|
|
|
|
|
free(surface->popup);
|
|
|
|
|
|
|
|
surface->popup = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
surface->role = WLR_XDG_SURFACE_ROLE_NONE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_surface_destroy(struct wlr_xdg_surface *surface) {
|
|
|
|
static void xdg_surface_destroy(struct wlr_xdg_surface *surface) {
|
|
|
|
if (surface->role != WLR_XDG_SURFACE_ROLE_NONE) {
|
|
|
|
if (surface->role != WLR_XDG_SURFACE_ROLE_NONE) {
|
|
|
|
xdg_surface_unmap(surface);
|
|
|
|
xdg_surface_unmap(surface);
|
|
|
@ -260,6 +277,18 @@ static void xdg_surface_destroy(struct wlr_xdg_surface *surface) {
|
|
|
|
|
|
|
|
|
|
|
|
wlr_signal_emit_safe(&surface->events.destroy, surface);
|
|
|
|
wlr_signal_emit_safe(&surface->events.destroy, surface);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (surface->role) {
|
|
|
|
|
|
|
|
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
|
|
|
|
|
|
|
|
xdg_toplevel_destroy(surface);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WLR_XDG_SURFACE_ROLE_POPUP:
|
|
|
|
|
|
|
|
xdg_popup_destroy(surface);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WLR_XDG_SURFACE_ROLE_NONE:
|
|
|
|
|
|
|
|
// This space is intentionally left blank
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wl_resource_set_user_data(surface->resource, NULL);
|
|
|
|
wl_resource_set_user_data(surface->resource, NULL);
|
|
|
|
wl_list_remove(&surface->link);
|
|
|
|
wl_list_remove(&surface->link);
|
|
|
|
wl_list_remove(&surface->surface_destroy_listener.link);
|
|
|
|
wl_list_remove(&surface->surface_destroy_listener.link);
|
|
|
@ -574,7 +603,7 @@ static void xdg_popup_resource_destroy(struct wl_resource *resource) {
|
|
|
|
struct wlr_xdg_surface *surface =
|
|
|
|
struct wlr_xdg_surface *surface =
|
|
|
|
xdg_surface_from_xdg_popup_resource(resource);
|
|
|
|
xdg_surface_from_xdg_popup_resource(resource);
|
|
|
|
if (surface != NULL) {
|
|
|
|
if (surface != NULL) {
|
|
|
|
xdg_surface_unmap(surface);
|
|
|
|
xdg_popup_destroy(surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -673,8 +702,8 @@ static void xdg_toplevel_handle_set_title(struct wl_client *client,
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
free(surface->title);
|
|
|
|
free(surface->toplevel->title);
|
|
|
|
surface->title = tmp;
|
|
|
|
surface->toplevel->title = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_handle_set_app_id(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_handle_set_app_id(struct wl_client *client,
|
|
|
@ -688,8 +717,8 @@ static void xdg_toplevel_handle_set_app_id(struct wl_client *client,
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
free(surface->app_id);
|
|
|
|
free(surface->toplevel->app_id);
|
|
|
|
surface->app_id = tmp;
|
|
|
|
surface->toplevel->app_id = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_handle_show_window_menu(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_handle_show_window_menu(struct wl_client *client,
|
|
|
@ -720,7 +749,7 @@ static void xdg_toplevel_handle_show_window_menu(struct wl_client *client,
|
|
|
|
.y = y,
|
|
|
|
.y = y,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_show_window_menu, &event);
|
|
|
|
wlr_signal_emit_safe(&surface->toplevel->events.request_show_window_menu, &event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_handle_move(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_handle_move(struct wl_client *client,
|
|
|
@ -749,7 +778,7 @@ static void xdg_toplevel_handle_move(struct wl_client *client,
|
|
|
|
.serial = serial,
|
|
|
|
.serial = serial,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_move, &event);
|
|
|
|
wlr_signal_emit_safe(&surface->toplevel->events.request_move, &event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_handle_resize(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_handle_resize(struct wl_client *client,
|
|
|
@ -779,7 +808,7 @@ static void xdg_toplevel_handle_resize(struct wl_client *client,
|
|
|
|
.edges = edges,
|
|
|
|
.edges = edges,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_resize, &event);
|
|
|
|
wlr_signal_emit_safe(&surface->toplevel->events.request_resize, &event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_handle_set_max_size(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_handle_set_max_size(struct wl_client *client,
|
|
|
@ -803,7 +832,7 @@ static void xdg_toplevel_handle_set_maximized(struct wl_client *client,
|
|
|
|
struct wlr_xdg_surface *surface =
|
|
|
|
struct wlr_xdg_surface *surface =
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
surface->toplevel->next.maximized = true;
|
|
|
|
surface->toplevel->next.maximized = true;
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_maximize, surface);
|
|
|
|
wlr_signal_emit_safe(&surface->toplevel->events.request_maximize, surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_handle_unset_maximized(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_handle_unset_maximized(struct wl_client *client,
|
|
|
@ -811,7 +840,7 @@ static void xdg_toplevel_handle_unset_maximized(struct wl_client *client,
|
|
|
|
struct wlr_xdg_surface *surface =
|
|
|
|
struct wlr_xdg_surface *surface =
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
surface->toplevel->next.maximized = false;
|
|
|
|
surface->toplevel->next.maximized = false;
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_maximize, surface);
|
|
|
|
wlr_signal_emit_safe(&surface->toplevel->events.request_maximize, surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_handle_set_fullscreen(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_handle_set_fullscreen(struct wl_client *client,
|
|
|
@ -832,7 +861,7 @@ static void xdg_toplevel_handle_set_fullscreen(struct wl_client *client,
|
|
|
|
.output = output,
|
|
|
|
.output = output,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_fullscreen, &event);
|
|
|
|
wlr_signal_emit_safe(&surface->toplevel->events.request_fullscreen, &event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_handle_unset_fullscreen(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_handle_unset_fullscreen(struct wl_client *client,
|
|
|
@ -848,14 +877,14 @@ static void xdg_toplevel_handle_unset_fullscreen(struct wl_client *client,
|
|
|
|
.output = NULL,
|
|
|
|
.output = NULL,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_fullscreen, &event);
|
|
|
|
wlr_signal_emit_safe(&surface->toplevel->events.request_fullscreen, &event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_handle_set_minimized(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_handle_set_minimized(struct wl_client *client,
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wlr_xdg_surface *surface =
|
|
|
|
struct wlr_xdg_surface *surface =
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_minimize, surface);
|
|
|
|
wlr_signal_emit_safe(&surface->toplevel->events.request_minimize, surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const struct xdg_toplevel_interface xdg_toplevel_implementation = {
|
|
|
|
static const struct xdg_toplevel_interface xdg_toplevel_implementation = {
|
|
|
@ -887,7 +916,7 @@ static void xdg_toplevel_resource_destroy(struct wl_resource *resource) {
|
|
|
|
struct wlr_xdg_surface *surface =
|
|
|
|
struct wlr_xdg_surface *surface =
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
if (surface != NULL) {
|
|
|
|
if (surface != NULL) {
|
|
|
|
xdg_surface_unmap(surface);
|
|
|
|
xdg_toplevel_destroy(surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -905,6 +934,12 @@ static void xdg_surface_handle_get_toplevel(struct wl_client *client,
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_signal_init(&surface->toplevel->events.request_maximize);
|
|
|
|
|
|
|
|
wl_signal_init(&surface->toplevel->events.request_fullscreen);
|
|
|
|
|
|
|
|
wl_signal_init(&surface->toplevel->events.request_minimize);
|
|
|
|
|
|
|
|
wl_signal_init(&surface->toplevel->events.request_move);
|
|
|
|
|
|
|
|
wl_signal_init(&surface->toplevel->events.request_resize);
|
|
|
|
|
|
|
|
wl_signal_init(&surface->toplevel->events.request_show_window_menu);
|
|
|
|
|
|
|
|
|
|
|
|
surface->role = WLR_XDG_SURFACE_ROLE_TOPLEVEL;
|
|
|
|
surface->role = WLR_XDG_SURFACE_ROLE_TOPLEVEL;
|
|
|
|
surface->toplevel->base = surface;
|
|
|
|
surface->toplevel->base = surface;
|
|
|
@ -1349,12 +1384,6 @@ static void xdg_shell_handle_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_move);
|
|
|
|
|
|
|
|
wl_signal_init(&surface->events.request_resize);
|
|
|
|
|
|
|
|
wl_signal_init(&surface->events.request_show_window_menu);
|
|
|
|
|
|
|
|
wl_signal_init(&surface->events.destroy);
|
|
|
|
wl_signal_init(&surface->events.destroy);
|
|
|
|
wl_signal_init(&surface->events.ping_timeout);
|
|
|
|
wl_signal_init(&surface->events.ping_timeout);
|
|
|
|
wl_signal_init(&surface->events.new_popup);
|
|
|
|
wl_signal_init(&surface->events.new_popup);
|
|
|
|