xdg-shell: fix inert xdg_surface handling
Closes: https://github.com/swaywm/sway/issues/4834 Closes: https://github.com/swaywm/wlroots/issues/1890
This commit is contained in:
parent
31f721286a
commit
7e521fed97
|
@ -244,6 +244,11 @@ struct wlr_xdg_toplevel_show_window_menu_event {
|
|||
|
||||
struct wlr_xdg_shell *wlr_xdg_shell_create(struct wl_display *display);
|
||||
|
||||
/** Returns the wlr_xdg_surface from an xdg_surface resource.
|
||||
*
|
||||
* Aborts if the resource doesn't have the correct type. Returns NULL if the
|
||||
* resource is inert.
|
||||
*/
|
||||
struct wlr_xdg_surface *wlr_xdg_surface_from_resource(
|
||||
struct wl_resource *resource);
|
||||
struct wlr_xdg_surface *wlr_xdg_surface_from_popup_resource(
|
||||
|
|
|
@ -96,6 +96,9 @@ void unmap_xdg_surface(struct wlr_xdg_surface *surface) {
|
|||
static void xdg_surface_handle_ack_configure(struct wl_client *client,
|
||||
struct wl_resource *resource, uint32_t serial) {
|
||||
struct wlr_xdg_surface *surface = wlr_xdg_surface_from_resource(resource);
|
||||
if (surface == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (surface->role == WLR_XDG_SURFACE_ROLE_NONE) {
|
||||
wl_resource_post_error(surface->resource,
|
||||
|
@ -236,6 +239,9 @@ static void xdg_surface_handle_get_popup(struct wl_client *client,
|
|||
wlr_xdg_surface_from_resource(resource);
|
||||
struct wlr_xdg_surface *parent =
|
||||
wlr_xdg_surface_from_resource(parent_resource);
|
||||
if (xdg_surface == NULL) {
|
||||
return; // TODO: create an inert xdg_popup
|
||||
}
|
||||
struct wlr_xdg_positioner_resource *positioner =
|
||||
get_xdg_positioner_from_resource(positioner_resource);
|
||||
create_xdg_popup(xdg_surface, parent, positioner, id);
|
||||
|
@ -245,6 +251,9 @@ static void xdg_surface_handle_get_toplevel(struct wl_client *client,
|
|||
struct wl_resource *resource, uint32_t id) {
|
||||
struct wlr_xdg_surface *xdg_surface =
|
||||
wlr_xdg_surface_from_resource(resource);
|
||||
if (xdg_surface == NULL) {
|
||||
return; // TODO: create an inert xdg_toplevel
|
||||
}
|
||||
create_xdg_toplevel(xdg_surface, id);
|
||||
}
|
||||
|
||||
|
@ -252,6 +261,9 @@ static void xdg_surface_handle_set_window_geometry(struct wl_client *client,
|
|||
struct wl_resource *resource, int32_t x, int32_t y, int32_t width,
|
||||
int32_t height) {
|
||||
struct wlr_xdg_surface *surface = wlr_xdg_surface_from_resource(resource);
|
||||
if (surface == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (surface->role == WLR_XDG_SURFACE_ROLE_NONE) {
|
||||
wl_resource_post_error(surface->resource,
|
||||
|
@ -277,6 +289,9 @@ static void xdg_surface_handle_set_window_geometry(struct wl_client *client,
|
|||
static void xdg_surface_handle_destroy(struct wl_client *client,
|
||||
struct wl_resource *resource) {
|
||||
struct wlr_xdg_surface *surface = wlr_xdg_surface_from_resource(resource);
|
||||
if (surface == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (surface->role != WLR_XDG_SURFACE_ROLE_NONE) {
|
||||
wlr_log(WLR_ERROR, "Tried to destroy an xdg_surface before its role "
|
||||
|
@ -502,7 +517,6 @@ void destroy_xdg_surface(struct wlr_xdg_surface *surface) {
|
|||
|
||||
struct wlr_xdg_surface *wlr_xdg_surface_from_resource(
|
||||
struct wl_resource *resource) {
|
||||
// TODO: Double check that all of the callers can deal with NULL
|
||||
if (!resource) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue