From 27c8865a4d92c785a8298022a21cf989206e4436 Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Sat, 8 Jan 2022 22:52:53 +0300 Subject: [PATCH] xdg-shell: unify function arguments' names `wlr_xdg_surface`s are now named "surface" everywhere, and `wlr_surface`s are called "wlr_surface". --- include/types/wlr_xdg_shell.h | 8 +-- types/xdg_shell/wlr_xdg_popup.c | 52 +++++++-------- types/xdg_shell/wlr_xdg_surface.c | 102 ++++++++++++++--------------- types/xdg_shell/wlr_xdg_toplevel.c | 56 ++++++++-------- 4 files changed, 109 insertions(+), 109 deletions(-) diff --git a/include/types/wlr_xdg_shell.h b/include/types/wlr_xdg_shell.h index f4e1ebe3..7613a15d 100644 --- a/include/types/wlr_xdg_shell.h +++ b/include/types/wlr_xdg_shell.h @@ -14,10 +14,10 @@ extern const struct wlr_surface_role xdg_toplevel_surface_role; extern const struct wlr_surface_role xdg_popup_surface_role; 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); 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 xdg_surface_role_commit(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 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_positioner_resource *positioner, uint32_t id); 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_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); void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel); struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure( diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c index 53e930bc..7066893a 100644 --- a/types/xdg_shell/wlr_xdg_popup.c +++ b/types/xdg_shell/wlr_xdg_popup.c @@ -295,63 +295,63 @@ const struct wlr_surface_role xdg_popup_surface_role = { .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_positioner_resource *positioner, uint32_t id) { if (positioner->attrs.size.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, "positioner object is not complete"); return; } - if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_NONE) { - wl_resource_post_error(xdg_surface->resource, + if (surface->role != WLR_XDG_SURFACE_ROLE_NONE) { + wl_resource_post_error(surface->resource, XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED, "xdg-surface has already been constructed"); return; } - if (!wlr_surface_set_role(xdg_surface->surface, &xdg_popup_surface_role, - xdg_surface, xdg_surface->resource, XDG_WM_BASE_ERROR_ROLE)) { + if (!wlr_surface_set_role(surface->surface, &xdg_popup_surface_role, + surface, surface->resource, XDG_WM_BASE_ERROR_ROLE)) { return; } - assert(xdg_surface->popup == NULL); - xdg_surface->popup = calloc(1, sizeof(struct wlr_xdg_popup)); - if (!xdg_surface->popup) { - wl_resource_post_no_memory(xdg_surface->resource); + assert(surface->popup == NULL); + surface->popup = calloc(1, sizeof(struct wlr_xdg_popup)); + if (!surface->popup) { + wl_resource_post_no_memory(surface->resource); return; } - xdg_surface->popup->base = xdg_surface; + surface->popup->base = surface; - xdg_surface->popup->resource = wl_resource_create( - xdg_surface->client->client, &xdg_popup_interface, - wl_resource_get_version(xdg_surface->resource), id); - if (xdg_surface->popup->resource == NULL) { - free(xdg_surface->popup); - wl_resource_post_no_memory(xdg_surface->resource); + surface->popup->resource = wl_resource_create( + surface->client->client, &xdg_popup_interface, + wl_resource_get_version(surface->resource), id); + if (surface->popup->resource == NULL) { + free(surface->popup); + wl_resource_post_no_memory(surface->resource); return; } - wl_resource_set_implementation(xdg_surface->popup->resource, - &xdg_popup_implementation, xdg_surface->popup, + wl_resource_set_implementation(surface->popup->resource, + &xdg_popup_implementation, surface->popup, xdg_popup_handle_resource_destroy); - xdg_surface->role = WLR_XDG_SURFACE_ROLE_POPUP; + surface->role = WLR_XDG_SURFACE_ROLE_POPUP; // positioner properties - memcpy(&xdg_surface->popup->positioner, &positioner->attrs, + memcpy(&surface->popup->positioner, &positioner->attrs, sizeof(struct wlr_xdg_positioner)); - xdg_surface->popup->geometry = + surface->popup->geometry = wlr_xdg_positioner_get_geometry(&positioner->attrs); if (parent) { - xdg_surface->popup->parent = parent->surface; - wl_list_insert(&parent->popups, &xdg_surface->popup->link); - wlr_signal_emit_safe(&parent->events.new_popup, xdg_surface->popup); + surface->popup->parent = parent->surface; + wl_list_insert(&parent->popups, &surface->popup->link); + wlr_signal_emit_safe(&parent->events.new_popup, surface->popup); } else { - wl_list_init(&xdg_surface->popup->link); + wl_list_init(&surface->popup->link); } } diff --git a/types/xdg_shell/wlr_xdg_surface.c b/types/xdg_shell/wlr_xdg_surface.c index 081474df..7db308c0 100644 --- a/types/xdg_shell/wlr_xdg_surface.c +++ b/types/xdg_shell/wlr_xdg_surface.c @@ -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_client *client, struct wlr_surface *surface, + struct wlr_xdg_client *client, struct wlr_surface *wlr_surface, uint32_t id) { - struct wlr_xdg_surface *xdg_surface = + struct wlr_xdg_surface *surface = calloc(1, sizeof(struct wlr_xdg_surface)); - if (xdg_surface == NULL) { + if (surface == NULL) { wl_client_post_no_memory(client->client); return NULL; } - xdg_surface->client = client; - xdg_surface->role = WLR_XDG_SURFACE_ROLE_NONE; - xdg_surface->surface = surface; - xdg_surface->resource = wl_resource_create(client->client, + surface->client = client; + surface->role = WLR_XDG_SURFACE_ROLE_NONE; + surface->surface = wlr_surface; + surface->resource = wl_resource_create(client->client, &xdg_surface_interface, wl_resource_get_version(client->resource), id); - if (xdg_surface->resource == NULL) { - free(xdg_surface); + if (surface->resource == NULL) { + free(surface); wl_client_post_no_memory(client->client); return NULL; } - if (wlr_surface_has_buffer(xdg_surface->surface)) { - wl_resource_destroy(xdg_surface->resource); - free(xdg_surface); + if (wlr_surface_has_buffer(surface->surface)) { + wl_resource_destroy(surface->resource); + free(surface); wl_resource_post_error(client->resource, XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER, "xdg_surface must not have a buffer at creation"); return NULL; } - wl_list_init(&xdg_surface->configure_list); - wl_list_init(&xdg_surface->popups); + wl_list_init(&surface->configure_list); + wl_list_init(&surface->popups); - wl_signal_init(&xdg_surface->events.destroy); - wl_signal_init(&xdg_surface->events.ping_timeout); - wl_signal_init(&xdg_surface->events.new_popup); - wl_signal_init(&xdg_surface->events.map); - wl_signal_init(&xdg_surface->events.unmap); - wl_signal_init(&xdg_surface->events.configure); - wl_signal_init(&xdg_surface->events.ack_configure); + wl_signal_init(&surface->events.destroy); + wl_signal_init(&surface->events.ping_timeout); + wl_signal_init(&surface->events.new_popup); + wl_signal_init(&surface->events.map); + wl_signal_init(&surface->events.unmap); + wl_signal_init(&surface->events.configure); + wl_signal_init(&surface->events.ack_configure); - wl_signal_add(&xdg_surface->surface->events.destroy, - &xdg_surface->surface_destroy); - xdg_surface->surface_destroy.notify = xdg_surface_handle_surface_destroy; + wl_signal_add(&surface->surface->events.destroy, + &surface->surface_destroy); + surface->surface_destroy.notify = xdg_surface_handle_surface_destroy; - wl_signal_add(&xdg_surface->surface->events.commit, - &xdg_surface->surface_commit); - xdg_surface->surface_commit.notify = xdg_surface_handle_surface_commit; + wl_signal_add(&surface->surface->events.commit, + &surface->surface_commit); + surface->surface_commit.notify = xdg_surface_handle_surface_commit; - wlr_log(WLR_DEBUG, "new xdg_surface %p (res %p)", xdg_surface, - xdg_surface->resource); - wl_resource_set_implementation(xdg_surface->resource, - &xdg_surface_implementation, xdg_surface, + wlr_log(WLR_DEBUG, "new xdg_surface %p (res %p)", surface, + surface->resource); + wl_resource_set_implementation(surface->resource, + &xdg_surface_implementation, surface, 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) { - if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_NONE) { - unmap_xdg_surface(xdg_surface); +void reset_xdg_surface(struct wlr_xdg_surface *surface) { + if (surface->role != WLR_XDG_SURFACE_ROLE_NONE) { + unmap_xdg_surface(surface); } - if (xdg_surface->added) { - wlr_signal_emit_safe(&xdg_surface->events.destroy, xdg_surface); - xdg_surface->added = false; + if (surface->added) { + wlr_signal_emit_safe(&surface->events.destroy, surface); + surface->added = false; } - switch (xdg_surface->role) { + switch (surface->role) { case WLR_XDG_SURFACE_ROLE_TOPLEVEL: - wl_resource_set_user_data(xdg_surface->toplevel->resource, NULL); - xdg_surface->toplevel->resource = NULL; + wl_resource_set_user_data(surface->toplevel->resource, NULL); + surface->toplevel->resource = NULL; struct wlr_xdg_toplevel_requested *req = - &xdg_surface->toplevel->requested; + &surface->toplevel->requested; if (req->fullscreen_output) { wl_list_remove(&req->fullscreen_output_destroy.link); } - free(xdg_surface->toplevel); - xdg_surface->toplevel = NULL; + free(surface->toplevel); + surface->toplevel = NULL; break; case WLR_XDG_SURFACE_ROLE_POPUP: - wl_resource_set_user_data(xdg_surface->popup->resource, NULL); - xdg_surface->popup->resource = NULL; + wl_resource_set_user_data(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); - xdg_surface->popup = NULL; + free(surface->popup); + surface->popup = NULL; break; case WLR_XDG_SURFACE_ROLE_NONE: // This space is intentionally left blank 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) { diff --git a/types/xdg_shell/wlr_xdg_toplevel.c b/types/xdg_shell/wlr_xdg_toplevel.c index d88e6659..376ab49c 100644 --- a/types/xdg_shell/wlr_xdg_toplevel.c +++ b/types/xdg_shell/wlr_xdg_toplevel.c @@ -438,51 +438,51 @@ const struct wlr_surface_role xdg_toplevel_surface_role = { .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) { - if (!wlr_surface_set_role(xdg_surface->surface, &xdg_toplevel_surface_role, - xdg_surface, xdg_surface->resource, XDG_WM_BASE_ERROR_ROLE)) { + if (!wlr_surface_set_role(surface->surface, &xdg_toplevel_surface_role, + surface, surface->resource, XDG_WM_BASE_ERROR_ROLE)) { return; } - if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_NONE) { - wl_resource_post_error(xdg_surface->resource, + if (surface->role != WLR_XDG_SURFACE_ROLE_NONE) { + wl_resource_post_error(surface->resource, XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED, "xdg-surface has already been constructed"); return; } - assert(xdg_surface->toplevel == NULL); - xdg_surface->toplevel = calloc(1, sizeof(struct wlr_xdg_toplevel)); - if (xdg_surface->toplevel == NULL) { - wl_resource_post_no_memory(xdg_surface->resource); + assert(surface->toplevel == NULL); + surface->toplevel = calloc(1, sizeof(struct wlr_xdg_toplevel)); + if (surface->toplevel == NULL) { + wl_resource_post_no_memory(surface->resource); return; } - xdg_surface->toplevel->base = xdg_surface; + surface->toplevel->base = surface; - wl_signal_init(&xdg_surface->toplevel->events.request_maximize); - wl_signal_init(&xdg_surface->toplevel->events.request_fullscreen); - wl_signal_init(&xdg_surface->toplevel->events.request_minimize); - wl_signal_init(&xdg_surface->toplevel->events.request_move); - wl_signal_init(&xdg_surface->toplevel->events.request_resize); - wl_signal_init(&xdg_surface->toplevel->events.request_show_window_menu); - wl_signal_init(&xdg_surface->toplevel->events.set_parent); - wl_signal_init(&xdg_surface->toplevel->events.set_title); - wl_signal_init(&xdg_surface->toplevel->events.set_app_id); + 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); + wl_signal_init(&surface->toplevel->events.set_parent); + wl_signal_init(&surface->toplevel->events.set_title); + wl_signal_init(&surface->toplevel->events.set_app_id); - xdg_surface->toplevel->resource = wl_resource_create( - xdg_surface->client->client, &xdg_toplevel_interface, - wl_resource_get_version(xdg_surface->resource), id); - if (xdg_surface->toplevel->resource == NULL) { - free(xdg_surface->toplevel); - wl_resource_post_no_memory(xdg_surface->resource); + surface->toplevel->resource = wl_resource_create( + surface->client->client, &xdg_toplevel_interface, + wl_resource_get_version(surface->resource), id); + if (surface->toplevel->resource == NULL) { + free(surface->toplevel); + wl_resource_post_no_memory(surface->resource); return; } - wl_resource_set_implementation(xdg_surface->toplevel->resource, - &xdg_toplevel_implementation, xdg_surface->toplevel, + wl_resource_set_implementation(surface->toplevel->resource, + &xdg_toplevel_implementation, surface->toplevel, 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) {