diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-02-07 18:17:57 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-02-07 18:17:57 -0500 |
commit | a7d49da23956c245f0e6b8f7dc9cb532eb14c4b9 (patch) | |
tree | 83f3d132a16e69deb4dbbdb8b4f8d1cda5964c27 /sway/input/seat.c | |
parent | make index_child static (diff) | |
download | sway-a7d49da23956c245f0e6b8f7dc9cb532eb14c4b9.tar.gz sway-a7d49da23956c245f0e6b8f7dc9cb532eb14c4b9.tar.zst sway-a7d49da23956c245f0e6b8f7dc9cb532eb14c4b9.zip |
separate seat get focus and seat get focus inactive
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r-- | sway/input/seat.c | 32 |
1 files changed, 19 insertions, 13 deletions
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 |