aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c82
1 files changed, 47 insertions, 35 deletions
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
90static void handle_seat_container_destroy(struct wl_listener *listener, 89static 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
450void 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
445void seat_set_focus_layer(struct sway_seat *seat, 473void 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
483void seat_set_exclusive_client(struct sway_seat *seat, 495void seat_set_exclusive_client(struct sway_seat *seat,