aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seatop_default.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/input/seatop_default.c')
-rw-r--r--sway/input/seatop_default.c570
1 files changed, 471 insertions, 99 deletions
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c
index a583ed62..0c6f7c5e 100644
--- a/sway/input/seatop_default.c
+++ b/sway/input/seatop_default.c
@@ -1,13 +1,17 @@
1#define _POSIX_C_SOURCE 200809L
2#include <float.h> 1#include <float.h>
3#include <libevdev/libevdev.h> 2#include <libevdev/libevdev.h>
4#include <wlr/types/wlr_cursor.h> 3#include <wlr/types/wlr_cursor.h>
4#include <wlr/types/wlr_subcompositor.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 "gesture.h"
8#include "sway/desktop/transaction.h"
7#include "sway/input/cursor.h" 9#include "sway/input/cursor.h"
8#include "sway/input/seat.h" 10#include "sway/input/seat.h"
9#include "sway/input/tablet.h" 11#include "sway/input/tablet.h"
12#include "sway/layers.h"
10#include "sway/output.h" 13#include "sway/output.h"
14#include "sway/scene_descriptor.h"
11#include "sway/tree/view.h" 15#include "sway/tree/view.h"
12#include "sway/tree/workspace.h" 16#include "sway/tree/workspace.h"
13#include "log.h" 17#include "log.h"
@@ -19,6 +23,7 @@ struct seatop_default_event {
19 struct sway_node *previous_node; 23 struct sway_node *previous_node;
20 uint32_t pressed_buttons[SWAY_CURSOR_PRESSED_BUTTONS_CAP]; 24 uint32_t pressed_buttons[SWAY_CURSOR_PRESSED_BUTTONS_CAP];
21 size_t pressed_button_count; 25 size_t pressed_button_count;
26 struct gesture_tracker gestures;
22}; 27};
23 28
24/*-----------------------------------------\ 29/*-----------------------------------------\
@@ -50,6 +55,9 @@ static bool edge_is_external(struct sway_container *cont, enum wlr_edges edge) {
50 while (cont) { 55 while (cont) {
51 if (container_parent_layout(cont) == layout) { 56 if (container_parent_layout(cont) == layout) {
52 list_t *siblings = container_get_siblings(cont); 57 list_t *siblings = container_get_siblings(cont);
58 if (!siblings) {
59 return false;
60 }
53 int index = list_find(siblings, cont); 61 int index = list_find(siblings, cont);
54 if (index > 0 && (edge == WLR_EDGE_LEFT || edge == WLR_EDGE_TOP)) { 62 if (index > 0 && (edge == WLR_EDGE_LEFT || edge == WLR_EDGE_TOP)) {
55 return false; 63 return false;
@@ -59,7 +67,7 @@ static bool edge_is_external(struct sway_container *cont, enum wlr_edges edge) {
59 return false; 67 return false;
60 } 68 }
61 } 69 }
62 cont = cont->parent; 70 cont = cont->pending.parent;
63 } 71 }
64 return true; 72 return true;
65} 73}
@@ -69,25 +77,25 @@ static enum wlr_edges find_edge(struct sway_container *cont,
69 if (!cont->view || (surface && cont->view->surface != surface)) { 77 if (!cont->view || (surface && cont->view->surface != surface)) {
70 return WLR_EDGE_NONE; 78 return WLR_EDGE_NONE;
71 } 79 }
72 if (cont->border == B_NONE || !cont->border_thickness || 80 if (cont->pending.border == B_NONE || !cont->pending.border_thickness ||
73 cont->border == B_CSD) { 81 cont->pending.border == B_CSD) {
74 return WLR_EDGE_NONE; 82 return WLR_EDGE_NONE;
75 } 83 }
76 if (cont->fullscreen_mode) { 84 if (cont->pending.fullscreen_mode) {
77 return WLR_EDGE_NONE; 85 return WLR_EDGE_NONE;
78 } 86 }
79 87
80 enum wlr_edges edge = 0; 88 enum wlr_edges edge = 0;
81 if (cursor->cursor->x < cont->x + cont->border_thickness) { 89 if (cursor->cursor->x < cont->pending.x + cont->pending.border_thickness) {
82 edge |= WLR_EDGE_LEFT; 90 edge |= WLR_EDGE_LEFT;
83 } 91 }
84 if (cursor->cursor->y < cont->y + cont->border_thickness) { 92 if (cursor->cursor->y < cont->pending.y + cont->pending.border_thickness) {
85 edge |= WLR_EDGE_TOP; 93 edge |= WLR_EDGE_TOP;
86 } 94 }
87 if (cursor->cursor->x >= cont->x + cont->width - cont->border_thickness) { 95 if (cursor->cursor->x >= cont->pending.x + cont->pending.width - cont->pending.border_thickness) {
88 edge |= WLR_EDGE_RIGHT; 96 edge |= WLR_EDGE_RIGHT;
89 } 97 }
90 if (cursor->cursor->y >= cont->y + cont->height - cont->border_thickness) { 98 if (cursor->cursor->y >= cont->pending.y + cont->pending.height - cont->pending.border_thickness) {
91 edge |= WLR_EDGE_BOTTOM; 99 edge |= WLR_EDGE_BOTTOM;
92 } 100 }
93 101
@@ -225,13 +233,15 @@ static void handle_tablet_tool_tip(struct sway_seat *seat,
225 struct sway_container *cont = node && node->type == N_CONTAINER ? 233 struct sway_container *cont = node && node->type == N_CONTAINER ?
226 node->sway_container : NULL; 234 node->sway_container : NULL;
227 235
228 if (wlr_surface_is_layer_surface(surface)) { 236 struct wlr_layer_surface_v1 *layer;
237#if HAVE_XWAYLAND
238 struct wlr_xwayland_surface *xsurface;
239#endif
240 if ((layer = wlr_layer_surface_v1_try_from_wlr_surface(surface)) &&
241 layer->current.keyboard_interactive) {
229 // Handle tapping a layer surface 242 // Handle tapping a layer surface
230 struct wlr_layer_surface_v1 *layer = 243 seat_set_focus_layer(seat, layer);
231 wlr_layer_surface_v1_from_wlr_surface(surface); 244 transaction_commit_dirty();
232 if (layer->current.keyboard_interactive) {
233 seat_set_focus_layer(seat, layer);
234 }
235 } else if (cont) { 245 } else if (cont) {
236 bool is_floating_or_child = container_is_floating_or_child(cont); 246 bool is_floating_or_child = container_is_floating_or_child(cont);
237 bool is_fullscreen_or_child = container_is_fullscreen_or_child(cont); 247 bool is_fullscreen_or_child = container_is_fullscreen_or_child(cont);
@@ -249,26 +259,24 @@ static void handle_tablet_tool_tip(struct sway_seat *seat,
249 259
250 // Handle moving a tiling container 260 // Handle moving a tiling container
251 if (config->tiling_drag && mod_pressed && !is_floating_or_child && 261 if (config->tiling_drag && mod_pressed && !is_floating_or_child &&
252 cont->fullscreen_mode == FULLSCREEN_NONE) { 262 cont->pending.fullscreen_mode == FULLSCREEN_NONE) {
253 seatop_begin_move_tiling(seat, cont); 263 seatop_begin_move_tiling(seat, cont);
254 return; 264 return;
255 } 265 }
256 266
257 // Handle tapping on a container surface 267 // Handle tapping on a container surface
258 seat_set_focus_container(seat, cont); 268 seat_set_focus_container(seat, cont);
259 seatop_begin_down(seat, node->sway_container, time_msec, sx, sy); 269 seatop_begin_down(seat, node->sway_container, sx, sy);
260 } 270 }
261#if HAVE_XWAYLAND 271#if HAVE_XWAYLAND
262 // Handle tapping on an xwayland unmanaged view 272 // Handle tapping on an xwayland unmanaged view
263 else if (wlr_surface_is_xwayland_surface(surface)) { 273 else if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(surface)) &&
264 struct wlr_xwayland_surface *xsurface = 274 xsurface->override_redirect &&
265 wlr_xwayland_surface_from_wlr_surface(surface); 275 wlr_xwayland_or_surface_wants_focus(xsurface)) {
266 if (xsurface->override_redirect && 276 struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland;
267 wlr_xwayland_or_surface_wants_focus(xsurface)) { 277 wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
268 struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland; 278 seat_set_focus_surface(seat, xsurface->surface, false);
269 wlr_xwayland_set_seat(xwayland, seat->wlr_seat); 279 transaction_commit_dirty();
270 seat_set_focus_surface(seat, xsurface->surface, false);
271 }
272 } 280 }
273#endif 281#endif
274 282
@@ -282,7 +290,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat,
282 290
283static bool trigger_pointer_button_binding(struct sway_seat *seat, 291static bool trigger_pointer_button_binding(struct sway_seat *seat,
284 struct wlr_input_device *device, uint32_t button, 292 struct wlr_input_device *device, uint32_t button,
285 enum wlr_button_state state, uint32_t modifiers, 293 enum wl_pointer_button_state state, uint32_t modifiers,
286 bool on_titlebar, bool on_border, bool on_contents, bool on_workspace) { 294 bool on_titlebar, bool on_border, bool on_contents, bool on_workspace) {
287 // We can reach this for non-pointer devices if we're currently emulating 295 // We can reach this for non-pointer devices if we're currently emulating
288 // pointer input for one. Emulated input should not trigger bindings. The 296 // pointer input for one. Emulated input should not trigger bindings. The
@@ -296,7 +304,7 @@ static bool trigger_pointer_button_binding(struct sway_seat *seat,
296 char *device_identifier = device ? input_device_get_identifier(device) 304 char *device_identifier = device ? input_device_get_identifier(device)
297 : strdup("*"); 305 : strdup("*");
298 struct sway_binding *binding = NULL; 306 struct sway_binding *binding = NULL;
299 if (state == WLR_BUTTON_PRESSED) { 307 if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
300 state_add_button(e, button); 308 state_add_button(e, button);
301 binding = get_active_mouse_binding(e, 309 binding = get_active_mouse_binding(e,
302 config->current_mode->mouse_bindings, modifiers, false, 310 config->current_mode->mouse_bindings, modifiers, false,
@@ -321,7 +329,7 @@ static bool trigger_pointer_button_binding(struct sway_seat *seat,
321 329
322static void handle_button(struct sway_seat *seat, uint32_t time_msec, 330static void handle_button(struct sway_seat *seat, uint32_t time_msec,
323 struct wlr_input_device *device, uint32_t button, 331 struct wlr_input_device *device, uint32_t button,
324 enum wlr_button_state state) { 332 enum wl_pointer_button_state state) {
325 struct sway_cursor *cursor = seat->cursor; 333 struct sway_cursor *cursor = seat->cursor;
326 334
327 // Determine what's under the cursor 335 // Determine what's under the cursor
@@ -354,19 +362,23 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
354 362
355 // Handle clicking an empty workspace 363 // Handle clicking an empty workspace
356 if (node && node->type == N_WORKSPACE) { 364 if (node && node->type == N_WORKSPACE) {
357 if (state == WLR_BUTTON_PRESSED) { 365 if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
358 seat_set_focus(seat, node); 366 seat_set_focus(seat, node);
367 transaction_commit_dirty();
359 } 368 }
360 seat_pointer_notify_button(seat, time_msec, button, state); 369 seat_pointer_notify_button(seat, time_msec, button, state);
361 return; 370 return;
362 } 371 }
363 372
364 // Handle clicking a layer surface 373 // Handle clicking a layer surface and its popups/subsurfaces
365 if (surface && wlr_surface_is_layer_surface(surface)) { 374 struct wlr_layer_surface_v1 *layer = NULL;
366 struct wlr_layer_surface_v1 *layer = 375 if ((layer = toplevel_layer_surface_from_surface(surface))) {
367 wlr_layer_surface_v1_from_wlr_surface(surface);
368 if (layer->current.keyboard_interactive) { 376 if (layer->current.keyboard_interactive) {
369 seat_set_focus_layer(seat, layer); 377 seat_set_focus_layer(seat, layer);
378 transaction_commit_dirty();
379 }
380 if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
381 seatop_begin_down_on_surface(seat, surface, sx, sy);
370 } 382 }
371 seat_pointer_notify_button(seat, time_msec, button, state); 383 seat_pointer_notify_button(seat, time_msec, button, state);
372 return; 384 return;
@@ -374,14 +386,14 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
374 386
375 // Handle tiling resize via border 387 // Handle tiling resize via border
376 if (cont && resize_edge && button == BTN_LEFT && 388 if (cont && resize_edge && button == BTN_LEFT &&
377 state == WLR_BUTTON_PRESSED && !is_floating) { 389 state == WL_POINTER_BUTTON_STATE_PRESSED && !is_floating) {
378 // If a resize is triggered on a tabbed or stacked container, change 390 // If a resize is triggered on a tabbed or stacked container, change
379 // focus to the tab which already had inactive focus -- otherwise, we'd 391 // focus to the tab which already had inactive focus -- otherwise, we'd
380 // change the active tab when the user probably just wanted to resize. 392 // change the active tab when the user probably just wanted to resize.
381 struct sway_container *cont_to_focus = cont; 393 struct sway_container *cont_to_focus = cont;
382 enum sway_container_layout layout = container_parent_layout(cont); 394 enum sway_container_layout layout = container_parent_layout(cont);
383 if (layout == L_TABBED || layout == L_STACKED) { 395 if (layout == L_TABBED || layout == L_STACKED) {
384 cont_to_focus = seat_get_focus_inactive_view(seat, &cont->parent->node); 396 cont_to_focus = seat_get_focus_inactive_view(seat, &cont->pending.parent->node);
385 } 397 }
386 398
387 seat_set_focus_container(seat, cont_to_focus); 399 seat_set_focus_container(seat, cont_to_focus);
@@ -392,14 +404,14 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
392 // Handle tiling resize via mod 404 // Handle tiling resize via mod
393 bool mod_pressed = modifiers & config->floating_mod; 405 bool mod_pressed = modifiers & config->floating_mod;
394 if (cont && !is_floating_or_child && mod_pressed && 406 if (cont && !is_floating_or_child && mod_pressed &&
395 state == WLR_BUTTON_PRESSED) { 407 state == WL_POINTER_BUTTON_STATE_PRESSED) {
396 uint32_t btn_resize = config->floating_mod_inverse ? 408 uint32_t btn_resize = config->floating_mod_inverse ?
397 BTN_LEFT : BTN_RIGHT; 409 BTN_LEFT : BTN_RIGHT;
398 if (button == btn_resize) { 410 if (button == btn_resize) {
399 edge = 0; 411 edge = 0;
400 edge |= cursor->cursor->x > cont->x + cont->width / 2 ? 412 edge |= cursor->cursor->x > cont->pending.x + cont->pending.width / 2 ?
401 WLR_EDGE_RIGHT : WLR_EDGE_LEFT; 413 WLR_EDGE_RIGHT : WLR_EDGE_LEFT;
402 edge |= cursor->cursor->y > cont->y + cont->height / 2 ? 414 edge |= cursor->cursor->y > cont->pending.y + cont->pending.height / 2 ?
403 WLR_EDGE_BOTTOM : WLR_EDGE_TOP; 415 WLR_EDGE_BOTTOM : WLR_EDGE_TOP;
404 416
405 const char *image = NULL; 417 const char *image = NULL;
@@ -419,13 +431,31 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
419 } 431 }
420 } 432 }
421 433
434 // Handle changing focus when clicking on a container
435 if (cont && state == WL_POINTER_BUTTON_STATE_PRESSED) {
436 // Default case: focus the container that was just clicked.
437 node = &cont->node;
438
439 // If the container is a tab/stacked container and the click happened
440 // on a tab, switch to the tab. If the tab contents were already
441 // focused, focus the tab container itself. If the tab container was
442 // already focused, cycle back to focusing the tab contents.
443 if (on_titlebar) {
444 struct sway_container *focus = seat_get_focused_container(seat);
445 if (focus == cont || !container_has_ancestor(focus, cont)) {
446 node = seat_get_focus_inactive(seat, &cont->node);
447 }
448 }
449
450 seat_set_focus(seat, node);
451 transaction_commit_dirty();
452 }
453
422 // Handle beginning floating move 454 // Handle beginning floating move
423 if (cont && is_floating_or_child && !is_fullscreen_or_child && 455 if (cont && is_floating_or_child && !is_fullscreen_or_child &&
424 state == WLR_BUTTON_PRESSED) { 456 state == WL_POINTER_BUTTON_STATE_PRESSED) {
425 uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT; 457 uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT;
426 if (button == btn_move && (mod_pressed || on_titlebar)) { 458 if (button == btn_move && (mod_pressed || on_titlebar)) {
427 seat_set_focus_container(seat,
428 seat_get_focus_inactive_view(seat, &cont->node));
429 seatop_begin_move_floating(seat, container_toplevel_ancestor(cont)); 459 seatop_begin_move_floating(seat, container_toplevel_ancestor(cont));
430 return; 460 return;
431 } 461 }
@@ -433,9 +463,10 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
433 463
434 // Handle beginning floating resize 464 // Handle beginning floating resize
435 if (cont && is_floating_or_child && !is_fullscreen_or_child && 465 if (cont && is_floating_or_child && !is_fullscreen_or_child &&
436 state == WLR_BUTTON_PRESSED) { 466 state == WL_POINTER_BUTTON_STATE_PRESSED) {
437 // Via border 467 // Via border
438 if (button == BTN_LEFT && resize_edge != WLR_EDGE_NONE) { 468 if (button == BTN_LEFT && resize_edge != WLR_EDGE_NONE) {
469 seat_set_focus_container(seat, cont);
439 seatop_begin_resize_floating(seat, cont, resize_edge); 470 seatop_begin_resize_floating(seat, cont, resize_edge);
440 return; 471 return;
441 } 472 }
@@ -446,10 +477,11 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
446 if (mod_pressed && button == btn_resize) { 477 if (mod_pressed && button == btn_resize) {
447 struct sway_container *floater = container_toplevel_ancestor(cont); 478 struct sway_container *floater = container_toplevel_ancestor(cont);
448 edge = 0; 479 edge = 0;
449 edge |= cursor->cursor->x > floater->x + floater->width / 2 ? 480 edge |= cursor->cursor->x > floater->pending.x + floater->pending.width / 2 ?
450 WLR_EDGE_RIGHT : WLR_EDGE_LEFT; 481 WLR_EDGE_RIGHT : WLR_EDGE_LEFT;
451 edge |= cursor->cursor->y > floater->y + floater->height / 2 ? 482 edge |= cursor->cursor->y > floater->pending.y + floater->pending.height / 2 ?
452 WLR_EDGE_BOTTOM : WLR_EDGE_TOP; 483 WLR_EDGE_BOTTOM : WLR_EDGE_TOP;
484 seat_set_focus_container(seat, floater);
453 seatop_begin_resize_floating(seat, floater, edge); 485 seatop_begin_resize_floating(seat, floater, edge);
454 return; 486 return;
455 } 487 }
@@ -457,53 +489,43 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
457 489
458 // Handle moving a tiling container 490 // Handle moving a tiling container
459 if (config->tiling_drag && (mod_pressed || on_titlebar) && 491 if (config->tiling_drag && (mod_pressed || on_titlebar) &&
460 state == WLR_BUTTON_PRESSED && !is_floating_or_child && 492 state == WL_POINTER_BUTTON_STATE_PRESSED && !is_floating_or_child &&
461 cont && cont->fullscreen_mode == FULLSCREEN_NONE) { 493 cont && cont->pending.fullscreen_mode == FULLSCREEN_NONE) {
462 struct sway_container *focus = seat_get_focused_container(seat); 494 // If moving a container by its title bar, use a threshold for the drag
463 bool focused = focus == cont || container_has_ancestor(focus, cont);
464 if (on_titlebar && !focused) {
465 node = seat_get_focus_inactive(seat, &cont->node);
466 seat_set_focus(seat, node);
467 }
468
469 // If moving a container by it's title bar, use a threshold for the drag
470 if (!mod_pressed && config->tiling_drag_threshold > 0) { 495 if (!mod_pressed && config->tiling_drag_threshold > 0) {
471 seatop_begin_move_tiling_threshold(seat, cont); 496 seatop_begin_move_tiling_threshold(seat, cont);
472 } else { 497 } else {
473 seatop_begin_move_tiling(seat, cont); 498 seatop_begin_move_tiling(seat, cont);
474 } 499 }
500
475 return; 501 return;
476 } 502 }
477 503
478 // Handle mousedown on a container surface 504 // Handle mousedown on a container surface
479 if (surface && cont && state == WLR_BUTTON_PRESSED) { 505 if (surface && cont && state == WL_POINTER_BUTTON_STATE_PRESSED) {
480 seat_set_focus_container(seat, cont); 506 seatop_begin_down(seat, cont, sx, sy);
481 seatop_begin_down(seat, cont, time_msec, sx, sy); 507 seat_pointer_notify_button(seat, time_msec, button, WL_POINTER_BUTTON_STATE_PRESSED);
482 seat_pointer_notify_button(seat, time_msec, button, WLR_BUTTON_PRESSED);
483 return; 508 return;
484 } 509 }
485 510
486 // Handle clicking a container surface or decorations 511 // Handle clicking a container surface or decorations
487 if (cont && state == WLR_BUTTON_PRESSED) { 512 if (cont && state == WL_POINTER_BUTTON_STATE_PRESSED) {
488 node = seat_get_focus_inactive(seat, &cont->node);
489 seat_set_focus(seat, node);
490 seat_pointer_notify_button(seat, time_msec, button, state); 513 seat_pointer_notify_button(seat, time_msec, button, state);
491 return; 514 return;
492 } 515 }
493 516
494#if HAVE_XWAYLAND 517#if HAVE_XWAYLAND
495 // Handle clicking on xwayland unmanaged view 518 // Handle clicking on xwayland unmanaged view
496 if (surface && wlr_surface_is_xwayland_surface(surface)) { 519 struct wlr_xwayland_surface *xsurface;
497 struct wlr_xwayland_surface *xsurface = 520 if (surface &&
498 wlr_xwayland_surface_from_wlr_surface(surface); 521 (xsurface = wlr_xwayland_surface_try_from_wlr_surface(surface)) &&
499 if (xsurface->override_redirect && 522 xsurface->override_redirect &&
500 wlr_xwayland_or_surface_wants_focus(xsurface)) { 523 wlr_xwayland_or_surface_wants_focus(xsurface)) {
501 struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland; 524 struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland;
502 wlr_xwayland_set_seat(xwayland, seat->wlr_seat); 525 wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
503 seat_set_focus_surface(seat, xsurface->surface, false); 526 seat_set_focus_surface(seat, xsurface->surface, false);
504 seat_pointer_notify_button(seat, time_msec, button, state); 527 transaction_commit_dirty();
505 return; 528 seat_pointer_notify_button(seat, time_msec, button, state);
506 }
507 } 529 }
508#endif 530#endif
509 531
@@ -526,10 +548,26 @@ static void check_focus_follows_mouse(struct sway_seat *seat,
526 if (wlr_output == NULL) { 548 if (wlr_output == NULL) {
527 return; 549 return;
528 } 550 }
551
552 struct wlr_surface *surface = NULL;
553 double sx, sy;
554 node_at_coords(seat, seat->cursor->cursor->x, seat->cursor->cursor->y,
555 &surface, &sx, &sy);
556
557 // Focus topmost layer surface
558 struct wlr_layer_surface_v1 *layer = NULL;
559 if ((layer = toplevel_layer_surface_from_surface(surface)) &&
560 layer->current.keyboard_interactive) {
561 seat_set_focus_layer(seat, layer);
562 transaction_commit_dirty();
563 return;
564 }
565
529 struct sway_output *hovered_output = wlr_output->data; 566 struct sway_output *hovered_output = wlr_output->data;
530 if (focus && hovered_output != node_get_output(focus)) { 567 if (focus && hovered_output != node_get_output(focus)) {
531 struct sway_workspace *ws = output_get_active_workspace(hovered_output); 568 struct sway_workspace *ws = output_get_active_workspace(hovered_output);
532 seat_set_focus(seat, &ws->node); 569 seat_set_focus(seat, &ws->node);
570 transaction_commit_dirty();
533 } 571 }
534 return; 572 return;
535 } 573 }
@@ -541,6 +579,7 @@ static void check_focus_follows_mouse(struct sway_seat *seat,
541 struct sway_output *hovered_output = node_get_output(hovered_node); 579 struct sway_output *hovered_output = node_get_output(hovered_node);
542 if (hovered_output != focused_output) { 580 if (hovered_output != focused_output) {
543 seat_set_focus(seat, seat_get_focus_inactive(seat, hovered_node)); 581 seat_set_focus(seat, seat_get_focus_inactive(seat, hovered_node));
582 transaction_commit_dirty();
544 } 583 }
545 return; 584 return;
546 } 585 }
@@ -556,6 +595,7 @@ static void check_focus_follows_mouse(struct sway_seat *seat,
556 if (hovered_node != e->previous_node || 595 if (hovered_node != e->previous_node ||
557 config->focus_follows_mouse == FOLLOWS_ALWAYS) { 596 config->focus_follows_mouse == FOLLOWS_ALWAYS) {
558 seat_set_focus(seat, hovered_node); 597 seat_set_focus(seat, hovered_node);
598 transaction_commit_dirty();
559 } 599 }
560 } 600 }
561} 601}
@@ -583,12 +623,7 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec) {
583 wlr_seat_pointer_notify_clear_focus(seat->wlr_seat); 623 wlr_seat_pointer_notify_clear_focus(seat->wlr_seat);
584 } 624 }
585 625
586 struct sway_drag_icon *drag_icon; 626 drag_icons_update_position(seat);
587 wl_list_for_each(drag_icon, &root->drag_icons, link) {
588 if (drag_icon->seat == seat) {
589 drag_icon_update_position(drag_icon);
590 }
591 }
592 627
593 e->previous_node = node; 628 e->previous_node = node;
594} 629}
@@ -618,25 +653,50 @@ static void handle_tablet_tool_motion(struct sway_seat *seat,
618 wlr_tablet_v2_tablet_tool_notify_proximity_out(tool->tablet_v2_tool); 653 wlr_tablet_v2_tablet_tool_notify_proximity_out(tool->tablet_v2_tool);
619 } 654 }
620 655
621 struct sway_drag_icon *drag_icon; 656 drag_icons_update_position(seat);
622 wl_list_for_each(drag_icon, &root->drag_icons, link) {
623 if (drag_icon->seat == seat) {
624 drag_icon_update_position(drag_icon);
625 }
626 }
627 657
628 e->previous_node = node; 658 e->previous_node = node;
629} 659}
630 660
661static void handle_touch_down(struct sway_seat *seat,
662 struct wlr_touch_down_event *event, double lx, double ly) {
663 struct wlr_surface *surface = NULL;
664 struct wlr_seat *wlr_seat = seat->wlr_seat;
665 struct sway_cursor *cursor = seat->cursor;
666 double sx, sy;
667 node_at_coords(seat, seat->touch_x, seat->touch_y, &surface, &sx, &sy);
668
669 if (surface && wlr_surface_accepts_touch(wlr_seat, surface)) {
670 if (seat_is_input_allowed(seat, surface)) {
671 cursor->simulating_pointer_from_touch = false;
672 seatop_begin_touch_down(seat, surface, event, sx, sy, lx, ly);
673 }
674 } else if (!cursor->simulating_pointer_from_touch &&
675 (!surface || seat_is_input_allowed(seat, surface))) {
676 // Fallback to cursor simulation.
677 // The pointer_touch_id state is needed, so drags are not aborted when over
678 // a surface supporting touch and multi touch events don't interfere.
679 cursor->simulating_pointer_from_touch = true;
680 cursor->pointer_touch_id = seat->touch_id;
681 double dx, dy;
682 dx = seat->touch_x - cursor->cursor->x;
683 dy = seat->touch_y - cursor->cursor->y;
684 pointer_motion(cursor, event->time_msec, &event->touch->base, dx, dy,
685 dx, dy);
686 dispatch_cursor_button(cursor, &event->touch->base, event->time_msec,
687 BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED);
688 }
689}
690
631/*----------------------------------------\ 691/*----------------------------------------\
632 * Functions used by handle_pointer_axis / 692 * Functions used by handle_pointer_axis /
633 *--------------------------------------*/ 693 *--------------------------------------*/
634 694
635static uint32_t wl_axis_to_button(struct wlr_event_pointer_axis *event) { 695static uint32_t wl_axis_to_button(struct wlr_pointer_axis_event *event) {
636 switch (event->orientation) { 696 switch (event->orientation) {
637 case WLR_AXIS_ORIENTATION_VERTICAL: 697 case WL_POINTER_AXIS_VERTICAL_SCROLL:
638 return event->delta < 0 ? SWAY_SCROLL_UP : SWAY_SCROLL_DOWN; 698 return event->delta < 0 ? SWAY_SCROLL_UP : SWAY_SCROLL_DOWN;
639 case WLR_AXIS_ORIENTATION_HORIZONTAL: 699 case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
640 return event->delta < 0 ? SWAY_SCROLL_LEFT : SWAY_SCROLL_RIGHT; 700 return event->delta < 0 ? SWAY_SCROLL_LEFT : SWAY_SCROLL_RIGHT;
641 default: 701 default:
642 sway_log(SWAY_DEBUG, "Unknown axis orientation"); 702 sway_log(SWAY_DEBUG, "Unknown axis orientation");
@@ -645,9 +705,9 @@ static uint32_t wl_axis_to_button(struct wlr_event_pointer_axis *event) {
645} 705}
646 706
647static void handle_pointer_axis(struct sway_seat *seat, 707static void handle_pointer_axis(struct sway_seat *seat,
648 struct wlr_event_pointer_axis *event) { 708 struct wlr_pointer_axis_event *event) {
649 struct sway_input_device *input_device = 709 struct sway_input_device *input_device =
650 event->device ? event->device->data : NULL; 710 event->pointer ? event->pointer->base.data : NULL;
651 struct input_config *ic = 711 struct input_config *ic =
652 input_device ? input_device_get_config(input_device) : NULL; 712 input_device ? input_device_get_config(input_device) : NULL;
653 struct sway_cursor *cursor = seat->cursor; 713 struct sway_cursor *cursor = seat->cursor;
@@ -664,7 +724,7 @@ static void handle_pointer_axis(struct sway_seat *seat,
664 bool on_border = edge != WLR_EDGE_NONE; 724 bool on_border = edge != WLR_EDGE_NONE;
665 bool on_titlebar = cont && !on_border && !surface; 725 bool on_titlebar = cont && !on_border && !surface;
666 bool on_titlebar_border = cont && on_border && 726 bool on_titlebar_border = cont && on_border &&
667 cursor->cursor->y < cont->content_y; 727 cursor->cursor->y < cont->pending.content_y;
668 bool on_contents = cont && !on_border && surface; 728 bool on_contents = cont && !on_border && surface;
669 bool on_workspace = node && node->type == N_WORKSPACE; 729 bool on_workspace = node && node->type == N_WORKSPACE;
670 float scroll_factor = 730 float scroll_factor =
@@ -693,6 +753,7 @@ static void handle_pointer_axis(struct sway_seat *seat,
693 753
694 // Scrolling on a tabbed or stacked title bar (handled as press event) 754 // Scrolling on a tabbed or stacked title bar (handled as press event)
695 if (!handled && (on_titlebar || on_titlebar_border)) { 755 if (!handled && (on_titlebar || on_titlebar_border)) {
756 struct sway_node *new_focus;
696 enum sway_container_layout layout = container_parent_layout(cont); 757 enum sway_container_layout layout = container_parent_layout(cont);
697 if (layout == L_TABBED || layout == L_STACKED) { 758 if (layout == L_TABBED || layout == L_STACKED) {
698 struct sway_node *tabcontainer = node_get_parent(node); 759 struct sway_node *tabcontainer = node_get_parent(node);
@@ -700,7 +761,7 @@ static void handle_pointer_axis(struct sway_seat *seat,
700 seat_get_active_tiling_child(seat, tabcontainer); 761 seat_get_active_tiling_child(seat, tabcontainer);
701 list_t *siblings = container_get_siblings(cont); 762 list_t *siblings = container_get_siblings(cont);
702 int desired = list_find(siblings, active->sway_container) + 763 int desired = list_find(siblings, active->sway_container) +
703 round(scroll_factor * event->delta_discrete); 764 roundf(scroll_factor * event->delta_discrete / WLR_POINTER_AXIS_DISCRETE_STEP);
704 if (desired < 0) { 765 if (desired < 0) {
705 desired = 0; 766 desired = 0;
706 } else if (desired >= siblings->length) { 767 } else if (desired >= siblings->length) {
@@ -709,13 +770,16 @@ static void handle_pointer_axis(struct sway_seat *seat,
709 770
710 struct sway_container *new_sibling_con = siblings->items[desired]; 771 struct sway_container *new_sibling_con = siblings->items[desired];
711 struct sway_node *new_sibling = &new_sibling_con->node; 772 struct sway_node *new_sibling = &new_sibling_con->node;
712 struct sway_node *new_focus =
713 seat_get_focus_inactive(seat, new_sibling);
714 // Use the focused child of the tabbed/stacked container, not the 773 // Use the focused child of the tabbed/stacked container, not the
715 // container the user scrolled on. 774 // container the user scrolled on.
716 seat_set_focus(seat, new_focus); 775 new_focus = seat_get_focus_inactive(seat, new_sibling);
717 handled = true; 776 } else {
777 new_focus = seat_get_focus_inactive(seat, &cont->node);
718 } 778 }
779
780 seat_set_focus(seat, new_focus);
781 transaction_commit_dirty();
782 handled = true;
719 } 783 }
720 784
721 // Handle mouse bindings - x11 mouse buttons 4-7 - release event 785 // Handle mouse bindings - x11 mouse buttons 4-7 - release event
@@ -731,8 +795,307 @@ static void handle_pointer_axis(struct sway_seat *seat,
731 795
732 if (!handled) { 796 if (!handled) {
733 wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec, 797 wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec,
734 event->orientation, scroll_factor * event->delta, 798 event->orientation, scroll_factor * event->delta,
735 round(scroll_factor * event->delta_discrete), event->source); 799 roundf(scroll_factor * event->delta_discrete), event->source,
800 event->relative_direction);
801 }
802}
803
804/*------------------------------------\
805 * Functions used by gesture support /
806 *----------------------------------*/
807
808/**
809 * Check gesture binding for a specific gesture type and finger count.
810 * Returns true if binding is present, false otherwise
811 */
812static bool gesture_binding_check(list_t *bindings, enum gesture_type type,
813 uint8_t fingers, struct sway_input_device *device) {
814 char *input =
815 device ? input_device_get_identifier(device->wlr_device) : strdup("*");
816
817 for (int i = 0; i < bindings->length; ++i) {
818 struct sway_gesture_binding *binding = bindings->items[i];
819
820 // Check type and finger count
821 if (!gesture_check(&binding->gesture, type, fingers)) {
822 continue;
823 }
824
825 // Check that input matches
826 if (strcmp(binding->input, "*") != 0 &&
827 strcmp(binding->input, input) != 0) {
828 continue;
829 }
830
831 free(input);
832
833 return true;
834 }
835
836 free(input);
837
838 return false;
839}
840
841/**
842 * Return the gesture binding which matches gesture type, finger count
843 * and direction, otherwise return null.
844 */
845static struct sway_gesture_binding* gesture_binding_match(
846 list_t *bindings, struct gesture *gesture, const char *input) {
847 struct sway_gesture_binding *current = NULL;
848
849 // Find best matching binding
850 for (int i = 0; i < bindings->length; ++i) {
851 struct sway_gesture_binding *binding = bindings->items[i];
852 bool exact = binding->flags & BINDING_EXACT;
853
854 // Check gesture matching
855 if (!gesture_match(&binding->gesture, gesture, exact)) {
856 continue;
857 }
858
859 // Check input matching
860 if (strcmp(binding->input, "*") != 0 &&
861 strcmp(binding->input, input) != 0) {
862 continue;
863 }
864
865 // If we already have a match ...
866 if (current) {
867 // ... check if input matching is equivalent
868 if (strcmp(current->input, binding->input) == 0) {
869
870 // ... - do not override an exact binding
871 if (!exact && current->flags & BINDING_EXACT) {
872 continue;
873 }
874
875 // ... - and ensure direction matching is better or equal
876 if (gesture_compare(&current->gesture, &binding->gesture) > 0) {
877 continue;
878 }
879 } else if (strcmp(binding->input, "*") == 0) {
880 // ... do not accept worse input match
881 continue;
882 }
883 }
884
885 // Accept newer or better match
886 current = binding;
887
888 // If exact binding and input is found, quit search
889 if (strcmp(current->input, input) == 0 &&
890 gesture_compare(&current->gesture, gesture) == 0) {
891 break;
892 }
893 } // for all gesture bindings
894
895 return current;
896}
897
898// Wrapper around gesture_tracker_end to use tracker with sway bindings
899static struct sway_gesture_binding* gesture_tracker_end_and_match(
900 struct gesture_tracker *tracker, struct sway_input_device* device) {
901 // Determine name of input that received gesture
902 char *input = device
903 ? input_device_get_identifier(device->wlr_device)
904 : strdup("*");
905
906 // Match tracking result to binding
907 struct gesture *gesture = gesture_tracker_end(tracker);
908 struct sway_gesture_binding *binding = gesture_binding_match(
909 config->current_mode->gesture_bindings, gesture, input);
910 free(gesture);
911 free(input);
912
913 return binding;
914}
915
916// Small wrapper around seat_execute_command to work on gesture bindings
917static void gesture_binding_execute(struct sway_seat *seat,
918 struct sway_gesture_binding *binding) {
919 struct sway_binding *dummy_binding =
920 calloc(1, sizeof(struct sway_binding));
921 dummy_binding->type = BINDING_GESTURE;
922 dummy_binding->command = binding->command;
923
924 char *description = gesture_to_string(&binding->gesture);
925 sway_log(SWAY_DEBUG, "executing gesture binding: %s", description);
926 free(description);
927
928 seat_execute_command(seat, dummy_binding);
929
930 free(dummy_binding);
931}
932
933static void handle_hold_begin(struct sway_seat *seat,
934 struct wlr_pointer_hold_begin_event *event) {
935 // Start tracking gesture if there is a matching binding ...
936 struct sway_input_device *device =
937 event->pointer ? event->pointer->base.data : NULL;
938 list_t *bindings = config->current_mode->gesture_bindings;
939 if (gesture_binding_check(bindings, GESTURE_TYPE_HOLD, event->fingers, device)) {
940 struct seatop_default_event *seatop = seat->seatop_data;
941 gesture_tracker_begin(&seatop->gestures, GESTURE_TYPE_HOLD, event->fingers);
942 } else {
943 // ... otherwise forward to client
944 struct sway_cursor *cursor = seat->cursor;
945 wlr_pointer_gestures_v1_send_hold_begin(
946 server.input->pointer_gestures, cursor->seat->wlr_seat,
947 event->time_msec, event->fingers);
948 }
949}
950
951static void handle_hold_end(struct sway_seat *seat,
952 struct wlr_pointer_hold_end_event *event) {
953 // Ensure that gesture is being tracked and was not cancelled
954 struct seatop_default_event *seatop = seat->seatop_data;
955 if (!gesture_tracker_check(&seatop->gestures, GESTURE_TYPE_HOLD)) {
956 struct sway_cursor *cursor = seat->cursor;
957 wlr_pointer_gestures_v1_send_hold_end(
958 server.input->pointer_gestures, cursor->seat->wlr_seat,
959 event->time_msec, event->cancelled);
960 return;
961 }
962 if (event->cancelled) {
963 gesture_tracker_cancel(&seatop->gestures);
964 return;
965 }
966
967 // End gesture tracking and execute matched binding
968 struct sway_input_device *device =
969 event->pointer ? event->pointer->base.data : NULL;
970 struct sway_gesture_binding *binding = gesture_tracker_end_and_match(
971 &seatop->gestures, device);
972
973 if (binding) {
974 gesture_binding_execute(seat, binding);
975 }
976}
977
978static void handle_pinch_begin(struct sway_seat *seat,
979 struct wlr_pointer_pinch_begin_event *event) {
980 // Start tracking gesture if there is a matching binding ...
981 struct sway_input_device *device =
982 event->pointer ? event->pointer->base.data : NULL;
983 list_t *bindings = config->current_mode->gesture_bindings;
984 if (gesture_binding_check(bindings, GESTURE_TYPE_PINCH, event->fingers, device)) {
985 struct seatop_default_event *seatop = seat->seatop_data;
986 gesture_tracker_begin(&seatop->gestures, GESTURE_TYPE_PINCH, event->fingers);
987 } else {
988 // ... otherwise forward to client
989 struct sway_cursor *cursor = seat->cursor;
990 wlr_pointer_gestures_v1_send_pinch_begin(
991 server.input->pointer_gestures, cursor->seat->wlr_seat,
992 event->time_msec, event->fingers);
993 }
994}
995
996static void handle_pinch_update(struct sway_seat *seat,
997 struct wlr_pointer_pinch_update_event *event) {
998 // Update any ongoing tracking ...
999 struct seatop_default_event *seatop = seat->seatop_data;
1000 if (gesture_tracker_check(&seatop->gestures, GESTURE_TYPE_PINCH)) {
1001 gesture_tracker_update(&seatop->gestures, event->dx, event->dy,
1002 event->scale, event->rotation);
1003 } else {
1004 // ... otherwise forward to client
1005 struct sway_cursor *cursor = seat->cursor;
1006 wlr_pointer_gestures_v1_send_pinch_update(
1007 server.input->pointer_gestures,
1008 cursor->seat->wlr_seat,
1009 event->time_msec, event->dx, event->dy,
1010 event->scale, event->rotation);
1011 }
1012}
1013
1014static void handle_pinch_end(struct sway_seat *seat,
1015 struct wlr_pointer_pinch_end_event *event) {
1016 // Ensure that gesture is being tracked and was not cancelled
1017 struct seatop_default_event *seatop = seat->seatop_data;
1018 if (!gesture_tracker_check(&seatop->gestures, GESTURE_TYPE_PINCH)) {
1019 struct sway_cursor *cursor = seat->cursor;
1020 wlr_pointer_gestures_v1_send_pinch_end(
1021 server.input->pointer_gestures, cursor->seat->wlr_seat,
1022 event->time_msec, event->cancelled);
1023 return;
1024 }
1025 if (event->cancelled) {
1026 gesture_tracker_cancel(&seatop->gestures);
1027 return;
1028 }
1029
1030 // End gesture tracking and execute matched binding
1031 struct sway_input_device *device =
1032 event->pointer ? event->pointer->base.data : NULL;
1033 struct sway_gesture_binding *binding = gesture_tracker_end_and_match(
1034 &seatop->gestures, device);
1035
1036 if (binding) {
1037 gesture_binding_execute(seat, binding);
1038 }
1039}
1040
1041static void handle_swipe_begin(struct sway_seat *seat,
1042 struct wlr_pointer_swipe_begin_event *event) {
1043 // Start tracking gesture if there is a matching binding ...
1044 struct sway_input_device *device =
1045 event->pointer ? event->pointer->base.data : NULL;
1046 list_t *bindings = config->current_mode->gesture_bindings;
1047 if (gesture_binding_check(bindings, GESTURE_TYPE_SWIPE, event->fingers, device)) {
1048 struct seatop_default_event *seatop = seat->seatop_data;
1049 gesture_tracker_begin(&seatop->gestures, GESTURE_TYPE_SWIPE, event->fingers);
1050 } else {
1051 // ... otherwise forward to client
1052 struct sway_cursor *cursor = seat->cursor;
1053 wlr_pointer_gestures_v1_send_swipe_begin(
1054 server.input->pointer_gestures, cursor->seat->wlr_seat,
1055 event->time_msec, event->fingers);
1056 }
1057}
1058
1059static void handle_swipe_update(struct sway_seat *seat,
1060 struct wlr_pointer_swipe_update_event *event) {
1061
1062 // Update any ongoing tracking ...
1063 struct seatop_default_event *seatop = seat->seatop_data;
1064 if (gesture_tracker_check(&seatop->gestures, GESTURE_TYPE_SWIPE)) {
1065 gesture_tracker_update(&seatop->gestures,
1066 event->dx, event->dy, NAN, NAN);
1067 } else {
1068 // ... otherwise forward to client
1069 struct sway_cursor *cursor = seat->cursor;
1070 wlr_pointer_gestures_v1_send_swipe_update(
1071 server.input->pointer_gestures, cursor->seat->wlr_seat,
1072 event->time_msec, event->dx, event->dy);
1073 }
1074}
1075
1076static void handle_swipe_end(struct sway_seat *seat,
1077 struct wlr_pointer_swipe_end_event *event) {
1078 // Ensure gesture is being tracked and was not cancelled
1079 struct seatop_default_event *seatop = seat->seatop_data;
1080 if (!gesture_tracker_check(&seatop->gestures, GESTURE_TYPE_SWIPE)) {
1081 struct sway_cursor *cursor = seat->cursor;
1082 wlr_pointer_gestures_v1_send_swipe_end(server.input->pointer_gestures,
1083 cursor->seat->wlr_seat, event->time_msec, event->cancelled);
1084 return;
1085 }
1086 if (event->cancelled) {
1087 gesture_tracker_cancel(&seatop->gestures);
1088 return;
1089 }
1090
1091 // End gesture tracking and execute matched binding
1092 struct sway_input_device *device =
1093 event->pointer ? event->pointer->base.data : NULL;
1094 struct sway_gesture_binding *binding = gesture_tracker_end_and_match(
1095 &seatop->gestures, device);
1096
1097 if (binding) {
1098 gesture_binding_execute(seat, binding);
736 } 1099 }
737} 1100}
738 1101
@@ -765,6 +1128,15 @@ static const struct sway_seatop_impl seatop_impl = {
765 .pointer_axis = handle_pointer_axis, 1128 .pointer_axis = handle_pointer_axis,
766 .tablet_tool_tip = handle_tablet_tool_tip, 1129 .tablet_tool_tip = handle_tablet_tool_tip,
767 .tablet_tool_motion = handle_tablet_tool_motion, 1130 .tablet_tool_motion = handle_tablet_tool_motion,
1131 .hold_begin = handle_hold_begin,
1132 .hold_end = handle_hold_end,
1133 .pinch_begin = handle_pinch_begin,
1134 .pinch_update = handle_pinch_update,
1135 .pinch_end = handle_pinch_end,
1136 .swipe_begin = handle_swipe_begin,
1137 .swipe_update = handle_swipe_update,
1138 .swipe_end = handle_swipe_end,
1139 .touch_down = handle_touch_down,
768 .rebase = handle_rebase, 1140 .rebase = handle_rebase,
769 .allow_set_cursor = true, 1141 .allow_set_cursor = true,
770}; 1142};
@@ -775,8 +1147,8 @@ void seatop_begin_default(struct sway_seat *seat) {
775 struct seatop_default_event *e = 1147 struct seatop_default_event *e =
776 calloc(1, sizeof(struct seatop_default_event)); 1148 calloc(1, sizeof(struct seatop_default_event));
777 sway_assert(e, "Unable to allocate seatop_default_event"); 1149 sway_assert(e, "Unable to allocate seatop_default_event");
1150
778 seat->seatop_impl = &seatop_impl; 1151 seat->seatop_impl = &seatop_impl;
779 seat->seatop_data = e; 1152 seat->seatop_data = e;
780
781 seatop_rebase(seat, 0); 1153 seatop_rebase(seat, 0);
782} 1154}