mirror of
https://github.com/swaywm/sway.git
synced 2025-11-25 06:59:48 -05:00
Minor refactor of input manager
The input manager is a singleton object. Passing the sway_input_manager argument to each of its functions is unnecessary, while removing the argument makes it obvious to the caller that it's a singleton. This patch removes the argument and makes the input manager use server.input instead. On a similar note: * sway_input_manager.server is removed in favour of using the server global. * seat.input is removed because it can get it from server.input. Due to a circular dependency, creating seat0 is now done directly in server_init rather than in input_manager_create. This is because creating seats must be done after server.input is set. Lastly, it now stores the default seat name using a constant and removes a second reference to seat0 (in input_manager_get_default_seat).
This commit is contained in:
parent
5b8257b88f
commit
c006717910
28 changed files with 116 additions and 149 deletions
|
|
@ -211,7 +211,7 @@ void arrange_layers(struct sway_output *output) {
|
|||
}
|
||||
|
||||
struct sway_seat *seat;
|
||||
wl_list_for_each(seat, &input_manager->seats, link) {
|
||||
wl_list_for_each(seat, &server.input->seats, link) {
|
||||
seat_set_focus_layer(seat, topmost ? topmost->layer_surface : NULL);
|
||||
}
|
||||
}
|
||||
|
|
@ -241,7 +241,7 @@ static void handle_output_destroy(struct wl_listener *listener, void *data) {
|
|||
wl_container_of(listener, sway_layer, output_destroy);
|
||||
// Determine if this layer is being used by an exclusive client. If it is,
|
||||
// try and find another layer owned by this client to pass focus to.
|
||||
struct sway_seat *seat = input_manager_get_default_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_get_default_seat();
|
||||
struct wl_client *client =
|
||||
wl_resource_get_client(sway_layer->layer_surface->resource);
|
||||
bool set_focus = seat->exclusive_client == client;
|
||||
|
|
@ -299,7 +299,7 @@ static void unmap(struct sway_layer_surface *sway_layer) {
|
|||
output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y,
|
||||
sway_layer->layer_surface->surface, true);
|
||||
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
if (seat->focused_layer == sway_layer->layer_surface) {
|
||||
seat_set_focus_layer(seat, NULL);
|
||||
}
|
||||
|
|
@ -370,7 +370,7 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
|
|||
if (!layer_surface->output) {
|
||||
// Assign last active output
|
||||
struct sway_output *output = NULL;
|
||||
struct sway_seat *seat = input_manager_get_default_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_get_default_seat();
|
||||
if (seat) {
|
||||
struct sway_workspace *ws = seat_get_focused_workspace(seat);
|
||||
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ static void scale_box(struct wlr_box *box, float scale) {
|
|||
}
|
||||
|
||||
struct sway_workspace *output_get_active_workspace(struct sway_output *output) {
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
struct sway_node *focus = seat_get_active_tiling_child(seat, &output->node);
|
||||
if (!focus) {
|
||||
return output->workspaces->items[0];
|
||||
|
|
|
|||
|
|
@ -885,7 +885,7 @@ static void render_floating(struct sway_output *soutput,
|
|||
static void render_dropzones(struct sway_output *output,
|
||||
pixman_region32_t *damage) {
|
||||
struct sway_seat *seat;
|
||||
wl_list_for_each(seat, &input_manager->seats, link) {
|
||||
wl_list_for_each(seat, &server.input->seats, link) {
|
||||
if (seat->operation == OP_MOVE_TILING && seat->op_target_node
|
||||
&& node_get_output(seat->op_target_node) == output) {
|
||||
float color[4];
|
||||
|
|
@ -995,7 +995,7 @@ void output_render(struct sway_output *output, struct timespec *when,
|
|||
|
||||
render_dropzones(output, damage);
|
||||
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
struct sway_container *focus = seat_get_focused_container(seat);
|
||||
if (focus && focus->view) {
|
||||
render_view_popups(focus->view, output, damage, focus->alpha);
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ static void copy_workspace_state(struct sway_workspace *ws,
|
|||
list_cat(state->floating, ws->floating);
|
||||
list_cat(state->tiling, ws->tiling);
|
||||
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
state->focused = seat_get_focus(seat) == &ws->node;
|
||||
|
||||
// Set focused_inactive_child to the direct tiling child
|
||||
|
|
@ -153,7 +153,7 @@ static void copy_container_state(struct sway_container *container,
|
|||
list_cat(state->children, container->children);
|
||||
}
|
||||
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
state->focused = seat_get_focus(seat) == &container->node;
|
||||
|
||||
if (!container->view) {
|
||||
|
|
|
|||
|
|
@ -70,9 +70,8 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) {
|
|||
desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true);
|
||||
|
||||
if (wlr_xwayland_or_surface_wants_focus(xsurface)) {
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct wlr_xwayland *xwayland =
|
||||
seat->input->server->xwayland.wlr_xwayland;
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland;
|
||||
wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
|
||||
seat_set_focus_surface(seat, xsurface->surface, false);
|
||||
}
|
||||
|
|
@ -86,7 +85,7 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
|
|||
wl_list_remove(&surface->link);
|
||||
wl_list_remove(&surface->commit.link);
|
||||
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
if (seat->wlr_seat->keyboard_state.focused_surface ==
|
||||
xsurface->surface) {
|
||||
// Restore focus
|
||||
|
|
@ -457,7 +456,7 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
|
|||
if (!container_is_floating(view->container)) {
|
||||
return;
|
||||
}
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
seat_begin_move_floating(seat, view->container, seat->last_button);
|
||||
}
|
||||
|
||||
|
|
@ -473,7 +472,7 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
|
|||
return;
|
||||
}
|
||||
struct wlr_xwayland_resize_event *e = data;
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
seat_begin_resize_floating(seat, view->container,
|
||||
seat->last_button, e->edges);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue