mirror of
https://github.com/swaywm/sway.git
synced 2025-11-05 13:29:51 -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
|
|
@ -200,7 +200,7 @@ static struct sway_container *container_at_tabbed(struct sway_node *parent,
|
|||
if (ly < box.y || ly > box.y + box.height) {
|
||||
return NULL;
|
||||
}
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
list_t *children = node_get_children(parent);
|
||||
if (!children->length) {
|
||||
return NULL;
|
||||
|
|
@ -234,7 +234,7 @@ static struct sway_container *container_at_stacked(struct sway_node *parent,
|
|||
if (ly < box.y || ly > box.y + box.height) {
|
||||
return NULL;
|
||||
}
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
list_t *children = node_get_children(parent);
|
||||
|
||||
// Title bars
|
||||
|
|
@ -358,7 +358,7 @@ struct sway_container *container_at(struct sway_workspace *workspace,
|
|||
struct wlr_surface **surface, double *sx, double *sy) {
|
||||
struct sway_container *c;
|
||||
|
||||
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);
|
||||
bool is_floating = focus && container_is_floating_or_child(focus);
|
||||
// Focused view's popups
|
||||
|
|
@ -651,7 +651,7 @@ void container_set_floating(struct sway_container *container, bool enable) {
|
|||
return;
|
||||
}
|
||||
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
struct sway_workspace *workspace = container->workspace;
|
||||
|
||||
if (enable) {
|
||||
|
|
@ -843,7 +843,7 @@ bool container_has_urgent_child(struct sway_container *container) {
|
|||
|
||||
void container_end_mouse_operation(struct sway_container *container) {
|
||||
struct sway_seat *seat;
|
||||
wl_list_for_each(seat, &input_manager->seats, link) {
|
||||
wl_list_for_each(seat, &server.input->seats, link) {
|
||||
if (seat->op_container == container) {
|
||||
seat->op_target_node = NULL; // ensure tiling move doesn't apply
|
||||
seat_end_mouse_operation(seat);
|
||||
|
|
@ -890,7 +890,7 @@ void container_set_fullscreen(struct sway_container *container, bool enable) {
|
|||
|
||||
struct sway_seat *seat;
|
||||
struct sway_workspace *focus_ws;
|
||||
wl_list_for_each(seat, &input_manager->seats, link) {
|
||||
wl_list_for_each(seat, &server.input->seats, link) {
|
||||
focus_ws = seat_get_focused_workspace(seat);
|
||||
if (focus_ws) {
|
||||
if (focus_ws == workspace) {
|
||||
|
|
@ -1033,7 +1033,7 @@ void container_add_gaps(struct sway_container *c) {
|
|||
struct sway_view *view = c->view;
|
||||
if (!view) {
|
||||
struct sway_seat *seat =
|
||||
input_manager_get_default_seat(input_manager);
|
||||
input_manager_get_default_seat();
|
||||
struct sway_container *focus =
|
||||
seat_get_focus_inactive_view(seat, &c->node);
|
||||
view = focus ? focus->view : NULL;
|
||||
|
|
@ -1187,7 +1187,7 @@ void container_replace(struct sway_container *container,
|
|||
|
||||
struct sway_container *container_split(struct sway_container *child,
|
||||
enum sway_container_layout layout) {
|
||||
struct sway_seat *seat = input_manager_get_default_seat(input_manager);
|
||||
struct sway_seat *seat = input_manager_get_default_seat();
|
||||
bool set_focus = (seat_get_focus(seat) == &child->node);
|
||||
|
||||
struct sway_container *cont = container_create(NULL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue