xdg-shell: unify function arguments' names

`wlr_xdg_surface`s are now named "surface" everywhere, and
`wlr_surface`s are called "wlr_surface".
This commit is contained in:
Kirill Primak 2022-01-08 22:52:53 +03:00
parent 70d4a30be3
commit 27c8865a4d
4 changed files with 109 additions and 109 deletions

View file

@ -14,10 +14,10 @@ extern const struct wlr_surface_role xdg_toplevel_surface_role;
extern const struct wlr_surface_role xdg_popup_surface_role; 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 *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 unmap_xdg_surface(struct wlr_xdg_surface *surface);
void reset_xdg_surface(struct wlr_xdg_surface *xdg_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 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,
@ -27,14 +27,14 @@ void create_xdg_positioner(struct wlr_xdg_client *client, uint32_t id);
struct wlr_xdg_positioner_resource *get_xdg_positioner_from_resource( struct wlr_xdg_positioner_resource *get_xdg_positioner_from_resource(
struct wl_resource *resource); struct wl_resource *resource);
void create_xdg_popup(struct wlr_xdg_surface *xdg_surface, void create_xdg_popup(struct wlr_xdg_surface *surface,
struct wlr_xdg_surface *parent, struct wlr_xdg_surface *parent,
struct wlr_xdg_positioner_resource *positioner, uint32_t id); struct wlr_xdg_positioner_resource *positioner, uint32_t id);
void handle_xdg_popup_committed(struct wlr_xdg_popup *popup); void handle_xdg_popup_committed(struct wlr_xdg_popup *popup);
struct wlr_xdg_popup_grab *get_xdg_shell_popup_grab_from_seat( struct wlr_xdg_popup_grab *get_xdg_shell_popup_grab_from_seat(
struct wlr_xdg_shell *shell, struct wlr_seat *seat); struct wlr_xdg_shell *shell, struct wlr_seat *seat);
void create_xdg_toplevel(struct wlr_xdg_surface *xdg_surface, void create_xdg_toplevel(struct wlr_xdg_surface *surface,
uint32_t id); uint32_t id);
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(

View file

@ -295,63 +295,63 @@ const struct wlr_surface_role xdg_popup_surface_role = {
.precommit = xdg_surface_role_precommit, .precommit = xdg_surface_role_precommit,
}; };
void create_xdg_popup(struct wlr_xdg_surface *xdg_surface, void create_xdg_popup(struct wlr_xdg_surface *surface,
struct wlr_xdg_surface *parent, struct wlr_xdg_surface *parent,
struct wlr_xdg_positioner_resource *positioner, uint32_t id) { struct wlr_xdg_positioner_resource *positioner, uint32_t id) {
if (positioner->attrs.size.width == 0 || if (positioner->attrs.size.width == 0 ||
positioner->attrs.anchor_rect.width == 0) { positioner->attrs.anchor_rect.width == 0) {
wl_resource_post_error(xdg_surface->resource, wl_resource_post_error(surface->resource,
XDG_WM_BASE_ERROR_INVALID_POSITIONER, XDG_WM_BASE_ERROR_INVALID_POSITIONER,
"positioner object is not complete"); "positioner object is not complete");
return; return;
} }
if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_NONE) { if (surface->role != WLR_XDG_SURFACE_ROLE_NONE) {
wl_resource_post_error(xdg_surface->resource, wl_resource_post_error(surface->resource,
XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED, XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED,
"xdg-surface has already been constructed"); "xdg-surface has already been constructed");
return; return;
} }
if (!wlr_surface_set_role(xdg_surface->surface, &xdg_popup_surface_role, if (!wlr_surface_set_role(surface->surface, &xdg_popup_surface_role,
xdg_surface, xdg_surface->resource, XDG_WM_BASE_ERROR_ROLE)) { surface, surface->resource, XDG_WM_BASE_ERROR_ROLE)) {
return; return;
} }
assert(xdg_surface->popup == NULL); assert(surface->popup == NULL);
xdg_surface->popup = calloc(1, sizeof(struct wlr_xdg_popup)); surface->popup = calloc(1, sizeof(struct wlr_xdg_popup));
if (!xdg_surface->popup) { if (!surface->popup) {
wl_resource_post_no_memory(xdg_surface->resource); wl_resource_post_no_memory(surface->resource);
return; return;
} }
xdg_surface->popup->base = xdg_surface; surface->popup->base = surface;
xdg_surface->popup->resource = wl_resource_create( surface->popup->resource = wl_resource_create(
xdg_surface->client->client, &xdg_popup_interface, surface->client->client, &xdg_popup_interface,
wl_resource_get_version(xdg_surface->resource), id); wl_resource_get_version(surface->resource), id);
if (xdg_surface->popup->resource == NULL) { if (surface->popup->resource == NULL) {
free(xdg_surface->popup); free(surface->popup);
wl_resource_post_no_memory(xdg_surface->resource); wl_resource_post_no_memory(surface->resource);
return; return;
} }
wl_resource_set_implementation(xdg_surface->popup->resource, wl_resource_set_implementation(surface->popup->resource,
&xdg_popup_implementation, xdg_surface->popup, &xdg_popup_implementation, surface->popup,
xdg_popup_handle_resource_destroy); xdg_popup_handle_resource_destroy);
xdg_surface->role = WLR_XDG_SURFACE_ROLE_POPUP; surface->role = WLR_XDG_SURFACE_ROLE_POPUP;
// positioner properties // positioner properties
memcpy(&xdg_surface->popup->positioner, &positioner->attrs, memcpy(&surface->popup->positioner, &positioner->attrs,
sizeof(struct wlr_xdg_positioner)); sizeof(struct wlr_xdg_positioner));
xdg_surface->popup->geometry = surface->popup->geometry =
wlr_xdg_positioner_get_geometry(&positioner->attrs); wlr_xdg_positioner_get_geometry(&positioner->attrs);
if (parent) { if (parent) {
xdg_surface->popup->parent = parent->surface; surface->popup->parent = parent->surface;
wl_list_insert(&parent->popups, &xdg_surface->popup->link); wl_list_insert(&parent->popups, &surface->popup->link);
wlr_signal_emit_safe(&parent->events.new_popup, xdg_surface->popup); wlr_signal_emit_safe(&parent->events.new_popup, surface->popup);
} else { } else {
wl_list_init(&xdg_surface->popup->link); wl_list_init(&surface->popup->link);
} }
} }

