xdg-toplevel: fix functions' main argument type

With this commit, `wlr_xdg_toplevel_*()` functions now expect
a `wlr_xdg_toplevel` instead of a `wlr_xdg_surface`.
This commit is contained in:
Kirill Primak 2022-01-08 22:52:51 +03:00
parent ee52c32915
commit affe0d8713
8 changed files with 212 additions and 226 deletions

View file

@ -36,11 +36,11 @@ struct wlr_xdg_popup_grab *get_xdg_shell_popup_grab_from_seat(
void create_xdg_toplevel(struct wlr_xdg_surface *xdg_surface, void create_xdg_toplevel(struct wlr_xdg_surface *xdg_surface,
uint32_t id); uint32_t id);
void handle_xdg_surface_toplevel_committed(struct wlr_xdg_surface *surface); void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel);
void send_xdg_toplevel_configure(struct wlr_xdg_surface *surface, struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure(
struct wlr_xdg_surface_configure *configure); struct wlr_xdg_toplevel *toplevel);
void handle_xdg_toplevel_ack_configure(struct wlr_xdg_surface *surface, void handle_xdg_toplevel_ack_configure(struct wlr_xdg_toplevel *toplevel,
struct wlr_xdg_surface_configure *configure); struct wlr_xdg_toplevel_configure *configure);
void destroy_xdg_toplevel(struct wlr_xdg_surface *surface); void destroy_xdg_toplevel(struct wlr_xdg_toplevel *toplevel);
#endif #endif

View file

