diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-03-30 00:02:29 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-03-30 00:04:04 -0400 |
commit | f26ecd9f58bb672fe107660ce9b37f4bf0777a8c (patch) | |
tree | 997658454de40db3f8b76b68d658efaf2b686188 /sway/input/seat.c | |
parent | Early return from render functions if necessary (diff) | |
parent | Merge pull request #1654 from acrisci/refactor-2-electric-boogaloo (diff) | |
download | sway-f26ecd9f58bb672fe107660ce9b37f4bf0777a8c.tar.gz sway-f26ecd9f58bb672fe107660ce9b37f4bf0777a8c.tar.zst sway-f26ecd9f58bb672fe107660ce9b37f4bf0777a8c.zip |
Merge remote-tracking branch 'origin/wlroots' into swaybar-layers
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r-- | sway/input/seat.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index 81bef7bd..7cf0dd08 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -1,14 +1,14 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _XOPEN_SOURCE 700 |
2 | #include <wlr/types/wlr_cursor.h> | 2 | #include <wlr/types/wlr_cursor.h> |
3 | #include <wlr/types/wlr_xcursor_manager.h> | 3 | #include <wlr/types/wlr_xcursor_manager.h> |
4 | #include "sway/container.h" | 4 | #include "sway/tree/container.h" |
5 | #include "sway/input/seat.h" | 5 | #include "sway/input/seat.h" |
6 | #include "sway/input/cursor.h" | 6 | #include "sway/input/cursor.h" |
7 | #include "sway/input/input-manager.h" | 7 | #include "sway/input/input-manager.h" |
8 | #include "sway/input/keyboard.h" | 8 | #include "sway/input/keyboard.h" |
9 | #include "sway/ipc-server.h" | 9 | #include "sway/ipc-server.h" |
10 | #include "sway/output.h" | 10 | #include "sway/output.h" |
11 | #include "sway/view.h" | 11 | #include "sway/tree/view.h" |
12 | #include "log.h" | 12 | #include "log.h" |
13 | 13 | ||
14 | static void seat_device_destroy(struct sway_seat_device *seat_device) { | 14 | static void seat_device_destroy(struct sway_seat_device *seat_device) { |
@@ -38,7 +38,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener, | |||
38 | struct sway_seat_container *seat_con = | 38 | struct sway_seat_container *seat_con = |
39 | wl_container_of(listener, seat_con, destroy); | 39 | wl_container_of(listener, seat_con, destroy); |
40 | struct sway_seat *seat = seat_con->seat; | 40 | struct sway_seat *seat = seat_con->seat; |
41 | swayc_t *con = seat_con->container; | 41 | struct sway_container *con = seat_con->container; |
42 | 42 | ||
43 | bool is_focus = (sway_seat_get_focus(seat) == con); | 43 | bool is_focus = (sway_seat_get_focus(seat) == con); |
44 | 44 | ||
@@ -47,7 +47,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener, | |||
47 | if (is_focus) { | 47 | if (is_focus) { |
48 | // pick next focus | 48 | // pick next focus |
49 | sway_seat_set_focus(seat, NULL); | 49 | sway_seat_set_focus(seat, NULL); |
50 | swayc_t *next = sway_seat_get_focus_inactive(seat, con->parent); | 50 | struct sway_container *next = sway_seat_get_focus_inactive(seat, con->parent); |
51 | if (next == NULL) { | 51 | if (next == NULL) { |
52 | next = con->parent; | 52 | next = con->parent; |
53 | } | 53 | } |
@@ -60,7 +60,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener, | |||
60 | } | 60 | } |
61 | 61 | ||
62 | static struct sway_seat_container *seat_container_from_container( | 62 | static struct sway_seat_container *seat_container_from_container( |
63 | struct sway_seat *seat, swayc_t *con) { | 63 | struct sway_seat *seat, struct sway_container *con) { |
64 | if (con->type < C_WORKSPACE) { | 64 | if (con->type < C_WORKSPACE) { |
65 | // these don't get seat containers ever | 65 | // these don't get seat containers ever |
66 | return NULL; | 66 | return NULL; |
@@ -90,11 +90,11 @@ static struct sway_seat_container *seat_container_from_container( | |||
90 | 90 | ||
91 | static void handle_new_container(struct wl_listener *listener, void *data) { | 91 | static void handle_new_container(struct wl_listener *listener, void *data) { |
92 | struct sway_seat *seat = wl_container_of(listener, seat, new_container); | 92 | struct sway_seat *seat = wl_container_of(listener, seat, new_container); |
93 | swayc_t *con = data; | 93 | struct sway_container *con = data; |
94 | seat_container_from_container(seat, con); | 94 | seat_container_from_container(seat, con); |
95 | } | 95 | } |
96 | 96 | ||
97 | static void collect_focus_iter(swayc_t *con, void *data) { | 97 | static void collect_focus_iter(struct sway_container *con, void *data) { |
98 | struct sway_seat *seat = data; | 98 | struct sway_seat *seat = data; |
99 | if (con->type > C_WORKSPACE) { | 99 | if (con->type > C_WORKSPACE) { |
100 | return; | 100 | return; |
@@ -131,7 +131,7 @@ struct sway_seat *sway_seat_create(struct sway_input_manager *input, | |||
131 | // init the focus stack | 131 | // init the focus stack |
132 | wl_list_init(&seat->focus_stack); | 132 | wl_list_init(&seat->focus_stack); |
133 | 133 | ||
134 | container_for_each_bfs(&root_container, collect_focus_iter, seat); | 134 | container_for_each_descendant_dfs(&root_container, collect_focus_iter, seat); |
135 | 135 | ||
136 | wl_signal_add(&root_container.sway_root->events.new_container, | 136 | wl_signal_add(&root_container.sway_root->events.new_container, |
137 | &seat->new_container); | 137 | &seat->new_container); |
@@ -167,7 +167,7 @@ static void seat_configure_keyboard(struct sway_seat *seat, | |||
167 | sway_keyboard_configure(seat_device->keyboard); | 167 | sway_keyboard_configure(seat_device->keyboard); |
168 | wlr_seat_set_keyboard(seat->wlr_seat, | 168 | wlr_seat_set_keyboard(seat->wlr_seat, |
169 | seat_device->input_device->wlr_device); | 169 | seat_device->input_device->wlr_device); |
170 | swayc_t *focus = sway_seat_get_focus(seat); | 170 | struct sway_container *focus = sway_seat_get_focus(seat); |
171 | if (focus && focus->type == C_VIEW) { | 171 | if (focus && focus->type == C_VIEW) { |
172 | // force notify reenter to pick up the new configuration | 172 | // force notify reenter to pick up the new configuration |
173 | wlr_seat_keyboard_clear_focus(seat->wlr_seat); | 173 | wlr_seat_keyboard_clear_focus(seat->wlr_seat); |
@@ -271,7 +271,7 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) { | |||
271 | } | 271 | } |
272 | 272 | ||
273 | for (int i = 0; i < root_container.children->length; ++i) { | 273 | for (int i = 0; i < root_container.children->length; ++i) { |
274 | swayc_t *output_container = root_container.children->items[i]; | 274 | struct sway_container *output_container = root_container.children->items[i]; |
275 | struct wlr_output *output = | 275 | struct wlr_output *output = |
276 | output_container->sway_output->wlr_output; | 276 | output_container->sway_output->wlr_output; |
277 | bool result = | 277 | bool result = |
@@ -290,8 +290,8 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) { | |||
290 | seat->cursor->cursor->y); | 290 | seat->cursor->cursor->y); |
291 | } | 291 | } |
292 | 292 | ||
293 | void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) { | 293 | void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *container) { |
294 | swayc_t *last_focus = sway_seat_get_focus(seat); | 294 | struct sway_container *last_focus = sway_seat_get_focus(seat); |
295 | 295 | ||
296 | if (container && last_focus == container) { | 296 | if (container && last_focus == container) { |
297 | return; | 297 | return; |
@@ -324,10 +324,9 @@ void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) { | |||
324 | } | 324 | } |
325 | 325 | ||
326 | if (last_focus) { | 326 | if (last_focus) { |
327 | swayc_t *last_ws = last_focus; | 327 | struct sway_container *last_ws = last_focus; |
328 | if (last_ws && last_ws->type != C_WORKSPACE) { | 328 | if (last_ws && last_ws->type != C_WORKSPACE) { |
329 | last_ws = swayc_parent_by_type( | 329 | last_ws = container_parent(last_focus, C_WORKSPACE); |
330 | last_focus, C_WORKSPACE); | ||
331 | } | 330 | } |
332 | if (last_ws) { | 331 | if (last_ws) { |
333 | wlr_log(L_DEBUG, "sending workspace event"); | 332 | wlr_log(L_DEBUG, "sending workspace event"); |
@@ -344,9 +343,9 @@ void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) { | |||
344 | seat->has_focus = (container != NULL); | 343 | seat->has_focus = (container != NULL); |
345 | } | 344 | } |
346 | 345 | ||
347 | swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container) { | 346 | struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, struct sway_container *container) { |
348 | struct sway_seat_container *current = NULL; | 347 | struct sway_seat_container *current = NULL; |
349 | swayc_t *parent = NULL; | 348 | struct sway_container *parent = NULL; |
350 | wl_list_for_each(current, &seat->focus_stack, link) { | 349 | wl_list_for_each(current, &seat->focus_stack, link) { |
351 | parent = current->container->parent; | 350 | parent = current->container->parent; |
352 | 351 | ||
@@ -365,21 +364,21 @@ swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container | |||
365 | return NULL; | 364 | return NULL; |
366 | } | 365 | } |
367 | 366 | ||
368 | swayc_t *sway_seat_get_focus(struct sway_seat *seat) { | 367 | struct sway_container *sway_seat_get_focus(struct sway_seat *seat) { |
369 | if (!seat->has_focus) { | 368 | if (!seat->has_focus) { |
370 | return NULL; | 369 | return NULL; |
371 | } | 370 | } |
372 | return sway_seat_get_focus_inactive(seat, &root_container); | 371 | return sway_seat_get_focus_inactive(seat, &root_container); |
373 | } | 372 | } |
374 | 373 | ||
375 | swayc_t *sway_seat_get_focus_by_type(struct sway_seat *seat, | 374 | struct sway_container *sway_seat_get_focus_by_type(struct sway_seat *seat, |
376 | enum swayc_types type) { | 375 | enum sway_container_type type) { |
377 | swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container); | 376 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); |
378 | if (focus->type == type) { | 377 | if (focus->type == type) { |
379 | return focus; | 378 | return focus; |
380 | } | 379 | } |
381 | 380 | ||
382 | return swayc_parent_by_type(focus, type); | 381 | return container_parent(focus, type); |
383 | } | 382 | } |
384 | 383 | ||
385 | void sway_seat_set_config(struct sway_seat *seat, | 384 | void sway_seat_set_config(struct sway_seat *seat, |