1 /* 2 * This an unstable interface of wlroots. No guarantees are made regarding the 3 * future consistency of this API. 4 */ 5 #ifndef WLR_USE_UNSTABLE 6 #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" 7 #endif 8 9 #ifndef WLR_TYPES_WLR_SEAT_H 10 #define WLR_TYPES_WLR_SEAT_H 11 12 #include <time.h> 13 #if defined(_C11_SOURCE) && defined(__FreeBSD__) && __FreeBSD__ < 12 14 #include <sys/_timespec.h> 15 #endif 16 #include <wayland-server-core.h> 17 #include <wlr/types/wlr_input_device.h> 18 #include <wlr/types/wlr_keyboard.h> 19 #include <wlr/types/wlr_surface.h> 20 21 #define WLR_SERIAL_RINGSET_SIZE 128 22 23 struct wlr_serial_range { 24 uint32_t min_incl; 25 uint32_t max_incl; 26 }; 27 struct wlr_serial_ringset { 28 struct wlr_serial_range data[WLR_SERIAL_RINGSET_SIZE]; 29 int end; 30 int count; 31 }; 32 33 /** 34 * Contains state for a single client's bound wl_seat resource and can be used 35 * to issue input events to that client. The lifetime of these objects is 36 * managed by wlr_seat; some may be NULL. 37 */ 38 struct wlr_seat_client { 39 struct wl_client *client; 40 struct wlr_seat *seat; 41 struct wl_list link; 42 43 // lists of wl_resource 44 struct wl_list resources; 45 struct wl_list pointers; 46 struct wl_list keyboards; 47 struct wl_list touches; 48 struct wl_list data_devices; 49 50 struct { 51 struct wl_signal destroy; 52 } events; 53 54 // set of serials which were sent to the client on this seat 55 // for use by wlr_seat_client_{next_serial,validate_event_serial} 56 struct wlr_serial_ringset serials; 57 }; 58 59 struct wlr_touch_point { 60 int32_t touch_id; 61 struct wlr_surface *surface; 62 struct wlr_seat_client *client; 63 64 struct wlr_surface *focus_surface; 65 struct wlr_seat_client *focus_client; 66 double sx, sy; 67 68 struct wl_listener surface_destroy; 69 struct wl_listener focus_surface_destroy; 70 struct wl_listener client_destroy; 71 72 struct { 73 struct wl_signal destroy; 74 } events; 75 76 struct wl_list link; 77 }; 78 79 struct wlr_seat_pointer_grab; 80 81 struct wlr_pointer_grab_interface { 82 void (*enter)(struct wlr_seat_pointer_grab *grab, 83 struct wlr_surface *surface, double sx, double sy); 84 void (*clear_focus)(struct wlr_seat_pointer_grab *grab); 85 void (*motion)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec, 86 double sx, double sy); 87 uint32_t (*button)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec, 88 uint32_t button, enum wlr_button_state state); 89 void (*axis)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec, 90 enum wlr_axis_orientation orientation, double value, 91 int32_t value_discrete, enum wlr_axis_source source); 92 void (*frame)(struct wlr_seat_pointer_grab *grab); 93 void (*cancel)(struct wlr_seat_pointer_grab *grab); 94 }; 95 96 struct wlr_seat_keyboard_grab; 97 98 struct wlr_keyboard_grab_interface { 99 void (*enter)(struct wlr_seat_keyboard_grab *grab, 100 struct wlr_surface *surface, uint32_t keycodes[], 101 size_t num_keycodes, struct wlr_keyboard_modifiers *modifiers); 102 void (*clear_focus)(struct wlr_seat_keyboard_grab *grab); 103 void (*key)(struct wlr_seat_keyboard_grab *grab, uint32_t time_msec, 104 uint32_t key, uint32_t state); 105 void (*modifiers)(struct wlr_seat_keyboard_grab *grab, 106 struct wlr_keyboard_modifiers *modifiers); 107 void (*cancel)(struct wlr_seat_keyboard_grab *grab); 108 }; 109 110 struct wlr_seat_touch_grab; 111 112 struct wlr_touch_grab_interface { 113 uint32_t (*down)(struct wlr_seat_touch_grab *grab, uint32_t time_msec, 114 struct wlr_touch_point *point); 115 void (*up)(struct wlr_seat_touch_grab *grab, uint32_t time_msec, 116 struct wlr_touch_point *point); 117 void (*motion)(struct wlr_seat_touch_grab *grab, uint32_t time_msec, 118 struct wlr_touch_point *point); 119 void (*enter)(struct wlr_seat_touch_grab *grab, uint32_t time_msec, 120 struct wlr_touch_point *point); 121 // XXX this will conflict with the actual touch cancel which is different so 122 // we need to rename this 123 void (*cancel)(struct wlr_seat_touch_grab *grab); 124 }; 125 126 /** 127 * Passed to `wlr_seat_touch_start_grab()` to start a grab of the touch device. 128 * The grabber is responsible for handling touch events for the seat. 129 */ 130 struct wlr_seat_touch_grab { 131 const struct wlr_touch_grab_interface *interface; 132 struct wlr_seat *seat; 133 void *data; 134 }; 135 136 /** 137 * Passed to `wlr_seat_keyboard_start_grab()` to start a grab of the keyboard. 138 * The grabber is responsible for handling keyboard events for the seat. 139 */ 140 struct wlr_seat_keyboard_grab { 141 const struct wlr_keyboard_grab_interface *interface; 142 struct wlr_seat *seat; 143 void *data; 144 }; 145 146 /** 147 * Passed to `wlr_seat_pointer_start_grab()` to start a grab of the pointer. The 148 * grabber is responsible for handling pointer events for the seat. 149 */ 150 struct wlr_seat_pointer_grab { 151 const struct wlr_pointer_grab_interface *interface; 152 struct wlr_seat *seat; 153 void *data; 154 }; 155 156 #define WLR_POINTER_BUTTONS_CAP 16 157 158 struct wlr_seat_pointer_state { 159 struct wlr_seat *seat; 160 struct wlr_seat_client *focused_client; 161 struct wlr_surface *focused_surface; 162 double sx, sy; 163 164 struct wlr_seat_pointer_grab *grab; 165 struct wlr_seat_pointer_grab *default_grab; 166 167 uint32_t buttons[WLR_POINTER_BUTTONS_CAP]; 168 size_t button_count; 169 uint32_t grab_button; 170 uint32_t grab_serial; 171 uint32_t grab_time; 172 173 struct wl_listener surface_destroy; 174 175 struct { 176 struct wl_signal focus_change; // wlr_seat_pointer_focus_change_event 177 } events; 178 }; 179 180 // TODO: May be useful to be able to simulate keyboard input events 181 struct wlr_seat_keyboard_state { 182 struct wlr_seat *seat; 183 struct wlr_keyboard *keyboard; 184 185 struct wlr_seat_client *focused_client; 186 struct wlr_surface *focused_surface; 187 188 struct wl_listener keyboard_destroy; 189 struct wl_listener keyboard_keymap; 190 struct wl_listener keyboard_repeat_info; 191 192 struct wl_listener surface_destroy; 193 194 struct wlr_seat_keyboard_grab *grab; 195 struct wlr_seat_keyboard_grab *default_grab; 196 197 struct { 198 struct wl_signal focus_change; // wlr_seat_keyboard_focus_change_event 199 } events; 200 }; 201 202 struct wlr_seat_touch_state { 203 struct wlr_seat *seat; 204 struct wl_list touch_points; // wlr_touch_point::link 205 206 uint32_t grab_serial; 207 uint32_t grab_id; 208 209 struct wlr_seat_touch_grab *grab; 210 struct wlr_seat_touch_grab *default_grab; 211 }; 212 213 struct wlr_primary_selection_source; 214 215 struct wlr_seat { 216 struct wl_global *global; 217 struct wl_display *display; 218 struct wl_list clients; 219 220 char *name; 221 uint32_t capabilities; 222 uint32_t accumulated_capabilities; 223 struct timespec last_event; 224 225 struct wlr_data_source *selection_source; 226 uint32_t selection_serial; 227 struct wl_list selection_offers; // wlr_data_offer::link 228 229 struct wlr_primary_selection_source *primary_selection_source; 230 uint32_t primary_selection_serial; 231 232 // `drag` goes away before `drag_source`, when the implicit grab ends 233 struct wlr_drag *drag; 234 struct wlr_data_source *drag_source; 235 uint32_t drag_serial; 236 struct wl_list drag_offers; // wlr_data_offer::link 237 238 struct wlr_seat_pointer_state pointer_state; 239 struct wlr_seat_keyboard_state keyboard_state; 240 struct wlr_seat_touch_state touch_state; 241 242 struct wl_listener display_destroy; 243 struct wl_listener selection_source_destroy; 244 struct wl_listener primary_selection_source_destroy; 245 struct wl_listener drag_source_destroy; 246 247 struct { 248 struct wl_signal pointer_grab_begin; 249 struct wl_signal pointer_grab_end; 250 251 struct wl_signal keyboard_grab_begin; 252 struct wl_signal keyboard_grab_end; 253 254 struct wl_signal touch_grab_begin; 255 struct wl_signal touch_grab_end; 256 257 // wlr_seat_pointer_request_set_cursor_event 258 struct wl_signal request_set_cursor; 259 260 // Called when an application _wants_ to set the selection (user copies some data). 261 // Compositors should listen to this event and call wlr_seat_set_selection 262 // if they want to accept the client's request. 263 struct wl_signal request_set_selection; // wlr_seat_request_set_selection_event 264 // Called after the data source is set for the selection. 265 struct wl_signal set_selection; 266 267 // Called when an application _wants_ to set the primary selection (user selects some data). 268 // Compositors should listen to this event and call wlr_seat_set_primary_selection 269 // if they want to accept the client's request. 270 struct wl_signal request_set_primary_selection; // wlr_seat_request_set_primary_selection_event 271 // Called after the primary selection source object is set. 272 struct wl_signal set_primary_selection; 273 274 // wlr_seat_request_start_drag_event 275 struct wl_signal request_start_drag; 276 struct wl_signal start_drag; // wlr_drag 277 278 struct wl_signal destroy; 279 } events; 280 281 void *data; 282 }; 283 284 struct wlr_seat_pointer_request_set_cursor_event { 285 struct wlr_seat_client *seat_client; 286 struct wlr_surface *surface; 287 uint32_t serial; 288 int32_t hotspot_x, hotspot_y; 289 }; 290 291 struct wlr_seat_request_set_selection_event { 292 struct wlr_data_source *source; 293 uint32_t serial; 294 }; 295 296 struct wlr_seat_request_set_primary_selection_event { 297 struct wlr_primary_selection_source *source; 298 uint32_t serial; 299 }; 300 301 struct wlr_seat_request_start_drag_event { 302 struct wlr_drag *drag; 303 struct wlr_surface *origin; 304 uint32_t serial; 305 }; 306 307 struct wlr_seat_pointer_focus_change_event { 308 struct wlr_seat *seat; 309 struct wlr_surface *old_surface, *new_surface; 310 double sx, sy; 311 }; 312 313 struct wlr_seat_keyboard_focus_change_event { 314 struct wlr_seat *seat; 315 struct wlr_surface *old_surface, *new_surface; 316 }; 317 318 /** 319 * Allocates a new wlr_seat and adds a wl_seat global to the display. 320 */ 321 struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name); 322 /** 323 * Destroys a wlr_seat and removes its wl_seat global. 324 */ 325 void wlr_seat_destroy(struct wlr_seat *wlr_seat); 326 /** 327 * Gets a wlr_seat_client for the specified client, or returns NULL if no 328 * client is bound for that client. 329 */ 330 struct wlr_seat_client *wlr_seat_client_for_wl_client(struct wlr_seat *wlr_seat, 331 struct wl_client *wl_client); 332 /** 333 * Updates the capabilities available on this seat. 334 * Will automatically send them to all clients. 335 */ 336 void wlr_seat_set_capabilities(struct wlr_seat *wlr_seat, 337 uint32_t capabilities); 338 /** 339 * Updates the name of this seat. 340 * Will automatically send it to all clients. 341 */ 342 void wlr_seat_set_name(struct wlr_seat *wlr_seat, const char *name); 343 344 /** 345 * Whether or not the surface has pointer focus 346 */ 347 bool wlr_seat_pointer_surface_has_focus(struct wlr_seat *wlr_seat, 348 struct wlr_surface *surface); 349 350 /** 351 * Send a pointer enter event to the given surface and consider it to be the 352 * focused surface for the pointer. This will send a leave event to the last 353 * surface that was entered. Coordinates for the enter event are surface-local. 354 * This function does not respect pointer grabs: you probably want 355 * `wlr_seat_pointer_notify_enter()` instead. 356 */ 357 void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat, 358 struct wlr_surface *surface, double sx, double sy); 359 360 /** 361 * Clear the focused surface for the pointer and leave all entered surfaces. 362 * This function does not respect pointer grabs: you probably want 363 * `wlr_seat_pointer_notify_clear_focus()` instead. 364 */ 365 void wlr_seat_pointer_clear_focus(struct wlr_seat *wlr_seat); 366 367 /** 368 * Send a motion event to the surface with pointer focus. Coordinates for the 369 * motion event are surface-local. This function does not respect pointer grabs: 370 * you probably want `wlr_seat_pointer_notify_motion()` instead. 371 */ 372 void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time_msec, 373 double sx, double sy); 374 375 /** 376 * Send a button event to the surface with pointer focus. Coordinates for the 377 * button event are surface-local. Returns the serial. This function does not 378 * respect pointer grabs: you probably want `wlr_seat_pointer_notify_button()` 379 * instead. 380 */ 381 uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, 382 uint32_t time_msec, uint32_t button, enum wlr_button_state state); 383 384 /** 385 * Send an axis event to the surface with pointer focus. This function does not 386 * respect pointer grabs: you probably want `wlr_seat_pointer_notify_axis()` 387 * instead. 388 */ 389 void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time_msec, 390 enum wlr_axis_orientation orientation, double value, 391 int32_t value_discrete, enum wlr_axis_source source); 392 393 /** 394 * Send a frame event to the surface with pointer focus. This function does not 395 * respect pointer grabs: you probably want `wlr_seat_pointer_notify_frame()` 396 * instead. 397 */ 398 void wlr_seat_pointer_send_frame(struct wlr_seat *wlr_seat); 399 400 /** 401 * Notify the seat of a pointer enter event to the given surface and request it 402 * to be the focused surface for the pointer. Pass surface-local coordinates 403 * where the enter occurred. This will send a leave event to the currently- 404 * focused surface. Defers to any grab of the pointer. 405 */ 406 void wlr_seat_pointer_notify_enter(struct wlr_seat *wlr_seat, 407 struct wlr_surface *surface, double sx, double sy); 408 409 /** 410 * Notify the seat of a pointer leave event to the currently-focused surface. 411 * Defers to any grab of the pointer. 412 */ 413 void wlr_seat_pointer_notify_clear_focus(struct wlr_seat *wlr_seat); 414 415 /** 416 * Warp the pointer of this seat to the given surface-local coordinates, without 417 * generating motion events. 418 */ 419 void wlr_seat_pointer_warp(struct wlr_seat *wlr_seat, double sx, double sy); 420 421 /** 422 * Notify the seat of motion over the given surface. Pass surface-local 423 * coordinates where the pointer motion occurred. Defers to any grab of the 424 * pointer. 425 */ 426 void wlr_seat_pointer_notify_motion(struct wlr_seat *wlr_seat, 427 uint32_t time_msec, double sx, double sy); 428 429 /** 430 * Notify the seat that a button has been pressed. Returns the serial of the 431 * button press or zero if no button press was sent. Defers to any grab of the 432 * pointer. 433 */ 434 uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat, 435 uint32_t time_msec, uint32_t button, enum wlr_button_state state); 436 437 /** 438 * Notify the seat of an axis event. Defers to any grab of the pointer. 439 */ 440 void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time_msec, 441 enum wlr_axis_orientation orientation, double value, 442 int32_t value_discrete, enum wlr_axis_source source); 443 444 /** 445 * Notify the seat of a frame event. Frame events are sent to end a group of 446 * events that logically belong together. Motion, button and axis events should 447 * all be followed by a frame event. Defers to any grab of the pointer. 448 */ 449 void wlr_seat_pointer_notify_frame(struct wlr_seat *wlr_seat); 450 451 /** 452 * Start a grab of the pointer of this seat. The grabber is responsible for 453 * handling all pointer events until the grab ends. 454 */ 455 void wlr_seat_pointer_start_grab(struct wlr_seat *wlr_seat, 456 struct wlr_seat_pointer_grab *grab); 457 458 /** 459 * End the grab of the pointer of this seat. This reverts the grab back to the 460 * default grab for the pointer. 461 */ 462 void wlr_seat_pointer_end_grab(struct wlr_seat *wlr_seat); 463 464 /** 465 * Whether or not the pointer has a grab other than the default grab. 466 */ 467 bool wlr_seat_pointer_has_grab(struct wlr_seat *seat); 468 469 /** 470 * Set this keyboard as the active keyboard for the seat. 471 */ 472 void wlr_seat_set_keyboard(struct wlr_seat *seat, struct wlr_input_device *dev); 473 474 /** 475 * Get the active keyboard for the seat. 476 */ 477 struct wlr_keyboard *wlr_seat_get_keyboard(struct wlr_seat *seat); 478 479 /** 480 * Send the keyboard key to focused keyboard resources. This function does not 481 * respect keyboard grabs: you probably want `wlr_seat_keyboard_notify_key()` 482 * instead. 483 */ 484 void wlr_seat_keyboard_send_key(struct wlr_seat *seat, uint32_t time_msec, 485 uint32_t key, uint32_t state); 486 487 /** 488 * Send the modifier state to focused keyboard resources. This function does 489 * not respect keyboard grabs: you probably want 490 * `wlr_seat_keyboard_notify_modifiers()` instead. 491 */ 492 void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat, 493 struct wlr_keyboard_modifiers *modifiers); 494 495 /** 496 * Send a keyboard enter event to the given surface and consider it to be the 497 * focused surface for the keyboard. This will send a leave event to the last 498 * surface that was entered. This function does not respect keyboard grabs: you 499 * probably want `wlr_seat_keyboard_notify_enter()` instead. 500 */ 501 void wlr_seat_keyboard_enter(struct wlr_seat *seat, 502 struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, 503 struct wlr_keyboard_modifiers *modifiers); 504 505 /** 506 * Clear the focused surface for the keyboard and leave all entered surfaces. 507 * This function does not respect keyboard grabs: you probably want 508 * `wlr_seat_keyboard_notify_clear_focus()` instead. 509 */ 510 void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat); 511 512 /** 513 * Notify the seat that a key has been pressed on the keyboard. Defers to any 514 * keyboard grabs. 515 */ 516 void wlr_seat_keyboard_notify_key(struct wlr_seat *seat, uint32_t time_msec, 517 uint32_t key, uint32_t state); 518 519 /** 520 * Notify the seat that the modifiers for the keyboard have changed. Defers to 521 * any keyboard grabs. 522 */ 523 void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat, 524 struct wlr_keyboard_modifiers *modifiers); 525 526 /** 527 * Notify the seat that the keyboard focus has changed and request it to be the 528 * focused surface for this keyboard. Defers to any current grab of the seat's 529 * keyboard. 530 */ 531 void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat, 532 struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, 533 struct wlr_keyboard_modifiers *modifiers); 534 535 /** 536 * Notify the seat of a keyboard leave event to the currently-focused surface. 537 * Defers to any keyboard grabs. 538 */ 539 void wlr_seat_keyboard_notify_clear_focus(struct wlr_seat *wlr_seat); 540 541 /** 542 * Start a grab of the keyboard of this seat. The grabber is responsible for 543 * handling all keyboard events until the grab ends. 544 */ 545 void wlr_seat_keyboard_start_grab(struct wlr_seat *wlr_seat, 546 struct wlr_seat_keyboard_grab *grab); 547 548 /** 549 * End the grab of the keyboard of this seat. This reverts the grab back to the 550 * default grab for the keyboard. 551 */ 552 void wlr_seat_keyboard_end_grab(struct wlr_seat *wlr_seat); 553 554 /** 555 * Whether or not the keyboard has a grab other than the default grab 556 */ 557 bool wlr_seat_keyboard_has_grab(struct wlr_seat *seat); 558 559 /** 560 * Get the active touch point with the given `touch_id`. If the touch point does 561 * not exist or is no longer active, returns NULL. 562 */ 563 struct wlr_touch_point *wlr_seat_touch_get_point(struct wlr_seat *seat, 564 int32_t touch_id); 565 566 /** 567 * Notify the seat that the touch point given by `touch_id` has entered a new 568 * surface. The surface is required. To clear focus, use 569 * `wlr_seat_touch_point_clear_focus()`. 570 */ 571 void wlr_seat_touch_point_focus(struct wlr_seat *seat, 572 struct wlr_surface *surface, uint32_t time_msec, 573 int32_t touch_id, double sx, double sy); 574 575 /** 576 * Clear the focused surface for the touch point given by `touch_id`. 577 */ 578 void wlr_seat_touch_point_clear_focus(struct wlr_seat *seat, uint32_t time_msec, 579 int32_t touch_id); 580 581 /** 582 * Send a touch down event to the client of the given surface. All future touch 583 * events for this point will go to this surface. If the touch down is valid, 584 * this will add a new touch point with the given `touch_id`. The touch down may 585 * not be valid if the surface seat client does not accept touch input. 586 * Coordinates are surface-local. This function does not respect touch grabs: 587 * you probably want `wlr_seat_touch_notify_down()` instead. 588 */ 589 uint32_t wlr_seat_touch_send_down(struct wlr_seat *seat, 590 struct wlr_surface *surface, uint32_t time_msec, 591 int32_t touch_id, double sx, double sy); 592 593 /** 594 * Send a touch up event for the touch point given by the `touch_id`. The event 595 * will go to the client for the surface given in the corresponding touch down 596 * event. This will remove the touch point. This function does not respect touch 597 * grabs: you probably want `wlr_seat_touch_notify_up()` instead. 598 */ 599 void wlr_seat_touch_send_up(struct wlr_seat *seat, uint32_t time_msec, 600 int32_t touch_id); 601 602 /** 603 * Send a touch motion event for the touch point given by the `touch_id`. The 604 * event will go to the client for the surface given in the corresponding touch 605 * down event. This function does not respect touch grabs: you probably want 606 * `wlr_seat_touch_notify_motion()` instead. 607 */ 608 void wlr_seat_touch_send_motion(struct wlr_seat *seat, uint32_t time_msec, 609 int32_t touch_id, double sx, double sy); 610 611 /** 612 * Notify the seat of a touch down on the given surface. Defers to any grab of 613 * the touch device. 614 */ 615 uint32_t wlr_seat_touch_notify_down(struct wlr_seat *seat, 616 struct wlr_surface *surface, uint32_t time_msec, 617 int32_t touch_id, double sx, double sy); 618 619 /** 620 * Notify the seat that the touch point given by `touch_id` is up. Defers to any 621 * grab of the touch device. 622 */ 623 void wlr_seat_touch_notify_up(struct wlr_seat *seat, uint32_t time_msec, 624 int32_t touch_id); 625 626 /** 627 * Notify the seat that the touch point given by `touch_id` has moved. Defers to 628 * any grab of the touch device. The seat should be notified of touch motion 629 * even if the surface is not the owner of the touch point for processing by 630 * grabs. 631 */ 632 void wlr_seat_touch_notify_motion(struct wlr_seat *seat, uint32_t time_msec, 633 int32_t touch_id, double sx, double sy); 634 635 /** 636 * How many touch points are currently down for the seat. 637 */ 638 int wlr_seat_touch_num_points(struct wlr_seat *seat); 639 640 /** 641 * Start a grab of the touch device of this seat. The grabber is responsible for 642 * handling all touch events until the grab ends. 643 */ 644 void wlr_seat_touch_start_grab(struct wlr_seat *wlr_seat, 645 struct wlr_seat_touch_grab *grab); 646 647 /** 648 * End the grab of the touch device of this seat. This reverts the grab back to 649 * the default grab for the touch device. 650 */ 651 void wlr_seat_touch_end_grab(struct wlr_seat *wlr_seat); 652 653 /** 654 * Whether or not the seat has a touch grab other than the default grab. 655 */ 656 bool wlr_seat_touch_has_grab(struct wlr_seat *seat); 657 658 /** 659 * Check whether this serial is valid to start a grab action such as an 660 * interactive move or resize. 661 */ 662 bool wlr_seat_validate_grab_serial(struct wlr_seat *seat, uint32_t serial); 663 664 /** 665 * Check whether this serial is valid to start a pointer grab action. 666 */ 667 bool wlr_seat_validate_pointer_grab_serial(struct wlr_seat *seat, 668 struct wlr_surface *origin, uint32_t serial); 669 670 /** 671 * Check whether this serial is valid to start a touch grab action. If it's the 672 * case and point_ptr is non-NULL, *point_ptr is set to the touch point matching 673 * the serial. 674 */ 675 bool wlr_seat_validate_touch_grab_serial(struct wlr_seat *seat, 676 struct wlr_surface *origin, uint32_t serial, 677 struct wlr_touch_point **point_ptr); 678 679 /** 680 * Return a new serial (from wl_display_serial_next()) for the client, and 681 * update the seat client's set of valid serials. Use this for all input 682 * events; otherwise wlr_seat_client_validate_event_serial() may fail when 683 * handed a correctly functioning client's request serials. 684 */ 685 uint32_t wlr_seat_client_next_serial(struct wlr_seat_client *client); 686 687 /** 688 * Return true if the serial number could have been produced by 689 * wlr_seat_client_next_serial() and is "older" (by less than UINT32_MAX/2) than 690 * the current display serial value. 691 * 692 * This function should have no false negatives, and the only false positive 693 * responses allowed are for elements that are still "older" than the current 694 * display serial value and also older than all serial values remaining in 695 * the seat client's serial ring buffer, if that buffer is also full. 696 */ 697 bool wlr_seat_client_validate_event_serial(struct wlr_seat_client *client, 698 uint32_t serial); 699 700 /** 701 * Get a seat client from a seat resource. Returns NULL if inert. 702 */ 703 struct wlr_seat_client *wlr_seat_client_from_resource( 704 struct wl_resource *resource); 705 706 /** 707 * Get a seat client from a pointer resource. Returns NULL if inert. 708 */ 709 struct wlr_seat_client *wlr_seat_client_from_pointer_resource( 710 struct wl_resource *resource); 711 712 /** 713 * Check whether a surface has bound to touch events. 714 */ 715 bool wlr_surface_accepts_touch(struct wlr_seat *wlr_seat, struct wlr_surface *surface); 716 717 #endif 718