mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-22 07:02:28 +00:00
xdg-shell: improve unmapping logic slightly
This commit is contained in:
parent
1b6fac4aa6
commit
a3489f2c64
@ -11,9 +11,8 @@ extern const struct wlr_surface_role xdg_popup_surface_role;
|
|||||||
struct wlr_xdg_surface *create_xdg_surface(
|
struct wlr_xdg_surface *create_xdg_surface(
|
||||||
struct wlr_xdg_client *client, struct wlr_surface *wlr_surface,
|
struct wlr_xdg_client *client, struct wlr_surface *wlr_surface,
|
||||||
uint32_t id);
|
uint32_t id);
|
||||||
void unmap_xdg_surface(struct wlr_xdg_surface *surface);
|
|
||||||
void reset_xdg_surface(struct wlr_xdg_surface *surface);
|
|
||||||
void destroy_xdg_surface(struct wlr_xdg_surface *surface);
|
void destroy_xdg_surface(struct wlr_xdg_surface *surface);
|
||||||
|
void destroy_xdg_surface_role_object(struct wlr_xdg_surface *surface);
|
||||||
void xdg_surface_role_commit(struct wlr_surface *wlr_surface);
|
void xdg_surface_role_commit(struct wlr_surface *wlr_surface);
|
||||||
void xdg_surface_role_precommit(struct wlr_surface *wlr_surface,
|
void xdg_surface_role_precommit(struct wlr_surface *wlr_surface,
|
||||||
const struct wlr_surface_state *state);
|
const struct wlr_surface_state *state);
|
||||||
@ -24,7 +23,7 @@ void create_xdg_positioner(struct wlr_xdg_client *client, uint32_t id);
|
|||||||
void create_xdg_popup(struct wlr_xdg_surface *surface,
|
void create_xdg_popup(struct wlr_xdg_surface *surface,
|
||||||
struct wlr_xdg_surface *parent,
|
struct wlr_xdg_surface *parent,
|
||||||
struct wlr_xdg_positioner *positioner, uint32_t id);
|
struct wlr_xdg_positioner *positioner, uint32_t id);
|
||||||
void unmap_xdg_popup(struct wlr_xdg_popup *popup);
|
void reset_xdg_popup(struct wlr_xdg_popup *popup);
|
||||||
void destroy_xdg_popup(struct wlr_xdg_popup *popup);
|
void destroy_xdg_popup(struct wlr_xdg_popup *popup);
|
||||||
void handle_xdg_popup_committed(struct wlr_xdg_popup *popup);
|
void handle_xdg_popup_committed(struct wlr_xdg_popup *popup);
|
||||||
struct wlr_xdg_popup_configure *send_xdg_popup_configure(
|
struct wlr_xdg_popup_configure *send_xdg_popup_configure(
|
||||||
@ -34,7 +33,7 @@ void handle_xdg_popup_ack_configure(struct wlr_xdg_popup *popup,
|
|||||||
|
|
||||||
void create_xdg_toplevel(struct wlr_xdg_surface *surface,
|
void create_xdg_toplevel(struct wlr_xdg_surface *surface,
|
||||||
uint32_t id);
|
uint32_t id);
|
||||||
void unmap_xdg_toplevel(struct wlr_xdg_toplevel *toplevel);
|
void reset_xdg_toplevel(struct wlr_xdg_toplevel *toplevel);
|
||||||
void destroy_xdg_toplevel(struct wlr_xdg_toplevel *toplevel);
|
void destroy_xdg_toplevel(struct wlr_xdg_toplevel *toplevel);
|
||||||
void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel);
|
void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel);
|
||||||
struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure(
|
struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure(
|
||||||
|
@ -425,7 +425,7 @@ void create_xdg_popup(struct wlr_xdg_surface *surface,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void unmap_xdg_popup(struct wlr_xdg_popup *popup) {
|
void reset_xdg_popup(struct wlr_xdg_popup *popup) {
|
||||||
if (popup->seat != NULL) {
|
if (popup->seat != NULL) {
|
||||||
struct wlr_xdg_popup_grab *grab =
|
struct wlr_xdg_popup_grab *grab =
|
||||||
get_xdg_shell_popup_grab_from_seat(
|
get_xdg_shell_popup_grab_from_seat(
|
||||||
@ -471,7 +471,7 @@ void wlr_xdg_popup_destroy(struct wlr_xdg_popup *popup) {
|
|||||||
|
|
||||||
xdg_popup_send_popup_done(popup->resource);
|
xdg_popup_send_popup_done(popup->resource);
|
||||||
wl_resource_set_user_data(popup->resource, NULL);
|
wl_resource_set_user_data(popup->resource, NULL);
|
||||||
reset_xdg_surface(popup->base);
|
destroy_xdg_surface_role_object(popup->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_xdg_popup_get_toplevel_coords(struct wlr_xdg_popup *popup,
|
void wlr_xdg_popup_get_toplevel_coords(struct wlr_xdg_popup *popup,
|
||||||
|
@ -24,16 +24,9 @@ static void xdg_surface_configure_destroy(
|
|||||||
free(configure);
|
free(configure);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unmap_xdg_surface(struct wlr_xdg_surface *surface) {
|
static void reset_xdg_surface(struct wlr_xdg_surface *surface) {
|
||||||
assert(surface->role != WLR_XDG_SURFACE_ROLE_NONE);
|
|
||||||
surface->configured = false;
|
surface->configured = false;
|
||||||
|
|
||||||
// TODO: probably need to ungrab before this event
|
|
||||||
if (surface->mapped) {
|
|
||||||
surface->mapped = false;
|
|
||||||
wl_signal_emit_mutable(&surface->events.unmap, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_xdg_popup *popup, *popup_tmp;
|
struct wlr_xdg_popup *popup, *popup_tmp;
|
||||||
wl_list_for_each_safe(popup, popup_tmp, &surface->popups, link) {
|
wl_list_for_each_safe(popup, popup_tmp, &surface->popups, link) {
|
||||||
wlr_xdg_popup_destroy(popup);
|
wlr_xdg_popup_destroy(popup);
|
||||||
@ -41,13 +34,13 @@ void unmap_xdg_surface(struct wlr_xdg_surface *surface) {
|
|||||||
|
|
||||||
switch (surface->role) {
|
switch (surface->role) {
|
||||||
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
|
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
|
||||||
unmap_xdg_toplevel(surface->toplevel);
|
reset_xdg_toplevel(surface->toplevel);
|
||||||
break;
|
break;
|
||||||
case WLR_XDG_SURFACE_ROLE_POPUP:
|
case WLR_XDG_SURFACE_ROLE_POPUP:
|
||||||
unmap_xdg_popup(surface->popup);
|
reset_xdg_popup(surface->popup);
|
||||||
break;
|
break;
|
||||||
case WLR_XDG_SURFACE_ROLE_NONE:
|
case WLR_XDG_SURFACE_ROLE_NONE:
|
||||||
assert(false && "not reached");
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_xdg_surface_configure *configure, *tmp;
|
struct wlr_xdg_surface_configure *configure, *tmp;
|
||||||
@ -61,6 +54,15 @@ void unmap_xdg_surface(struct wlr_xdg_surface *surface) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void unmap_xdg_surface(struct wlr_xdg_surface *surface) {
|
||||||
|
surface->mapped = false;
|
||||||
|
|
||||||
|
// TODO: probably need to ungrab before this event
|
||||||
|
wl_signal_emit_mutable(&surface->events.unmap, NULL);
|
||||||
|
|
||||||
|
reset_xdg_surface(surface);
|
||||||
|
}
|
||||||
|
|
||||||
static void xdg_surface_handle_ack_configure(struct wl_client *client,
|
static void xdg_surface_handle_ack_configure(struct wl_client *client,
|
||||||
struct wl_resource *resource, uint32_t serial) {
|
struct wl_resource *resource, uint32_t serial) {
|
||||||
struct wlr_xdg_surface *surface = wlr_xdg_surface_from_resource(resource);
|
struct wlr_xdg_surface *surface = wlr_xdg_surface_from_resource(resource);
|
||||||
@ -328,7 +330,7 @@ void xdg_surface_role_destroy(struct wlr_surface *wlr_surface) {
|
|||||||
struct wlr_xdg_surface *surface = wlr_xdg_surface_try_from_wlr_surface(wlr_surface);
|
struct wlr_xdg_surface *surface = wlr_xdg_surface_try_from_wlr_surface(wlr_surface);
|
||||||
assert(surface != NULL);
|
assert(surface != NULL);
|
||||||
|
|
||||||
reset_xdg_surface(surface);
|
destroy_xdg_surface_role_object(surface);
|
||||||
|
|
||||||
wl_list_remove(&surface->link);
|
wl_list_remove(&surface->link);
|
||||||
wl_list_remove(&surface->surface_commit.link);
|
wl_list_remove(&surface->surface_commit.link);
|
||||||
@ -393,9 +395,11 @@ struct wlr_xdg_surface *create_xdg_surface(
|
|||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_xdg_surface(struct wlr_xdg_surface *surface) {
|
void destroy_xdg_surface_role_object(struct wlr_xdg_surface *surface) {
|
||||||
if (surface->role != WLR_XDG_SURFACE_ROLE_NONE) {
|
if (surface->configured && surface->mapped) {
|
||||||
unmap_xdg_surface(surface);
|
unmap_xdg_surface(surface);
|
||||||
|
} else {
|
||||||
|
reset_xdg_surface(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface->added) {
|
if (surface->added) {
|
||||||
|
@ -469,7 +469,7 @@ static void xdg_toplevel_handle_resource_destroy(struct wl_resource *resource) {
|
|||||||
if (toplevel == NULL) {
|
if (toplevel == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reset_xdg_surface(toplevel->base);
|
destroy_xdg_surface_role_object(toplevel->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct wlr_surface_role xdg_toplevel_surface_role = {
|
const struct wlr_surface_role xdg_toplevel_surface_role = {
|
||||||
@ -527,7 +527,7 @@ void create_xdg_toplevel(struct wlr_xdg_surface *surface,
|
|||||||
surface->role = WLR_XDG_SURFACE_ROLE_TOPLEVEL;
|
surface->role = WLR_XDG_SURFACE_ROLE_TOPLEVEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unmap_xdg_toplevel(struct wlr_xdg_toplevel *toplevel) {
|
void reset_xdg_toplevel(struct wlr_xdg_toplevel *toplevel) {
|
||||||
if (toplevel->parent) {
|
if (toplevel->parent) {
|
||||||
wl_list_remove(&toplevel->parent_unmap.link);
|
wl_list_remove(&toplevel->parent_unmap.link);
|
||||||
toplevel->parent = NULL;
|
toplevel->parent = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user