1 /* 2 * Copyright © 2008-2011 Kristian Høgsberg 3 * Copyright © 2012, 2017, 2018 Collabora, Ltd. 4 * Copyright © 2017, 2018 General Electric Company 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining 7 * a copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sublicense, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial 16 * portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 * SOFTWARE. 26 */ 27 #define LOG_TAG "WAYLAND_SERVER" // OHOS logcat 28 29 #ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_ 30 #define _WAYLAND_SYSTEM_COMPOSITOR_H_ 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #include <stdbool.h> 37 #include <stdint.h> 38 #include <time.h> 39 #include <pixman.h> 40 #include <hilog/log.h> // OHOS hilog 41 #include <xkbcommon/xkbcommon.h> 42 43 #define WL_HIDE_DEPRECATED 44 #include <wayland-server.h> 45 46 #include <libweston/matrix.h> 47 #include <libweston/zalloc.h> 48 49 struct weston_geometry { 50 int32_t x, y; 51 int32_t width, height; 52 }; 53 54 struct weston_position { 55 int32_t x, y; 56 }; 57 58 struct weston_size { 59 int32_t width, height; 60 }; 61 62 struct weston_transform { 63 struct weston_matrix matrix; 64 struct wl_list link; 65 }; 66 67 /** 2D device coordinates normalized to [0, 1] range */ 68 struct weston_point2d_device_normalized { 69 double x; 70 double y; 71 }; 72 73 struct weston_surface; 74 struct weston_buffer; 75 struct shell_surface; 76 struct weston_seat; 77 struct weston_output; 78 struct input_method; 79 struct weston_pointer; 80 struct linux_dmabuf_buffer; 81 struct weston_recorder; 82 struct weston_pointer_constraint; 83 struct ro_anonymous_file; 84 85 enum weston_keyboard_modifier { 86 MODIFIER_CTRL = (1 << 0), 87 MODIFIER_ALT = (1 << 1), 88 MODIFIER_SUPER = (1 << 2), 89 MODIFIER_SHIFT = (1 << 3), 90 }; 91 92 enum weston_keyboard_locks { 93 WESTON_NUM_LOCK = (1 << 0), 94 WESTON_CAPS_LOCK = (1 << 1), 95 }; 96 97 enum weston_led { 98 LED_NUM_LOCK = (1 << 0), 99 LED_CAPS_LOCK = (1 << 1), 100 LED_SCROLL_LOCK = (1 << 2), 101 }; 102 103 enum weston_mode_aspect_ratio { 104 /** The picture aspect ratio values, for the aspect_ratio field of 105 * weston_mode. The values here, are taken from 106 * DRM_MODE_PICTURE_ASPECT_* from drm_mode.h. 107 */ 108 WESTON_MODE_PIC_AR_NONE = 0, /* DRM_MODE_PICTURE_ASPECT_NONE */ 109 WESTON_MODE_PIC_AR_4_3 = 1, /* DRM_MODE_PICTURE_ASPECT_4_3 */ 110 WESTON_MODE_PIC_AR_16_9 = 2, /* DRM_MODE_PICTURE_ASPECT_16_9 */ 111 WESTON_MODE_PIC_AR_64_27 = 3, /* DRM_MODE_PICTURE_ASPECT_64_27 */ 112 WESTON_MODE_PIC_AR_256_135 = 4, /* DRM_MODE_PICTURE_ASPECT_256_135*/ 113 }; 114 115 enum weston_surface_protection_mode { 116 WESTON_SURFACE_PROTECTION_MODE_RELAXED, 117 WESTON_SURFACE_PROTECTION_MODE_ENFORCED 118 }; 119 120 struct weston_mode { 121 uint32_t flags; 122 enum weston_mode_aspect_ratio aspect_ratio; 123 int32_t width, height; 124 uint32_t refresh; 125 struct wl_list link; 126 }; 127 128 struct weston_animation { 129 void (*frame)(struct weston_animation *animation, 130 struct weston_output *output, 131 const struct timespec *time); 132 int frame_counter; 133 struct wl_list link; 134 }; 135 136 enum { 137 WESTON_SPRING_OVERSHOOT, 138 WESTON_SPRING_CLAMP, 139 WESTON_SPRING_BOUNCE 140 }; 141 142 struct weston_spring { 143 double k; 144 double friction; 145 double current; 146 double target; 147 double previous; 148 double min, max; 149 struct timespec timestamp; 150 uint32_t clip; 151 }; 152 153 struct weston_output_zoom { 154 bool active; 155 float increment; 156 float level; 157 float max_level; 158 float trans_x, trans_y; 159 struct { 160 double x, y; 161 } current; 162 struct weston_seat *seat; 163 struct weston_animation animation_z; 164 struct weston_spring spring_z; 165 struct wl_listener motion_listener; 166 }; 167 168 /* bit compatible with drm definitions. */ 169 enum dpms_enum { 170 WESTON_DPMS_ON, 171 WESTON_DPMS_STANDBY, 172 WESTON_DPMS_SUSPEND, 173 WESTON_DPMS_OFF 174 }; 175 176 /* enum for content protection requests/status 177 * 178 * This enum represents the content protection requests and statuses in 179 * libweston and its enum values correspond to those of 'type' enum defined in 180 * weston-content-protection protocol. The values should exactly match to the 181 * values of the 'type' enum of the protocol. 182 */ 183 184 enum weston_hdcp_protection { 185 WESTON_HDCP_DISABLE = 0, 186 WESTON_HDCP_ENABLE_TYPE_0, 187 WESTON_HDCP_ENABLE_TYPE_1 188 }; 189 190 /** Represents a head, usually a display connector 191 * 192 * \rst 193 See :ref:`libweston-head`. \endrst 194 * 195 * \ingroup head 196 */ 197 struct weston_head { 198 struct weston_compositor *compositor; /**< owning compositor */ 199 struct wl_list compositor_link; /**< in weston_compositor::head_list */ 200 struct wl_signal destroy_signal; /**< destroy callbacks */ 201 202 struct weston_output *output; /**< the output driving this head */ 203 struct wl_list output_link; /**< in weston_output::head_list */ 204 205 struct wl_list resource_list; /**< wl_output protocol objects */ 206 struct wl_global *global; /**< wl_output global */ 207 208 struct wl_list xdg_output_resource_list; /**< xdg_output protocol objects */ 209 210 int32_t mm_width; /**< physical image width in mm */ 211 int32_t mm_height; /**< physical image height in mm */ 212 213 /** WL_OUTPUT_TRANSFORM enum to apply to match native orientation */ 214 uint32_t transform; 215 216 char *make; /**< monitor manufacturer (PNP ID) */ 217 char *model; /**< monitor model */ 218 char *serial_number; /**< monitor serial */ 219 uint32_t subpixel; /**< enum wl_output_subpixel */ 220 bool connection_internal; /**< embedded monitor (e.g. laptop) */ 221 bool device_changed; /**< monitor information has changed */ 222 223 char *name; /**< head name, e.g. connector name */ 224 bool connected; /**< is physically connected */ 225 bool non_desktop; /**< non-desktop display, e.g. HMD */ 226 227 /** Current content protection status */ 228 enum weston_hdcp_protection current_protection; 229 }; 230 231 /** Content producer for heads 232 * 233 * \rst 234 See :ref:`libweston-output`. \endrst 235 * 236 * \ingroup output 237 */ 238 struct weston_output { 239 uint32_t id; 240 char *name; 241 242 /** Matches the lifetime from the user perspective */ 243 struct wl_signal user_destroy_signal; 244 245 void *renderer_state; 246 247 struct wl_list link; 248 struct weston_compositor *compositor; 249 250 /** From global to output buffer coordinates. */ 251 struct weston_matrix matrix; 252 /** From output buffer to global coordinates. */ 253 struct weston_matrix inverse_matrix; 254 255 struct wl_list animation_list; 256 int32_t x, y, width, height; 257 258 /** Output area in global coordinates, simple rect */ 259 pixman_region32_t region; 260 261 /** True if damage has occurred since the last repaint for this output; 262 * if set, a repaint will eventually occur. */ 263 bool repaint_needed; 264 265 /** Used only between repaint_begin and repaint_cancel. */ 266 bool repainted; 267 268 /** State of the repaint loop */ 269 enum { 270 REPAINT_NOT_SCHEDULED = 0, /**< idle; no repaint will occur */ 271 REPAINT_BEGIN_FROM_IDLE, /**< start_repaint_loop scheduled */ 272 REPAINT_SCHEDULED, /**< repaint is scheduled to occur */ 273 REPAINT_AWAITING_COMPLETION, /**< last repaint not yet finished */ 274 } repaint_status; 275 276 /** If repaint_status is REPAINT_SCHEDULED, contains the time the 277 * next repaint should be run */ 278 struct timespec next_repaint; 279 280 /** For cancelling the idle_repaint callback on output destruction. */ 281 struct wl_event_source *idle_repaint_source; 282 283 struct weston_output_zoom zoom; 284 int dirty; 285 struct wl_signal frame_signal; 286 struct wl_signal destroy_signal; /**< sent when disabled */ 287 int move_x, move_y; 288 struct timespec frame_time; /* presentation timestamp */ 289 uint64_t msc; /* media stream counter */ 290 int disable_planes; 291 int destroying; 292 struct wl_list feedback_list; 293 294 uint32_t transform; 295 int32_t native_scale; 296 int32_t current_scale; 297 int32_t original_scale; 298 299 struct weston_mode *native_mode; 300 struct weston_mode *current_mode; 301 struct weston_mode *original_mode; 302 struct wl_list mode_list; 303 304 struct wl_list head_list; /**< List of driven weston_heads */ 305 306 enum weston_hdcp_protection desired_protection; 307 enum weston_hdcp_protection current_protection; 308 bool allow_protection; 309 310 int (*start_repaint_loop)(struct weston_output *output); 311 int (*repaint)(struct weston_output *output, 312 pixman_region32_t *damage, 313 void *repaint_data); 314 void (*destroy)(struct weston_output *output); 315 void (*assign_planes)(struct weston_output *output, void *repaint_data); 316 int (*switch_mode)(struct weston_output *output, struct weston_mode *mode); 317 318 /* backlight values are on 0-255 range, where higher is brighter */ 319 int32_t backlight_current; 320 void (*set_backlight)(struct weston_output *output, uint32_t value); 321 void (*set_dpms)(struct weston_output *output, enum dpms_enum level); 322 323 uint16_t gamma_size; 324 void (*set_gamma)(struct weston_output *output, 325 uint16_t size, 326 uint16_t *r, 327 uint16_t *g, 328 uint16_t *b); 329 330 bool enabled; /**< is in the output_list, not pending list */ 331 int scale; 332 333 int (*enable)(struct weston_output *output); 334 int (*disable)(struct weston_output *output); 335 336 /** Attach a head in the backend 337 * 338 * @param output The output to attach to. 339 * @param head The head to attach. 340 * @return 0 on success, -1 on failure. 341 * 342 * Do anything necessary to account for a new head being attached to 343 * the output, and check any conditions possible. On failure, both 344 * the head and the output must be left as before the call. 345 * 346 * Libweston core will add the head to the head_list after a successful 347 * call. 348 */ 349 int (*attach_head)(struct weston_output *output, 350 struct weston_head *head); 351 352 /** Detach a head in the backend 353 * 354 * @param output The output to detach from. 355 * @param head The head to detach. 356 * 357 * Do any clean-up necessary to detach this head from the output. 358 * The head has already been removed from the output's head_list. 359 */ 360 void (*detach_head)(struct weston_output *output, 361 struct weston_head *head); 362 }; 363 364 enum weston_pointer_motion_mask { 365 WESTON_POINTER_MOTION_ABS = 1 << 0, 366 WESTON_POINTER_MOTION_REL = 1 << 1, 367 WESTON_POINTER_MOTION_REL_UNACCEL = 1 << 2, 368 }; 369 370 struct weston_pointer_motion_event { 371 uint32_t mask; 372 struct timespec time; 373 double x; 374 double y; 375 double dx; 376 double dy; 377 double dx_unaccel; 378 double dy_unaccel; 379 }; 380 381 struct weston_pointer_axis_event { 382 uint32_t axis; 383 double value; 384 bool has_discrete; 385 int32_t discrete; 386 }; 387 388 struct weston_pointer_grab; 389 struct weston_pointer_grab_interface { 390 void (*focus)(struct weston_pointer_grab *grab); 391 void (*motion)(struct weston_pointer_grab *grab, 392 const struct timespec *time, 393 struct weston_pointer_motion_event *event); 394 void (*button)(struct weston_pointer_grab *grab, 395 const struct timespec *time, 396 uint32_t button, uint32_t state); 397 void (*axis)(struct weston_pointer_grab *grab, 398 const struct timespec *time, 399 struct weston_pointer_axis_event *event); 400 void (*axis_source)(struct weston_pointer_grab *grab, uint32_t source); 401 void (*frame)(struct weston_pointer_grab *grab); 402 void (*cancel)(struct weston_pointer_grab *grab); 403 }; 404 405 struct weston_pointer_grab { 406 const struct weston_pointer_grab_interface *interface; 407 struct weston_pointer *pointer; 408 }; 409 410 struct weston_keyboard_grab; 411 struct weston_keyboard_grab_interface { 412 void (*key)(struct weston_keyboard_grab *grab, 413 const struct timespec *time, uint32_t key, uint32_t state); 414 void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial, 415 uint32_t mods_depressed, uint32_t mods_latched, 416 uint32_t mods_locked, uint32_t group); 417 void (*cancel)(struct weston_keyboard_grab *grab); 418 }; 419 420 struct weston_keyboard_grab { 421 const struct weston_keyboard_grab_interface *interface; 422 struct weston_keyboard *keyboard; 423 }; 424 425 struct weston_touch_grab; 426 struct weston_touch_grab_interface { 427 void (*down)(struct weston_touch_grab *grab, 428 const struct timespec *time, 429 int touch_id, 430 wl_fixed_t sx, 431 wl_fixed_t sy); 432 void (*up)(struct weston_touch_grab *grab, 433 const struct timespec *time, 434 int touch_id); 435 void (*motion)(struct weston_touch_grab *grab, 436 const struct timespec *time, 437 int touch_id, 438 wl_fixed_t sx, 439 wl_fixed_t sy); 440 void (*frame)(struct weston_touch_grab *grab); 441 void (*cancel)(struct weston_touch_grab *grab); 442 }; 443 444 struct weston_touch_grab { 445 const struct weston_touch_grab_interface *interface; 446 struct weston_touch *touch; 447 }; 448 449 struct weston_data_offer { 450 struct wl_resource *resource; 451 struct weston_data_source *source; 452 struct wl_listener source_destroy_listener; 453 uint32_t dnd_actions; 454 enum wl_data_device_manager_dnd_action preferred_dnd_action; 455 bool in_ask; 456 }; 457 458 struct weston_data_source { 459 struct wl_resource *resource; 460 struct wl_signal destroy_signal; 461 struct wl_array mime_types; 462 struct weston_data_offer *offer; 463 struct weston_seat *seat; 464 bool accepted; 465 bool actions_set; 466 bool set_selection; 467 uint32_t dnd_actions; 468 enum wl_data_device_manager_dnd_action current_dnd_action; 469 enum wl_data_device_manager_dnd_action compositor_action; 470 471 void (*accept)(struct weston_data_source *source, 472 uint32_t serial, const char *mime_type); 473 void (*send)(struct weston_data_source *source, 474 const char *mime_type, int32_t fd); 475 void (*cancel)(struct weston_data_source *source); 476 }; 477 478 struct weston_pointer_client { 479 struct wl_list link; 480 struct wl_client *client; 481 struct wl_list pointer_resources; 482 struct wl_list relative_pointer_resources; 483 }; 484 485 struct weston_pointer { 486 struct weston_seat *seat; 487 488 struct wl_list pointer_clients; 489 490 struct weston_view *focus; 491 struct weston_pointer_client *focus_client; 492 uint32_t focus_serial; 493 struct wl_listener focus_view_listener; 494 struct wl_listener focus_resource_listener; 495 struct wl_signal focus_signal; 496 struct wl_signal motion_signal; 497 struct wl_signal destroy_signal; 498 499 struct weston_view *sprite; 500 struct wl_listener sprite_destroy_listener; 501 int32_t hotspot_x, hotspot_y; 502 503 struct weston_pointer_grab *grab; 504 struct weston_pointer_grab default_grab; 505 wl_fixed_t grab_x, grab_y; 506 uint32_t grab_button; 507 uint32_t grab_serial; 508 struct timespec grab_time; 509 510 wl_fixed_t x, y; 511 wl_fixed_t sx, sy; 512 uint32_t button_count; 513 514 struct wl_listener output_destroy_listener; 515 516 struct wl_list timestamps_list; 517 }; 518 519 /** libinput style calibration matrix 520 * 521 * See https://wayland.freedesktop.org/libinput/doc/latest/absolute_axes.html 522 * and libinput_device_config_calibration_set_matrix(). 523 */ 524 struct weston_touch_device_matrix { 525 float m[6]; 526 }; 527 528 struct weston_touch_device; 529 530 /** Operations for a calibratable touchscreen */ 531 struct weston_touch_device_ops { 532 /** Get the associated output if existing. */ 533 struct weston_output *(*get_output)(struct weston_touch_device *device); 534 535 /** Get the name of the associated head if existing. */ 536 const char * 537 (*get_calibration_head_name)(struct weston_touch_device *device); 538 539 /** Retrieve the current calibration matrix. */ 540 void (*get_calibration)(struct weston_touch_device *device, 541 struct weston_touch_device_matrix *cal); 542 543 /** Set a new calibration matrix. */ 544 void (*set_calibration)(struct weston_touch_device *device, 545 const struct weston_touch_device_matrix *cal); 546 }; 547 548 enum weston_touch_mode { 549 /** Normal touch event handling */ 550 WESTON_TOUCH_MODE_NORMAL, 551 552 /** Prepare moving to WESTON_TOUCH_MODE_CALIB. 553 * 554 * Move to WESTON_TOUCH_MODE_CALIB as soon as no touches are down on 555 * any seat. Until then, all touch events are routed normally. 556 */ 557 WESTON_TOUCH_MODE_PREP_CALIB, 558 559 /** Calibration mode 560 * 561 * Only a single weston_touch_device forwards events to the calibrator 562 * all other touch device cause a calibrator "wrong device" event to 563 * be sent. 564 */ 565 WESTON_TOUCH_MODE_CALIB, 566 567 /** Prepare moving to WESTON_TOUCH_MODE_NORMAL. 568 * 569 * Move to WESTON_TOUCH_MODE_NORMAL as soon as no touches are down on 570 * any seat. Until then, touch events are routed as in 571 * WESTON_TOUCH_MODE_CALIB except "wrong device" events are not sent. 572 */ 573 WESTON_TOUCH_MODE_PREP_NORMAL 574 }; 575 576 /** Represents a physical touchscreen input device */ 577 struct weston_touch_device { 578 char *syspath; /**< unique name */ 579 580 struct weston_touch *aggregate; /**< weston_touch this is part of */ 581 struct wl_list link; /**< in weston_touch::device_list */ 582 struct wl_signal destroy_signal; /**< destroy notifier */ 583 584 void *backend_data; /**< backend-specific private */ 585 586 const struct weston_touch_device_ops *ops; 587 struct weston_touch_device_matrix saved_calibration; 588 }; 589 590 /** Represents a set of touchscreen devices aggregated under a seat */ 591 struct weston_touch { 592 struct weston_seat *seat; 593 594 struct wl_list device_list; /* struct weston_touch_device::link */ 595 596 struct wl_list resource_list; 597 struct wl_list focus_resource_list; 598 struct weston_view *focus; 599 struct wl_listener focus_view_listener; 600 struct wl_listener focus_resource_listener; 601 uint32_t focus_serial; 602 struct wl_signal focus_signal; 603 604 uint32_t num_tp; 605 606 struct weston_touch_grab *grab; 607 struct weston_touch_grab default_grab; 608 int grab_touch_id; 609 wl_fixed_t grab_x, grab_y; 610 uint32_t grab_serial; 611 struct timespec grab_time; 612 613 struct wl_list timestamps_list; 614 }; 615 616 void 617 weston_pointer_motion_to_abs(struct weston_pointer *pointer, 618 struct weston_pointer_motion_event *event, 619 wl_fixed_t *x, wl_fixed_t *y); 620 621 void 622 weston_pointer_send_motion(struct weston_pointer *pointer, 623 const struct timespec *time, 624 struct weston_pointer_motion_event *event); 625 bool 626 weston_pointer_has_focus_resource(struct weston_pointer *pointer); 627 void 628 weston_pointer_send_button(struct weston_pointer *pointer, 629 const struct timespec *time, 630 uint32_t button, uint32_t state_w); 631 void 632 weston_pointer_send_axis(struct weston_pointer *pointer, 633 const struct timespec *time, 634 struct weston_pointer_axis_event *event); 635 void 636 weston_pointer_send_axis_source(struct weston_pointer *pointer, 637 uint32_t source); 638 void 639 weston_pointer_send_frame(struct weston_pointer *pointer); 640 641 void 642 weston_pointer_set_focus(struct weston_pointer *pointer, 643 struct weston_view *view, 644 wl_fixed_t sx, wl_fixed_t sy); 645 void 646 weston_pointer_clear_focus(struct weston_pointer *pointer); 647 void 648 weston_pointer_start_grab(struct weston_pointer *pointer, 649 struct weston_pointer_grab *grab); 650 void 651 weston_pointer_end_grab(struct weston_pointer *pointer); 652 void 653 weston_pointer_move(struct weston_pointer *pointer, 654 struct weston_pointer_motion_event *event); 655 void 656 weston_keyboard_set_focus(struct weston_keyboard *keyboard, 657 struct weston_surface *surface); 658 void 659 weston_keyboard_start_grab(struct weston_keyboard *device, 660 struct weston_keyboard_grab *grab); 661 void 662 weston_keyboard_end_grab(struct weston_keyboard *keyboard); 663 int 664 /* 665 * 'mask' and 'value' should be a bitwise mask of one or more 666 * valued of the weston_keyboard_locks enum. 667 */ 668 weston_keyboard_set_locks(struct weston_keyboard *keyboard, 669 uint32_t mask, uint32_t value); 670 671 void 672 weston_keyboard_send_key(struct weston_keyboard *keyboard, 673 const struct timespec *time, uint32_t key, 674 enum wl_keyboard_key_state state); 675 void 676 weston_keyboard_send_modifiers(struct weston_keyboard *keyboard, 677 uint32_t serial, uint32_t mods_depressed, 678 uint32_t mods_latched, 679 uint32_t mods_locked, uint32_t group); 680 681 void 682 weston_touch_set_focus(struct weston_touch *touch, 683 struct weston_view *view); 684 void 685 weston_touch_start_grab(struct weston_touch *touch, 686 struct weston_touch_grab *grab); 687 void 688 weston_touch_end_grab(struct weston_touch *touch); 689 690 void 691 weston_touch_send_down(struct weston_touch *touch, const struct timespec *time, 692 int touch_id, wl_fixed_t x, wl_fixed_t y); 693 void 694 weston_touch_send_up(struct weston_touch *touch, const struct timespec *time, 695 int touch_id); 696 void 697 weston_touch_send_motion(struct weston_touch *touch, 698 const struct timespec *time, int touch_id, 699 wl_fixed_t x, wl_fixed_t y); 700 void 701 weston_touch_send_frame(struct weston_touch *touch); 702 703 704 void 705 weston_seat_set_selection(struct weston_seat *seat, 706 struct weston_data_source *source, uint32_t serial); 707 708 int 709 weston_pointer_start_drag(struct weston_pointer *pointer, 710 struct weston_data_source *source, 711 struct weston_surface *icon, 712 struct wl_client *client); 713 struct weston_xkb_info { 714 struct xkb_keymap *keymap; 715 struct ro_anonymous_file *keymap_rofile; 716 int32_t ref_count; 717 xkb_mod_index_t shift_mod; 718 xkb_mod_index_t caps_mod; 719 xkb_mod_index_t ctrl_mod; 720 xkb_mod_index_t alt_mod; 721 xkb_mod_index_t mod2_mod; 722 xkb_mod_index_t mod3_mod; 723 xkb_mod_index_t super_mod; 724 xkb_mod_index_t mod5_mod; 725 xkb_led_index_t num_led; 726 xkb_led_index_t caps_led; 727 xkb_led_index_t scroll_led; 728 }; 729 730 struct weston_keyboard { 731 struct weston_seat *seat; 732 733 struct wl_list resource_list; 734 struct wl_list focus_resource_list; 735 struct weston_surface *focus; 736 struct wl_listener focus_resource_listener; 737 uint32_t focus_serial; 738 struct wl_signal focus_signal; 739 740 struct weston_keyboard_grab *grab; 741 struct weston_keyboard_grab default_grab; 742 uint32_t grab_key; 743 uint32_t grab_serial; 744 struct timespec grab_time; 745 746 struct wl_array keys; 747 748 struct { 749 uint32_t mods_depressed; 750 uint32_t mods_latched; 751 uint32_t mods_locked; 752 uint32_t group; 753 } modifiers; 754 755 struct weston_keyboard_grab input_method_grab; 756 struct wl_resource *input_method_resource; 757 758 struct weston_xkb_info *xkb_info; 759 struct { 760 struct xkb_state *state; 761 enum weston_led leds; 762 } xkb_state; 763 struct xkb_keymap *pending_keymap; 764 765 struct wl_list timestamps_list; 766 }; 767 768 struct weston_seat { 769 struct wl_list base_resource_list; 770 771 struct wl_global *global; 772 struct weston_pointer *pointer_state; 773 struct weston_keyboard *keyboard_state; 774 struct weston_touch *touch_state; 775 int pointer_device_count; 776 int keyboard_device_count; 777 int touch_device_count; 778 779 struct weston_output *output; /* constraint */ 780 781 struct wl_signal destroy_signal; 782 struct wl_signal updated_caps_signal; 783 784 struct weston_compositor *compositor; 785 struct wl_list link; 786 enum weston_keyboard_modifier modifier_state; 787 struct weston_surface *saved_kbd_focus; 788 struct wl_listener saved_kbd_focus_listener; 789 struct wl_list drag_resource_list; 790 791 uint32_t selection_serial; 792 struct weston_data_source *selection_data_source; 793 struct wl_listener selection_data_source_listener; 794 struct wl_signal selection_signal; 795 796 void (*led_update)(struct weston_seat *ws, enum weston_led leds); 797 798 struct input_method *input_method; 799 char *seat_name; 800 }; 801 802 enum { 803 WESTON_COMPOSITOR_ACTIVE, /* normal rendering and events */ 804 WESTON_COMPOSITOR_IDLE, /* shell->unlock called on activity */ 805 WESTON_COMPOSITOR_OFFSCREEN, /* no rendering, no frame events */ 806 WESTON_COMPOSITOR_SLEEPING /* same as offscreen, but also set dpms 807 * to off */ 808 }; 809 810 struct weston_layer_entry { 811 struct wl_list link; 812 struct weston_layer *layer; 813 }; 814 815 /** 816 * Higher value means higher in the stack. 817 * 818 * These values are based on well-known concepts in a classic desktop 819 * environment. Third-party modules based on libweston are encouraged to use 820 * them to integrate better with other projects. 821 * 822 * A fully integrated environment can use any value, based on these or not, 823 * at their discretion. 824 */ 825 enum weston_layer_position { 826 /* 827 * Special value to make the layer invisible and still rendered. 828 * This is used by compositors wanting e.g. minimized surfaces to still 829 * receive frame callbacks. 830 */ 831 WESTON_LAYER_POSITION_HIDDEN = 0x00000000, 832 833 /* 834 * There should always be a background layer with a surface covering 835 * the visible area. 836 * 837 * If the compositor handles the background itself, it should use 838 * BACKGROUND. 839 * 840 * If the compositor supports runtime-loadable modules to set the 841 * background, it should put a solid color surface at (BACKGROUND - 1) 842 * and modules must use BACKGROUND. 843 */ 844 WESTON_LAYER_POSITION_BACKGROUND = 0x00000002, 845 846 /* For "desktop widgets" and applications like conky. */ 847 WESTON_LAYER_POSITION_BOTTOM_UI = 0x30000000, 848 849 /* For regular applications, only one layer should have this value 850 * to ensure proper stacking control. */ 851 WESTON_LAYER_POSITION_NORMAL = 0x50000000, 852 853 /* For desktop UI, like panels. */ 854 WESTON_LAYER_POSITION_UI = 0x80000000, 855 856 /* For fullscreen applications that should cover UI. */ 857 WESTON_LAYER_POSITION_FULLSCREEN = 0xb0000000, 858 859 /* For special UI like on-screen keyboard that fullscreen applications 860 * will need. */ 861 WESTON_LAYER_POSITION_TOP_UI = 0xe0000000, 862 863 /* For the lock surface. */ 864 WESTON_LAYER_POSITION_LOCK = 0xffff0000, 865 866 /* Values reserved for libweston internal usage */ 867 WESTON_LAYER_POSITION_CURSOR = 0xfffffffe, 868 WESTON_LAYER_POSITION_FADE = 0xffffffff, 869 }; 870 871 struct weston_layer { 872 struct weston_compositor *compositor; 873 struct wl_list link; /* weston_compositor::layer_list */ 874 enum weston_layer_position position; 875 pixman_box32_t mask; 876 struct weston_layer_entry view_list; 877 }; 878 879 struct weston_plane { 880 struct weston_compositor *compositor; 881 pixman_region32_t damage; /**< in global coords */ 882 pixman_region32_t clip; 883 int32_t x, y; 884 struct wl_list link; 885 }; 886 887 struct weston_renderer { 888 int (*read_pixels)(struct weston_output *output, 889 pixman_format_code_t format, void *pixels, 890 uint32_t x, uint32_t y, 891 uint32_t width, uint32_t height); 892 void (*repaint_output)(struct weston_output *output, 893 pixman_region32_t *output_damage); 894 void (*flush_damage)(struct weston_surface *surface); 895 void (*attach)(struct weston_surface *es, struct weston_buffer *buffer); 896 void (*surface_set_color)(struct weston_surface *surface, 897 float red, float green, 898 float blue, float alpha); 899 void (*destroy)(struct weston_compositor *ec); 900 901 902 /** See weston_surface_get_content_size() */ 903 void (*surface_get_content_size)(struct weston_surface *surface, 904 int *width, int *height); 905 906 /** See weston_surface_copy_content() */ 907 int (*surface_copy_content)(struct weston_surface *surface, 908 void *target, size_t size, 909 int src_x, int src_y, 910 int width, int height); 911 912 /** See weston_compositor_import_dmabuf() */ 913 bool (*import_dmabuf)(struct weston_compositor *ec, 914 struct linux_dmabuf_buffer *buffer); 915 916 /** On error sets num_formats to zero */ 917 void (*query_dmabuf_formats)(struct weston_compositor *ec, 918 int **formats, int *num_formats); 919 920 /** On error sets num_modifiers to zero */ 921 void (*query_dmabuf_modifiers)(struct weston_compositor *ec, 922 int format, uint64_t **modifiers, 923 int *num_modifiers); 924 }; 925 926 enum weston_capability { 927 /* backend/renderer supports arbitrary rotation */ 928 WESTON_CAP_ROTATION_ANY = 0x0001, 929 930 /* screencaptures need to be y-flipped */ 931 WESTON_CAP_CAPTURE_YFLIP = 0x0002, 932 933 /* backend/renderer has a separate cursor plane */ 934 WESTON_CAP_CURSOR_PLANE = 0x0004, 935 936 /* backend supports setting arbitrary resolutions */ 937 WESTON_CAP_ARBITRARY_MODES = 0x0008, 938 939 /* renderer supports weston_view_set_mask() clipping */ 940 WESTON_CAP_VIEW_CLIP_MASK = 0x0010, 941 942 /* renderer supports explicit synchronization */ 943 WESTON_CAP_EXPLICIT_SYNC = 0x0020, 944 }; 945 946 /* Configuration struct for a backend. 947 * 948 * This struct carries the configuration for a backend, and it's 949 * passed to the backend's init entry point. The backend will 950 * likely want to subclass this in order to handle backend specific 951 * data. 952 * 953 * \rststar 954 * .. note: 955 * 956 * Alternate designs were proposed (Feb 2016) for using opaque structures[1] 957 * and for section+key/value getter/setters[2]. The rationale for selecting 958 * the transparent structure design is based on several assumptions[3] which 959 * may require re-evaluating the design choice if they fail to hold. 960 * 961 * 1. https://lists.freedesktop.org/archives/wayland-devel/2016-February/026989.html 962 * 2. https://lists.freedesktop.org/archives/wayland-devel/2016-February/026929.html 963 * 3. https://lists.freedesktop.org/archives/wayland-devel/2016-February/027228.html 964 * 965 * \endrststar 966 */ 967 struct weston_backend_config { 968 /** Major version for the backend-specific config struct 969 * 970 * This version must match exactly what the backend expects, otherwise 971 * the struct is incompatible. 972 */ 973 uint32_t struct_version; 974 975 /** Minor version of the backend-specific config struct 976 * 977 * This must be set to sizeof(struct backend-specific config). 978 * If the value here is smaller than what the backend expects, the 979 * extra config members will assume their default values. 980 * 981 * A value greater than what the backend expects is incompatible. 982 */ 983 size_t struct_size; 984 }; 985 986 struct weston_backend; 987 988 /** Callback for saving calibration 989 * 990 * \param compositor The compositor. 991 * \param device The physical touch device to save for. 992 * \param calibration The new calibration from a client. 993 * \return -1 on failure, 0 on success. 994 * 995 * Failure will prevent taking the new calibration into use. 996 */ 997 typedef int (*weston_touch_calibration_save_func)( 998 struct weston_compositor *compositor, 999 struct weston_touch_device *device, 1000 const struct weston_touch_device_matrix *calibration); 1001 struct weston_touch_calibrator; 1002 1003 struct weston_desktop_xwayland; 1004 struct weston_desktop_xwayland_interface; 1005 struct weston_debug_compositor; 1006 1007 /** Main object, container-like structure which aggregates all other objects. 1008 * 1009 * \ingroup compositor 1010 */ 1011 struct weston_compositor { 1012 struct wl_signal destroy_signal; 1013 1014 struct wl_display *wl_display; 1015 struct weston_desktop_xwayland *xwayland; 1016 const struct weston_desktop_xwayland_interface *xwayland_interface; 1017 1018 /* surface signals */ 1019 struct wl_signal create_surface_signal; 1020 struct wl_signal activate_signal; 1021 struct wl_signal transform_signal; 1022 1023 struct wl_signal kill_signal; 1024 struct wl_signal idle_signal; 1025 struct wl_signal wake_signal; 1026 1027 struct wl_signal show_input_panel_signal; 1028 struct wl_signal hide_input_panel_signal; 1029 struct wl_signal update_input_panel_signal; 1030 1031 struct wl_signal seat_created_signal; 1032 struct wl_signal output_created_signal; 1033 struct wl_signal output_destroyed_signal; 1034 struct wl_signal output_moved_signal; 1035 struct wl_signal output_resized_signal; /* callback argument: resized output */ 1036 1037 /* Signal for output changes triggered by configuration from frontend 1038 * or head state changes from backend. 1039 */ 1040 struct wl_signal output_heads_changed_signal; /* arg: weston_output */ 1041 1042 struct wl_signal session_signal; 1043 bool session_active; 1044 1045 struct weston_layer fade_layer; 1046 struct weston_layer cursor_layer; 1047 1048 struct wl_list pending_output_list; 1049 struct wl_list output_list; 1050 struct wl_list head_list; /* struct weston_head::compositor_link */ 1051 struct wl_list seat_list; 1052 struct wl_list layer_list; /* struct weston_layer::link */ 1053 struct wl_list view_list; /* struct weston_view::link */ 1054 struct wl_list plane_list; 1055 struct wl_list key_binding_list; 1056 struct wl_list modifier_binding_list; 1057 struct wl_list button_binding_list; 1058 struct wl_list touch_binding_list; 1059 struct wl_list axis_binding_list; 1060 struct wl_list debug_binding_list; 1061 1062 uint32_t state; 1063 struct wl_event_source *idle_source; 1064 uint32_t idle_inhibit; 1065 int idle_time; /* timeout, s */ 1066 struct wl_event_source *repaint_timer; 1067 1068 const struct weston_pointer_grab_interface *default_pointer_grab; 1069 1070 /* Repaint state. */ 1071 struct weston_plane primary_plane; 1072 uint32_t capabilities; /* combination of enum weston_capability */ 1073 1074 struct weston_renderer *renderer; 1075 1076 pixman_format_code_t read_format; 1077 1078 struct weston_backend *backend; 1079 1080 struct weston_launcher *launcher; 1081 1082 struct wl_list plugin_api_list; /* struct weston_plugin_api::link */ 1083 1084 uint32_t output_id_pool; 1085 1086 struct xkb_rule_names xkb_names; 1087 struct xkb_context *xkb_context; 1088 struct weston_xkb_info *xkb_info; 1089 1090 int32_t kb_repeat_rate; 1091 int32_t kb_repeat_delay; 1092 1093 bool vt_switching; 1094 1095 clockid_t presentation_clock; 1096 int32_t repaint_msec; 1097 1098 unsigned int activate_serial; 1099 1100 struct wl_global *pointer_constraints; 1101 1102 int exit_code; 1103 1104 void *user_data; 1105 void (*exit)(struct weston_compositor *c); 1106 1107 /* Whether to let the compositor run without any input device. */ 1108 bool require_input; 1109 1110 /* Signal for a backend to inform a frontend about possible changes 1111 * in head status. 1112 */ 1113 struct wl_signal heads_changed_signal; 1114 struct wl_event_source *heads_changed_source; 1115 1116 /* Touchscreen calibrator support: */ 1117 enum weston_touch_mode touch_mode; 1118 struct wl_global *touch_calibration; 1119 weston_touch_calibration_save_func touch_calibration_save; 1120 struct weston_layer calibrator_layer; 1121 struct weston_touch_calibrator *touch_calibrator; 1122 1123 // OHOS remove logger 1124 // struct weston_log_context *weston_log_ctx; 1125 // struct weston_log_scope *debug_scene; 1126 struct weston_log_scope *timeline; 1127 1128 struct content_protection *content_protection; 1129 }; 1130 1131 struct weston_buffer { 1132 struct wl_resource *resource; 1133 struct wl_signal destroy_signal; 1134 struct wl_listener destroy_listener; 1135 1136 union { 1137 struct wl_shm_buffer *shm_buffer; 1138 void *legacy_buffer; 1139 }; 1140 int32_t width, height; 1141 uint32_t busy_count; 1142 int y_inverted; 1143 }; 1144 1145 struct weston_buffer_reference { 1146 struct weston_buffer *buffer; 1147 struct wl_listener destroy_listener; 1148 }; 1149 1150 struct weston_buffer_viewport { 1151 struct { 1152 /* wl_surface.set_buffer_transform */ 1153 uint32_t transform; 1154 1155 /* wl_surface.set_scaling_factor */ 1156 int32_t scale; 1157 1158 /* 1159 * If src_width != wl_fixed_from_int(-1), 1160 * then and only then src_* are used. 1161 */ 1162 wl_fixed_t src_x, src_y; 1163 wl_fixed_t src_width, src_height; 1164 } buffer; 1165 1166 struct { 1167 /* 1168 * If width == -1, the size is inferred from the buffer. 1169 */ 1170 int32_t width, height; 1171 } surface; 1172 1173 int changed; 1174 }; 1175 1176 struct weston_buffer_release { 1177 /* The associated zwp_linux_buffer_release_v1 resource. */ 1178 struct wl_resource *resource; 1179 /* How many weston_buffer_release_reference objects point to this 1180 * object. */ 1181 uint32_t ref_count; 1182 /* The fence fd, if any, associated with this release. If the fence fd 1183 * is -1 then this is considered an immediate release. */ 1184 int fence_fd; 1185 }; 1186 1187 struct weston_buffer_release_reference { 1188 struct weston_buffer_release *buffer_release; 1189 /* Listener for the destruction of the wl_resource associated with the 1190 * referenced buffer_release object. */ 1191 struct wl_listener destroy_listener; 1192 }; 1193 1194 struct weston_region { 1195 struct wl_resource *resource; 1196 pixman_region32_t region; 1197 }; 1198 1199 /* Using weston_view transformations 1200 * 1201 * To add a transformation to a view, create a struct weston_transform, and 1202 * add it to the list view->geometry.transformation_list. Whenever you 1203 * change the list, anything under view->geometry, or anything in the 1204 * weston_transforms linked into the list, you must call 1205 * weston_view_geometry_dirty(). 1206 * 1207 * The order in the list defines the order of transformations. Let the list 1208 * contain the transformation matrices M1, ..., Mn as head to tail. The 1209 * transformation is applied to view-local coordinate vector p as 1210 * P = Mn * ... * M2 * M1 * p 1211 * to produce the global coordinate vector P. The total transform 1212 * Mn * ... * M2 * M1 1213 * is cached in view->transform.matrix, and the inverse of it in 1214 * view->transform.inverse. 1215 * 1216 * The list always contains view->transform.position transformation, which 1217 * is the translation by view->geometry.x and y. 1218 * 1219 * If you want to apply a transformation in local coordinates, add your 1220 * weston_transform to the head of the list. If you want to apply a 1221 * transformation in global coordinates, add it to the tail of the list. 1222 * 1223 * If view->geometry.parent is set, the total transformation of this 1224 * view will be the parent's total transformation and this transformation 1225 * combined: 1226 * Mparent * Mn * ... * M2 * M1 1227 */ 1228 1229 struct weston_view { 1230 struct weston_surface *surface; 1231 struct wl_list surface_link; 1232 struct wl_signal destroy_signal; 1233 1234 struct wl_list link; /* weston_compositor::view_list */ 1235 struct weston_layer_entry layer_link; /* part of geometry */ 1236 struct weston_plane *plane; 1237 1238 /* For weston_layer inheritance from another view */ 1239 struct weston_view *parent_view; 1240 1241 unsigned int click_to_activate_serial; 1242 1243 pixman_region32_t clip; /* See weston_view_damage_below() */ 1244 float alpha; /* part of geometry, see below */ 1245 1246 void *renderer_state; 1247 1248 /* Surface geometry state, mutable. 1249 * If you change anything, call weston_surface_geometry_dirty(). 1250 * That includes the transformations referenced from the list. 1251 */ 1252 struct { 1253 float x, y; /* surface translation on display */ 1254 1255 /* struct weston_transform */ 1256 struct wl_list transformation_list; 1257 1258 /* managed by weston_surface_set_transform_parent() */ 1259 struct weston_view *parent; 1260 struct wl_listener parent_destroy_listener; 1261 struct wl_list child_list; /* geometry.parent_link */ 1262 struct wl_list parent_link; 1263 1264 /* managed by weston_view_set_mask() */ 1265 bool scissor_enabled; 1266 pixman_region32_t scissor; /* always a simple rect */ 1267 } geometry; 1268 1269 /* State derived from geometry state, read-only. 1270 * This is updated by weston_view_update_transform(). 1271 */ 1272 struct { 1273 int dirty; 1274 1275 /* Approximations in global coordinates: 1276 * - boundingbox is guaranteed to include the whole view in 1277 * the smallest possible single rectangle. 1278 * - opaque is guaranteed to be fully opaque, though not 1279 * necessarily include all opaque areas. 1280 */ 1281 pixman_region32_t boundingbox; 1282 pixman_region32_t opaque; 1283 1284 /* matrix and inverse are used only if enabled = 1. 1285 * If enabled = 0, use x, y, width, height directly. 1286 */ 1287 int enabled; 1288 struct weston_matrix matrix; 1289 struct weston_matrix inverse; 1290 1291 struct weston_transform position; /* matrix from x, y */ 1292 } transform; 1293 1294 /* 1295 * The primary output for this view. 1296 * Used for picking the output for driving internal animations on the 1297 * view, inheriting the primary output for related views in shells, etc. 1298 */ 1299 struct weston_output *output; 1300 struct wl_listener output_destroy_listener; 1301 1302 /* 1303 * A more complete representation of all outputs this surface is 1304 * displayed on. 1305 */ 1306 uint32_t output_mask; 1307 1308 /* Per-surface Presentation feedback flags, controlled by backend. */ 1309 uint32_t psf_flags; 1310 1311 bool is_mapped; 1312 }; 1313 1314 struct weston_surface_state { 1315 /* wl_surface.attach */ 1316 int newly_attached; 1317 struct weston_buffer *buffer; 1318 struct wl_listener buffer_destroy_listener; 1319 int32_t sx; 1320 int32_t sy; 1321 1322 /* wl_surface.damage */ 1323 pixman_region32_t damage_surface; 1324 /* wl_surface.damage_buffer */ 1325 pixman_region32_t damage_buffer; 1326 1327 /* wl_surface.set_opaque_region */ 1328 pixman_region32_t opaque; 1329 1330 /* wl_surface.set_input_region */ 1331 pixman_region32_t input; 1332 1333 /* wl_surface.frame */ 1334 struct wl_list frame_callback_list; 1335 1336 /* presentation.feedback */ 1337 struct wl_list feedback_list; 1338 1339 /* wl_surface.set_buffer_transform */ 1340 /* wl_surface.set_scaling_factor */ 1341 /* wp_viewport.set_source */ 1342 /* wp_viewport.set_destination */ 1343 struct weston_buffer_viewport buffer_viewport; 1344 1345 /* zwp_surface_synchronization_v1.set_acquire_fence */ 1346 int acquire_fence_fd; 1347 1348 /* zwp_surface_synchronization_v1.get_release */ 1349 struct weston_buffer_release_reference buffer_release_ref; 1350 1351 /* weston_protected_surface.set_type */ 1352 enum weston_hdcp_protection desired_protection; 1353 1354 /* weston_protected_surface.enforced/relaxed */ 1355 enum weston_surface_protection_mode protection_mode; 1356 }; 1357 1358 struct weston_surface_activation_data { 1359 struct weston_surface *surface; 1360 struct weston_seat *seat; 1361 }; 1362 1363 struct weston_pointer_constraint { 1364 struct wl_list link; 1365 1366 struct weston_surface *surface; 1367 struct weston_view *view; 1368 struct wl_resource *resource; 1369 struct weston_pointer_grab grab; 1370 struct weston_pointer *pointer; 1371 uint32_t lifetime; 1372 1373 pixman_region32_t region; 1374 pixman_region32_t region_pending; 1375 bool region_is_pending; 1376 1377 wl_fixed_t hint_x; 1378 wl_fixed_t hint_y; 1379 wl_fixed_t hint_x_pending; 1380 wl_fixed_t hint_y_pending; 1381 bool hint_is_pending; 1382 1383 struct wl_listener pointer_destroy_listener; 1384 struct wl_listener surface_destroy_listener; 1385 struct wl_listener surface_commit_listener; 1386 struct wl_listener surface_activate_listener; 1387 }; 1388 1389 struct weston_surface { 1390 struct wl_resource *resource; 1391 struct wl_signal destroy_signal; /* callback argument: this surface */ 1392 struct weston_compositor *compositor; 1393 struct wl_signal commit_signal; 1394 1395 /** Damage in local coordinates from the client, for tex upload. */ 1396 pixman_region32_t damage; 1397 1398 pixman_region32_t opaque; /* part of geometry, see below */ 1399 pixman_region32_t input; 1400 int32_t width, height; 1401 int32_t ref_count; 1402 1403 /* Not for long-term storage. This exists for book-keeping while 1404 * iterating over surfaces and views 1405 */ 1406 bool touched; 1407 1408 void *renderer_state; 1409 1410 struct wl_list views; 1411 1412 /* 1413 * Which output to vsync this surface to. 1414 * Used to determine whether to send or queue frame events, and for 1415 * other client-visible syncing/throttling tied to the output 1416 * repaint cycle. 1417 */ 1418 struct weston_output *output; 1419 1420 /* 1421 * A more complete representation of all outputs this surface is 1422 * displayed on. 1423 */ 1424 uint32_t output_mask; 1425 1426 struct wl_list frame_callback_list; 1427 struct wl_list feedback_list; 1428 1429 struct weston_buffer_reference buffer_ref; 1430 struct weston_buffer_viewport buffer_viewport; 1431 int32_t width_from_buffer; /* before applying viewport */ 1432 int32_t height_from_buffer; 1433 bool keep_buffer; /* for backends to prevent early release */ 1434 1435 /* wp_viewport resource for this surface */ 1436 struct wl_resource *viewport_resource; 1437 1438 /* All the pending state, that wl_surface.commit will apply. */ 1439 struct weston_surface_state pending; 1440 1441 /* Matrices representating of the full transformation between 1442 * buffer and surface coordinates. These matrices are updated 1443 * using the weston_surface_build_buffer_matrix function. */ 1444 struct weston_matrix buffer_to_surface_matrix; 1445 struct weston_matrix surface_to_buffer_matrix; 1446 1447 /* 1448 * If non-NULL, this function will be called on 1449 * wl_surface::commit after a new buffer has been set up for 1450 * this surface. The integer params are the sx and sy 1451 * parameters supplied to wl_surface::attach. 1452 */ 1453 void (*committed)(struct weston_surface *es, int32_t sx, int32_t sy); 1454 void *committed_private; 1455 int (*get_label)(struct weston_surface *surface, char *buf, size_t len); 1456 1457 /* Parent's list of its sub-surfaces, weston_subsurface:parent_link. 1458 * Contains also the parent itself as a dummy weston_subsurface, 1459 * if the list is not empty. 1460 */ 1461 struct wl_list subsurface_list; /* weston_subsurface::parent_link */ 1462 struct wl_list subsurface_list_pending; /* ...::parent_link_pending */ 1463 1464 /* 1465 * For tracking protocol role assignments. Different roles may 1466 * have the same configure hook, e.g. in shell.c. Configure hook 1467 * may get reset, this will not. 1468 * XXX: map configure functions 1:1 to roles, and never reset it, 1469 * and replace role_name with configure. 1470 */ 1471 const char *role_name; 1472 1473 bool is_mapped; 1474 bool is_opaque; 1475 1476 /* An list of per seat pointer constraints. */ 1477 struct wl_list pointer_constraints; 1478 1479 /* zwp_surface_synchronization_v1 resource for this surface */ 1480 struct wl_resource *synchronization_resource; 1481 int acquire_fence_fd; 1482 struct weston_buffer_release_reference buffer_release_ref; 1483 1484 enum weston_hdcp_protection desired_protection; 1485 enum weston_hdcp_protection current_protection; 1486 enum weston_surface_protection_mode protection_mode; 1487 enum wl_surface_type type; // OHOS surface type 1488 }; 1489 1490 struct weston_subsurface { 1491 struct wl_resource *resource; 1492 1493 /* guaranteed to be valid and non-NULL */ 1494 struct weston_surface *surface; 1495 struct wl_listener surface_destroy_listener; 1496 1497 /* can be NULL */ 1498 struct weston_surface *parent; 1499 struct wl_listener parent_destroy_listener; 1500 struct wl_list parent_link; 1501 struct wl_list parent_link_pending; 1502 1503 struct { 1504 int32_t x; 1505 int32_t y; 1506 int set; 1507 } position; 1508 1509 int has_cached_data; 1510 struct weston_surface_state cached; 1511 struct weston_buffer_reference cached_buffer_ref; 1512 1513 /* Sub-surface has been reordered; need to apply damage. */ 1514 bool reordered; 1515 1516 int synchronized; 1517 1518 /* Used for constructing the view tree */ 1519 struct wl_list unused_views; 1520 }; 1521 1522 struct protected_surface { 1523 struct weston_surface *surface; 1524 struct wl_listener surface_destroy_listener; 1525 struct wl_list link; 1526 struct wl_resource *protection_resource; 1527 struct content_protection *cp_backptr; 1528 }; 1529 1530 struct content_protection { 1531 struct weston_compositor *compositor; 1532 struct wl_listener destroy_listener; 1533 // OHOS remove logger 1534 // struct weston_log_scope *debug; 1535 struct wl_list protected_list; 1536 struct wl_event_source *surface_protection_update; 1537 }; 1538 1539 1540 enum weston_key_state_update { 1541 STATE_UPDATE_AUTOMATIC, 1542 STATE_UPDATE_NONE, 1543 }; 1544 1545 enum weston_activate_flag { 1546 WESTON_ACTIVATE_FLAG_NONE = 0, 1547 WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 0, 1548 WESTON_ACTIVATE_FLAG_CLICKED = 1 << 1, 1549 }; 1550 1551 void 1552 weston_version(int *major, int *minor, int *micro); 1553 1554 void 1555 weston_view_set_output(struct weston_view *view, struct weston_output *output); 1556 1557 void 1558 weston_view_update_transform(struct weston_view *view); 1559 1560 void 1561 weston_view_geometry_dirty(struct weston_view *view); 1562 1563 void 1564 weston_view_to_global_float(struct weston_view *view, 1565 float sx, float sy, float *x, float *y); 1566 1567 void 1568 weston_view_from_global(struct weston_view *view, 1569 int32_t x, int32_t y, int32_t *vx, int32_t *vy); 1570 void 1571 weston_view_from_global_fixed(struct weston_view *view, 1572 wl_fixed_t x, wl_fixed_t y, 1573 wl_fixed_t *vx, wl_fixed_t *vy); 1574 1575 void 1576 weston_view_activate(struct weston_view *view, 1577 struct weston_seat *seat, 1578 uint32_t flags); 1579 1580 void 1581 notify_modifiers(struct weston_seat *seat, uint32_t serial); 1582 1583 void 1584 weston_layer_entry_insert(struct weston_layer_entry *list, 1585 struct weston_layer_entry *entry); 1586 void 1587 weston_layer_entry_remove(struct weston_layer_entry *entry); 1588 void 1589 weston_layer_init(struct weston_layer *layer, 1590 struct weston_compositor *compositor); 1591 void 1592 weston_layer_set_position(struct weston_layer *layer, 1593 enum weston_layer_position position); 1594 void 1595 weston_layer_unset_position(struct weston_layer *layer); 1596 1597 void 1598 weston_layer_set_mask(struct weston_layer *layer, int x, int y, int width, int height); 1599 1600 void 1601 weston_layer_set_mask_infinite(struct weston_layer *layer); 1602 1603 bool 1604 weston_layer_mask_is_infinite(struct weston_layer *layer); 1605 1606 /* An invalid flag in presented_flags to catch logic errors. */ 1607 #define WP_PRESENTATION_FEEDBACK_INVALID (1U << 31) 1608 1609 void 1610 weston_output_schedule_repaint(struct weston_output *output); 1611 void 1612 weston_compositor_schedule_repaint(struct weston_compositor *compositor); 1613 void 1614 weston_compositor_damage_all(struct weston_compositor *compositor); 1615 void 1616 weston_compositor_wake(struct weston_compositor *compositor); 1617 void 1618 weston_compositor_sleep(struct weston_compositor *compositor); 1619 struct weston_view * 1620 weston_compositor_pick_view(struct weston_compositor *compositor, 1621 wl_fixed_t x, wl_fixed_t y, 1622 wl_fixed_t *sx, wl_fixed_t *sy); 1623 1624 1625 struct weston_binding; 1626 typedef void (*weston_key_binding_handler_t)(struct weston_keyboard *keyboard, 1627 const struct timespec *time, 1628 uint32_t key, 1629 void *data); 1630 struct weston_binding * 1631 weston_compositor_add_key_binding(struct weston_compositor *compositor, 1632 uint32_t key, 1633 enum weston_keyboard_modifier modifier, 1634 weston_key_binding_handler_t binding, 1635 void *data); 1636 // OHOS remove debugger 1637 //struct weston_binding * 1638 //weston_compositor_add_debug_binding(struct weston_compositor *compositor, 1639 // uint32_t key, 1640 // weston_key_binding_handler_t binding, 1641 // void *data); 1642 1643 typedef void (*weston_modifier_binding_handler_t)(struct weston_keyboard *keyboard, 1644 enum weston_keyboard_modifier modifier, 1645 void *data); 1646 struct weston_binding * 1647 weston_compositor_add_modifier_binding(struct weston_compositor *compositor, 1648 enum weston_keyboard_modifier modifier, 1649 weston_modifier_binding_handler_t binding, 1650 void *data); 1651 1652 typedef void (*weston_button_binding_handler_t)(struct weston_pointer *pointer, 1653 const struct timespec *time, 1654 uint32_t button, 1655 void *data); 1656 struct weston_binding * 1657 weston_compositor_add_button_binding(struct weston_compositor *compositor, 1658 uint32_t button, 1659 enum weston_keyboard_modifier modifier, 1660 weston_button_binding_handler_t binding, 1661 void *data); 1662 1663 typedef void (*weston_touch_binding_handler_t)(struct weston_touch *touch, 1664 const struct timespec *time, 1665 void *data); 1666 struct weston_binding * 1667 weston_compositor_add_touch_binding(struct weston_compositor *compositor, 1668 enum weston_keyboard_modifier modifier, 1669 weston_touch_binding_handler_t binding, 1670 void *data); 1671 1672 typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer, 1673 const struct timespec *time, 1674 struct weston_pointer_axis_event *event, 1675 void *data); 1676 struct weston_binding * 1677 weston_compositor_add_axis_binding(struct weston_compositor *compositor, 1678 uint32_t axis, 1679 enum weston_keyboard_modifier modifier, 1680 weston_axis_binding_handler_t binding, 1681 void *data); 1682 1683 void 1684 weston_binding_destroy(struct weston_binding *binding); 1685 1686 void 1687 weston_install_debug_key_binding(struct weston_compositor *compositor, 1688 uint32_t mod); 1689 1690 void 1691 weston_compositor_set_default_pointer_grab(struct weston_compositor *compositor, 1692 const struct weston_pointer_grab_interface *interface); 1693 1694 struct weston_surface * 1695 weston_surface_create(struct weston_compositor *compositor); 1696 1697 struct weston_view * 1698 weston_view_create(struct weston_surface *surface); 1699 1700 void 1701 weston_view_destroy(struct weston_view *view); 1702 1703 void 1704 weston_view_set_position(struct weston_view *view, 1705 float x, float y); 1706 1707 void 1708 weston_view_set_transform_parent(struct weston_view *view, 1709 struct weston_view *parent); 1710 1711 void 1712 weston_view_set_mask(struct weston_view *view, 1713 int x, int y, int width, int height); 1714 1715 void 1716 weston_view_set_mask_infinite(struct weston_view *view); 1717 1718 bool 1719 weston_view_is_mapped(struct weston_view *view); 1720 1721 void 1722 weston_view_schedule_repaint(struct weston_view *view); 1723 1724 bool 1725 weston_surface_is_mapped(struct weston_surface *surface); 1726 1727 void 1728 weston_surface_set_size(struct weston_surface *surface, 1729 int32_t width, int32_t height); 1730 1731 void 1732 weston_surface_damage(struct weston_surface *surface); 1733 1734 void 1735 weston_view_damage_below(struct weston_view *view); 1736 1737 void 1738 weston_view_unmap(struct weston_view *view); 1739 1740 void 1741 weston_surface_unmap(struct weston_surface *surface); 1742 1743 struct weston_surface * 1744 weston_surface_get_main_surface(struct weston_surface *surface); 1745 1746 int 1747 weston_surface_set_role(struct weston_surface *surface, 1748 const char *role_name, 1749 struct wl_resource *error_resource, 1750 uint32_t error_code); 1751 const char * 1752 weston_surface_get_role(struct weston_surface *surface); 1753 1754 void 1755 weston_surface_set_label_func(struct weston_surface *surface, 1756 int (*desc)(struct weston_surface *, 1757 char *, size_t)); 1758 1759 void 1760 weston_surface_get_content_size(struct weston_surface *surface, 1761 int *width, int *height); 1762 1763 struct weston_geometry 1764 weston_surface_get_bounding_box(struct weston_surface *surface); 1765 1766 int 1767 weston_surface_copy_content(struct weston_surface *surface, 1768 void *target, size_t size, 1769 int src_x, int src_y, 1770 int width, int height); 1771 1772 struct weston_buffer * 1773 weston_buffer_from_resource(struct wl_resource *resource); 1774 1775 void 1776 weston_compositor_get_time(struct timespec *time); 1777 1778 void 1779 weston_compositor_destroy(struct weston_compositor *ec); 1780 1781 // OHOS remove logger 1782 //struct weston_compositor * 1783 //weston_compositor_create(struct wl_display *display, 1784 // struct weston_log_context *log_ctx, void *user_data); 1785 struct weston_compositor * 1786 weston_compositor_create(struct wl_display *display, void *user_data); 1787 1788 bool 1789 weston_compositor_add_destroy_listener_once(struct weston_compositor *compositor, 1790 struct wl_listener *listener, 1791 wl_notify_func_t destroy_handler); 1792 1793 enum weston_compositor_backend { 1794 WESTON_BACKEND_DRM, 1795 WESTON_BACKEND_FBDEV, 1796 WESTON_BACKEND_HEADLESS, 1797 WESTON_BACKEND_RDP, 1798 WESTON_BACKEND_WAYLAND, 1799 WESTON_BACKEND_X11, 1800 WESTON_BACKEND_HDI, 1801 }; 1802 1803 int 1804 weston_compositor_load_backend(struct weston_compositor *compositor, 1805 enum weston_compositor_backend backend, 1806 struct weston_backend_config *config_base); 1807 void 1808 weston_compositor_exit(struct weston_compositor *ec); 1809 void * 1810 weston_compositor_get_user_data(struct weston_compositor *compositor); 1811 void 1812 weston_compositor_exit_with_code(struct weston_compositor *compositor, 1813 int exit_code); 1814 void 1815 weston_output_update_zoom(struct weston_output *output); 1816 void 1817 weston_output_activate_zoom(struct weston_output *output, 1818 struct weston_seat *seat); 1819 void 1820 weston_output_add_destroy_listener(struct weston_output *output, 1821 struct wl_listener *listener); 1822 struct wl_listener * 1823 weston_output_get_destroy_listener(struct weston_output *output, 1824 wl_notify_func_t notify); 1825 int 1826 weston_compositor_set_xkb_rule_names(struct weston_compositor *ec, 1827 struct xkb_rule_names *names); 1828 1829 /* String literal of spaces, the same width as the timestamp. */ 1830 #define STAMP_SPACE " " 1831 1832 /** 1833 * \ingroup wlog 1834 */ 1835 // OHOS remove logger 1836 //typedef int (*log_func_t)(const char *fmt, va_list ap); 1837 //void 1838 //weston_log_set_handler(log_func_t log, log_func_t cont); 1839 //int 1840 //weston_log(const char *fmt, ...) 1841 // __attribute__ ((format (printf, 1, 2))); 1842 //int 1843 //weston_log_continue(const char *fmt, ...) 1844 // __attribute__ ((format (printf, 1, 2))); 1845 // OHOS logcat 1846 #define weston_log(fmt, ...) (HILOG_INFO(LOG_CORE, fmt, ##__VA_ARGS__)) 1847 #define weston_vlog vprintf 1848 #define weston_log_continue(fmt, ...) (HILOG_DEBUG(LOG_CORE, fmt, ##__VA_ARGS__)) 1849 1850 1851 enum weston_screenshooter_outcome { 1852 WESTON_SCREENSHOOTER_SUCCESS, 1853 WESTON_SCREENSHOOTER_NO_MEMORY, 1854 WESTON_SCREENSHOOTER_BAD_BUFFER 1855 }; 1856 1857 typedef void (*weston_screenshooter_done_func_t)(void *data, 1858 enum weston_screenshooter_outcome outcome); 1859 int 1860 weston_screenshooter_shoot(struct weston_output *output, struct weston_buffer *buffer, 1861 weston_screenshooter_done_func_t done, void *data); 1862 struct weston_recorder * 1863 weston_recorder_start(struct weston_output *output, const char *filename); 1864 void 1865 weston_recorder_stop(struct weston_recorder *recorder); 1866 1867 struct weston_view_animation; 1868 typedef void (*weston_view_animation_done_func_t)(struct weston_view_animation *animation, void *data); 1869 1870 void 1871 weston_view_animation_destroy(struct weston_view_animation *animation); 1872 1873 struct weston_view_animation * 1874 weston_zoom_run(struct weston_view *view, float start, float stop, 1875 weston_view_animation_done_func_t done, void *data); 1876 1877 struct weston_view_animation * 1878 weston_fade_run(struct weston_view *view, 1879 float start, float end, float k, 1880 weston_view_animation_done_func_t done, void *data); 1881 1882 struct weston_view_animation * 1883 weston_move_scale_run(struct weston_view *view, int dx, int dy, 1884 float start, float end, bool reverse, 1885 weston_view_animation_done_func_t done, void *data); 1886 1887 struct weston_view_animation * 1888 weston_move_run(struct weston_view *view, int dx, int dy, 1889 float start, float end, bool reverse, 1890 weston_view_animation_done_func_t done, void *data); 1891 1892 void 1893 weston_fade_update(struct weston_view_animation *fade, float target); 1894 1895 struct weston_view_animation * 1896 weston_stable_fade_run(struct weston_view *front_view, float start, 1897 struct weston_view *back_view, float end, 1898 weston_view_animation_done_func_t done, void *data); 1899 1900 struct weston_view_animation * 1901 weston_slide_run(struct weston_view *view, float start, float stop, 1902 weston_view_animation_done_func_t done, void *data); 1903 1904 void 1905 weston_surface_set_color(struct weston_surface *surface, 1906 float red, float green, float blue, float alpha); 1907 1908 void 1909 weston_surface_destroy(struct weston_surface *surface); 1910 1911 int 1912 weston_output_mode_switch_to_temporary(struct weston_output *output, 1913 struct weston_mode *mode, 1914 int32_t scale); 1915 int 1916 weston_output_mode_switch_to_native(struct weston_output *output); 1917 1918 int 1919 weston_backend_init(struct weston_compositor *c, 1920 struct weston_backend_config *config_base); 1921 int 1922 weston_module_init(struct weston_compositor *compositor); 1923 1924 void * 1925 weston_load_module(const char *name, const char *entrypoint); 1926 1927 size_t 1928 weston_module_path_from_env(const char *name, char *path, size_t path_len); 1929 1930 int 1931 weston_parse_transform(const char *transform, uint32_t *out); 1932 1933 const char * 1934 weston_transform_to_string(uint32_t output_transform); 1935 1936 struct weston_keyboard * 1937 weston_seat_get_keyboard(struct weston_seat *seat); 1938 1939 struct weston_pointer * 1940 weston_seat_get_pointer(struct weston_seat *seat); 1941 1942 struct weston_touch * 1943 weston_seat_get_touch(struct weston_seat *seat); 1944 1945 void 1946 weston_seat_set_keyboard_focus(struct weston_seat *seat, 1947 struct weston_surface *surface); 1948 1949 void 1950 weston_keyboard_send_keymap(struct weston_keyboard *kbd, 1951 struct wl_resource *resource); 1952 1953 int 1954 weston_compositor_load_xwayland(struct weston_compositor *compositor); 1955 1956 bool 1957 weston_head_is_connected(struct weston_head *head); 1958 1959 bool 1960 weston_head_is_enabled(struct weston_head *head); 1961 1962 bool 1963 weston_head_is_device_changed(struct weston_head *head); 1964 1965 bool 1966 weston_head_is_non_desktop(struct weston_head *head); 1967 1968 void 1969 weston_head_reset_device_changed(struct weston_head *head); 1970 1971 const char * 1972 weston_head_get_name(struct weston_head *head); 1973 1974 struct weston_output * 1975 weston_head_get_output(struct weston_head *head); 1976 1977 uint32_t 1978 weston_head_get_transform(struct weston_head *head); 1979 1980 void 1981 weston_head_detach(struct weston_head *head); 1982 1983 void 1984 weston_head_add_destroy_listener(struct weston_head *head, 1985 struct wl_listener *listener); 1986 1987 struct wl_listener * 1988 weston_head_get_destroy_listener(struct weston_head *head, 1989 wl_notify_func_t notify); 1990 1991 void 1992 weston_head_set_content_protection_status(struct weston_head *head, 1993 enum weston_hdcp_protection status); 1994 1995 struct weston_head * 1996 weston_compositor_iterate_heads(struct weston_compositor *compositor, 1997 struct weston_head *iter); 1998 1999 void 2000 weston_compositor_add_heads_changed_listener(struct weston_compositor *compositor, 2001 struct wl_listener *listener); 2002 2003 struct weston_output * 2004 weston_compositor_find_output_by_name(struct weston_compositor *compositor, 2005 const char *name); 2006 2007 struct weston_output * 2008 weston_compositor_create_output(struct weston_compositor *compositor, 2009 const char *name); 2010 2011 struct weston_output * 2012 weston_compositor_create_output_with_head(struct weston_compositor *compositor, 2013 struct weston_head *head); 2014 2015 void 2016 weston_output_destroy(struct weston_output *output); 2017 2018 int 2019 weston_output_attach_head(struct weston_output *output, 2020 struct weston_head *head); 2021 2022 struct weston_head * 2023 weston_output_iterate_heads(struct weston_output *output, 2024 struct weston_head *iter); 2025 2026 void 2027 weston_output_set_scale(struct weston_output *output, 2028 int32_t scale); 2029 2030 void 2031 weston_output_set_transform(struct weston_output *output, 2032 uint32_t transform); 2033 2034 void 2035 weston_output_init(struct weston_output *output, 2036 struct weston_compositor *compositor, 2037 const char *name); 2038 2039 void 2040 weston_output_move(struct weston_output *output, int x, int y); 2041 2042 int 2043 weston_output_enable(struct weston_output *output); 2044 2045 void 2046 weston_output_disable(struct weston_output *output); 2047 2048 void 2049 weston_compositor_flush_heads_changed(struct weston_compositor *compositor); 2050 2051 struct weston_head * 2052 weston_head_from_resource(struct wl_resource *resource); 2053 2054 struct weston_head * 2055 weston_output_get_first_head(struct weston_output *output); 2056 2057 void 2058 weston_output_allow_protection(struct weston_output *output, 2059 bool allow_protection); 2060 2061 int 2062 weston_compositor_enable_touch_calibrator(struct weston_compositor *compositor, 2063 weston_touch_calibration_save_func save); 2064 2065 // OHOS remove logger 2066 //struct weston_log_context * 2067 //weston_log_ctx_create(void); 2068 // 2069 //void 2070 //weston_log_ctx_destroy(struct weston_log_context *log_ctx); 2071 2072 int 2073 weston_compositor_enable_content_protection(struct weston_compositor *compositor); 2074 2075 // OHOS remove timeline 2076 //void 2077 //weston_timeline_refresh_subscription_objects(struct weston_compositor *wc, 2078 // void *object); 2079 2080 #ifdef __cplusplus 2081 } 2082 #endif 2083 2084 #endif 2085