diff options
Diffstat (limited to 'sway/input/seatop_default.c')
-rw-r--r-- | sway/input/seatop_default.c | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index a583ed62..4320a3b4 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <wlr/types/wlr_cursor.h> | 4 | #include <wlr/types/wlr_cursor.h> |
5 | #include <wlr/types/wlr_tablet_v2.h> | 5 | #include <wlr/types/wlr_tablet_v2.h> |
6 | #include <wlr/types/wlr_xcursor_manager.h> | 6 | #include <wlr/types/wlr_xcursor_manager.h> |
7 | #include "sway/desktop/transaction.h" | ||
7 | #include "sway/input/cursor.h" | 8 | #include "sway/input/cursor.h" |
8 | #include "sway/input/seat.h" | 9 | #include "sway/input/seat.h" |
9 | #include "sway/input/tablet.h" | 10 | #include "sway/input/tablet.h" |
@@ -59,7 +60,7 @@ static bool edge_is_external(struct sway_container *cont, enum wlr_edges edge) { | |||
59 | return false; | 60 | return false; |
60 | } | 61 | } |
61 | } | 62 | } |
62 | cont = cont->parent; | 63 | cont = cont->pending.parent; |
63 | } | 64 | } |
64 | return true; | 65 | return true; |
65 | } | 66 | } |
@@ -69,25 +70,25 @@ static enum wlr_edges find_edge(struct sway_container *cont, | |||
69 | if (!cont->view || (surface && cont->view->surface != surface)) { | 70 | if (!cont->view || (surface && cont->view->surface != surface)) { |
70 | return WLR_EDGE_NONE; | 71 | return WLR_EDGE_NONE; |
71 | } | 72 | } |
72 | if (cont->border == B_NONE || !cont->border_thickness || | 73 | if (cont->pending.border == B_NONE || !cont->pending.border_thickness || |
73 | cont->border == B_CSD) { | 74 | cont->pending.border == B_CSD) { |
74 | return WLR_EDGE_NONE; | 75 | return WLR_EDGE_NONE; |
75 | } | 76 | } |
76 | if (cont->fullscreen_mode) { | 77 | if (cont->pending.fullscreen_mode) { |
77 | return WLR_EDGE_NONE; | 78 | return WLR_EDGE_NONE; |
78 | } | 79 | } |
79 | 80 | ||
80 | enum wlr_edges edge = 0; | 81 | enum wlr_edges edge = 0; |
81 | if (cursor->cursor->x < cont->x + cont->border_thickness) { | 82 | if (cursor->cursor->x < cont->pending.x + cont->pending.border_thickness) { |
82 | edge |= WLR_EDGE_LEFT; | 83 | edge |= WLR_EDGE_LEFT; |
83 | } | 84 | } |
84 | if (cursor->cursor->y < cont->y + cont->border_thickness) { | 85 | if (cursor->cursor->y < cont->pending.y + cont->pending.border_thickness) { |
85 | edge |= WLR_EDGE_TOP; | 86 | edge |= WLR_EDGE_TOP; |
86 | } | 87 | } |
87 | if (cursor->cursor->x >= cont->x + cont->width - cont->border_thickness) { | 88 | if (cursor->cursor->x >= cont->pending.x + cont->pending.width - cont->pending.border_thickness) { |
88 | edge |= WLR_EDGE_RIGHT; | 89 | edge |= WLR_EDGE_RIGHT; |
89 | } | 90 | } |
90 | if (cursor->cursor->y >= cont->y + cont->height - cont->border_thickness) { | 91 | if (cursor->cursor->y >= cont->pending.y + cont->pending.height - cont->pending.border_thickness) { |
91 | edge |= WLR_EDGE_BOTTOM; | 92 | edge |= WLR_EDGE_BOTTOM; |
92 | } | 93 | } |
93 | 94 | ||
@@ -231,6 +232,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat, | |||
231 | wlr_layer_surface_v1_from_wlr_surface(surface); | 232 | wlr_layer_surface_v1_from_wlr_surface(surface); |
232 | if (layer->current.keyboard_interactive) { | 233 | if (layer->current.keyboard_interactive) { |
233 | seat_set_focus_layer(seat, layer); | 234 | seat_set_focus_layer(seat, layer); |
235 | transaction_commit_dirty(); | ||
234 | } | 236 | } |
235 | } else if (cont) { | 237 | } else if (cont) { |
236 | bool is_floating_or_child = container_is_floating_or_child(cont); | 238 | bool is_floating_or_child = container_is_floating_or_child(cont); |
@@ -249,7 +251,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat, | |||
249 | 251 | ||
250 | // Handle moving a tiling container | 252 | // Handle moving a tiling container |
251 | if (config->tiling_drag && mod_pressed && !is_floating_or_child && | 253 | if (config->tiling_drag && mod_pressed && !is_floating_or_child && |
252 | cont->fullscreen_mode == FULLSCREEN_NONE) { | 254 | cont->pending.fullscreen_mode == FULLSCREEN_NONE) { |
253 | seatop_begin_move_tiling(seat, cont); | 255 | seatop_begin_move_tiling(seat, cont); |
254 | return; | 256 | return; |
255 | } | 257 | } |
@@ -268,6 +270,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat, | |||
268 | struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland; | 270 | struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland; |
269 | wlr_xwayland_set_seat(xwayland, seat->wlr_seat); | 271 | wlr_xwayland_set_seat(xwayland, seat->wlr_seat); |
270 | seat_set_focus_surface(seat, xsurface->surface, false); | 272 | seat_set_focus_surface(seat, xsurface->surface, false); |
273 | transaction_commit_dirty(); | ||
271 | } | 274 | } |
272 | } | 275 | } |
273 | #endif | 276 | #endif |
@@ -356,6 +359,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
356 | if (node && node->type == N_WORKSPACE) { | 359 | if (node && node->type == N_WORKSPACE) { |
357 | if (state == WLR_BUTTON_PRESSED) { | 360 | if (state == WLR_BUTTON_PRESSED) { |
358 | seat_set_focus(seat, node); | 361 | seat_set_focus(seat, node); |
362 | transaction_commit_dirty(); | ||
359 | } | 363 | } |
360 | seat_pointer_notify_button(seat, time_msec, button, state); | 364 | seat_pointer_notify_button(seat, time_msec, button, state); |
361 | return; | 365 | return; |
@@ -367,6 +371,10 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
367 | wlr_layer_surface_v1_from_wlr_surface(surface); | 371 | wlr_layer_surface_v1_from_wlr_surface(surface); |
368 | if (layer->current.keyboard_interactive) { | 372 | if (layer->current.keyboard_interactive) { |
369 | seat_set_focus_layer(seat, layer); | 373 | seat_set_focus_layer(seat, layer); |
374 | transaction_commit_dirty(); | ||
375 | } | ||
376 | if (state == WLR_BUTTON_PRESSED) { | ||
377 | seatop_begin_down_on_surface(seat, surface, time_msec, sx, sy); | ||
370 | } | 378 | } |
371 | seat_pointer_notify_button(seat, time_msec, button, state); | 379 | seat_pointer_notify_button(seat, time_msec, button, state); |
372 | return; | 380 | return; |
@@ -381,7 +389,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
381 | struct sway_container *cont_to_focus = cont; | 389 | struct sway_container *cont_to_focus = cont; |
382 | enum sway_container_layout layout = container_parent_layout(cont); | 390 | enum sway_container_layout layout = container_parent_layout(cont); |
383 | if (layout == L_TABBED || layout == L_STACKED) { | 391 | if (layout == L_TABBED || layout == L_STACKED) { |
384 | cont_to_focus = seat_get_focus_inactive_view(seat, &cont->parent->node); | 392 | cont_to_focus = seat_get_focus_inactive_view(seat, &cont->pending.parent->node); |
385 | } | 393 | } |
386 | 394 | ||
387 | seat_set_focus_container(seat, cont_to_focus); | 395 | seat_set_focus_container(seat, cont_to_focus); |
@@ -397,9 +405,9 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
397 | BTN_LEFT : BTN_RIGHT; | 405 | BTN_LEFT : BTN_RIGHT; |
398 | if (button == btn_resize) { | 406 | if (button == btn_resize) { |
399 | edge = 0; | 407 | edge = 0; |
400 | edge |= cursor->cursor->x > cont->x + cont->width / 2 ? | 408 | edge |= cursor->cursor->x > cont->pending.x + cont->pending.width / 2 ? |
401 | WLR_EDGE_RIGHT : WLR_EDGE_LEFT; | 409 | WLR_EDGE_RIGHT : WLR_EDGE_LEFT; |
402 | edge |= cursor->cursor->y > cont->y + cont->height / 2 ? | 410 | edge |= cursor->cursor->y > cont->pending.y + cont->pending.height / 2 ? |
403 | WLR_EDGE_BOTTOM : WLR_EDGE_TOP; | 411 | WLR_EDGE_BOTTOM : WLR_EDGE_TOP; |
404 | 412 | ||
405 | const char *image = NULL; | 413 | const char *image = NULL; |
@@ -446,9 +454,9 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
446 | if (mod_pressed && button == btn_resize) { | 454 | if (mod_pressed && button == btn_resize) { |
447 | struct sway_container *floater = container_toplevel_ancestor(cont); | 455 | struct sway_container *floater = container_toplevel_ancestor(cont); |
448 | edge = 0; | 456 | edge = 0; |
449 | edge |= cursor->cursor->x > floater->x + floater->width / 2 ? | 457 | edge |= cursor->cursor->x > floater->pending.x + floater->pending.width / 2 ? |
450 | WLR_EDGE_RIGHT : WLR_EDGE_LEFT; | 458 | WLR_EDGE_RIGHT : WLR_EDGE_LEFT; |
451 | edge |= cursor->cursor->y > floater->y + floater->height / 2 ? | 459 | edge |= cursor->cursor->y > floater->pending.y + floater->pending.height / 2 ? |
452 | WLR_EDGE_BOTTOM : WLR_EDGE_TOP; | 460 | WLR_EDGE_BOTTOM : WLR_EDGE_TOP; |
453 | seatop_begin_resize_floating(seat, floater, edge); | 461 | seatop_begin_resize_floating(seat, floater, edge); |
454 | return; | 462 | return; |
@@ -458,7 +466,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
458 | // Handle moving a tiling container | 466 | // Handle moving a tiling container |
459 | if (config->tiling_drag && (mod_pressed || on_titlebar) && | 467 | if (config->tiling_drag && (mod_pressed || on_titlebar) && |
460 | state == WLR_BUTTON_PRESSED && !is_floating_or_child && | 468 | state == WLR_BUTTON_PRESSED && !is_floating_or_child && |
461 | cont && cont->fullscreen_mode == FULLSCREEN_NONE) { | 469 | cont && cont->pending.fullscreen_mode == FULLSCREEN_NONE) { |
462 | struct sway_container *focus = seat_get_focused_container(seat); | 470 | struct sway_container *focus = seat_get_focused_container(seat); |
463 | bool focused = focus == cont || container_has_ancestor(focus, cont); | 471 | bool focused = focus == cont || container_has_ancestor(focus, cont); |
464 | if (on_titlebar && !focused) { | 472 | if (on_titlebar && !focused) { |
@@ -487,6 +495,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
487 | if (cont && state == WLR_BUTTON_PRESSED) { | 495 | if (cont && state == WLR_BUTTON_PRESSED) { |
488 | node = seat_get_focus_inactive(seat, &cont->node); | 496 | node = seat_get_focus_inactive(seat, &cont->node); |
489 | seat_set_focus(seat, node); | 497 | seat_set_focus(seat, node); |
498 | transaction_commit_dirty(); | ||
490 | seat_pointer_notify_button(seat, time_msec, button, state); | 499 | seat_pointer_notify_button(seat, time_msec, button, state); |
491 | return; | 500 | return; |
492 | } | 501 | } |
@@ -501,6 +510,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
501 | struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland; | 510 | struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland; |
502 | wlr_xwayland_set_seat(xwayland, seat->wlr_seat); | 511 | wlr_xwayland_set_seat(xwayland, seat->wlr_seat); |
503 | seat_set_focus_surface(seat, xsurface->surface, false); | 512 | seat_set_focus_surface(seat, xsurface->surface, false); |
513 | transaction_commit_dirty(); | ||
504 | seat_pointer_notify_button(seat, time_msec, button, state); | 514 | seat_pointer_notify_button(seat, time_msec, button, state); |
505 | return; | 515 | return; |
506 | } | 516 | } |
@@ -530,6 +540,7 @@ static void check_focus_follows_mouse(struct sway_seat *seat, | |||
530 | if (focus && hovered_output != node_get_output(focus)) { | 540 | if (focus && hovered_output != node_get_output(focus)) { |
531 | struct sway_workspace *ws = output_get_active_workspace(hovered_output); | 541 | struct sway_workspace *ws = output_get_active_workspace(hovered_output); |
532 | seat_set_focus(seat, &ws->node); | 542 | seat_set_focus(seat, &ws->node); |
543 | transaction_commit_dirty(); | ||
533 | } | 544 | } |
534 | return; | 545 | return; |
535 | } | 546 | } |
@@ -541,6 +552,7 @@ static void check_focus_follows_mouse(struct sway_seat *seat, | |||
541 | struct sway_output *hovered_output = node_get_output(hovered_node); | 552 | struct sway_output *hovered_output = node_get_output(hovered_node); |
542 | if (hovered_output != focused_output) { | 553 | if (hovered_output != focused_output) { |
543 | seat_set_focus(seat, seat_get_focus_inactive(seat, hovered_node)); | 554 | seat_set_focus(seat, seat_get_focus_inactive(seat, hovered_node)); |
555 | transaction_commit_dirty(); | ||
544 | } | 556 | } |
545 | return; | 557 | return; |
546 | } | 558 | } |
@@ -556,6 +568,7 @@ static void check_focus_follows_mouse(struct sway_seat *seat, | |||
556 | if (hovered_node != e->previous_node || | 568 | if (hovered_node != e->previous_node || |
557 | config->focus_follows_mouse == FOLLOWS_ALWAYS) { | 569 | config->focus_follows_mouse == FOLLOWS_ALWAYS) { |
558 | seat_set_focus(seat, hovered_node); | 570 | seat_set_focus(seat, hovered_node); |
571 | transaction_commit_dirty(); | ||
559 | } | 572 | } |
560 | } | 573 | } |
561 | } | 574 | } |
@@ -664,7 +677,7 @@ static void handle_pointer_axis(struct sway_seat *seat, | |||
664 | bool on_border = edge != WLR_EDGE_NONE; | 677 | bool on_border = edge != WLR_EDGE_NONE; |
665 | bool on_titlebar = cont && !on_border && !surface; | 678 | bool on_titlebar = cont && !on_border && !surface; |
666 | bool on_titlebar_border = cont && on_border && | 679 | bool on_titlebar_border = cont && on_border && |
667 | cursor->cursor->y < cont->content_y; | 680 | cursor->cursor->y < cont->pending.content_y; |
668 | bool on_contents = cont && !on_border && surface; | 681 | bool on_contents = cont && !on_border && surface; |
669 | bool on_workspace = node && node->type == N_WORKSPACE; | 682 | bool on_workspace = node && node->type == N_WORKSPACE; |
670 | float scroll_factor = | 683 | float scroll_factor = |
@@ -714,6 +727,7 @@ static void handle_pointer_axis(struct sway_seat *seat, | |||
714 | // Use the focused child of the tabbed/stacked container, not the | 727 | // Use the focused child of the tabbed/stacked container, not the |
715 | // container the user scrolled on. | 728 | // container the user scrolled on. |
716 | seat_set_focus(seat, new_focus); | 729 | seat_set_focus(seat, new_focus); |
730 | transaction_commit_dirty(); | ||
717 | handled = true; | 731 | handled = true; |
718 | } | 732 | } |
719 | } | 733 | } |