View file

@ -364,102 +364,102 @@ static void xdg_surface_handle_surface_destroy(struct wl_listener *listener,
} }
struct wlr_xdg_surface *create_xdg_surface( struct wlr_xdg_surface *create_xdg_surface(
struct wlr_xdg_client *client, struct wlr_surface *surface, struct wlr_xdg_client *client, struct wlr_surface *wlr_surface,
uint32_t id) { uint32_t id) {
struct wlr_xdg_surface *xdg_surface = struct wlr_xdg_surface *surface =
calloc(1, sizeof(struct wlr_xdg_surface)); calloc(1, sizeof(struct wlr_xdg_surface));
if (xdg_surface == NULL) { if (surface == NULL) {
wl_client_post_no_memory(client->client); wl_client_post_no_memory(client->client);
return NULL; return NULL;
} }
xdg_surface->client = client; surface->client = client;
xdg_surface->role = WLR_XDG_SURFACE_ROLE_NONE; surface->role = WLR_XDG_SURFACE_ROLE_NONE;
xdg_surface->surface = surface; surface->surface = wlr_surface;
xdg_surface->resource = wl_resource_create(client->client, surface->resource = wl_resource_create(client->client,
&xdg_surface_interface, wl_resource_get_version(client->resource), &xdg_surface_interface, wl_resource_get_version(client->resource),
id); id);
if (xdg_surface->resource == NULL) { if (surface->resource == NULL) {
free(xdg_surface); free(surface);
wl_client_post_no_memory(client->client); wl_client_post_no_memory(client->client);
return NULL; return NULL;
} }
if (wlr_surface_has_buffer(xdg_surface->surface)) { if (wlr_surface_has_buffer(surface->surface)) {
wl_resource_destroy(xdg_surface->resource); wl_resource_destroy(surface->resource);
free(xdg_surface); free(surface);
wl_resource_post_error(client->resource, wl_resource_post_error(client->resource,
XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER, XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER,
"xdg_surface must not have a buffer at creation"); "xdg_surface must not have a buffer at creation");
return NULL; return NULL;
} }
wl_list_init(&xdg_surface->configure_list); wl_list_init(&surface->configure_list);
wl_list_init(&xdg_surface->popups); wl_list_init(&surface->popups);
wl_signal_init(&xdg_surface->events.destroy); wl_signal_init(&surface->events.destroy);
wl_signal_init(&xdg_surface->events.ping_timeout); wl_signal_init(&surface->events.ping_timeout);
wl_signal_init(&xdg_surface->events.new_popup); wl_signal_init(&surface->events.new_popup);
wl_signal_init(&xdg_surface->events.map); wl_signal_init(&surface->events.map);
wl_signal_init(&xdg_surface->events.unmap); wl_signal_init(&surface->events.unmap);
wl_signal_init(&xdg_surface->events.configure); wl_signal_init(&surface->events.configure);
wl_signal_init(&xdg_surface->events.ack_configure); wl_signal_init(&surface->events.ack_configure);
wl_signal_add(&xdg_surface->surface->events.destroy, wl_signal_add(&surface->surface->events.destroy,
&xdg_surface->surface_destroy); &surface->surface_destroy);
xdg_surface->surface_destroy.notify = xdg_surface_handle_surface_destroy; surface->surface_destroy.notify = xdg_surface_handle_surface_destroy;
wl_signal_add(&xdg_surface->surface->events.commit, wl_signal_add(&surface->surface->events.commit,
&xdg_surface->surface_commit); &surface->surface_commit);
xdg_surface->surface_commit.notify = xdg_surface_handle_surface_commit; surface->surface_commit.notify = xdg_surface_handle_surface_commit;
wlr_log(WLR_DEBUG, "new xdg_surface %p (res %p)", xdg_surface, wlr_log(WLR_DEBUG, "new xdg_surface %p (res %p)", surface,
xdg_surface->resource); surface->resource);
wl_resource_set_implementation(xdg_surface->resource, wl_resource_set_implementation(surface->resource,
&xdg_surface_implementation, xdg_surface, &xdg_surface_implementation, surface,
xdg_surface_handle_resource_destroy); xdg_surface_handle_resource_destroy);
wl_list_insert(&client->surfaces, &xdg_surface->link); wl_list_insert(&client->surfaces, &surface->link);
return xdg_surface; return surface;
} }
void reset_xdg_surface(struct wlr_xdg_surface *xdg_surface) { void reset_xdg_surface(struct wlr_xdg_surface *surface) {
if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_NONE) { if (surface->role != WLR_XDG_SURFACE_ROLE_NONE) {
unmap_xdg_surface(xdg_surface); unmap_xdg_surface(surface);
} }
if (xdg_surface->added) { if (surface->added) {
wlr_signal_emit_safe(&xdg_surface->events.destroy, xdg_surface); wlr_signal_emit_safe(&surface->events.destroy, surface);
xdg_surface->added = false; surface->added = false;
} }
switch (xdg_surface->role) { switch (surface->role) {
case WLR_XDG_SURFACE_ROLE_TOPLEVEL: case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
wl_resource_set_user_data(xdg_surface->toplevel->resource, NULL); wl_resource_set_user_data(surface->toplevel->resource, NULL);
xdg_surface->toplevel->resource = NULL; surface->toplevel->resource = NULL;
struct wlr_xdg_toplevel_requested *req = struct wlr_xdg_toplevel_requested *req =
&xdg_surface->toplevel->requested; &surface->toplevel->requested;
if (req->fullscreen_output) { if (req->fullscreen_output) {
wl_list_remove(&req->fullscreen_output_destroy.link); wl_list_remove(&req->fullscreen_output_destroy.link);
} }
free(xdg_surface->toplevel); free(surface->toplevel);
xdg_surface->toplevel = NULL; surface->toplevel = NULL;
break; break;
case WLR_XDG_SURFACE_ROLE_POPUP: case WLR_XDG_SURFACE_ROLE_POPUP:
wl_resource_set_user_data(xdg_surface->popup->resource, NULL); wl_resource_set_user_data(surface->popup->resource, NULL);
xdg_surface->popup->resource = NULL; surface->popup->resource = NULL;
wl_list_remove(&xdg_surface->popup->link); wl_list_remove(&surface->popup->link);
free(xdg_surface->popup); free(surface->popup);
xdg_surface->popup = NULL; surface->popup = NULL;
break; break;
case WLR_XDG_SURFACE_ROLE_NONE: case WLR_XDG_SURFACE_ROLE_NONE:
// This space is intentionally left blank // This space is intentionally left blank
break; break;
} }
xdg_surface->role = WLR_XDG_SURFACE_ROLE_NONE; surface->role = WLR_XDG_SURFACE_ROLE_NONE;
} }
void destroy_xdg_surface(struct wlr_xdg_surface *surface) { void destroy_xdg_surface(struct wlr_xdg_surface *surface) {

View file

@ -438,51 +438,51 @@ const struct wlr_surface_role xdg_toplevel_surface_role = {
.precommit = xdg_surface_role_precommit, .precommit = xdg_surface_role_precommit,
}; };
void create_xdg_toplevel(struct wlr_xdg_surface *xdg_surface, void create_xdg_toplevel(struct wlr_xdg_surface *surface,
uint32_t id) { uint32_t id) {
if (!wlr_surface_set_role(xdg_surface->surface, &xdg_toplevel_surface_role, if (!wlr_surface_set_role(surface->surface, &xdg_toplevel_surface_role,
xdg_surface, xdg_surface->resource, XDG_WM_BASE_ERROR_ROLE)) { surface, surface->resource, XDG_WM_BASE_ERROR_ROLE)) {
return; return;
} }
if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_NONE) { if (surface->role != WLR_XDG_SURFACE_ROLE_NONE) {
wl_resource_post_error(xdg_surface->resource, wl_resource_post_error(surface->resource,
XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED, XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED,
"xdg-surface has already been constructed"); "xdg-surface has already been constructed");
return; return;
} }
assert(xdg_surface->toplevel == NULL); assert(surface->toplevel == NULL);
xdg_surface->toplevel = calloc(1, sizeof(struct wlr_xdg_toplevel)); surface->toplevel = calloc(1, sizeof(struct wlr_xdg_toplevel));
if (xdg_surface->toplevel == NULL) { if (surface->toplevel == NULL) {
wl_resource_post_no_memory(xdg_surface->resource); wl_resource_post_no_memory(surface->resource);
return; return;
} }
xdg_surface->toplevel->base = xdg_surface; surface->toplevel->base = surface;
wl_signal_init(&xdg_surface->toplevel->events.request_maximize); wl_signal_init(&surface->toplevel->events.request_maximize);
wl_signal_init(&xdg_surface->toplevel->events.request_fullscreen); wl_signal_init(&surface->toplevel->events.request_fullscreen);
wl_signal_init(&xdg_surface->toplevel->events.request_minimize); wl_signal_init(&surface->toplevel->events.request_minimize);
wl_signal_init(&xdg_surface->toplevel->events.request_move); wl_signal_init(&surface->toplevel->events.request_move);
wl_signal_init(&xdg_surface->toplevel->events.request_resize); wl_signal_init(&surface->toplevel->events.request_resize);
wl_signal_init(&xdg_surface->toplevel->events.request_show_window_menu); wl_signal_init(&surface->toplevel->events.request_show_window_menu);
wl_signal_init(&xdg_surface->toplevel->events.set_parent); wl_signal_init(&surface->toplevel->events.set_parent);
wl_signal_init(&xdg_surface->toplevel->events.set_title); wl_signal_init(&surface->toplevel->events.set_title);
wl_signal_init(&xdg_surface->toplevel->events.set_app_id); wl_signal_init(&surface->toplevel->events.set_app_id);
xdg_surface->toplevel->resource = wl_resource_create( surface->toplevel->resource = wl_resource_create(
xdg_surface->client->client, &xdg_toplevel_interface, surface->client->client, &xdg_toplevel_interface,
wl_resource_get_version(xdg_surface->resource), id); wl_resource_get_version(surface->resource), id);
if (xdg_surface->toplevel->resource == NULL) { if (surface->toplevel->resource == NULL) {
free(xdg_surface->toplevel); free(surface->toplevel);
wl_resource_post_no_memory(xdg_surface->resource); wl_resource_post_no_memory(surface->resource);
return; return;
} }
wl_resource_set_implementation(xdg_surface->toplevel->resource, wl_resource_set_implementation(surface->toplevel->resource,
&xdg_toplevel_implementation, xdg_surface->toplevel, &xdg_toplevel_implementation, surface->toplevel,
xdg_toplevel_handle_resource_destroy); xdg_toplevel_handle_resource_destroy);
xdg_surface->role = WLR_XDG_SURFACE_ROLE_TOPLEVEL; surface->role = WLR_XDG_SURFACE_ROLE_TOPLEVEL;
} }
void destroy_xdg_toplevel(struct wlr_xdg_toplevel *toplevel) { void destroy_xdg_toplevel(struct wlr_xdg_toplevel *toplevel) {