diff options
-rw-r--r-- | include/sway/input/seat.h | 4 | ||||
-rw-r--r-- | sway/commands.c | 4 | ||||
-rw-r--r-- | sway/commands/workspace.c | 2 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 2 | ||||
-rw-r--r-- | sway/input/input-manager.c | 2 | ||||
-rw-r--r-- | sway/input/seat.c | 32 | ||||
-rw-r--r-- | sway/tree/workspace.c | 8 |
7 files changed, 30 insertions, 24 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 8d5d6b75..26a7e5dc 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -56,7 +56,9 @@ void sway_seat_configure_xcursor(struct sway_seat *seat); | |||
56 | 56 | ||
57 | void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container); | 57 | void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container); |
58 | 58 | ||
59 | swayc_t *sway_seat_get_focus(struct sway_seat *seat, swayc_t *container); | 59 | swayc_t *sway_seat_get_focus(struct sway_seat *seat); |
60 | |||
61 | swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container); | ||
60 | 62 | ||
61 | void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config); | 63 | void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config); |
62 | 64 | ||
diff --git a/sway/commands.c b/sway/commands.c index 6bb4db0b..d8d29a1c 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -282,9 +282,7 @@ struct cmd_results *handle_command(char *_exec) { | |||
282 | } | 282 | } |
283 | if (seat) { | 283 | if (seat) { |
284 | config->handler_context.current_container = | 284 | config->handler_context.current_container = |
285 | (seat->has_focus ? | 285 | sway_seat_get_focus(seat); |
286 | sway_seat_get_focus(seat, &root_container) : | ||
287 | NULL); | ||
288 | struct cmd_results *res = handler->handle(argc-1, argv+1); | 286 | struct cmd_results *res = handler->handle(argc-1, argv+1); |
289 | if (res->status != CMD_SUCCESS) { | 287 | if (res->status != CMD_SUCCESS) { |
290 | free_argv(argc, argv); | 288 | free_argv(argc, argv); |
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index e7d6cc9f..fa891398 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c | |||
@@ -91,7 +91,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
91 | } | 91 | } |
92 | workspace_switch(ws); | 92 | workspace_switch(ws); |
93 | current_container = | 93 | current_container = |
94 | sway_seat_get_focus(config->handler_context.seat, &root_container); | 94 | sway_seat_get_focus(config->handler_context.seat); |
95 | swayc_t *new_output = swayc_parent_by_type(current_container, C_OUTPUT); | 95 | swayc_t *new_output = swayc_parent_by_type(current_container, C_OUTPUT); |
96 | 96 | ||
97 | if (config->mouse_warping && old_output != new_output) { | 97 | if (config->mouse_warping && old_output != new_output) { |
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 04d89015..b44d9e54 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -135,7 +135,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { | |||
135 | wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy); | 135 | wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy); |
136 | 136 | ||
137 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 137 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
138 | swayc_t *focus = sway_seat_get_focus(seat, &root_container); | 138 | swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container); |
139 | swayc_t *cont = new_view(focus, sway_view); | 139 | swayc_t *cont = new_view(focus, sway_view); |
140 | sway_view->swayc = cont; | 140 | sway_view->swayc = cont; |
141 | 141 | ||
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index a406636e..90eb8cf6 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -282,7 +282,7 @@ bool sway_input_manager_has_focus(struct sway_input_manager *input, | |||
282 | swayc_t *container) { | 282 | swayc_t *container) { |
283 | struct sway_seat *seat = NULL; | 283 | struct sway_seat *seat = NULL; |
284 | wl_list_for_each(seat, &input->seats, link) { | 284 | wl_list_for_each(seat, &input->seats, link) { |
285 | if (seat->has_focus && sway_seat_get_focus(seat, &root_container) == container) { | 285 | if (sway_seat_get_focus(seat) == container) { |
286 | return true; | 286 | return true; |
287 | } | 287 | } |
288 | } | 288 | } |
diff --git a/sway/input/seat.c b/sway/input/seat.c index cbf05abd..d2ffca64 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -137,16 +137,14 @@ static void seat_configure_keyboard(struct sway_seat *seat, | |||
137 | struct wlr_keyboard *wlr_keyboard = seat_device->input_device->wlr_device->keyboard; | 137 | struct wlr_keyboard *wlr_keyboard = seat_device->input_device->wlr_device->keyboard; |
138 | sway_keyboard_configure(seat_device->keyboard); | 138 | sway_keyboard_configure(seat_device->keyboard); |
139 | wlr_seat_set_keyboard(seat->wlr_seat, | 139 | wlr_seat_set_keyboard(seat->wlr_seat, |
140 | seat_device->input_device->wlr_device); | 140 | seat_device->input_device->wlr_device); |
141 | if (seat->has_focus) { | 141 | swayc_t *focus = sway_seat_get_focus(seat); |
142 | swayc_t *focus = sway_seat_get_focus(seat, &root_container); | 142 | if (focus && focus->type == C_VIEW) { |
143 | if (focus && focus->type == C_VIEW) { | 143 | // force notify reenter to pick up the new configuration |
144 | // force notify reenter to pick up the new configuration | 144 | wlr_seat_keyboard_clear_focus(seat->wlr_seat); |
145 | wlr_seat_keyboard_clear_focus(seat->wlr_seat); | 145 | wlr_seat_keyboard_notify_enter(seat->wlr_seat, |
146 | wlr_seat_keyboard_notify_enter(seat->wlr_seat, | 146 | focus->sway_view->surface, wlr_keyboard->keycodes, |
147 | focus->sway_view->surface, wlr_keyboard->keycodes, | 147 | wlr_keyboard->num_keycodes, &wlr_keyboard->modifiers); |
148 | wlr_keyboard->num_keycodes, &wlr_keyboard->modifiers); | ||
149 | } | ||
150 | } | 148 | } |
151 | } | 149 | } |
152 | 150 | ||
@@ -266,12 +264,13 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) { | |||
266 | static void handle_focus_destroy(struct wl_listener *listener, void *data) { | 264 | static void handle_focus_destroy(struct wl_listener *listener, void *data) { |
267 | struct sway_seat *seat = wl_container_of(listener, seat, focus_destroy); | 265 | struct sway_seat *seat = wl_container_of(listener, seat, focus_destroy); |
268 | swayc_t *container = data; | 266 | swayc_t *container = data; |
267 | // TODO dont set focus to the parent, set focus to the next focus inactive | ||
268 | // of the parent | ||
269 | sway_seat_set_focus(seat, container->parent); | 269 | sway_seat_set_focus(seat, container->parent); |
270 | } | 270 | } |
271 | 271 | ||
272 | void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) { | 272 | void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) { |
273 | swayc_t *last_focus = | 273 | swayc_t *last_focus = sway_seat_get_focus(seat); |
274 | (seat->has_focus ? sway_seat_get_focus(seat, &root_container) : NULL); | ||
275 | 274 | ||
276 | if (container && last_focus == container) { | 275 | if (container && last_focus == container) { |
277 | return; | 276 | return; |
@@ -314,7 +313,7 @@ void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) { | |||
314 | } | 313 | } |
315 | } | 314 | } |
316 | 315 | ||
317 | swayc_t *sway_seat_get_focus(struct sway_seat *seat, swayc_t *container) { | 316 | swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container) { |
318 | struct sway_seat_container *current = NULL; | 317 | struct sway_seat_container *current = NULL; |
319 | swayc_t *parent = NULL; | 318 | swayc_t *parent = NULL; |
320 | wl_list_for_each(current, &seat->focus_stack, link) { | 319 | wl_list_for_each(current, &seat->focus_stack, link) { |
@@ -338,6 +337,13 @@ swayc_t *sway_seat_get_focus(struct sway_seat *seat, swayc_t *container) { | |||
338 | return NULL; | 337 | return NULL; |
339 | } | 338 | } |
340 | 339 | ||
340 | swayc_t *sway_seat_get_focus(struct sway_seat *seat) { | ||
341 | if (!seat->has_focus) { | ||
342 | return NULL; | ||
343 | } | ||
344 | return sway_seat_get_focus_inactive(seat, &root_container); | ||
345 | } | ||
346 | |||
341 | void sway_seat_set_config(struct sway_seat *seat, | 347 | void sway_seat_set_config(struct sway_seat *seat, |
342 | struct seat_config *seat_config) { | 348 | struct seat_config *seat_config) { |
343 | // clear configs | 349 | // clear configs |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index ce5b425c..29f07f74 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -63,8 +63,8 @@ static bool _workspace_by_name(swayc_t *view, void *data) { | |||
63 | swayc_t *workspace_by_name(const char *name) { | 63 | swayc_t *workspace_by_name(const char *name) { |
64 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 64 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
65 | swayc_t *current_workspace = NULL, *current_output = NULL; | 65 | swayc_t *current_workspace = NULL, *current_output = NULL; |
66 | if (seat->has_focus) { | 66 | swayc_t *focus = sway_seat_get_focus(seat); |
67 | swayc_t *focus = sway_seat_get_focus(seat, &root_container); | 67 | if (focus) { |
68 | current_workspace = swayc_parent_by_type(focus, C_WORKSPACE); | 68 | current_workspace = swayc_parent_by_type(focus, C_WORKSPACE); |
69 | current_output = swayc_parent_by_type(focus, C_OUTPUT); | 69 | current_output = swayc_parent_by_type(focus, C_OUTPUT); |
70 | } | 70 | } |
@@ -103,7 +103,7 @@ swayc_t *workspace_create(const char *name) { | |||
103 | } | 103 | } |
104 | // Otherwise create a new one | 104 | // Otherwise create a new one |
105 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 105 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
106 | swayc_t *focus = sway_seat_get_focus(seat, &root_container); | 106 | swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container); |
107 | parent = focus; | 107 | parent = focus; |
108 | parent = swayc_parent_by_type(parent, C_OUTPUT); | 108 | parent = swayc_parent_by_type(parent, C_OUTPUT); |
109 | return new_workspace(parent, name); | 109 | return new_workspace(parent, name); |
@@ -195,7 +195,7 @@ bool workspace_switch(swayc_t *workspace) { | |||
195 | return false; | 195 | return false; |
196 | } | 196 | } |
197 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 197 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
198 | swayc_t *focus = sway_seat_get_focus(seat, &root_container); | 198 | swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container); |
199 | if (!seat || !focus) { | 199 | if (!seat || !focus) { |
200 | return false; | 200 | return false; |
201 | } | 201 | } |