diff options
Diffstat (limited to 'sway/input')
-rw-r--r-- | sway/input/cursor.c | 11 | ||||
-rw-r--r-- | sway/input/seat.c | 36 |
2 files changed, 43 insertions, 4 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 97b4473c..9229e92d 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -180,13 +180,18 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { | |||
180 | double sx, sy; | 180 | double sx, sy; |
181 | struct sway_container *cont = | 181 | struct sway_container *cont = |
182 | container_at_cursor(cursor, &surface, &sx, &sy); | 182 | container_at_cursor(cursor, &surface, &sx, &sy); |
183 | if (surface && wlr_surface_is_layer_surface(surface)) { | ||
184 | struct wlr_layer_surface *layer = | ||
185 | wlr_layer_surface_from_wlr_surface(surface); | ||
186 | if (layer->current.keyboard_interactive) { | ||
187 | seat_set_focus_layer(cursor->seat, layer); | ||
188 | return; | ||
189 | } | ||
190 | } | ||
183 | // Avoid moving keyboard focus from a surface that accepts it to one | 191 | // Avoid moving keyboard focus from a surface that accepts it to one |
184 | // that does not unless the change would move us to a new workspace. | 192 | // that does not unless the change would move us to a new workspace. |
185 | // | 193 | // |
186 | // This prevents, for example, losing focus when clicking on swaybar. | 194 | // This prevents, for example, losing focus when clicking on swaybar. |
187 | // | ||
188 | // TODO: Replace this condition with something like | ||
189 | // !surface_accepts_keyboard_input | ||
190 | if (surface && cont && cont->type != C_VIEW) { | 195 | if (surface && cont && cont->type != C_VIEW) { |
191 | struct sway_container *new_ws = cont; | 196 | struct sway_container *new_ws = cont; |
192 | if (new_ws && new_ws->type != C_WORKSPACE) { | 197 | if (new_ws && new_ws->type != C_WORKSPACE) { |
diff --git a/sway/input/seat.c b/sway/input/seat.c index c326f176..4a99e9eb 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -352,8 +352,11 @@ void seat_configure_xcursor(struct sway_seat *seat) { | |||
352 | 352 | ||
353 | void seat_set_focus_warp(struct sway_seat *seat, | 353 | void seat_set_focus_warp(struct sway_seat *seat, |
354 | struct sway_container *container, bool warp) { | 354 | struct sway_container *container, bool warp) { |
355 | struct sway_container *last_focus = seat_get_focus(seat); | 355 | if (seat->focused_layer) { |
356 | return; | ||
357 | } | ||
356 | 358 | ||
359 | struct sway_container *last_focus = seat_get_focus(seat); | ||
357 | if (container && last_focus == container) { | 360 | if (container && last_focus == container) { |
358 | return; | 361 | return; |
359 | } | 362 | } |
@@ -419,6 +422,37 @@ void seat_set_focus(struct sway_seat *seat, | |||
419 | seat_set_focus_warp(seat, container, true); | 422 | seat_set_focus_warp(seat, container, true); |
420 | } | 423 | } |
421 | 424 | ||
425 | void seat_set_focus_layer(struct sway_seat *seat, | ||
426 | struct wlr_layer_surface *layer) { | ||
427 | if (!layer) { | ||
428 | seat->focused_layer = NULL; | ||
429 | return; | ||
430 | } | ||
431 | if (seat->focused_layer == layer) { | ||
432 | return; | ||
433 | } | ||
434 | if (seat->has_focus) { | ||
435 | struct sway_container *focus = seat_get_focus(seat); | ||
436 | if (focus->type == C_VIEW) { | ||
437 | wlr_seat_keyboard_clear_focus(seat->wlr_seat); | ||
438 | view_set_activated(focus->sway_view, false); | ||
439 | } | ||
440 | } | ||
441 | if (layer->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) { | ||
442 | seat->focused_layer = layer; | ||
443 | } | ||
444 | struct wlr_keyboard *keyboard = | ||
445 | wlr_seat_get_keyboard(seat->wlr_seat); | ||
446 | if (keyboard) { | ||
447 | wlr_seat_keyboard_notify_enter(seat->wlr_seat, | ||
448 | layer->surface, keyboard->keycodes, | ||
449 | keyboard->num_keycodes, &keyboard->modifiers); | ||
450 | } else { | ||
451 | wlr_seat_keyboard_notify_enter(seat->wlr_seat, | ||
452 | layer->surface, NULL, 0, NULL); | ||
453 | } | ||
454 | } | ||
455 | |||
422 | struct sway_container *seat_get_focus_inactive(struct sway_seat *seat, | 456 | struct sway_container *seat_get_focus_inactive(struct sway_seat *seat, |
423 | struct sway_container *container) { | 457 | struct sway_container *container) { |
424 | return seat_get_focus_by_type(seat, container, C_TYPES); | 458 | return seat_get_focus_by_type(seat, container, C_TYPES); |