diff options
-rw-r--r-- | include/sway/input/seat.h | 3 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 7 | ||||
-rw-r--r-- | sway/input/input-manager.c | 2 | ||||
-rw-r--r-- | sway/input/seat.c | 82 |
4 files changed, 58 insertions, 36 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index d1cfbe4c..c7be58b5 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -64,6 +64,9 @@ void seat_set_focus(struct sway_seat *seat, struct sway_container *container); | |||
64 | void seat_set_focus_warp(struct sway_seat *seat, | 64 | void seat_set_focus_warp(struct sway_seat *seat, |
65 | struct sway_container *container, bool warp); | 65 | struct sway_container *container, bool warp); |
66 | 66 | ||
67 | void seat_set_focus_surface(struct sway_seat *seat, | ||
68 | struct wlr_surface *surface); | ||
69 | |||
67 | void seat_set_focus_layer(struct sway_seat *seat, | 70 | void seat_set_focus_layer(struct sway_seat *seat, |
68 | struct wlr_layer_surface *layer); | 71 | struct wlr_layer_surface *layer); |
69 | 72 | ||
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 6de1365d..413dbf8b 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -59,6 +59,13 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) { | |||
59 | surface->ly = xsurface->y; | 59 | surface->ly = xsurface->y; |
60 | desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true); | 60 | desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true); |
61 | 61 | ||
62 | if (!wlr_xwayland_surface_is_unmanaged(xsurface)) { | ||
63 | struct sway_seat *seat = input_manager_current_seat(input_manager); | ||
64 | struct wlr_xwayland *xwayland = seat->input->server->xwayland; | ||
65 | wlr_xwayland_set_seat(xwayland, seat->wlr_seat); | ||
66 | seat_set_focus_surface(seat, xsurface->surface); | ||
67 | } | ||
68 | |||
62 | // TODO: we don't send surface enter/leave events to xwayland unmanaged | 69 | // TODO: we don't send surface enter/leave events to xwayland unmanaged |
63 | // surfaces, but xwayland doesn't support HiDPI anyway | 70 | // surfaces, but xwayland doesn't support HiDPI anyway |
64 | } | 71 | } |
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index f71a06e4..ae55d2a1 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -333,7 +333,7 @@ bool input_manager_has_focus(struct sway_input_manager *input, | |||
333 | 333 | ||
334 | void input_manager_set_focus(struct sway_input_manager *input, | 334 | void input_manager_set_focus(struct sway_input_manager *input, |
335 | struct sway_container *container) { | 335 | struct sway_container *container) { |
336 | struct sway_seat *seat ; | 336 | struct sway_seat *seat; |
337 | wl_list_for_each(seat, &input->seats, link) { | 337 | wl_list_for_each(seat, &input->seats, link) { |
338 | seat_set_focus(seat, container); | 338 | seat_set_focus(seat, container); |
339 | } | 339 | } |
diff --git a/sway/input/seat.c b/sway/input/seat.c index e8cf9824..b94e3291 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -84,7 +84,6 @@ static void seat_send_focus(struct sway_seat *seat, | |||
84 | wlr_seat_keyboard_notify_enter( | 84 | wlr_seat_keyboard_notify_enter( |
85 | seat->wlr_seat, view->surface, NULL, 0, NULL); | 85 | seat->wlr_seat, view->surface, NULL, 0, NULL); |
86 | } | 86 | } |
87 | |||
88 | } | 87 | } |
89 | 88 | ||
90 | static void handle_seat_container_destroy(struct wl_listener *listener, | 89 | static void handle_seat_container_destroy(struct wl_listener *listener, |
@@ -405,23 +404,29 @@ void seat_set_focus_warp(struct sway_seat *seat, | |||
405 | container_destroy(last_ws); | 404 | container_destroy(last_ws); |
406 | } | 405 | } |
407 | } | 406 | } |
408 | struct sway_container *last_output = last_focus; | 407 | |
409 | if (last_output && last_output->type != C_OUTPUT) { | 408 | if (config->mouse_warping && warp) { |
410 | last_output = container_parent(last_output, C_OUTPUT); | 409 | struct sway_container *last_output = last_focus; |
411 | } | 410 | if (last_output && last_output->type != C_OUTPUT) { |
412 | struct sway_container *new_output = container; | 411 | last_output = container_parent(last_output, C_OUTPUT); |
413 | if (new_output && new_output->type != C_OUTPUT) { | 412 | } |
414 | new_output = container_parent(new_output, C_OUTPUT); | 413 | struct sway_container *new_output = container; |
415 | } | 414 | if (new_output && new_output->type != C_OUTPUT) { |
416 | if (new_output && last_output && new_output != last_output | 415 | new_output = container_parent(new_output, C_OUTPUT); |
417 | && config->mouse_warping && warp) { | 416 | } |
418 | struct wlr_output *output = new_output->sway_output->wlr_output; | 417 | if (new_output && last_output && new_output != last_output) { |
419 | double x = container->x + output->lx + container->width / 2.0; | 418 | double x = new_output->x + container->x + |
420 | double y = container->y + output->ly + container->height / 2.0; | 419 | container->width / 2.0; |
421 | if (!wlr_output_layout_contains_point( | 420 | double y = new_output->y + container->y + |
422 | root_container.sway_root->output_layout, | 421 | container->height / 2.0; |
423 | output, seat->cursor->cursor->x, seat->cursor->cursor->y)) { | 422 | struct wlr_output *wlr_output = |
424 | wlr_cursor_warp(seat->cursor->cursor, NULL, x, y); | 423 | new_output->sway_output->wlr_output; |
424 | if (!wlr_output_layout_contains_point( | ||
425 | root_container.sway_root->output_layout, | ||
426 | wlr_output, seat->cursor->cursor->x, | ||
427 | seat->cursor->cursor->y)) { | ||
428 | wlr_cursor_warp(seat->cursor->cursor, NULL, x, y); | ||
429 | } | ||
425 | } | 430 | } |
426 | } | 431 | } |
427 | } | 432 | } |
@@ -442,6 +447,29 @@ void seat_set_focus(struct sway_seat *seat, | |||
442 | seat_set_focus_warp(seat, container, true); | 447 | seat_set_focus_warp(seat, container, true); |
443 | } | 448 | } |
444 | 449 | ||
450 | void seat_set_focus_surface(struct sway_seat *seat, | ||
451 | struct wlr_surface *surface) { | ||
452 | if (seat->focused_layer != NULL) { | ||
453 | return; | ||
454 | } | ||
455 | if (seat->has_focus) { | ||
456 | struct sway_container *focus = seat_get_focus(seat); | ||
457 | if (focus->type == C_VIEW) { | ||
458 | wlr_seat_keyboard_clear_focus(seat->wlr_seat); | ||
459 | view_set_activated(focus->sway_view, false); | ||
460 | } | ||
461 | seat->has_focus = false; | ||
462 | } | ||
463 | struct wlr_keyboard *keyboard = | ||
464 | wlr_seat_get_keyboard(seat->wlr_seat); | ||
465 | if (keyboard) { | ||
466 | wlr_seat_keyboard_notify_enter(seat->wlr_seat, surface, | ||
467 | keyboard->keycodes, keyboard->num_keycodes, &keyboard->modifiers); | ||
468 | } else { | ||
469 | wlr_seat_keyboard_notify_enter(seat->wlr_seat, surface, NULL, 0, NULL); | ||
470 | } | ||
471 | } | ||
472 | |||
445 | void seat_set_focus_layer(struct sway_seat *seat, | 473 | void seat_set_focus_layer(struct sway_seat *seat, |
446 | struct wlr_layer_surface *layer) { | 474 | struct wlr_layer_surface *layer) { |
447 | if (!layer && seat->focused_layer) { | 475 | if (!layer && seat->focused_layer) { |
@@ -458,26 +486,10 @@ void seat_set_focus_layer(struct sway_seat *seat, | |||
458 | } else if (!layer || seat->focused_layer == layer) { | 486 | } else if (!layer || seat->focused_layer == layer) { |
459 | return; | 487 | return; |
460 | } | 488 | } |
461 | if (seat->has_focus) { | 489 | seat_set_focus_surface(seat, layer->surface); |
462 | struct sway_container *focus = seat_get_focus(seat); | ||
463 | if (focus->type == C_VIEW) { | ||
464 | wlr_seat_keyboard_clear_focus(seat->wlr_seat); | ||
465 | view_set_activated(focus->sway_view, false); | ||
466 | } | ||
467 | } | ||
468 | if (layer->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) { | 490 | if (layer->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) { |
469 | seat->focused_layer = layer; | 491 | seat->focused_layer = layer; |
470 | } | 492 | } |
471 | struct wlr_keyboard *keyboard = | ||
472 | wlr_seat_get_keyboard(seat->wlr_seat); | ||
473 | if (keyboard) { | ||
474 | wlr_seat_keyboard_notify_enter(seat->wlr_seat, | ||
475 | layer->surface, keyboard->keycodes, | ||
476 | keyboard->num_keycodes, &keyboard->modifiers); | ||
477 | } else { | ||
478 | wlr_seat_keyboard_notify_enter(seat->wlr_seat, | ||
479 | layer->surface, NULL, 0, NULL); | ||
480 | } | ||
481 | } | 493 | } |
482 | 494 | ||
483 | void seat_set_exclusive_client(struct sway_seat *seat, | 495 | void seat_set_exclusive_client(struct sway_seat *seat, |