1 #ifndef _ECORE_WL2_PRIVATE_H 2 # define _ECORE_WL2_PRIVATE_H 3 4 # include <unistd.h> 5 # include "Ecore_Wl2.h" 6 # include "Ecore_Input.h" 7 # include <xkbcommon/xkbcommon-compose.h> 8 # include "www-client-protocol.h" 9 # include "ecore_wl2_internal.h" 10 11 # define EFL_TEAMWORK_VERSION 2 12 # include "teamwork-client-protocol.h" 13 14 # include "session-recovery-client-protocol.h" 15 16 # include "xdg-shell-client-protocol.h" 17 # include "xdg-shell-unstable-v6-client-protocol.h" 18 # include "efl-aux-hints-client-protocol.h" 19 20 extern int _ecore_wl2_log_dom; 21 extern Eina_Bool no_session_recovery; 22 23 # ifdef EAPI 24 # undef EAPI 25 # endif 26 27 # ifdef __GNUC__ 28 # if __GNUC__ >= 4 29 # define EAPI __attribute__ ((visibility("default"))) 30 # else 31 # define EAPI 32 # endif 33 # else 34 # define EAPI 35 # endif 36 37 # ifdef ECORE_WL2_DEFAULT_LOG_COLOR 38 # undef ECORE_WL2_DEFAULT_LOG_COLOR 39 # endif 40 # define ECORE_WL2_DEFAULT_LOG_COLOR EINA_COLOR_BLUE 41 42 # ifdef ERR 43 # undef ERR 44 # endif 45 # define ERR(...) EINA_LOG_DOM_ERR(_ecore_wl2_log_dom, __VA_ARGS__) 46 47 # ifdef DBG 48 # undef DBG 49 # endif 50 # define DBG(...) EINA_LOG_DOM_DBG(_ecore_wl2_log_dom, __VA_ARGS__) 51 52 # ifdef INF 53 # undef INF 54 # endif 55 # define INF(...) EINA_LOG_DOM_INFO(_ecore_wl2_log_dom, __VA_ARGS__) 56 57 # ifdef WRN 58 # undef WRN 59 # endif 60 # define WRN(...) EINA_LOG_DOM_WARN(_ecore_wl2_log_dom, __VA_ARGS__) 61 62 # ifdef CRI 63 # undef CRI 64 # endif 65 # define CRI(...) EINA_LOG_DOM_CRIT(_ecore_wl2_log_dom, __VA_ARGS__) 66 67 typedef struct _Ecore_Wl2_Input_Devices 68 { 69 Eo *pointer_dev; 70 Eo *keyboard_dev; 71 Eo *touch_dev; 72 Eo *seat_dev; 73 Ecore_Wl2_Window *window; 74 } Ecore_Wl2_Input_Devices; 75 76 struct _Ecore_Wl2_Display 77 { 78 int refs; 79 char *name; 80 pid_t pid; 81 82 struct 83 { 84 struct wl_display *display; 85 struct wl_registry *registry; 86 struct wl_compositor *compositor; 87 struct wl_subcompositor *subcompositor; 88 struct wl_data_device_manager *data_device_manager; 89 int data_device_manager_version; 90 struct wl_shm *shm; 91 struct zwp_linux_dmabuf_v1 *dmabuf; 92 struct zxdg_shell_v6 *zxdg_shell; 93 struct xdg_wm_base *xdg_wm_base; 94 struct www *www; 95 struct zwp_e_session_recovery *session_recovery; 96 struct efl_aux_hints *efl_aux_hints; 97 struct zwp_teamwork *teamwork; 98 struct efl_hints *efl_hints; 99 int compositor_version; 100 } wl; 101 102 uint32_t serial; 103 104 struct xkb_context *xkb_context; 105 106 Ecore_Fd_Handler *fd_hdl; 107 108 Eina_Hash *globals; 109 Ecore_Timer *recovery_timer; 110 111 Eina_Inlist *windows; 112 Eina_Inlist *outputs; 113 Eina_Inlist *inputs; 114 Eina_Inlist *seats; 115 116 int syncs; 117 118 Eina_Bool sync_done : 1; 119 Eina_Bool shell_done : 1; 120 Eina_Bool recovering : 1; 121 }; 122 123 struct _Ecore_Wl2_Subsurface 124 { 125 EINA_INLIST; 126 127 int x, y; 128 129 Ecore_Wl2_Window *parent; 130 131 struct 132 { 133 struct wl_surface *surface; 134 struct wl_subsurface *subsurface; 135 } wl; 136 137 Eina_Bool sync : 1; 138 }; 139 140 struct _Ecore_Wl2_Aux_Hint 141 { 142 EINA_INLIST; 143 144 int id; 145 const char *hint, *val; 146 }; 147 148 struct _Ecore_Wl2_Frame_Cb_Handle 149 { 150 EINA_INLIST; 151 Ecore_Wl2_Window *win; 152 Ecore_Wl2_Frame_Cb cb; 153 void *data; 154 }; 155 156 typedef struct _Ecore_Wl2_Window_Configure_State 157 { 158 uint32_t serial; 159 Eina_Rectangle geometry; 160 Eina_Bool maximized : 1; 161 Eina_Bool fullscreen : 1; 162 Eina_Bool focused : 1; 163 Eina_Bool resizing : 1; 164 } Ecore_Wl2_Window_Configure_State; 165 166 struct _Ecore_Wl2_Window 167 { 168 EINA_INLIST; 169 170 Ecore_Wl2_Display *display; 171 172 Ecore_Wl2_Window *parent; 173 Ecore_Wl2_Input *grab; 174 175 Ecore_Wl2_Surface *wl2_surface; 176 177 int rotation, surface_id; 178 const char *title; 179 const char *class; 180 const char *role; 181 182 struct wl_surface *surface; 183 void *buffer; 184 struct wl_callback *callback; 185 struct www_surface *www_surface; 186 struct xdg_surface *xdg_surface; 187 struct xdg_toplevel *xdg_toplevel; 188 struct xdg_popup *xdg_popup; 189 190 struct zxdg_surface_v6 *zxdg_surface; 191 struct zxdg_toplevel_v6 *zxdg_toplevel; 192 struct zxdg_popup_v6 *zxdg_popup; 193 194 void (*cb_close) (void *data, Ecore_Wl2_Window *win); 195 void *cb_close_data; 196 197 Eina_Stringshare *uuid; 198 199 void (*xdg_configure_ack)(struct xdg_surface *surface, uint32_t serial); 200 void (*xdg_set_min_size)(struct xdg_toplevel *toplevel, int32_t w, int32_t h); 201 void (*xdg_set_max_size)(struct xdg_toplevel *toplevel, int32_t w, int32_t h); 202 203 void (*zxdg_configure_ack)(struct zxdg_surface_v6 *surface, uint32_t serial); 204 void (*zxdg_set_min_size)(struct zxdg_toplevel_v6 *toplevel, int32_t w, int32_t h); 205 void (*zxdg_set_max_size)(struct zxdg_toplevel_v6 *toplevel, int32_t w, int32_t h); 206 207 Eina_Rectangle saved; 208 Eina_Rectangle opaque; 209 Eina_Rectangle input_rect; 210 211 Ecore_Wl2_Window_Type type; 212 213 struct 214 { 215 int w, h; 216 unsigned int aspect; 217 Eina_Bool set : 1; 218 } aspect; 219 220 struct 221 { 222 int w, h; 223 Eina_Bool set : 1; 224 } weight; 225 226 Eina_Inlist *subsurfs; 227 Eina_List *supported_aux_hints; 228 Eina_Inlist *frame_callbacks; 229 230 Eina_List *outputs; 231 232 Ecore_Wl2_Window_Configure_State set_config; 233 Ecore_Wl2_Window_Configure_State req_config; 234 Ecore_Wl2_Window_Configure_State def_config; 235 236 Eina_Bool alpha : 1; 237 238 Eina_Bool input_set : 1; 239 Eina_Bool opaque_set : 1; 240 241 Eina_Bool focus_skip : 1; 242 Eina_Bool floating : 1; 243 244 Eina_Bool commit_pending : 1; 245 246 struct 247 { 248 Eina_Bool configure : 1; 249 Eina_Bool min : 1; 250 Eina_Bool max : 1; 251 Eina_Bool geom : 1; 252 Eina_Bool opaque : 1; 253 Eina_Bool input : 1; 254 Eina_Bool fullscreen : 1; 255 Eina_Bool maximized : 1; 256 } pending; 257 258 struct 259 { 260 Eina_Bool supported : 1; 261 Eina_Bool app_set : 1; 262 int preferred_rot; 263 int *available_rots; 264 unsigned int count; 265 } wm_rot; 266 Eina_Bool has_buffer : 1; 267 Eina_Bool updating : 1; 268 Eina_Bool deferred_minimize : 1; 269 270 Eina_Bool visible : 1; 271 }; 272 273 struct _Ecore_Wl2_Output 274 { 275 EINA_INLIST; 276 277 Ecore_Wl2_Display *display; 278 struct wl_output *wl_output; 279 280 int mw, mh, transform; 281 const char *make, *model; 282 Eina_Rectangle geometry; 283 }; 284 285 typedef struct _Ecore_Wl2_Dnd_Source 286 { 287 Ecore_Wl2_Input *input; 288 289 int x, y; 290 Ecore_Fd_Handler *fdh; 291 292 struct wl_data_offer *offer; 293 struct wl_array types; 294 uint32_t dnd_action; 295 uint32_t source_actions; 296 Ecore_Wl2_Selection_Type sel_type; 297 Eina_Bool active_read; 298 void *read_data; 299 unsigned int len; 300 } Ecore_Wl2_Dnd_Source; 301 302 303 /** TODO: Refactor ALL Input code :( 304 * 305 * wl_seat is a GROUP of Input Devices (such as): 306 * keyboards, pointers, touch devices 307 */ 308 struct _Ecore_Wl2_Pointer 309 { 310 EINA_INLIST; 311 312 Ecore_Wl2_Seat *seat; 313 314 double sx, sy; 315 unsigned int button; 316 unsigned int enter_serial; 317 318 struct 319 { 320 unsigned int button, count, timestamp; 321 Ecore_Wl2_Window *window; 322 } grab; 323 324 Ecore_Wl2_Window *focus; 325 326 Eina_List *resources; 327 }; 328 329 struct _Ecore_Wl2_Keyboard 330 { 331 EINA_INLIST; 332 333 Ecore_Wl2_Seat *seat; 334 335 unsigned int modifiers; 336 337 struct 338 { 339 struct xkb_keymap *keymap; 340 struct xkb_state *state; 341 xkb_mod_mask_t control_mask; 342 xkb_mod_mask_t alt_mask; 343 xkb_mod_mask_t shift_mask; 344 xkb_mod_mask_t win_mask; 345 xkb_mod_mask_t scroll_mask; 346 xkb_mod_mask_t num_mask; 347 xkb_mod_mask_t caps_mask; 348 xkb_mod_mask_t altgr_mask; 349 unsigned int mods_depressed; 350 unsigned int mods_latched; 351 unsigned int mods_locked; 352 unsigned int mods_group; 353 } xkb; 354 355 struct 356 { 357 Ecore_Timer *tmr; 358 unsigned int sym, key, time; 359 double rate, delay; 360 Eina_Bool enabled : 1; 361 } repeat; 362 363 struct 364 { 365 unsigned int button, count, timestamp; 366 Ecore_Wl2_Window *window; 367 } grab; 368 369 Ecore_Wl2_Window *focus; 370 371 Eina_List *resources; 372 }; 373 374 struct _Ecore_Wl2_Touch 375 { 376 EINA_INLIST; 377 378 struct 379 { 380 unsigned int button, count, timestamp; 381 Ecore_Wl2_Window *window; 382 } grab; 383 }; 384 385 struct _Ecore_Wl2_Seat 386 { 387 EINA_INLIST; 388 389 uint32_t id; 390 uint32_t version; 391 const char *name; 392 struct wl_global *global; 393 const struct wl_seat_interface *implementation; 394 395 struct 396 { 397 struct wl_global *global; 398 struct wl_resource *resource; 399 } im; 400 401 Ecore_Wl2_Bind_Cb bind_cb; 402 Ecore_Wl2_Unbind_Cb unbind_cb; 403 404 Ecore_Wl2_Pointer *pointer; 405 int pointer_count; 406 407 Ecore_Wl2_Keyboard *keyboard; 408 int keyboard_count; 409 410 Ecore_Wl2_Touch *touch; 411 int touch_count; 412 413 Eina_List *resources; 414 }; 415 416 struct _Ecore_Wl2_Input 417 { 418 EINA_INLIST; 419 420 Ecore_Wl2_Display *display; 421 422 unsigned int timestamp; 423 424 struct 425 { 426 struct wl_seat *seat; 427 struct wl_pointer *pointer; 428 struct wl_keyboard *keyboard; 429 struct wl_touch *touch; 430 } wl; 431 432 struct 433 { 434 struct wl_data_device *device; 435 struct 436 { 437 struct wl_data_source *source; 438 struct wl_array types; 439 uint32_t serial; 440 } selection; 441 struct 442 { 443 struct wl_data_source *source; 444 struct wl_array types; 445 uint32_t action; 446 uint32_t serial; 447 } drag; 448 } data; 449 450 struct 451 { 452 const char *name; 453 unsigned int size; 454 struct wl_surface *surface; 455 int hot_x, hot_y; 456 } cursor; 457 458 struct 459 { 460 double sx, sy; 461 unsigned int button; 462 unsigned int enter_serial; 463 } pointer; 464 465 struct 466 { 467 unsigned int modifiers; 468 } keyboard; 469 470 struct 471 { 472 Ecore_Wl2_Window *pointer; 473 Ecore_Wl2_Window *prev_pointer; 474 Ecore_Wl2_Window *keyboard; 475 Ecore_Wl2_Window *touch; 476 } focus; 477 478 struct 479 { 480 unsigned int button, count, timestamp; 481 Ecore_Wl2_Window *window; 482 unsigned int touch_count; 483 } grab; 484 485 struct 486 { 487 struct xkb_keymap *keymap; 488 struct xkb_state *state; 489 struct xkb_state *maskless_state; 490 struct xkb_compose_table *compose_table; 491 struct xkb_compose_state *compose_state; 492 xkb_mod_mask_t control_mask; 493 xkb_mod_mask_t alt_mask; 494 xkb_mod_mask_t shift_mask; 495 xkb_mod_mask_t win_mask; 496 xkb_mod_mask_t scroll_mask; 497 xkb_mod_mask_t num_mask; 498 xkb_mod_mask_t caps_mask; 499 xkb_mod_mask_t altgr_mask; 500 unsigned int mods_depressed; 501 unsigned int mods_latched; 502 unsigned int mods_locked; 503 unsigned int mods_group; 504 } xkb; 505 506 struct 507 { 508 Ecore_Timer *timer; 509 unsigned int sym, sym_name, key, time; 510 double rate, delay; 511 Eina_Bool enabled : 1; 512 Eina_Bool repeating : 1; 513 Eina_Bool changed : 1; 514 } repeat; 515 516 struct 517 { 518 Ecore_Wl2_Offer *offer; 519 uint32_t enter_serial; 520 Ecore_Wl2_Window *window; 521 } drag, selection; 522 523 unsigned int seat_version; 524 unsigned int id; 525 Eina_Stringshare *name; 526 527 Ecore_Event_Handler *dev_add_handler; 528 Ecore_Event_Handler *dev_remove_handler; 529 Eina_List *devices_list; 530 }; 531 532 typedef struct Ecore_Wl2_Event_Window_WWW 533 { 534 Ecore_Wl2_Window *window; 535 int x_rel; 536 int y_rel; 537 uint32_t timestamp; 538 } Ecore_Wl2_Event_Window_WWW; 539 540 typedef struct Ecore_Wl2_Event_Window_WWW_Drag 541 { 542 Ecore_Wl2_Window *window; 543 Eina_Bool dragging; 544 } Ecore_Wl2_Event_Window_WWW_Drag; 545 546 typedef struct _Buffer_Handle Buffer_Handle; 547 typedef struct _Ecore_Wl2_Buffer 548 { 549 struct wl_buffer *wl_buffer; 550 int size; 551 int w, h; 552 int age; 553 unsigned long stride; 554 Buffer_Handle *bh; 555 int fd; 556 void *mapping; 557 558 int index; 559 Eina_Bool locked : 1; 560 Eina_Bool busy : 1; 561 Eina_Bool orphaned : 1; 562 Eina_Bool alpha : 1; 563 } Ecore_Wl2_Buffer; 564 565 typedef struct _Ecore_Wl2_Surface 566 { 567 void *private_data; 568 Ecore_Wl2_Window *wl2_win; 569 570 int w, h; 571 Ecore_Wl2_Surface_Interface *funcs; 572 Ecore_Event_Handler *offscreen_handler; 573 Eina_Bool alpha : 1; 574 } Ecore_Wl2_Surface; 575 576 EAPI extern int _ecore_wl2_event_window_www; 577 EAPI extern int _ecore_wl2_event_window_www_drag; 578 579 Ecore_Wl2_Window *_ecore_wl2_display_window_surface_find(Ecore_Wl2_Display *display, struct wl_surface *wl_surface); 580 void _display_event_free(void *d, void *event EINA_UNUSED); 581 582 void _ecore_wl2_output_add(Ecore_Wl2_Display *display, unsigned int id); 583 void _ecore_wl2_output_del(Ecore_Wl2_Output *output); 584 585 void _ecore_wl2_input_add(Ecore_Wl2_Display *display, unsigned int id, unsigned int version); 586 void _ecore_wl2_input_del(Ecore_Wl2_Input *input); 587 588 void _ecore_wl2_input_ungrab(Ecore_Wl2_Input *input); 589 void _ecore_wl2_input_grab(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window, unsigned int button); 590 591 void _ecore_wl2_input_cursor_set(Ecore_Wl2_Input *input, const char *cursor); 592 Eina_Bool _ecore_wl2_input_cursor_update(void *data); 593 void _ecore_wl2_input_window_remove(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window); 594 595 void _ecore_wl2_dnd_add(Ecore_Wl2_Input *input, struct wl_data_offer *offer); 596 void _ecore_wl2_dnd_enter(Ecore_Wl2_Input *input, struct wl_data_offer *offer, struct wl_surface *surface, int x, int y, uint32_t serial); 597 void _ecore_wl2_dnd_leave(Ecore_Wl2_Input *input); 598 void _ecore_wl2_dnd_motion(Ecore_Wl2_Input *input, int x, int y, uint32_t serial); 599 void _ecore_wl2_dnd_drop(Ecore_Wl2_Input *input); 600 void _ecore_wl2_dnd_selection(Ecore_Wl2_Input *input, struct wl_data_offer *offer); 601 void _ecore_wl2_dnd_del(Ecore_Wl2_Dnd_Source *source); 602 603 void _ecore_wl2_subsurf_unmap(Ecore_Wl2_Subsurface *subsurf); 604 void _ecore_wl2_subsurf_free(Ecore_Wl2_Subsurface *subsurf); 605 606 void _ecore_wl2_window_surface_create(Ecore_Wl2_Window *window); 607 void _ecore_wl2_window_shell_surface_init(Ecore_Wl2_Window *window); 608 void _ecore_wl2_window_www_surface_init(Ecore_Wl2_Window *window); 609 void _ecore_wl2_window_semi_free(Ecore_Wl2_Window *window); 610 611 void _ecore_wl2_offer_unref(Ecore_Wl2_Offer *offer); 612 Eina_Bool _ecore_wl2_display_sync_get(void); 613 614 void _ecore_wl2_buffer_test(Ecore_Wl2_Display *ewd); 615 616 EAPI void ecore_wl2_window_weight_set(Ecore_Wl2_Window *window, double w, double h); 617 618 Ecore_Wl2_Output *_ecore_wl2_output_find(Ecore_Wl2_Display *dsp, struct wl_output *op); 619 620 #endif 621