@ -258,7 +258,7 @@ struct wlr_xdg_toplevel_show_window_menu_event {
struct wlr_xdg_shell *wlr_xdg_shell_create(struct wl_display *display); struct wlr_xdg_shell *wlr_xdg_shell_create(struct wl_display *display);
/** Returns the wlr_xdg_surface from an xdg_surface resource. /** Get the corresponding wlr_xdg_surface from a resource.
* *
* Aborts if the resource doesn't have the correct type. Returns NULL if the * Aborts if the resource doesn't have the correct type. Returns NULL if the
* resource is inert. * resource is inert.
@ -267,7 +267,13 @@ struct wlr_xdg_surface *wlr_xdg_surface_from_resource(
struct wl_resource *resource); struct wl_resource *resource);
struct wlr_xdg_surface *wlr_xdg_surface_from_popup_resource( struct wlr_xdg_surface *wlr_xdg_surface_from_popup_resource(
struct wl_resource *resource); struct wl_resource *resource);
struct wlr_xdg_surface *wlr_xdg_surface_from_toplevel_resource(
/** Get the corresponding wlr_xdg_toplevel from a resource.
*
* Aborts if the resource doesn't have the correct type. Returns NULL if the
* resource is inert.
*/
struct wlr_xdg_toplevel *wlr_xdg_toplevel_from_resource(
struct wl_resource *resource); struct wl_resource *resource);
/** /**
@ -280,55 +286,55 @@ void wlr_xdg_surface_ping(struct wlr_xdg_surface *surface);
* Request that this toplevel surface be the given size. Returns the associated * Request that this toplevel surface be the given size. Returns the associated
* configure serial. * configure serial.
*/ */
uint32_t wlr_xdg_toplevel_set_size(struct wlr_xdg_surface *surface, uint32_t wlr_xdg_toplevel_set_size(struct wlr_xdg_toplevel *toplevel,
uint32_t width, uint32_t height); uint32_t width, uint32_t height);
/** /**
* Request that this toplevel surface show itself in an activated or deactivated * Request that this toplevel show itself in an activated or deactivated
* state. Returns the associated configure serial. * state. Returns the associated configure serial.
*/ */
uint32_t wlr_xdg_toplevel_set_activated(struct wlr_xdg_surface *surface, uint32_t wlr_xdg_toplevel_set_activated(struct wlr_xdg_toplevel *toplevel,
bool activated); bool activated);
/** /**
* Request that this toplevel surface consider itself maximized or not * Request that this toplevel consider itself maximized or not
* maximized. Returns the associated configure serial. * maximized. Returns the associated configure serial.
*/ */
uint32_t wlr_xdg_toplevel_set_maximized(struct wlr_xdg_surface *surface, uint32_t wlr_xdg_toplevel_set_maximized(struct wlr_xdg_toplevel *toplevel,
bool maximized); bool maximized);
/** /**
* Request that this toplevel surface consider itself fullscreen or not * Request that this toplevel consider itself fullscreen or not
* fullscreen. Returns the associated configure serial. * fullscreen. Returns the associated configure serial.
*/ */
uint32_t wlr_xdg_toplevel_set_fullscreen(struct wlr_xdg_surface *surface, uint32_t wlr_xdg_toplevel_set_fullscreen(struct wlr_xdg_toplevel *toplevel,
bool fullscreen); bool fullscreen);
/** /**
* Request that this toplevel surface consider itself to be resizing or not * Request that this toplevel consider itself to be resizing or not
* resizing. Returns the associated configure serial. * resizing. Returns the associated configure serial.
*/ */
uint32_t wlr_xdg_toplevel_set_resizing(struct wlr_xdg_surface *surface, uint32_t wlr_xdg_toplevel_set_resizing(struct wlr_xdg_toplevel *toplevel,
bool resizing); bool resizing);
/** /**
* Request that this toplevel surface consider itself in a tiled layout and some * Request that this toplevel consider itself in a tiled layout and some
* edges are adjacent to another part of the tiling grid. `tiled_edges` is a * edges are adjacent to another part of the tiling grid. `tiled_edges` is a
* bitfield of `enum wlr_edges`. Returns the associated configure serial. * bitfield of `enum wlr_edges`. Returns the associated configure serial.
*/ */
uint32_t wlr_xdg_toplevel_set_tiled(struct wlr_xdg_surface *surface, uint32_t wlr_xdg_toplevel_set_tiled(struct wlr_xdg_toplevel *toplevel,
uint32_t tiled_edges); uint32_t tiled_edges);
/** /**
* Request that this xdg toplevel closes. * Request that this xdg toplevel closes.
*/ */
void wlr_xdg_toplevel_send_close(struct wlr_xdg_surface *surface); void wlr_xdg_toplevel_send_close(struct wlr_xdg_toplevel *toplevel);
/** /**
* Sets the parent of this toplevel. Parent can be NULL. * Sets the parent of this toplevel. Parent can be NULL.
*/ */
void wlr_xdg_toplevel_set_parent(struct wlr_xdg_surface *surface, void wlr_xdg_toplevel_set_parent(struct wlr_xdg_toplevel *toplevel,
struct wlr_xdg_surface *parent); struct wlr_xdg_toplevel *parent);
/** /**
* Request that this xdg popup closes. * Request that this xdg popup closes.

View file

@ -78,7 +78,7 @@ struct tinywl_output {
struct tinywl_view { struct tinywl_view {
struct wl_list link; struct wl_list link;
struct tinywl_server *server; struct tinywl_server *server;
struct wlr_xdg_surface *xdg_surface; struct wlr_xdg_toplevel *xdg_toplevel;
struct wlr_scene_node *scene_node; struct wlr_scene_node *scene_node;
struct wl_listener map; struct wl_listener map;
struct wl_listener unmap; struct wl_listener unmap;
@ -117,7 +117,8 @@ static void focus_view(struct tinywl_view *view, struct wlr_surface *surface) {
*/ */
struct wlr_xdg_surface *previous = wlr_xdg_surface_from_wlr_surface( struct wlr_xdg_surface *previous = wlr_xdg_surface_from_wlr_surface(
seat->keyboard_state.focused_surface); seat->keyboard_state.focused_surface);
wlr_xdg_toplevel_set_activated(previous, false); assert(previous->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
wlr_xdg_toplevel_set_activated(previous->toplevel, false);
} }
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat); struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
/* Move the view to the front */ /* Move the view to the front */
@ -125,13 +126,13 @@ static void focus_view(struct tinywl_view *view, struct wlr_surface *surface) {
wl_list_remove(&view->link); wl_list_remove(&view->link);
wl_list_insert(&server->views, &view->link); wl_list_insert(&server->views, &view->link);
/* Activate the new surface */ /* Activate the new surface */
wlr_xdg_toplevel_set_activated(view->xdg_surface, true); wlr_xdg_toplevel_set_activated(view->xdg_toplevel, true);
/* /*
* Tell the seat to have the keyboard enter this surface. wlroots will keep * Tell the seat to have the keyboard enter this surface. wlroots will keep
* track of this and automatically send key events to the appropriate * track of this and automatically send key events to the appropriate
* clients without additional work on your part. * clients without additional work on your part.
*/ */
wlr_seat_keyboard_notify_enter(seat, view->xdg_surface->surface, wlr_seat_keyboard_notify_enter(seat, view->xdg_toplevel->base->surface,
keyboard->keycodes, keyboard->num_keycodes, &keyboard->modifiers); keyboard->keycodes, keyboard->num_keycodes, &keyboard->modifiers);
} }
@ -172,7 +173,7 @@ static bool handle_keybinding(struct tinywl_server *server, xkb_keysym_t sym) {
} }
struct tinywl_view *next_view = wl_container_of( struct tinywl_view *next_view = wl_container_of(
server->views.prev, next_view, link); server->views.prev, next_view, link);
focus_view(next_view, next_view->xdg_surface->surface); focus_view(next_view, next_view->xdg_toplevel->base->surface);
break; break;
default: default:
return false; return false;
@ -381,14 +382,14 @@ static void process_cursor_resize(struct tinywl_server *server, uint32_t time) {
} }
struct wlr_box geo_box; struct wlr_box geo_box;
wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box); wlr_xdg_surface_get_geometry(view->xdg_toplevel->base, &geo_box);
view->x = new_left - geo_box.x; view->x = new_left - geo_box.x;
view->y = new_top - geo_box.y; view->y = new_top - geo_box.y;
wlr_scene_node_set_position(view->scene_node, view->x, view->y); wlr_scene_node_set_position(view->scene_node, view->x, view->y);
int new_width = new_right - new_left; int new_width = new_right - new_left;
int new_height = new_bottom - new_top; int new_height = new_bottom - new_top;
wlr_xdg_toplevel_set_size(view->xdg_surface, new_width, new_height); wlr_xdg_toplevel_set_size(view->xdg_toplevel, new_width, new_height);
} }
static void process_cursor_motion(struct tinywl_server *server, uint32_t time) { static void process_cursor_motion(struct tinywl_server *server, uint32_t time) {
@ -581,7 +582,7 @@ static void xdg_toplevel_map(struct wl_listener *listener, void *data) {
wl_list_insert(&view->server->views, &view->link); wl_list_insert(&view->server->views, &view->link);
focus_view(view, view->xdg_surface->surface); focus_view(view, view->xdg_toplevel->base->surface);
} }
static void xdg_toplevel_unmap(struct wl_listener *listener, void *data) { static void xdg_toplevel_unmap(struct wl_listener *listener, void *data) {
@ -612,7 +613,7 @@ static void begin_interactive(struct tinywl_view *view,
struct tinywl_server *server = view->server; struct tinywl_server *server = view->server;
struct wlr_surface *focused_surface = struct wlr_surface *focused_surface =
server->seat->pointer_state.focused_surface; server->seat->pointer_state.focused_surface;
if (view->xdg_surface->surface != if (view->xdg_toplevel->base->surface !=
wlr_surface_get_root_surface(focused_surface)) { wlr_surface_get_root_surface(focused_surface)) {
/* Deny move/resize requests from unfocused clients. */ /* Deny move/resize requests from unfocused clients. */
return; return;
@ -625,7 +626,7 @@ static void begin_interactive(struct tinywl_view *view,
server->grab_y = server->cursor->y - view->y; server->grab_y = server->cursor->y - view->y;
} else { } else {
struct wlr_box geo_box; struct wlr_box geo_box;
wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box); wlr_xdg_surface_get_geometry(view->xdg_toplevel->base, &geo_box);
double border_x = (view->x + geo_box.x) + double border_x = (view->x + geo_box.x) +
((edges & WLR_EDGE_RIGHT) ? geo_box.width : 0); ((edges & WLR_EDGE_RIGHT) ? geo_box.width : 0);
@ -691,9 +692,9 @@ static void server_new_xdg_surface(struct wl_listener *listener, void *data) {
struct tinywl_view *view = struct tinywl_view *view =
calloc(1, sizeof(struct tinywl_view)); calloc(1, sizeof(struct tinywl_view));
view->server = server; view->server = server;
view->xdg_surface = xdg_surface; view->xdg_toplevel = xdg_surface->toplevel;
view->scene_node = wlr_scene_xdg_surface_create( view->scene_node = wlr_scene_xdg_surface_create(
&view->server->scene->node, view->xdg_surface); &view->server->scene->node, view->xdg_toplevel->base);
view->scene_node->data = view; view->scene_node->data = view;
xdg_surface->data = view->scene_node; xdg_surface->data = view->scene_node;

View file

@ -173,11 +173,10 @@ static void decoration_manager_handle_get_toplevel_decoration(
uint32_t id, struct wl_resource *toplevel_resource) { uint32_t id, struct wl_resource *toplevel_resource) {
struct wlr_xdg_decoration_manager_v1 *manager = struct wlr_xdg_decoration_manager_v1 *manager =
decoration_manager_from_resource(manager_resource); decoration_manager_from_resource(manager_resource);
struct wlr_xdg_surface *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(toplevel_resource); wlr_xdg_toplevel_from_resource(toplevel_resource);
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
if (wlr_surface_has_buffer(surface->surface)) { if (wlr_surface_has_buffer(toplevel->base->surface)) {
wl_resource_post_error(manager_resource, wl_resource_post_error(manager_resource,
ZXDG_TOPLEVEL_DECORATION_V1_ERROR_UNCONFIGURED_BUFFER, ZXDG_TOPLEVEL_DECORATION_V1_ERROR_UNCONFIGURED_BUFFER,
"xdg_toplevel_decoration must not have a buffer at creation"); "xdg_toplevel_decoration must not have a buffer at creation");
@ -191,7 +190,7 @@ static void decoration_manager_handle_get_toplevel_decoration(
return; return;
} }
decoration->manager = manager; decoration->manager = manager;
decoration->surface = surface; decoration->surface = toplevel->base;
uint32_t version = wl_resource_get_version(manager_resource); uint32_t version = wl_resource_get_version(manager_resource);
decoration->resource = wl_resource_create(client, decoration->resource = wl_resource_create(client,
@ -212,24 +211,26 @@ static void decoration_manager_handle_get_toplevel_decoration(
wl_signal_init(&decoration->events.destroy); wl_signal_init(&decoration->events.destroy);
wl_signal_init(&decoration->events.request_mode); wl_signal_init(&decoration->events.request_mode);
wl_signal_add(&surface->events.destroy, &decoration->surface_destroy); wl_signal_add(&toplevel->base->events.destroy,
&decoration->surface_destroy);
decoration->surface_destroy.notify = decoration->surface_destroy.notify =
toplevel_decoration_handle_surface_destroy; toplevel_decoration_handle_surface_destroy;
wl_signal_add(&surface->events.configure, &decoration->surface_configure); wl_signal_add(&toplevel->base->events.configure,
&decoration->surface_configure);
decoration->surface_configure.notify = decoration->surface_configure.notify =
toplevel_decoration_handle_surface_configure; toplevel_decoration_handle_surface_configure;
wl_signal_add(&surface->events.ack_configure, wl_signal_add(&toplevel->base->events.ack_configure,
&decoration->surface_ack_configure); &decoration->surface_ack_configure);
decoration->surface_ack_configure.notify = decoration->surface_ack_configure.notify =
toplevel_decoration_handle_surface_ack_configure; toplevel_decoration_handle_surface_ack_configure;
wl_signal_add(&surface->surface->events.commit, wl_signal_add(&toplevel->base->surface->events.commit,
&decoration->surface_commit); &decoration->surface_commit);
decoration->surface_commit.notify = decoration->surface_commit.notify =
toplevel_decoration_handle_surface_commit; toplevel_decoration_handle_surface_commit;
wl_list_insert(&manager->decorations, &decoration->link); wl_list_insert(&manager->decorations, &decoration->link);
if (surface->added) { if (toplevel->base->added) {
decoration->added = true; decoration->added = true;
wlr_signal_emit_safe(&manager->events.new_toplevel_decoration, wlr_signal_emit_safe(&manager->events.new_toplevel_decoration,
decoration); decoration);

View file

@ -103,7 +103,7 @@ static void xdg_imported_handle_set_parent_of(struct wl_client *client,
struct wlr_xdg_surface *surface_child = struct wlr_xdg_surface *surface_child =
wlr_xdg_surface_from_wlr_surface(wlr_surface_child); wlr_xdg_surface_from_wlr_surface(wlr_surface_child);
wlr_xdg_toplevel_set_parent(surface_child, surface); wlr_xdg_toplevel_set_parent(surface_child->toplevel, surface->toplevel);
wl_signal_add(&surface_child->events.unmap, wl_signal_add(&surface_child->events.unmap,
&child->xdg_surface_unmap); &child->xdg_surface_unmap);
wl_signal_add(&surface_child->toplevel->events.set_parent, wl_signal_add(&surface_child->toplevel->events.set_parent,
@ -153,7 +153,7 @@ static void destroy_imported(struct wlr_xdg_imported_v1 *imported) {
wlr_xdg_surface_from_wlr_surface(child->surface); wlr_xdg_surface_from_wlr_surface(child->surface);
if (xdg_child != NULL) { if (xdg_child != NULL) {
wlr_xdg_toplevel_set_parent(xdg_child, NULL); wlr_xdg_toplevel_set_parent(xdg_child->toplevel, NULL);
} }
} }

View file

@ -109,7 +109,7 @@ static void xdg_imported_handle_set_parent_of(struct wl_client *client,
struct wlr_xdg_surface *surface_child = struct wlr_xdg_surface *surface_child =
wlr_xdg_surface_from_wlr_surface(wlr_surface_child); wlr_xdg_surface_from_wlr_surface(wlr_surface_child);
wlr_xdg_toplevel_set_parent(surface_child, surface); wlr_xdg_toplevel_set_parent(surface_child->toplevel, surface->toplevel);
wl_signal_add(&surface_child->events.unmap, wl_signal_add(&surface_child->events.unmap,
&child->xdg_surface_unmap); &child->xdg_surface_unmap);
wl_signal_add(&surface_child->toplevel->events.set_parent, wl_signal_add(&surface_child->toplevel->events.set_parent,
@ -159,7 +159,7 @@ static void destroy_imported(struct wlr_xdg_imported_v2 *imported) {
wlr_xdg_surface_from_wlr_surface(child->surface); wlr_xdg_surface_from_wlr_surface(child->surface);
if (xdg_child != NULL) { if (xdg_child != NULL) {
wlr_xdg_toplevel_set_parent(xdg_child, NULL); wlr_xdg_toplevel_set_parent(xdg_child->toplevel, NULL);
} }
} }

View file

@ -130,7 +130,8 @@ static void xdg_surface_handle_ack_configure(struct wl_client *client,
assert(0 && "not reached"); assert(0 && "not reached");
break; break;
case WLR_XDG_SURFACE_ROLE_TOPLEVEL: case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
handle_xdg_toplevel_ack_configure(surface, configure); handle_xdg_toplevel_ack_configure(surface->toplevel,
configure->toplevel_configure);
break; break;
case WLR_XDG_SURFACE_ROLE_POPUP: case WLR_XDG_SURFACE_ROLE_POPUP:
break; break;
@ -164,7 +165,8 @@ static void surface_send_configure(void *user_data) {
assert(0 && "not reached"); assert(0 && "not reached");
break; break;
case WLR_XDG_SURFACE_ROLE_TOPLEVEL: case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
send_xdg_toplevel_configure(surface, configure); configure->toplevel_configure =
send_xdg_toplevel_configure(surface->toplevel);
break; break;
case WLR_XDG_SURFACE_ROLE_POPUP: case WLR_XDG_SURFACE_ROLE_POPUP:
xdg_popup_send_configure(surface->popup->resource, xdg_popup_send_configure(surface->popup->resource,
@ -319,7 +321,7 @@ void xdg_surface_role_commit(struct wlr_surface *wlr_surface) {
// inert toplevel or popup // inert toplevel or popup
return; return;
case WLR_XDG_SURFACE_ROLE_TOPLEVEL: case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
handle_xdg_surface_toplevel_committed(surface); handle_xdg_toplevel_committed(surface->toplevel);
break; break;
case WLR_XDG_SURFACE_ROLE_POPUP: case WLR_XDG_SURFACE_ROLE_POPUP:
handle_xdg_surface_popup_committed(surface); handle_xdg_surface_popup_committed(surface);
@ -493,12 +495,6 @@ void wlr_xdg_surface_ping(struct wlr_xdg_surface *surface) {
surface->client->ping_serial); surface->client->ping_serial);
} }
void wlr_xdg_toplevel_send_close(struct wlr_xdg_surface *surface) {
assert(surface->toplevel);
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
xdg_toplevel_send_close(surface->toplevel->resource);
}
void wlr_xdg_popup_destroy(struct wlr_xdg_surface *surface) { void wlr_xdg_popup_destroy(struct wlr_xdg_surface *surface) {
if (surface == NULL) { if (surface == NULL) {
return; return;

View file

@ -8,38 +8,32 @@
#include "util/signal.h" #include "util/signal.h"
void handle_xdg_toplevel_ack_configure( void handle_xdg_toplevel_ack_configure(
struct wlr_xdg_surface *surface, struct wlr_xdg_toplevel *toplevel,
struct wlr_xdg_surface_configure *configure) { struct wlr_xdg_toplevel_configure *configure) {
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); toplevel->pending.maximized = configure->maximized;
toplevel->pending.fullscreen = configure->fullscreen;
toplevel->pending.resizing = configure->resizing;
toplevel->pending.activated = configure->activated;
toplevel->pending.tiled = configure->tiled;
struct wlr_xdg_toplevel_configure *acked = configure->toplevel_configure; toplevel->pending.width = configure->width;
assert(acked != NULL); toplevel->pending.height = configure->height;
surface->toplevel->pending.maximized = acked->maximized;
surface->toplevel->pending.fullscreen = acked->fullscreen;
surface->toplevel->pending.resizing = acked->resizing;
surface->toplevel->pending.activated = acked->activated;
surface->toplevel->pending.tiled = acked->tiled;
surface->toplevel->pending.width = acked->width;
surface->toplevel->pending.height = acked->height;
} }
void send_xdg_toplevel_configure(struct wlr_xdg_surface *surface, struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure(
struct wlr_xdg_surface_configure *configure) { struct wlr_xdg_toplevel *toplevel) {
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); struct wlr_xdg_toplevel_configure *configure =
calloc(1, sizeof(*configure));
configure->toplevel_configure = malloc(sizeof(*configure->toplevel_configure)); if (configure == NULL) {
if (configure->toplevel_configure == NULL) {
wlr_log(WLR_ERROR, "Allocation failed"); wlr_log(WLR_ERROR, "Allocation failed");
wl_resource_post_no_memory(surface->toplevel->resource); wl_resource_post_no_memory(toplevel->resource);
return; return NULL;
} }
*configure->toplevel_configure = surface->toplevel->scheduled; *configure = toplevel->scheduled;
struct wl_array states; struct wl_array states;
wl_array_init(&states); wl_array_init(&states);
if (surface->toplevel->scheduled.maximized) { if (configure->maximized) {
uint32_t *s = wl_array_add(&states, sizeof(uint32_t)); uint32_t *s = wl_array_add(&states, sizeof(uint32_t));
if (!s) { if (!s) {
wlr_log(WLR_ERROR, "Could not allocate state for maximized xdg_toplevel"); wlr_log(WLR_ERROR, "Could not allocate state for maximized xdg_toplevel");
@ -47,7 +41,7 @@ void send_xdg_toplevel_configure(struct wlr_xdg_surface *surface,
} }
*s = XDG_TOPLEVEL_STATE_MAXIMIZED; *s = XDG_TOPLEVEL_STATE_MAXIMIZED;
} }
if (surface->toplevel->scheduled.fullscreen) { if (configure->fullscreen) {
uint32_t *s = wl_array_add(&states, sizeof(uint32_t)); uint32_t *s = wl_array_add(&states, sizeof(uint32_t));
if (!s) { if (!s) {
wlr_log(WLR_ERROR, "Could not allocate state for fullscreen xdg_toplevel"); wlr_log(WLR_ERROR, "Could not allocate state for fullscreen xdg_toplevel");
@ -55,7 +49,7 @@ void send_xdg_toplevel_configure(struct wlr_xdg_surface *surface,
} }
*s = XDG_TOPLEVEL_STATE_FULLSCREEN; *s = XDG_TOPLEVEL_STATE_FULLSCREEN;
} }
if (surface->toplevel->scheduled.resizing) { if (configure->resizing) {
uint32_t *s = wl_array_add(&states, sizeof(uint32_t)); uint32_t *s = wl_array_add(&states, sizeof(uint32_t));
if (!s) { if (!s) {
wlr_log(WLR_ERROR, "Could not allocate state for resizing xdg_toplevel"); wlr_log(WLR_ERROR, "Could not allocate state for resizing xdg_toplevel");
@ -63,7 +57,7 @@ void send_xdg_toplevel_configure(struct wlr_xdg_surface *surface,
} }
*s = XDG_TOPLEVEL_STATE_RESIZING; *s = XDG_TOPLEVEL_STATE_RESIZING;
} }
if (surface->toplevel->scheduled.activated) { if (configure->activated) {
uint32_t *s = wl_array_add(&states, sizeof(uint32_t)); uint32_t *s = wl_array_add(&states, sizeof(uint32_t));
if (!s) { if (!s) {
wlr_log(WLR_ERROR, "Could not allocate state for activated xdg_toplevel"); wlr_log(WLR_ERROR, "Could not allocate state for activated xdg_toplevel");
@ -71,8 +65,8 @@ void send_xdg_toplevel_configure(struct wlr_xdg_surface *surface,
} }
*s = XDG_TOPLEVEL_STATE_ACTIVATED; *s = XDG_TOPLEVEL_STATE_ACTIVATED;
} }
if (surface->toplevel->scheduled.tiled) { if (configure->tiled) {
if (wl_resource_get_version(surface->resource) >= if (wl_resource_get_version(toplevel->resource) >=
XDG_TOPLEVEL_STATE_TILED_LEFT_SINCE_VERSION) { XDG_TOPLEVEL_STATE_TILED_LEFT_SINCE_VERSION) {
const struct { const struct {
enum wlr_edges edge; enum wlr_edges edge;
@ -85,8 +79,7 @@ void send_xdg_toplevel_configure(struct wlr_xdg_surface *surface,
}; };
for (size_t i = 0; i < sizeof(tiled)/sizeof(tiled[0]); ++i) { for (size_t i = 0; i < sizeof(tiled)/sizeof(tiled[0]); ++i) {
if ((surface->toplevel->scheduled.tiled & if ((configure->tiled & tiled[i].edge) == 0) {
tiled[i].edge) == 0) {
continue; continue;
} }
@ -98,7 +91,7 @@ void send_xdg_toplevel_configure(struct wlr_xdg_surface *surface,
} }
*s = tiled[i].state; *s = tiled[i].state;
} }
} else if (!surface->toplevel->scheduled.maximized) { } else if (!configure->maximized) {
// This version doesn't support tiling, best we can do is make the // This version doesn't support tiling, best we can do is make the
// toplevel maximized // toplevel maximized
uint32_t *s = wl_array_add(&states, sizeof(uint32_t)); uint32_t *s = wl_array_add(&states, sizeof(uint32_t));
@ -111,36 +104,35 @@ void send_xdg_toplevel_configure(struct wlr_xdg_surface *surface,
} }
} }
uint32_t width = surface->toplevel->scheduled.width; uint32_t width = configure->width;
uint32_t height = surface->toplevel->scheduled.height; uint32_t height = configure->height;
xdg_toplevel_send_configure(surface->toplevel->resource, width, height, xdg_toplevel_send_configure(toplevel->resource, width, height, &states);
&states);
wl_array_release(&states); wl_array_release(&states);
return; return configure;
error_out: error_out:
wl_array_release(&states); wl_array_release(&states);
wl_resource_post_no_memory(surface->toplevel->resource); free(configure);
wl_resource_post_no_memory(toplevel->resource);
return NULL;
} }
void handle_xdg_surface_toplevel_committed(struct wlr_xdg_surface *surface) { void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel) {
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); if (!toplevel->added) {
if (!surface->toplevel->added) {
// on the first commit, send a configure request to tell the client it // on the first commit, send a configure request to tell the client it
// is added // is added
wlr_xdg_surface_schedule_configure(surface); wlr_xdg_surface_schedule_configure(toplevel->base);
surface->toplevel->added = true; toplevel->added = true;
return; return;
} }
surface->toplevel->current = surface->toplevel->pending; toplevel->current = toplevel->pending;
} }
static const struct xdg_toplevel_interface xdg_toplevel_implementation; static const struct xdg_toplevel_interface xdg_toplevel_implementation;
struct wlr_xdg_surface *wlr_xdg_surface_from_toplevel_resource( struct wlr_xdg_toplevel *wlr_xdg_toplevel_from_resource(
struct wl_resource *resource) { struct wl_resource *resource) {
assert(wl_resource_instance_of(resource, &xdg_toplevel_interface, assert(wl_resource_instance_of(resource, &xdg_toplevel_interface,
&xdg_toplevel_implementation)); &xdg_toplevel_implementation));
@ -150,46 +142,45 @@ struct wlr_xdg_surface *wlr_xdg_surface_from_toplevel_resource(
static void handle_parent_unmap(struct wl_listener *listener, void *data) { static void handle_parent_unmap(struct wl_listener *listener, void *data) {
struct wlr_xdg_toplevel *toplevel = struct wlr_xdg_toplevel *toplevel =
wl_container_of(listener, toplevel, parent_unmap); wl_container_of(listener, toplevel, parent_unmap);
wlr_xdg_toplevel_set_parent(toplevel->base, wlr_xdg_toplevel_set_parent(toplevel,
toplevel->parent->toplevel->parent); toplevel->parent->toplevel->parent->toplevel);
} }
void wlr_xdg_toplevel_set_parent(struct wlr_xdg_surface *surface, void wlr_xdg_toplevel_set_parent(struct wlr_xdg_toplevel *toplevel,
struct wlr_xdg_surface *parent) { struct wlr_xdg_toplevel *parent) {
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); if (toplevel->parent) {
assert(!parent || parent->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); wl_list_remove(&toplevel->parent_unmap.link);
if (surface->toplevel->parent) {
wl_list_remove(&surface->toplevel->parent_unmap.link);
} }
surface->toplevel->parent = parent; if (parent) {
if (surface->toplevel->parent) { toplevel->parent = parent->base;
surface->toplevel->parent_unmap.notify = handle_parent_unmap; toplevel->parent_unmap.notify = handle_parent_unmap;
wl_signal_add(&surface->toplevel->parent->events.unmap, wl_signal_add(&toplevel->parent->events.unmap,
&surface->toplevel->parent_unmap); &toplevel->parent_unmap);
} else {
toplevel->parent = NULL;
} }
wlr_signal_emit_safe(&surface->toplevel->events.set_parent, surface); wlr_signal_emit_safe(&toplevel->events.set_parent, NULL);
} }
static void xdg_toplevel_handle_set_parent(struct wl_client *client, static void xdg_toplevel_handle_set_parent(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *parent_resource) { struct wl_resource *resource, struct wl_resource *parent_resource) {
struct wlr_xdg_surface *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
struct wlr_xdg_surface *parent = NULL; struct wlr_xdg_toplevel *parent = NULL;
if (parent_resource != NULL) { if (parent_resource != NULL) {
parent = wlr_xdg_surface_from_toplevel_resource(parent_resource); parent = wlr_xdg_toplevel_from_resource(parent_resource);
} }
wlr_xdg_toplevel_set_parent(surface, parent); wlr_xdg_toplevel_set_parent(toplevel, parent);
} }
static void xdg_toplevel_handle_set_title(struct wl_client *client, static void xdg_toplevel_handle_set_title(struct wl_client *client,
struct wl_resource *resource, const char *title) { struct wl_resource *resource, const char *title) {
struct wlr_xdg_surface *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
char *tmp; char *tmp;
tmp = strdup(title); tmp = strdup(title);
@ -197,15 +188,15 @@ static void xdg_toplevel_handle_set_title(struct wl_client *client,
return; return;
} }
free(surface->toplevel->title); free(toplevel->title);
surface->toplevel->title = tmp; toplevel->title = tmp;
wlr_signal_emit_safe(&surface->toplevel->events.set_title, surface); wlr_signal_emit_safe(&toplevel->events.set_title, NULL);
} }
static void xdg_toplevel_handle_set_app_id(struct wl_client *client, static void xdg_toplevel_handle_set_app_id(struct wl_client *client,
struct wl_resource *resource, const char *app_id) { struct wl_resource *resource, const char *app_id) {
struct wlr_xdg_surface *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
char *tmp; char *tmp;
tmp = strdup(app_id); tmp = strdup(app_id);
@ -213,21 +204,21 @@ static void xdg_toplevel_handle_set_app_id(struct wl_client *client,
return; return;
} }
free(surface->toplevel->app_id); free(toplevel->app_id);
surface->toplevel->app_id = tmp; toplevel->app_id = tmp;
wlr_signal_emit_safe(&surface->toplevel->events.set_app_id, surface); wlr_signal_emit_safe(&toplevel->events.set_app_id, NULL);
} }
static void xdg_toplevel_handle_show_window_menu(struct wl_client *client, static void xdg_toplevel_handle_show_window_menu(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *seat_resource, struct wl_resource *resource, struct wl_resource *seat_resource,
uint32_t serial, int32_t x, int32_t y) { uint32_t serial, int32_t x, int32_t y) {
struct wlr_xdg_surface *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
struct wlr_seat_client *seat = struct wlr_seat_client *seat =
wlr_seat_client_from_resource(seat_resource); wlr_seat_client_from_resource(seat_resource);
if (!surface->configured) { if (!toplevel->base->configured) {
wl_resource_post_error(surface->toplevel->resource, wl_resource_post_error(toplevel->base->resource,
XDG_SURFACE_ERROR_NOT_CONSTRUCTED, XDG_SURFACE_ERROR_NOT_CONSTRUCTED,
"surface has not been configured yet"); "surface has not been configured yet");
return; return;
@ -239,26 +230,26 @@ static void xdg_toplevel_handle_show_window_menu(struct wl_client *client,
} }
struct wlr_xdg_toplevel_show_window_menu_event event = { struct wlr_xdg_toplevel_show_window_menu_event event = {
.surface = surface, .surface = toplevel->base,
.seat = seat, .seat = seat,
.serial = serial, .serial = serial,
.x = x, .x = x,
.y = y, .y = y,
}; };
wlr_signal_emit_safe(&surface->toplevel->events.request_show_window_menu, &event); wlr_signal_emit_safe(&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,
struct wl_resource *resource, struct wl_resource *seat_resource, struct wl_resource *resource, struct wl_resource *seat_resource,
uint32_t serial) { uint32_t serial) {
struct wlr_xdg_surface *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
struct wlr_seat_client *seat = struct wlr_seat_client *seat =
wlr_seat_client_from_resource(seat_resource); wlr_seat_client_from_resource(seat_resource);
if (!surface->configured) { if (!toplevel->base->configured) {
wl_resource_post_error(surface->toplevel->resource, wl_resource_post_error(toplevel->base->resource,
XDG_SURFACE_ERROR_NOT_CONSTRUCTED, XDG_SURFACE_ERROR_NOT_CONSTRUCTED,
"surface has not been configured yet"); "surface has not been configured yet");
return; return;
@ -270,24 +261,24 @@ static void xdg_toplevel_handle_move(struct wl_client *client,
} }
struct wlr_xdg_toplevel_move_event event = { struct wlr_xdg_toplevel_move_event event = {
.surface = surface, .surface = toplevel->base,
.seat = seat, .seat = seat,
.serial = serial, .serial = serial,
}; };
wlr_signal_emit_safe(&surface->toplevel->events.request_move, &event); wlr_signal_emit_safe(&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,
struct wl_resource *resource, struct wl_resource *seat_resource, struct wl_resource *resource, struct wl_resource *seat_resource,
uint32_t serial, uint32_t edges) { uint32_t serial, uint32_t edges) {
struct wlr_xdg_surface *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
struct wlr_seat_client *seat = struct wlr_seat_client *seat =
wlr_seat_client_from_resource(seat_resource); wlr_seat_client_from_resource(seat_resource);
if (!surface->configured) { if (!toplevel->base->configured) {
wl_resource_post_error(surface->toplevel->resource, wl_resource_post_error(toplevel->base->resource,
XDG_SURFACE_ERROR_NOT_CONSTRUCTED, XDG_SURFACE_ERROR_NOT_CONSTRUCTED,
"surface has not been configured yet"); "surface has not been configured yet");
return; return;
@ -299,47 +290,47 @@ static void xdg_toplevel_handle_resize(struct wl_client *client,
} }
struct wlr_xdg_toplevel_resize_event event = { struct wlr_xdg_toplevel_resize_event event = {
.surface = surface, .surface = toplevel->base,
.seat = seat, .seat = seat,
.serial = serial, .serial = serial,
.edges = edges, .edges = edges,
}; };
wlr_signal_emit_safe(&surface->toplevel->events.request_resize, &event); wlr_signal_emit_safe(&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,
struct wl_resource *resource, int32_t width, int32_t height) { struct wl_resource *resource, int32_t width, int32_t height) {
struct wlr_xdg_surface *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
surface->toplevel->pending.max_width = width; toplevel->pending.max_width = width;
surface->toplevel->pending.max_height = height; toplevel->pending.max_height = height;
} }
static void xdg_toplevel_handle_set_min_size(struct wl_client *client, static void xdg_toplevel_handle_set_min_size(struct wl_client *client,
struct wl_resource *resource, int32_t width, int32_t height) { struct wl_resource *resource, int32_t width, int32_t height) {
struct wlr_xdg_surface *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
surface->toplevel->pending.min_width = width; toplevel->pending.min_width = width;
surface->toplevel->pending.min_height = height; toplevel->pending.min_height = height;
} }
static void xdg_toplevel_handle_set_maximized(struct wl_client *client, static void xdg_toplevel_handle_set_maximized(struct wl_client *client,
struct wl_resource *resource) { struct wl_resource *resource) {
struct wlr_xdg_surface *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
surface->toplevel->requested.maximized = true; toplevel->requested.maximized = true;
wlr_signal_emit_safe(&surface->toplevel->events.request_maximize, surface); wlr_signal_emit_safe(&toplevel->events.request_maximize, NULL);
wlr_xdg_surface_schedule_configure(surface); wlr_xdg_surface_schedule_configure(toplevel->base);
} }
static void xdg_toplevel_handle_unset_maximized(struct wl_client *client, static void xdg_toplevel_handle_unset_maximized(struct wl_client *client,
struct wl_resource *resource) { struct wl_resource *resource) {
struct wlr_xdg_surface *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
surface->toplevel->requested.maximized = false; toplevel->requested.maximized = false;
wlr_signal_emit_safe(&surface->toplevel->events.request_maximize, surface); wlr_signal_emit_safe(&toplevel->events.request_maximize, NULL);
wlr_xdg_surface_schedule_configure(surface); wlr_xdg_surface_schedule_configure(toplevel->base);
} }
static void handle_fullscreen_output_destroy(struct wl_listener *listener, static void handle_fullscreen_output_destroy(struct wl_listener *listener,
@ -350,9 +341,9 @@ static void handle_fullscreen_output_destroy(struct wl_listener *listener,
wl_list_remove(&req->fullscreen_output_destroy.link); wl_list_remove(&req->fullscreen_output_destroy.link);
} }
static void store_fullscreen_requested(struct wlr_xdg_surface *surface, static void store_fullscreen_requested(struct wlr_xdg_toplevel *toplevel,
bool fullscreen, struct wlr_output *output) { bool fullscreen, struct wlr_output *output) {
struct wlr_xdg_toplevel_requested *req = &surface->toplevel->requested; struct wlr_xdg_toplevel_requested *req = &toplevel->requested;
req->fullscreen = fullscreen; req->fullscreen = fullscreen;
if (req->fullscreen_output) { if (req->fullscreen_output) {
wl_list_remove(&req->fullscreen_output_destroy.link); wl_list_remove(&req->fullscreen_output_destroy.link);
@ -368,49 +359,49 @@ static void store_fullscreen_requested(struct wlr_xdg_surface *surface,
static void xdg_toplevel_handle_set_fullscreen(struct wl_client *client, static void xdg_toplevel_handle_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 *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
struct wlr_output *output = NULL; struct wlr_output *output = NULL;
if (output_resource != NULL) { if (output_resource != NULL) {
output = wlr_output_from_resource(output_resource); output = wlr_output_from_resource(output_resource);
} }
store_fullscreen_requested(surface, true, output); store_fullscreen_requested(toplevel, true, output);
struct wlr_xdg_toplevel_set_fullscreen_event event = { struct wlr_xdg_toplevel_set_fullscreen_event event = {
.surface = surface, .surface = toplevel->base,
.fullscreen = true, .fullscreen = true,
.output = output, .output = output,
}; };
wlr_signal_emit_safe(&surface->toplevel->events.request_fullscreen, &event); wlr_signal_emit_safe(&toplevel->events.request_fullscreen, &event);
wlr_xdg_surface_schedule_configure(surface); wlr_xdg_surface_schedule_configure(toplevel->base);
} }
static void xdg_toplevel_handle_unset_fullscreen(struct wl_client *client, static void xdg_toplevel_handle_unset_fullscreen(struct wl_client *client,
struct wl_resource *resource) { struct wl_resource *resource) {
struct wlr_xdg_surface *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
store_fullscreen_requested(surface, false, NULL); store_fullscreen_requested(toplevel, false, NULL);
struct wlr_xdg_toplevel_set_fullscreen_event event = { struct wlr_xdg_toplevel_set_fullscreen_event event = {
.surface = surface, .surface = toplevel->base,
.fullscreen = false, .fullscreen = false,
.output = NULL, .output = NULL,
}; };
wlr_signal_emit_safe(&surface->toplevel->events.request_fullscreen, &event); wlr_signal_emit_safe(&toplevel->events.request_fullscreen, &event);
wlr_xdg_surface_schedule_configure(surface); wlr_xdg_surface_schedule_configure(toplevel->base);
} }
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_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
surface->toplevel->requested.minimized = true; toplevel->requested.minimized = true;
wlr_signal_emit_safe(&surface->toplevel->events.request_minimize, surface); wlr_signal_emit_safe(&toplevel->events.request_minimize, NULL);
} }
static void xdg_toplevel_handle_destroy(struct wl_client *client, static void xdg_toplevel_handle_destroy(struct wl_client *client,
@ -436,9 +427,9 @@ static const struct xdg_toplevel_interface xdg_toplevel_implementation = {
}; };
static void xdg_toplevel_handle_resource_destroy(struct wl_resource *resource) { static void xdg_toplevel_handle_resource_destroy(struct wl_resource *resource) {
struct wlr_xdg_surface *surface = struct wlr_xdg_toplevel *toplevel =
wlr_xdg_surface_from_toplevel_resource(resource); wlr_xdg_toplevel_from_resource(resource);
destroy_xdg_toplevel(surface); destroy_xdg_toplevel(toplevel);
} }
const struct wlr_surface_role xdg_toplevel_surface_role = { const struct wlr_surface_role xdg_toplevel_surface_role = {
@ -488,65 +479,56 @@ void create_xdg_toplevel(struct wlr_xdg_surface *xdg_surface,
return; return;
} }
wl_resource_set_implementation(xdg_surface->toplevel->resource, wl_resource_set_implementation(xdg_surface->toplevel->resource,
&xdg_toplevel_implementation, xdg_surface, &xdg_toplevel_implementation, xdg_surface->toplevel,
xdg_toplevel_handle_resource_destroy); xdg_toplevel_handle_resource_destroy);
xdg_surface->role = WLR_XDG_SURFACE_ROLE_TOPLEVEL; xdg_surface->role = WLR_XDG_SURFACE_ROLE_TOPLEVEL;
} }
void destroy_xdg_toplevel(struct wlr_xdg_surface *xdg_surface) { void destroy_xdg_toplevel(struct wlr_xdg_toplevel *toplevel) {
if (xdg_surface == NULL) { if (toplevel == NULL) {
return; return;
} }
assert(xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); reset_xdg_surface(toplevel->base);
reset_xdg_surface(xdg_surface);
} }
uint32_t wlr_xdg_toplevel_set_size(struct wlr_xdg_surface *surface, void wlr_xdg_toplevel_send_close(struct wlr_xdg_toplevel *toplevel) {
xdg_toplevel_send_close(toplevel->resource);
}
uint32_t wlr_xdg_toplevel_set_size(struct wlr_xdg_toplevel *toplevel,
uint32_t width, uint32_t height) { uint32_t width, uint32_t height) {
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); toplevel->scheduled.width = width;
surface->toplevel->scheduled.width = width; toplevel->scheduled.height = height;
surface->toplevel->scheduled.height = height; return wlr_xdg_surface_schedule_configure(toplevel->base);
return wlr_xdg_surface_schedule_configure(surface);
} }
uint32_t wlr_xdg_toplevel_set_activated(struct wlr_xdg_surface *surface, uint32_t wlr_xdg_toplevel_set_activated(struct wlr_xdg_toplevel *toplevel,
bool activated) { bool activated) {
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); toplevel->scheduled.activated = activated;
surface->toplevel->scheduled.activated = activated; return wlr_xdg_surface_schedule_configure(toplevel->base);
return wlr_xdg_surface_schedule_configure(surface);
} }
uint32_t wlr_xdg_toplevel_set_maximized(struct wlr_xdg_surface *surface, uint32_t wlr_xdg_toplevel_set_maximized(struct wlr_xdg_toplevel *toplevel,
bool maximized) { bool maximized) {
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); toplevel->scheduled.maximized = maximized;
surface->toplevel->scheduled.maximized = maximized; return wlr_xdg_surface_schedule_configure(toplevel->base);
return wlr_xdg_surface_schedule_configure(surface);
} }
uint32_t wlr_xdg_toplevel_set_fullscreen(struct wlr_xdg_surface *surface, uint32_t wlr_xdg_toplevel_set_fullscreen(struct wlr_xdg_toplevel *toplevel,
bool fullscreen) { bool fullscreen) {
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); toplevel->scheduled.fullscreen = fullscreen;
surface->toplevel->scheduled.fullscreen = fullscreen; return wlr_xdg_surface_schedule_configure(toplevel->base);
return wlr_xdg_surface_schedule_configure(surface);
} }
uint32_t wlr_xdg_toplevel_set_resizing(struct wlr_xdg_surface *surface, uint32_t wlr_xdg_toplevel_set_resizing(struct wlr_xdg_toplevel *toplevel,
bool resizing) { bool resizing) {
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); toplevel->scheduled.resizing = resizing;
surface->toplevel->scheduled.resizing = resizing; return wlr_xdg_surface_schedule_configure(toplevel->base);
return wlr_xdg_surface_schedule_configure(surface);
} }
uint32_t wlr_xdg_toplevel_set_tiled(struct wlr_xdg_surface *surface, uint32_t wlr_xdg_toplevel_set_tiled(struct wlr_xdg_toplevel *toplevel,
uint32_t tiled) { uint32_t tiled) {
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); toplevel->scheduled.tiled = tiled;
surface->toplevel->scheduled.tiled = tiled; return wlr_xdg_surface_schedule_configure(toplevel->base);
return wlr_xdg_surface_schedule_configure(surface);
} }