Remove the unneeded surface argument from focus_toplevel, like tinywl does

This commit is contained in:
Keith Bowes 2024-12-08 23:02:21 -05:00
parent 80bc1d51cd
commit d7f4d1001f
5 changed files with 12 additions and 11 deletions

View file

@ -43,7 +43,7 @@ struct wb_toplevel {
};
void init_xdg_shell(struct wb_server *server);
void focus_toplevel(struct wb_toplevel *toplevel, struct wlr_surface *surface);
void focus_toplevel(struct wb_toplevel *toplevel);
struct wlr_output *get_active_output(struct wb_toplevel *toplevel);
struct wb_toplevel *get_toplevel_at(
struct wb_server *server, double lx, double ly,

View file

@ -149,7 +149,7 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
reset_cursor_mode(cursor->server);
} else {
/* Focus that client if the button was _pressed_ */
focus_toplevel(toplevel, surface);
focus_toplevel(toplevel);
}
wlr_idle_notifier_v1_notify_activity(cursor->server->idle_notifier, cursor->server->seat->seat);

View file

@ -175,7 +175,7 @@ static void handle_unmap(struct wl_listener *listener, void *data) {
struct wb_toplevel *toplevel = wl_container_of(surface->server->toplevels.next, toplevel, link);
if (toplevel && toplevel->scene_tree && toplevel->scene_tree->node.enabled) {
focus_toplevel(toplevel, toplevel->xdg_toplevel->base->surface);
focus_toplevel(toplevel);
}
}

View file

@ -30,7 +30,7 @@ static void cycle_toplevels(struct wb_server *server) {
struct wb_toplevel *current_toplevel = wl_container_of(
server->toplevels.prev, current_toplevel, link);
deiconify_toplevel(current_toplevel);
focus_toplevel(current_toplevel, current_toplevel->xdg_toplevel->base->surface);
focus_toplevel(current_toplevel);
/* Move the current toplevel to the beginning of the list */
wl_list_remove(&current_toplevel->link);
@ -48,7 +48,7 @@ static void cycle_toplevels_reverse(struct wb_server *server) {
struct wb_toplevel *next_toplevel = wl_container_of(
current_toplevel->link.next, next_toplevel, link);
deiconify_toplevel(next_toplevel);
focus_toplevel(next_toplevel, next_toplevel->xdg_toplevel->base->surface);
focus_toplevel(next_toplevel);
/* Move the current toplevel to after the previous toplevel in the list */
wl_list_remove(&current_toplevel->link);

View file

@ -29,12 +29,13 @@ struct wb_toplevel *get_toplevel_at(
return tree->node.data;
}
void focus_toplevel(struct wb_toplevel *toplevel, struct wlr_surface *surface) {
void focus_toplevel(struct wb_toplevel *toplevel) {
/* Note: this function only deals with keyboard focus. */
if (toplevel == NULL || toplevel->xdg_toplevel->base->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
return;
}
struct wlr_surface *surface = toplevel->xdg_toplevel->base->surface;
struct wlr_xdg_surface *xdg_surface = wlr_xdg_surface_try_from_wlr_surface(surface);
if (xdg_surface != NULL)
wlr_log(WLR_INFO, "%s: %s", _("Keyboard focus is now on surface"),
@ -74,7 +75,7 @@ void focus_toplevel(struct wb_toplevel *toplevel, struct wlr_surface *surface) {
* track of this and automatically send key events to the appropriate
* clients without additional work on your part.
*/
seat_focus_surface(server->seat, toplevel->xdg_toplevel->base->surface);
seat_focus_surface(server->seat, surface);
}
struct wlr_output *get_active_output(struct wb_toplevel *toplevel) {
@ -125,7 +126,7 @@ static void xdg_toplevel_map(struct wl_listener *listener, void *data) {
wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel,
toplevel->geometry.width, toplevel->geometry.height);
focus_toplevel(toplevel, toplevel->xdg_toplevel->base->surface);
focus_toplevel(toplevel);
wlr_scene_node_set_position(&toplevel->scene_tree->node,
toplevel->geometry.x, toplevel->geometry.y);
@ -144,7 +145,7 @@ static void xdg_toplevel_unmap(struct wl_listener *listener, void *data) {
if (next_toplevel && next_toplevel->xdg_toplevel && next_toplevel->scene_tree && next_toplevel->scene_tree->node.enabled) {
wlr_log(WLR_INFO, "%s: %s", _("Focusing next toplevel"),
next_toplevel->xdg_toplevel->app_id);
focus_toplevel(next_toplevel, next_toplevel->xdg_toplevel->base->surface);
focus_toplevel(next_toplevel);
}
}
}
@ -292,9 +293,9 @@ static void xdg_toplevel_request_minimize(struct wl_listener *listener, void *da
struct wb_toplevel *next_toplevel = wl_container_of(toplevel->link.next, next_toplevel, link);
if (wl_list_length(&toplevel->link) > 1)
focus_toplevel(next_toplevel, next_toplevel->xdg_toplevel->base->surface);
focus_toplevel(next_toplevel);
else
focus_toplevel(toplevel, toplevel->xdg_toplevel->base->surface);
focus_toplevel(toplevel);
} else {
toplevel->geometry = toplevel->previous_geometry;
}