9 #ifndef zakero_Yetani_h
10 #define zakero_Yetani_h
233 #include <linux/input-event-codes.h>
236 #include <wayland/wayland-client.h>
265 #define ZAKERO_YETANI__ERROR_DATA \
266 X(Error_None , 0 , "No Error" ) \
267 X(Error_Compositor_Was_Not_Found , 1 , "Could not find the Compositor object in the Global Repository." ) \
268 X(Error_Connection_Failed , 2 , "Failed to connect to the Wayland Server." ) \
269 X(Error_Cursor_Already_Exists , 3 , "A cursor with that name already exists." ) \
270 X(Error_Cursor_Does_Not_Exist , 4 , "No cursors exists with that name." ) \
271 X(Error_Cursor_Frame_Time_Too_Large , 5 , "The cursor time per frame is too large, must be <= Size_Max." ) \
272 X(Error_Cursor_Frame_Time_Too_Small , 6 , "The cursor time per frame is too small, must be greater than 0." ) \
273 X(Error_Cursor_Image_Data_Is_Empty , 7 , "The cursor image data can not be empty." ) \
274 X(Error_Cursor_Name_Is_Invalid , 8 , "The cursor name is invalid." ) \
275 X(Error_Cursor_Not_Attached , 9 , "The specified cursor is not attached/in-use." ) \
276 X(Error_Cursor_Size_Too_Small , 10 , "The cursor size, both width and height must be greater than 0." ) \
277 X(Error_Invalid_Display_Name , 11 , "An invalid dispaly name was given to the Wayland Server." ) \
278 X(Error_Minimum_Size_Greater_Than_Maximum_Size , 12 , "The minimum window size is larger than the maximum window size." ) \
279 X(Error_No_Output_Available , 13 , "No output devices are available." ) \
280 X(Error_Registry_Not_Available , 14 , "Unable to get the registery." ) \
281 X(Error_Server_Side_Decorations_Not_Available , 15 , "The Wayland Compositor does not support Server Side Decorations." ) \
282 X(Error_Shm_Was_Not_Found , 16 , "Could not find the Shm object in the Global Repository." ) \
283 X(Error_Wayland_Not_Available , 17 , "Could not find the Wayland Server." ) \
284 X(Error_Window_Initialization_Failed , 18 , "The window was not able to be initialized." ) \
285 X(Error_Window_Size_Too_Small , 19 , "The window size was too small." ) \
286 X(Error_Xdg_WM_Base_Was_Not_Found , 20 , "Could not find the XDG WM Base object the Global Repository." ) \
328 struct zxdg_decoration_manager_v1;
329 struct zxdg_toplevel_decoration_v1;
330 extern const struct wl_interface zxdg_decoration_manager_v1_interface;
331 extern const struct wl_interface zxdg_toplevel_decoration_v1_interface;
333 zxdg_decoration_manager_v1_set_user_data(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1,
void *user_data)
335 wl_proxy_set_user_data((
struct wl_proxy *) zxdg_decoration_manager_v1, user_data);
338 zxdg_decoration_manager_v1_get_user_data(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
340 return wl_proxy_get_user_data((
struct wl_proxy *) zxdg_decoration_manager_v1);
342 static inline uint32_t
343 zxdg_decoration_manager_v1_get_version(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
345 return wl_proxy_get_version((
struct wl_proxy *) zxdg_decoration_manager_v1);
348 zxdg_decoration_manager_v1_destroy(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
350 wl_proxy_marshal((
struct wl_proxy *) zxdg_decoration_manager_v1,
352 wl_proxy_destroy((
struct wl_proxy *) zxdg_decoration_manager_v1);
354 static inline struct zxdg_toplevel_decoration_v1 *
355 zxdg_decoration_manager_v1_get_toplevel_decoration(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1,
struct xdg_toplevel *toplevel)
358 id = wl_proxy_marshal_constructor((
struct wl_proxy *) zxdg_decoration_manager_v1,
359 1, &zxdg_toplevel_decoration_v1_interface, NULL, toplevel);
360 return (
struct zxdg_toplevel_decoration_v1 *) id;
362 enum zxdg_toplevel_decoration_v1_error {
363 ZXDG_TOPLEVEL_DECORATION_V1_ERROR_UNCONFIGURED_BUFFER = 0,
364 ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ALREADY_CONSTRUCTED = 1,
365 ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ORPHANED = 2,
367 enum zxdg_toplevel_decoration_v1_mode {
368 ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE = 1,
369 ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE = 2,
371 struct zxdg_toplevel_decoration_v1_listener {
372 void (*configure)(
void *data,
373 struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
377 zxdg_toplevel_decoration_v1_add_listener(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
378 const struct zxdg_toplevel_decoration_v1_listener *listener,
void *data)
380 return wl_proxy_add_listener((
struct wl_proxy *) zxdg_toplevel_decoration_v1,
381 (
void (**)(
void)) listener, data);
384 zxdg_toplevel_decoration_v1_set_user_data(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
void *user_data)
386 wl_proxy_set_user_data((
struct wl_proxy *) zxdg_toplevel_decoration_v1, user_data);
389 zxdg_toplevel_decoration_v1_get_user_data(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
391 return wl_proxy_get_user_data((
struct wl_proxy *) zxdg_toplevel_decoration_v1);
393 static inline uint32_t
394 zxdg_toplevel_decoration_v1_get_version(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
396 return wl_proxy_get_version((
struct wl_proxy *) zxdg_toplevel_decoration_v1);
399 zxdg_toplevel_decoration_v1_destroy(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
401 wl_proxy_marshal((
struct wl_proxy *) zxdg_toplevel_decoration_v1,
403 wl_proxy_destroy((
struct wl_proxy *) zxdg_toplevel_decoration_v1);
406 zxdg_toplevel_decoration_v1_set_mode(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, uint32_t mode)
408 wl_proxy_marshal((
struct wl_proxy *) zxdg_toplevel_decoration_v1,
412 zxdg_toplevel_decoration_v1_unset_mode(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
414 wl_proxy_marshal((
struct wl_proxy *) zxdg_toplevel_decoration_v1,
417 #ifdef ZAKERO_YETANI_IMPLEMENTATION
418 extern const struct wl_interface xdg_toplevel_interface;
419 extern const struct wl_interface zxdg_toplevel_decoration_v1_interface;
420 static const struct wl_interface *xdg_decoration_unstable_v1_types[] = {
422 &zxdg_toplevel_decoration_v1_interface,
423 &xdg_toplevel_interface,
425 static const struct wl_message zxdg_decoration_manager_v1_requests[] = {
426 {
"destroy",
"", xdg_decoration_unstable_v1_types + 0 },
427 {
"get_toplevel_decoration",
"no", xdg_decoration_unstable_v1_types + 1 },
429 const struct wl_interface zxdg_decoration_manager_v1_interface = {
430 "zxdg_decoration_manager_v1", 1,
431 2, zxdg_decoration_manager_v1_requests,
434 static const struct wl_message zxdg_toplevel_decoration_v1_requests[] = {
435 {
"destroy",
"", xdg_decoration_unstable_v1_types + 0 },
436 {
"set_mode",
"u", xdg_decoration_unstable_v1_types + 0 },
437 {
"unset_mode",
"", xdg_decoration_unstable_v1_types + 0 },
439 static const struct wl_message zxdg_toplevel_decoration_v1_events[] = {
440 {
"configure",
"u", xdg_decoration_unstable_v1_types + 0 },
442 const struct wl_interface zxdg_toplevel_decoration_v1_interface = {
443 "zxdg_toplevel_decoration_v1", 1,
444 3, zxdg_toplevel_decoration_v1_requests,
445 1, zxdg_toplevel_decoration_v1_events,
454 struct xdg_positioner;
458 extern const struct wl_interface xdg_wm_base_interface;
459 extern const struct wl_interface xdg_positioner_interface;
460 extern const struct wl_interface xdg_surface_interface;
461 extern const struct wl_interface xdg_toplevel_interface;
462 extern const struct wl_interface xdg_popup_interface;
463 enum xdg_wm_base_error {
464 XDG_WM_BASE_ERROR_ROLE = 0,
465 XDG_WM_BASE_ERROR_DEFUNCT_SURFACES = 1,
466 XDG_WM_BASE_ERROR_NOT_THE_TOPMOST_POPUP = 2,
467 XDG_WM_BASE_ERROR_INVALID_POPUP_PARENT = 3,
468 XDG_WM_BASE_ERROR_INVALID_SURFACE_STATE = 4,
469 XDG_WM_BASE_ERROR_INVALID_POSITIONER = 5,
471 struct xdg_wm_base_listener {
472 void (*ping)(
void *data,
473 struct xdg_wm_base *xdg_wm_base,
477 xdg_wm_base_add_listener(
struct xdg_wm_base *xdg_wm_base,
478 const struct xdg_wm_base_listener *listener,
void *data)
480 return wl_proxy_add_listener((
struct wl_proxy *) xdg_wm_base,
481 (
void (**)(
void)) listener, data);
484 xdg_wm_base_set_user_data(
struct xdg_wm_base *xdg_wm_base,
void *user_data)
486 wl_proxy_set_user_data((
struct wl_proxy *) xdg_wm_base, user_data);
489 xdg_wm_base_get_user_data(
struct xdg_wm_base *xdg_wm_base)
491 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_wm_base);
493 static inline uint32_t
494 xdg_wm_base_get_version(
struct xdg_wm_base *xdg_wm_base)
496 return wl_proxy_get_version((
struct wl_proxy *) xdg_wm_base);
499 xdg_wm_base_destroy(
struct xdg_wm_base *xdg_wm_base)
501 wl_proxy_marshal((
struct wl_proxy *) xdg_wm_base,
503 wl_proxy_destroy((
struct wl_proxy *) xdg_wm_base);
505 static inline struct xdg_positioner *
506 xdg_wm_base_create_positioner(
struct xdg_wm_base *xdg_wm_base)
509 id = wl_proxy_marshal_constructor((
struct wl_proxy *) xdg_wm_base,
510 1, &xdg_positioner_interface, NULL);
511 return (
struct xdg_positioner *) id;
513 static inline struct xdg_surface *
514 xdg_wm_base_get_xdg_surface(
struct xdg_wm_base *xdg_wm_base,
struct wl_surface *surface)
517 id = wl_proxy_marshal_constructor((
struct wl_proxy *) xdg_wm_base,
518 2, &xdg_surface_interface, NULL, surface);
519 return (
struct xdg_surface *) id;
522 xdg_wm_base_pong(
struct xdg_wm_base *xdg_wm_base, uint32_t serial)
524 wl_proxy_marshal((
struct wl_proxy *) xdg_wm_base,
527 enum xdg_positioner_error {
528 XDG_POSITIONER_ERROR_INVALID_INPUT = 0,
530 enum xdg_positioner_anchor {
531 XDG_POSITIONER_ANCHOR_NONE = 0,
532 XDG_POSITIONER_ANCHOR_TOP = 1,
533 XDG_POSITIONER_ANCHOR_BOTTOM = 2,
534 XDG_POSITIONER_ANCHOR_LEFT = 3,
535 XDG_POSITIONER_ANCHOR_RIGHT = 4,
536 XDG_POSITIONER_ANCHOR_TOP_LEFT = 5,
537 XDG_POSITIONER_ANCHOR_BOTTOM_LEFT = 6,
538 XDG_POSITIONER_ANCHOR_TOP_RIGHT = 7,
539 XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT = 8,
541 enum xdg_positioner_gravity {
542 XDG_POSITIONER_GRAVITY_NONE = 0,
543 XDG_POSITIONER_GRAVITY_TOP = 1,
544 XDG_POSITIONER_GRAVITY_BOTTOM = 2,
545 XDG_POSITIONER_GRAVITY_LEFT = 3,
546 XDG_POSITIONER_GRAVITY_RIGHT = 4,
547 XDG_POSITIONER_GRAVITY_TOP_LEFT = 5,
548 XDG_POSITIONER_GRAVITY_BOTTOM_LEFT = 6,
549 XDG_POSITIONER_GRAVITY_TOP_RIGHT = 7,
550 XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT = 8,
552 enum xdg_positioner_constraint_adjustment {
553 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE = 0,
554 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X = 1,
555 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y = 2,
556 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X = 4,
557 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y = 8,
558 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X = 16,
559 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32,
562 xdg_positioner_set_user_data(
struct xdg_positioner *xdg_positioner,
void *user_data)
564 wl_proxy_set_user_data((
struct wl_proxy *) xdg_positioner, user_data);
567 xdg_positioner_get_user_data(
struct xdg_positioner *xdg_positioner)
569 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_positioner);
571 static inline uint32_t
572 xdg_positioner_get_version(
struct xdg_positioner *xdg_positioner)
574 return wl_proxy_get_version((
struct wl_proxy *) xdg_positioner);
577 xdg_positioner_destroy(
struct xdg_positioner *xdg_positioner)
579 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
581 wl_proxy_destroy((
struct wl_proxy *) xdg_positioner);
584 xdg_positioner_set_size(
struct xdg_positioner *xdg_positioner, int32_t width, int32_t height)
586 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
590 xdg_positioner_set_anchor_rect(
struct xdg_positioner *xdg_positioner, int32_t x, int32_t y, int32_t width, int32_t height)
592 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
593 2, x, y, width, height);
596 xdg_positioner_set_anchor(
struct xdg_positioner *xdg_positioner, uint32_t anchor)
598 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
602 xdg_positioner_set_gravity(
struct xdg_positioner *xdg_positioner, uint32_t gravity)
604 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
608 xdg_positioner_set_constraint_adjustment(
struct xdg_positioner *xdg_positioner, uint32_t constraint_adjustment)
610 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
611 5, constraint_adjustment);
614 xdg_positioner_set_offset(
struct xdg_positioner *xdg_positioner, int32_t x, int32_t y)
616 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
620 xdg_positioner_set_reactive(
struct xdg_positioner *xdg_positioner)
622 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
626 xdg_positioner_set_parent_size(
struct xdg_positioner *xdg_positioner, int32_t parent_width, int32_t parent_height)
628 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
629 8, parent_width, parent_height);
632 xdg_positioner_set_parent_configure(
struct xdg_positioner *xdg_positioner, uint32_t serial)
634 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
637 enum xdg_surface_error {
638 XDG_SURFACE_ERROR_NOT_CONSTRUCTED = 1,
639 XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED = 2,
640 XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER = 3,
642 struct xdg_surface_listener {
643 void (*configure)(
void *data,
644 struct xdg_surface *xdg_surface,
648 xdg_surface_add_listener(
struct xdg_surface *xdg_surface,
649 const struct xdg_surface_listener *listener,
void *data)
651 return wl_proxy_add_listener((
struct wl_proxy *) xdg_surface,
652 (
void (**)(
void)) listener, data);
655 xdg_surface_set_user_data(
struct xdg_surface *xdg_surface,
void *user_data)
657 wl_proxy_set_user_data((
struct wl_proxy *) xdg_surface, user_data);
660 xdg_surface_get_user_data(
struct xdg_surface *xdg_surface)
662 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_surface);
664 static inline uint32_t
665 xdg_surface_get_version(
struct xdg_surface *xdg_surface)
667 return wl_proxy_get_version((
struct wl_proxy *) xdg_surface);
670 xdg_surface_destroy(
struct xdg_surface *xdg_surface)
672 wl_proxy_marshal((
struct wl_proxy *) xdg_surface,
674 wl_proxy_destroy((
struct wl_proxy *) xdg_surface);
676 static inline struct xdg_toplevel *
677 xdg_surface_get_toplevel(
struct xdg_surface *xdg_surface)
680 id = wl_proxy_marshal_constructor((
struct wl_proxy *) xdg_surface,
681 1, &xdg_toplevel_interface, NULL);
682 return (
struct xdg_toplevel *) id;
684 static inline struct xdg_popup *
685 xdg_surface_get_popup(
struct xdg_surface *xdg_surface,
struct xdg_surface *parent,
struct xdg_positioner *positioner)
688 id = wl_proxy_marshal_constructor((
struct wl_proxy *) xdg_surface,
689 2, &xdg_popup_interface, NULL, parent, positioner);
690 return (
struct xdg_popup *) id;
693 xdg_surface_set_window_geometry(
struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height)
695 wl_proxy_marshal((
struct wl_proxy *) xdg_surface,
696 3, x, y, width, height);
699 xdg_surface_ack_configure(
struct xdg_surface *xdg_surface, uint32_t serial)
701 wl_proxy_marshal((
struct wl_proxy *) xdg_surface,
704 enum xdg_toplevel_resize_edge {
705 XDG_TOPLEVEL_RESIZE_EDGE_NONE = 0,
706 XDG_TOPLEVEL_RESIZE_EDGE_TOP = 1,
707 XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM = 2,
708 XDG_TOPLEVEL_RESIZE_EDGE_LEFT = 4,
709 XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT = 5,
710 XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT = 6,
711 XDG_TOPLEVEL_RESIZE_EDGE_RIGHT = 8,
712 XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT = 9,
713 XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT = 10,
715 enum xdg_toplevel_state {
716 XDG_TOPLEVEL_STATE_MAXIMIZED = 1,
717 XDG_TOPLEVEL_STATE_FULLSCREEN = 2,
718 XDG_TOPLEVEL_STATE_RESIZING = 3,
719 XDG_TOPLEVEL_STATE_ACTIVATED = 4,
720 XDG_TOPLEVEL_STATE_TILED_LEFT = 5,
721 XDG_TOPLEVEL_STATE_TILED_RIGHT = 6,
722 XDG_TOPLEVEL_STATE_TILED_TOP = 7,
723 XDG_TOPLEVEL_STATE_TILED_BOTTOM = 8,
725 struct xdg_toplevel_listener {
726 void (*configure)(
void *data,
727 struct xdg_toplevel *xdg_toplevel,
730 struct wl_array *states);
731 void (*close)(
void *data,
732 struct xdg_toplevel *xdg_toplevel);
735 xdg_toplevel_add_listener(
struct xdg_toplevel *xdg_toplevel,
736 const struct xdg_toplevel_listener *listener,
void *data)
738 return wl_proxy_add_listener((
struct wl_proxy *) xdg_toplevel,
739 (
void (**)(
void)) listener, data);
742 xdg_toplevel_set_user_data(
struct xdg_toplevel *xdg_toplevel,
void *user_data)
744 wl_proxy_set_user_data((
struct wl_proxy *) xdg_toplevel, user_data);
747 xdg_toplevel_get_user_data(
struct xdg_toplevel *xdg_toplevel)
749 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_toplevel);
751 static inline uint32_t
752 xdg_toplevel_get_version(
struct xdg_toplevel *xdg_toplevel)
754 return wl_proxy_get_version((
struct wl_proxy *) xdg_toplevel);
757 xdg_toplevel_destroy(
struct xdg_toplevel *xdg_toplevel)
759 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
761 wl_proxy_destroy((
struct wl_proxy *) xdg_toplevel);
764 xdg_toplevel_set_parent(
struct xdg_toplevel *xdg_toplevel,
struct xdg_toplevel *parent)
766 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
770 xdg_toplevel_set_title(
struct xdg_toplevel *xdg_toplevel,
const char *title)
772 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
776 xdg_toplevel_set_app_id(
struct xdg_toplevel *xdg_toplevel,
const char *app_id)
778 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
782 xdg_toplevel_show_window_menu(
struct xdg_toplevel *xdg_toplevel,
struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
784 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
785 4, seat, serial, x, y);
788 xdg_toplevel_move(
struct xdg_toplevel *xdg_toplevel,
struct wl_seat *seat, uint32_t serial)
790 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
794 xdg_toplevel_resize(
struct xdg_toplevel *xdg_toplevel,
struct wl_seat *seat, uint32_t serial, uint32_t edges)
796 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
797 6, seat, serial, edges);
800 xdg_toplevel_set_max_size(
struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height)
802 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
806 xdg_toplevel_set_min_size(
struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height)
808 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
812 xdg_toplevel_set_maximized(
struct xdg_toplevel *xdg_toplevel)
814 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
818 xdg_toplevel_unset_maximized(
struct xdg_toplevel *xdg_toplevel)
820 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
824 xdg_toplevel_set_fullscreen(
struct xdg_toplevel *xdg_toplevel,
struct wl_output *output)
826 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
830 xdg_toplevel_unset_fullscreen(
struct xdg_toplevel *xdg_toplevel)
832 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
836 xdg_toplevel_set_minimized(
struct xdg_toplevel *xdg_toplevel)
838 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
841 enum xdg_popup_error {
842 XDG_POPUP_ERROR_INVALID_GRAB = 0,
844 struct xdg_popup_listener {
845 void (*configure)(
void *data,
846 struct xdg_popup *xdg_popup,
851 void (*popup_done)(
void *data,
852 struct xdg_popup *xdg_popup);
853 void (*repositioned)(
void *data,
854 struct xdg_popup *xdg_popup,
858 xdg_popup_add_listener(
struct xdg_popup *xdg_popup,
859 const struct xdg_popup_listener *listener,
void *data)
861 return wl_proxy_add_listener((
struct wl_proxy *) xdg_popup,
862 (
void (**)(
void)) listener, data);
865 xdg_popup_set_user_data(
struct xdg_popup *xdg_popup,
void *user_data)
867 wl_proxy_set_user_data((
struct wl_proxy *) xdg_popup, user_data);
870 xdg_popup_get_user_data(
struct xdg_popup *xdg_popup)
872 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_popup);
874 static inline uint32_t
875 xdg_popup_get_version(
struct xdg_popup *xdg_popup)
877 return wl_proxy_get_version((
struct wl_proxy *) xdg_popup);
880 xdg_popup_destroy(
struct xdg_popup *xdg_popup)
882 wl_proxy_marshal((
struct wl_proxy *) xdg_popup,
884 wl_proxy_destroy((
struct wl_proxy *) xdg_popup);
887 xdg_popup_grab(
struct xdg_popup *xdg_popup,
struct wl_seat *seat, uint32_t serial)
889 wl_proxy_marshal((
struct wl_proxy *) xdg_popup,
893 xdg_popup_reposition(
struct xdg_popup *xdg_popup,
struct xdg_positioner *positioner, uint32_t token)
895 wl_proxy_marshal((
struct wl_proxy *) xdg_popup,
896 2, positioner, token);
898 #ifdef ZAKERO_YETANI_IMPLEMENTATION
899 extern const struct wl_interface wl_output_interface;
900 extern const struct wl_interface wl_seat_interface;
901 extern const struct wl_interface wl_surface_interface;
902 extern const struct wl_interface xdg_popup_interface;
903 extern const struct wl_interface xdg_positioner_interface;
904 extern const struct wl_interface xdg_surface_interface;
905 extern const struct wl_interface xdg_toplevel_interface;
906 static const struct wl_interface *xdg_shell_types[] = {
911 &xdg_positioner_interface,
912 &xdg_surface_interface,
913 &wl_surface_interface,
914 &xdg_toplevel_interface,
915 &xdg_popup_interface,
916 &xdg_surface_interface,
917 &xdg_positioner_interface,
918 &xdg_toplevel_interface,
928 &wl_output_interface,
931 &xdg_positioner_interface,
934 static const struct wl_message xdg_wm_base_requests[] = {
935 {
"destroy",
"", xdg_shell_types + 0 },
936 {
"create_positioner",
"n", xdg_shell_types + 4 },
937 {
"get_xdg_surface",
"no", xdg_shell_types + 5 },
938 {
"pong",
"u", xdg_shell_types + 0 },
940 static const struct wl_message xdg_wm_base_events[] = {
941 {
"ping",
"u", xdg_shell_types + 0 },
943 const struct wl_interface xdg_wm_base_interface = {
945 4, xdg_wm_base_requests,
946 1, xdg_wm_base_events,
948 static const struct wl_message xdg_positioner_requests[] = {
949 {
"destroy",
"", xdg_shell_types + 0 },
950 {
"set_size",
"ii", xdg_shell_types + 0 },
951 {
"set_anchor_rect",
"iiii", xdg_shell_types + 0 },
952 {
"set_anchor",
"u", xdg_shell_types + 0 },
953 {
"set_gravity",
"u", xdg_shell_types + 0 },
954 {
"set_constraint_adjustment",
"u", xdg_shell_types + 0 },
955 {
"set_offset",
"ii", xdg_shell_types + 0 },
956 {
"set_reactive",
"3", xdg_shell_types + 0 },
957 {
"set_parent_size",
"3ii", xdg_shell_types + 0 },
958 {
"set_parent_configure",
"3u", xdg_shell_types + 0 },
960 const struct wl_interface xdg_positioner_interface = {
962 10, xdg_positioner_requests,
965 static const struct wl_message xdg_surface_requests[] = {
966 {
"destroy",
"", xdg_shell_types + 0 },
967 {
"get_toplevel",
"n", xdg_shell_types + 7 },
968 {
"get_popup",
"n?oo", xdg_shell_types + 8 },
969 {
"set_window_geometry",
"iiii", xdg_shell_types + 0 },
970 {
"ack_configure",
"u", xdg_shell_types + 0 },
972 static const struct wl_message xdg_surface_events[] = {
973 {
"configure",
"u", xdg_shell_types + 0 },
975 const struct wl_interface xdg_surface_interface = {
977 5, xdg_surface_requests,
978 1, xdg_surface_events,
980 static const struct wl_message xdg_toplevel_requests[] = {
981 {
"destroy",
"", xdg_shell_types + 0 },
982 {
"set_parent",
"?o", xdg_shell_types + 11 },
983 {
"set_title",
"s", xdg_shell_types + 0 },
984 {
"set_app_id",
"s", xdg_shell_types + 0 },
985 {
"show_window_menu",
"ouii", xdg_shell_types + 12 },
986 {
"move",
"ou", xdg_shell_types + 16 },
987 {
"resize",
"ouu", xdg_shell_types + 18 },
988 {
"set_max_size",
"ii", xdg_shell_types + 0 },
989 {
"set_min_size",
"ii", xdg_shell_types + 0 },
990 {
"set_maximized",
"", xdg_shell_types + 0 },
991 {
"unset_maximized",
"", xdg_shell_types + 0 },
992 {
"set_fullscreen",
"?o", xdg_shell_types + 21 },
993 {
"unset_fullscreen",
"", xdg_shell_types + 0 },
994 {
"set_minimized",
"", xdg_shell_types + 0 },
996 static const struct wl_message xdg_toplevel_events[] = {
997 {
"configure",
"iia", xdg_shell_types + 0 },
998 {
"close",
"", xdg_shell_types + 0 },
1000 const struct wl_interface xdg_toplevel_interface = {
1002 14, xdg_toplevel_requests,
1003 2, xdg_toplevel_events,
1005 static const struct wl_message xdg_popup_requests[] = {
1006 {
"destroy",
"", xdg_shell_types + 0 },
1007 {
"grab",
"ou", xdg_shell_types + 22 },
1008 {
"reposition",
"3ou", xdg_shell_types + 24 },
1010 static const struct wl_message xdg_popup_events[] = {
1011 {
"configure",
"iiii", xdg_shell_types + 0 },
1012 {
"popup_done",
"", xdg_shell_types + 0 },
1013 {
"repositioned",
"3u", xdg_shell_types + 0 },
1015 const struct wl_interface xdg_popup_interface = {
1017 3, xdg_popup_requests,
1018 3, xdg_popup_events,
1035 #define X(name_, val_, mesg_) \
1036 static constexpr int name_ = val_;
1037 ZAKERO_YETANI__ERROR_DATA
1061 static constexpr uint32_t KeyModifier_NumLock = 0x00000010;
1175 static
Yetani*
connect(const std::
string&, std::error_code&) noexcept;
1183 wl_shm_format format = WL_SHM_FORMAT_ARGB8888;
1184 int32_t hotspot_x = 0;
1185 int32_t hotspot_y = 0;
1186 std::chrono::milliseconds time_per_frame = std::chrono::milliseconds(0);
1206 std::string make =
"";
1207 std::string model =
"";
1212 uint32_t physical_width_mm = 0;
1213 uint32_t physical_height_mm = 0;
1214 int32_t subpixel = 0;
1215 int32_t refresh_mHz = 0;
1216 int32_t scale_factor = 0;
1217 int32_t transform = 0;
1219 float pixels_per_mm_horizontal = 0.0;
1220 float pixels_per_mm_vertical = 0.0;
1225 using OutputId = uint32_t;
1227 using LambdaOutputId = std::function<void(
const Yetani::OutputId)>;
1229 using VectorOutputId = std::vector<OutputId>;
1276 using VectorShmFormat = std::vector<wl_shm_format>;
1283 static std::
string shmFormatName(const wl_shm_format) noexcept;
1327 void classSet(
const std::string&) noexcept;
1328 void titleSet(
const std::string&) noexcept;
1364 uint32_t
time()
const noexcept;
1383 std::error_code
cursorUse(
const std::string&) noexcept;
1430 struct wl_buffer* wl_buffer;
1431 struct wl_surface* wl_surface;
1432 struct xdg_surface* xdg_surface;
1433 struct xdg_toplevel* xdg_toplevel;
1434 struct zxdg_toplevel_decoration_v1* xdg_decoration;
1436 wl_shm_format pixel_format;
1461 static constexpr uint32_t Size_Max = (uint32_t)std::numeric_limits<int32_t>::max();
1467 using VectorWlSurface = std::vector<struct wl_surface*>;
1472 void disconnect() noexcept;
1479 struct wl_surface* wl_surface =
nullptr;
1480 std::vector<::wl_buffer*> buffer_vector = {};
1481 wl_shm_format format = WL_SHM_FORMAT_ARGB8888;
1482 int64_t next_frame_time = 0;
1483 size_t buffer_index = 0;
1484 uint32_t time_per_frame = 0;
1487 int32_t hotspot_x = 0;
1488 int32_t hotspot_y = 0;
1491 using MapStringCursor = std::unordered_map<std::string, Yetani::Cursor>;
1493 MapStringCursor cursor_map;
1497 struct CursorSurface
1499 struct wl_pointer* wl_pointer;
1500 struct wl_surface* wl_surface;
1507 using MapCursorSurface = std::unordered_map<struct wl_surface*, Yetani::CursorSurface>;
1509 MapCursorSurface cursor_surface_map;
1514 mutable std::mutex cursor_mutex;
1515 struct wl_shm_pool* cursor_shm_pool;
1516 struct wl_pointer* cursor_pointer;
1520 void cursorAnimate() noexcept;
1521 std::error_code cursorCreateCursor(const std::
string&, const Yetani::CursorConfig&) noexcept;
1522 void cursorEnter(struct wl_pointer*, uint32_t, struct wl_surface*) noexcept;
1523 void cursorLeave(struct wl_surface*) noexcept;
1524 void cursorHide(struct wl_surface*) noexcept;
1525 void cursorShow(struct wl_surface*) noexcept;
1526 bool cursorIsHidden(struct wl_surface*) const noexcept;
1527 void cursorSetup() noexcept;
1528 void cursorTeardown() noexcept;
1529 std::error_code cursorAttach(const std::
string&, struct wl_surface*) noexcept;
1530 std::error_code cursorDetach(struct wl_surface*) noexcept;
1535 std::jthread event_loop;
1536 std::atomic<
bool> event_loop_is_running;
1540 void eventLoopStart() noexcept;
1541 static
void eventLoop(std::stop_token, Yetani*) noexcept;
1546 struct wl_compositor* compositor;
1547 struct wl_display* display;
1548 struct wl_registry* registry;
1550 Yetani::VectorShmFormat shm_format_vector;
1557 struct wl_keyboard* wl_keyboard =
nullptr;
1558 struct wl_pointer* wl_pointer =
nullptr;
1559 struct wl_touch* wl_touch =
nullptr;
1560 std::string name =
"";
1561 uint32_t version = 0;
1564 using MapSeat = std::map<struct wl_seat*, Seat>;
1565 using MapIdWlSeat = std::map<uint32_t, struct wl_seat*>;
1567 Yetani::MapSeat seat_map;
1568 Yetani::MapIdWlSeat id_to_seat;
1572 struct wl_seat* seat;
1576 void seatDestroy(
struct wl_seat*&) noexcept;
1581 struct KeyRepeatData
1583 std::chrono::time_point<std::chrono::steady_clock> trigger_time = {};
1584 uint32_t base_time = 0;
1587 using KeyRepeatMap = std::map<uint32_t, Yetani::KeyRepeatData>;
1591 struct KeyboardEvent
1598 using MapKeyboardEvent = std::unordered_map<struct wl_surface*, Yetani::KeyboardEvent>;
1604 struct wl_surface* wl_surface =
nullptr;
1605 Yetani::KeyboardEvent*
event =
nullptr;
1606 Yetani::MapKeyboardEvent event_map = {};
1607 Yetani::KeyModifier modifier = {};
1608 Yetani::KeyRepeatMap repeat_map = {};
1609 char* keymap =
nullptr;
1610 uint32_t keymap_size = 0;
1611 int32_t repeat_delay = 0;
1612 int32_t repeat_rate = 0;
1615 Yetani::Keyboard keyboard;
1619 static void keyboardDestroy(Yetani::Keyboard&) noexcept;
1620 static void keyboardRepeat(Yetani::Keyboard&) noexcept;
1621 static void keyboardRepeatAdd(Yetani::Keyboard&, uint32_t, uint32_t) noexcept;
1622 static void keyboardRepeatReleaseAll(Yetani::Keyboard&) noexcept;
1623 static void keyboardRepeatRemove(Yetani::Keyboard&, uint32_t) noexcept;
1646 using MapPointerEvent = std::unordered_map<struct wl_surface*, Yetani::PointerEvent>;
1653 Yetani* yetani =
nullptr;
1654 struct wl_surface* wl_surface =
nullptr;
1655 struct wl_pointer* wl_pointer =
nullptr;
1656 Yetani::PointerEvent*
event =
nullptr;
1657 Yetani::MapPointerEvent event_map = {};
1660 Yetani::PointMm point_mm = {};
1661 Yetani::PointPercent point_percent = {};
1662 Yetani::PointPixel point_pixel = {};
1665 Yetani::PointerAxis axis = {};
1668 Yetani::PointerButton button = {};
1669 uint32_t button_event_code = 0;
1670 bool button_is_pressed =
false;
1671 uint32_t button_time = {};
1674 struct wl_surface* enter_surface =
nullptr;
1675 Yetani::PointPixel enter_point = {};
1676 uint32_t enter_serial = 0;
1679 struct wl_surface* leave_surface =
nullptr;
1682 Yetani::PointPixel motion_point = {};
1685 Yetani::Pointer pointer;
1689 static void pointerClear(
struct Pointer&) noexcept;
1694 enum struct OutputState
1702 using VectorWlOutput = std::vector<struct wl_output*>;
1704 using MapWlOutputOutputState = std::unordered_map<struct wl_output*, Yetani::OutputState>;
1705 using MapOutputIdWlOutput = std::unordered_map<Yetani::OutputId, struct wl_output*>;
1706 using MapWlOutputOutputId = std::unordered_map<struct wl_output*, Yetani::OutputId>;
1707 using MapWlSurfaceVectorWlOutput = std::unordered_map<struct wl_surface*, Yetani::VectorWlOutput>;
1708 using MapWlOutputOutput = std::unordered_map<struct wl_output*, Output>;
1714 Yetani::MapWlSurfaceVectorWlOutput surface_output_map = {};
1715 Yetani::MapOutputIdWlOutput outputid_to_wloutput = {};
1716 Yetani::MapWlOutputOutput output_map = {};
1717 Yetani::MapWlOutputOutputId wloutput_to_outputid = {};
1718 mutable std::mutex mutex = {};
1721 Yetani::OutputData output_data;
1725 Yetani::LambdaOutputId on_output_add;
1726 Yetani::LambdaOutputId on_output_change;
1727 Yetani::LambdaOutputId on_output_remove;
1729 Yetani::MapWlOutputOutput output_changes_map;
1730 Yetani::MapWlOutputOutputState output_state_map;
1732 Yetani::VectorWlSurface output_notify_surface_vector;
1736 void convertPixel(
struct wl_surface*,
const int32_t,
const int32_t,
float&,
float&,
float&,
float&)
const noexcept;
1738 std::pair<float, float> convertPixelToMm(
const Yetani::Output&, int32_t, int32_t)
const noexcept;
1739 std::pair<float, float> convertPixelToPercent(
const Yetani::Output&, int32_t, int32_t)
const noexcept;
1740 std::pair<int32_t, int32_t> convertMmToPixel(
const Yetani::Output&,
float,
float)
const noexcept;
1741 std::pair<int32_t, int32_t> convertPercentToPixel(
const Yetani::Output&,
float,
float)
const noexcept;
1743 static void outputNotifySurface(Yetani*,
struct wl_output*,
struct wl_surface*) noexcept;
1752 MemoryPool* memory_pool =
nullptr;
1756 using MapBufferData = std::unordered_map<struct wl_buffer*, BufferData>;
1762 MapBufferData map = {};
1763 std::mutex mutex = {};
1770 static wl_buffer* bufferCreate(Yetani::SurfaceSize&, Yetani::Window::Memory*, Yetani::Buffer*) noexcept;
1771 static void bufferDestroy(
struct wl_buffer*&) noexcept;
1783 using MapSurfaceEvent = std::map<struct wl_surface*, Yetani::SurfaceEvent>;
1785 MapSurfaceEvent surface_event_map;
1789 enum struct SizeUnit
1797 struct SurfaceExtent
1799 Yetani::SizeUnit preferred_unit = {};
1800 Yetani::SizeMm preferred_mm = {};
1801 Yetani::SizePercent preferred_percent = {};
1802 Yetani::SizeMm size_mm = {};
1803 Yetani::SizePercent size_percent = {};
1804 Yetani::SizePixel size_pixel = {};
1805 Yetani::SizePixel size_pixel_max = {};
1806 Yetani::SizePixel size_pixel_min = {};
1809 using MapSurfaceExtent = std::unordered_map<struct wl_surface*, Yetani::SurfaceExtent>;
1811 MapSurfaceExtent surface_extent_map;
1812 std::mutex surface_extent_mutex;
1818 struct wl_surface* wl_surface =
nullptr;
1819 std::atomic<wl_buffer*> buffer_next = {};
1821 uint32_t height = 0;
1822 uint32_t time_ms = 0;
1825 using MapSurfaceFrame = std::unordered_map<struct wl_surface*, Yetani::SurfaceFrame>;
1827 MapSurfaceFrame surface_frame_map;
1837 wl_shm_format pixel_format;
1838 uint8_t bytes_per_pixel;
1841 using MapSurfaceSize = std::unordered_map<struct wl_surface*, Yetani::SurfaceSize>;
1843 MapSurfaceSize surface_size_map;
1847 using MapSurfaceResizeMutex = std::unordered_map<struct wl_surface*, std::mutex>;
1849 MapSurfaceResizeMutex surface_resize_mutex_map;
1853 static void surfaceCalculateSize(Yetani*,
struct wl_surface*,
const Yetani::SizePixel&) noexcept;
1854 static struct wl_surface* surfaceCreate(Yetani*,
const wl_shm_format,
const Yetani::SizePixel&, Yetani::Window::Memory&) noexcept;
1855 static void surfaceDestroy(Yetani*,
struct wl_surface*&) noexcept;
1863 struct wl_shm* wl_shm;
1864 struct wl_output* wl_output;
1865 std::string file_name;
1866 Yetani::SizeMm size_mm;
1867 Yetani::SizePercent size_percent;
1868 Yetani::SizePixel size_pixel;
1869 Yetani::SizeUnit size_unit;
1870 wl_shm_format pixel_format;
1871 std::error_code error;
1876 Yetani::Window*
windowCreate(
const Yetani::SizeUnit,
const Yetani::SizeMm&,
const Yetani::SizePercent&,
const Yetani::SizePixel&,
const wl_shm_format, std::error_code&) noexcept;
1877 void windowDataInit(Yetani::WindowData&) noexcept;
1878 void windowDataInitOutput(Yetani::WindowData&) noexcept;
1879 void windowInitMemory(Yetani::WindowData&, Yetani::Window::Memory&) noexcept;
1880 void windowInitOutput(Yetani::WindowData&,
struct wl_surface*) noexcept;
1881 void windowEraseMemory(Yetani::Window::Memory&) noexcept;
1882 void windowEraseOutput(
struct wl_surface*) noexcept;
1883 void windowEraseSurfaceExtent(
struct wl_surface*) noexcept;
1888 std::vector<Yetani::Window*> window_vector;
1889 std::mutex window_vector_mutex;
1893 void windowAdd(Yetani::Window*) noexcept;
1894 void windowRemove(Yetani::Window*) noexcept;
1899 enum XdgState : int32_t
1901 , Toplevel_Active = 1
1902 , Toplevel_Attach_Buffer = 2
1903 , Toplevel_Resizing = 3
1904 , Toplevel_Window_Fullscreen = 4
1905 , Toplevel_Window_Maximized = 5
1906 , Toplevel_Window_Normal = 6
1907 , Toplevel_Decoration = 7
1910 using VectorXdgStateChange = std::vector<int32_t>;
1911 using MapXdgStateChange = std::unordered_map<struct xdg_surface*, Yetani::VectorXdgStateChange>;
1913 Yetani::MapXdgStateChange xdg_state_change_map;
1914 std::mutex xdg_state_change_mutex;
1918 struct xdg_wm_base* xdg_wm_base;
1930 Yetani* yetani =
nullptr;
1931 struct wl_surface* wl_surface =
nullptr;
1934 using MapXdgSurface = std::unordered_map<struct wl_surface*, Yetani::XdgSurface>;
1936 Yetani::MapXdgSurface xdg_surface_map;
1940 struct xdg_surface* xdgSurfaceCreate(
struct wl_surface*) noexcept;
1941 void xdgSurfaceDestroy(
struct wl_surface*,
struct xdg_surface*&) noexcept;
1942 void xdgSurfaceSetExtent(
struct wl_surface*,
const Yetani::SizeUnit&,
const Yetani::SizeMm&,
const Yetani::SizePercent&,
const Yetani::SizePixel&) noexcept;
1949 Yetani::VectorXdgStateChange* state_change =
nullptr;
1952 bool is_active =
false;
1953 Yetani::XdgState window_state = XdgState::Unknown;
1955 Yetani::SizePixel previous_size = {};
1956 struct xdg_toplevel* xdg_toplevel =
nullptr;
1959 using MapXdgToplevel = std::unordered_map<struct xdg_surface*, Yetani::XdgToplevel>;
1961 MapXdgToplevel xdg_toplevel_map;
1965 struct xdg_toplevel* xdgToplevelCreate(
struct xdg_surface*) noexcept;
1966 void xdgToplevelDestroy(
struct xdg_surface*,
struct xdg_toplevel*&) noexcept;
1967 static void xdgToplevelSizeChange(Yetani*,
struct wl_surface*,
const Yetani::SizePixel&) noexcept;
1968 static void xdgToplevelSizeMinMaxChange(Yetani*,
struct xdg_toplevel*,
struct wl_surface*,
const Yetani::SizePixel&,
const Yetani::SizePixel&) noexcept;
1969 static void xdgToplevelWindowChange(Yetani*,
struct wl_surface*, Yetani::XdgToplevel&,
const Yetani::XdgState,
const Yetani::SizePixel&) noexcept;
1974 struct XdgDecoration
1976 Yetani::VectorXdgStateChange* state_change =
nullptr;
1979 bool is_present =
false;
1983 using MapXdgDecoration = std::unordered_map<struct xdg_surface*, Yetani::XdgDecoration>;
1985 MapXdgDecoration xdg_decoration_map;
1989 struct zxdg_decoration_manager_v1* decoration_manager;
1993 struct zxdg_toplevel_decoration_v1* xdgDecorationCreate(
struct xdg_surface*,
struct xdg_toplevel*) noexcept;
1994 void xdgDecorationDestroy(
struct xdg_surface*,
struct xdg_toplevel*,
struct zxdg_toplevel_decoration_v1*&) noexcept;
1995 static void xdgDecorationChange(Yetani::XdgDecoration&,
const uint32_t) noexcept;
2000 static struct wl_buffer_listener buffer_listener;
2001 static struct wl_callback_listener frame_callback_listener;
2002 static struct wl_keyboard_listener keyboard_listener;
2003 static struct wl_output_listener output_listener;
2004 static struct wl_pointer_listener pointer_listener;
2005 static struct wl_registry_listener registry_listener;
2006 static struct wl_seat_listener seat_listener;
2007 static struct wl_shm_listener shm_listener;
2008 static struct wl_surface_listener surface_listener;
2012 static void handlerBufferRelease(
void*,
struct wl_buffer*) noexcept;
2014 static void handlerKeyboardEnter(
void*,
struct wl_keyboard*, uint32_t,
struct wl_surface*,
struct wl_array*) noexcept;
2015 static void handlerKeyboardKey(
void*,
struct wl_keyboard*, uint32_t, uint32_t, uint32_t, uint32_t) noexcept;
2016 static void handlerKeyboardKeymap(
void*,
struct wl_keyboard*, uint32_t, int32_t, uint32_t) noexcept;
2017 static void handlerKeyboardLeave(
void*,
struct wl_keyboard*, uint32_t,
struct wl_surface*) noexcept;
2018 static void handlerKeyboardModifiers(
void*,
struct wl_keyboard*, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t) noexcept;
2019 static void handlerKeyboardRepeatInfo(
void*,
struct wl_keyboard*, int32_t, int32_t) noexcept;
2021 static void handlerOutputDone(
void*,
struct wl_output*) noexcept;
2022 static void handlerOutputGeometry(
void*,
struct wl_output*, int32_t, int32_t, int32_t, int32_t, int32_t,
const char*,
const char*, int32_t) noexcept;
2023 static void handlerOutputMode(
void*,
struct wl_output*, uint32_t, int32_t, int32_t, int32_t) noexcept;
2024 static void handlerOutputScale(
void*,
struct wl_output*, int32_t) noexcept;
2025 static void handlerPointerAxis(
void*,
struct wl_pointer*, uint32_t, uint32_t, wl_fixed_t) noexcept;
2026 static void handlerPointerAxisDiscrete(
void*,
struct wl_pointer*, uint32_t, int32_t) noexcept;
2027 static void handlerPointerAxisSource(
void*,
struct wl_pointer*, uint32_t) noexcept;
2028 static void handlerPointerAxisStop(
void*,
struct wl_pointer*, uint32_t, uint32_t) noexcept;
2029 static void handlerPointerButton(
void*,
struct wl_pointer*, uint32_t, uint32_t, uint32_t, uint32_t) noexcept;
2030 static void handlerPointerEnter(
void*,
struct wl_pointer*, uint32_t,
struct wl_surface*, wl_fixed_t, wl_fixed_t) noexcept;
2031 static void handlerPointerFrame(
void*,
struct wl_pointer*) noexcept;
2032 static void handlerPointerLeave(
void*,
struct wl_pointer*, uint32_t,
struct wl_surface*) noexcept;
2033 static void handlerPointerMotion(
void*,
struct wl_pointer*, uint32_t, wl_fixed_t, wl_fixed_t) noexcept;
2034 static void handlerRegistryGlobal(
void*,
struct wl_registry*, uint32_t,
const char*, uint32_t) noexcept;
2035 static void handlerRegistryRemove(
void*,
struct wl_registry*, uint32_t) noexcept;
2036 static void handlerSeatCapabilities(
void*,
struct wl_seat*, uint32_t) noexcept;
2037 static void handlerSeatName(
void*,
struct wl_seat*,
const char*) noexcept;
2038 static void handlerShmFormat(
void*,
struct wl_shm*, uint32_t) noexcept;
2039 static void handlerSurfaceEnter(
void*,
struct wl_surface*,
struct wl_output*) noexcept;
2040 static void handlerSurfaceLeave(
void*,
struct wl_surface*,
struct wl_output*) noexcept;
2041 static void handlerSwapBuffers(
void*,
struct wl_callback*, uint32_t) noexcept;
2048 static struct xdg_wm_base_listener xdg_wm_base_listener;
2049 static struct xdg_surface_listener xdg_surface_listener;
2050 static struct xdg_toplevel_listener xdg_toplevel_listener;
2054 static void handlerXdgSurfaceConfigure(
void*,
struct xdg_surface*, uint32_t) noexcept;
2055 static void handlerXdgToplevelClose(
void*,
struct xdg_toplevel*) noexcept;
2056 static void handlerXdgToplevelConfigure(
void*,
struct xdg_toplevel*, int32_t, int32_t,
struct wl_array*) noexcept;
2057 static void handlerXdgWmBasePing(
void*,
struct xdg_wm_base*, uint32_t) noexcept;
2062 static struct zxdg_toplevel_decoration_v1_listener xdg_toplevel_decoration_listener;
2066 static void handlerXdgToplevelDecorationConfigure(
void*,
struct zxdg_toplevel_decoration_v1*, uint32_t mode) noexcept;
2070 Yetani(
const Yetani&) =
delete;
2071 Yetani& operator=(
const Yetani&) =
delete;
2077 std::string
to_string(
const wl_shm_format&) noexcept;
2078 std::string
to_string(
const std::error_code&) noexcept;
2079 std::string
to_string(
const Yetani::Key&) noexcept;
2080 std::string
to_string(
const Yetani::KeyModifier&) noexcept;
2082 std::string
to_string(
const Yetani::Output&) noexcept;
2083 std::string
to_string(
const Yetani::PointMm&) noexcept;
2084 std::string
to_string(
const Yetani::PointPercent&) noexcept;
2085 std::string
to_string(
const Yetani::PointPixel&) noexcept;
2086 std::string
to_string(
const Yetani::PointerAxis&) noexcept;
2097 #ifdef ZAKERO_YETANI_IMPLEMENTATION
2103 #ifdef ZAKERO__DOXYGEN_DEFINE_DOCS
2118 #define ZAKERO_YETANI_IMPLEMENTATION
2128 #define ZAKERO_YETANI_ENABLE_DEBUG
2138 #define ZAKERO_YETANI_ENABLE_SAFE_MODE
2159 #ifdef ZAKERO_YETANI_ENABLE_DEBUG
2160 #define ZAKERO_YETANI__DEBUG_DISABLED false
2162 #define ZAKERO_YETANI__DEBUG_DISABLED true
2178 #ifndef ZAKERO_YETANI_ENABLE_DEBUG_STREAM
2179 #define ZAKERO_YETANI_ENABLE_DEBUG_STREAM std::cerr
2200 #define ZAKERO_YETANI__DEBUG \
2201 if(ZAKERO_YETANI__DEBUG_DISABLED) {} \
2202 else ZAKERO_YETANI_ENABLE_DEBUG_STREAM \
2204 << std::to_string(__LINE__) \
2206 << __PRETTY_FUNCTION__ \
2225 #define ZAKERO_YETANI__DEBUG_VAR(var_) \
2226 ZAKERO_YETANI__DEBUG \
2227 << #var_ << ": " << var_ \
2245 #define ZAKERO_YETANI__DEBUG_BOOL(var_) \
2246 ZAKERO_YETANI__DEBUG \
2247 << #var_ << ": " << std::boolalpha << var_ \
2260 #define ZAKERO_YETANI__ERROR(err_) std::error_code(err_, YetaniErrorCategory)
2279 #define ZAKERO_YETANI__SHM_FORMAT \
2280 X(WL_SHM_FORMAT_ARGB8888 , 4 , "32-bit ARGB format, [31:0] A:R:G:B 8:8:8:8 little endian" ) \
2281 X(WL_SHM_FORMAT_XRGB8888 , 4 , "32-bit RGB format, [31:0] x:R:G:B 8:8:8:8 little endian" ) \
2282 X(WL_SHM_FORMAT_C8 , 1 , "8-bit color index format, [7:0] C" ) \
2283 X(WL_SHM_FORMAT_RGB332 , 1 , "8-bit RGB format, [7:0] R:G:B 3:3:2" ) \
2284 X(WL_SHM_FORMAT_BGR233 , 1 , "8-bit BGR format, [7:0] B:G:R 2:3:3" ) \
2285 X(WL_SHM_FORMAT_XRGB4444 , 2 , "16-bit xRGB format, [15:0] x:R:G:B 4:4:4:4 little endian" ) \
2286 X(WL_SHM_FORMAT_XBGR4444 , 2 , "16-bit xBGR format, [15:0] x:B:G:R 4:4:4:4 little endian" ) \
2287 X(WL_SHM_FORMAT_RGBX4444 , 2 , "16-bit RGBx format, [15:0] R:G:B:x 4:4:4:4 little endian" ) \
2288 X(WL_SHM_FORMAT_BGRX4444 , 2 , "16-bit BGRx format, [15:0] B:G:R:x 4:4:4:4 little endian" ) \
2289 X(WL_SHM_FORMAT_ARGB4444 , 2 , "16-bit ARGB format, [15:0] A:R:G:B 4:4:4:4 little endian" ) \
2290 X(WL_SHM_FORMAT_ABGR4444 , 2 , "16-bit ABGR format, [15:0] A:B:G:R 4:4:4:4 little endian" ) \
2291 X(WL_SHM_FORMAT_RGBA4444 , 2 , "16-bit RBGA format, [15:0] R:G:B:A 4:4:4:4 little endian" ) \
2292 X(WL_SHM_FORMAT_BGRA4444 , 2 , "16-bit BGRA format, [15:0] B:G:R:A 4:4:4:4 little endian" ) \
2293 X(WL_SHM_FORMAT_XRGB1555 , 2 , "16-bit xRGB format, [15:0] x:R:G:B 1:5:5:5 little endian" ) \
2294 X(WL_SHM_FORMAT_XBGR1555 , 2 , "16-bit xBGR 1555 format, [15:0] x:B:G:R 1:5:5:5 little endian" ) \
2295 X(WL_SHM_FORMAT_RGBX5551 , 2 , "16-bit RGBx 5551 format, [15:0] R:G:B:x 5:5:5:1 little endian" ) \
2296 X(WL_SHM_FORMAT_BGRX5551 , 2 , "16-bit BGRx 5551 format, [15:0] B:G:R:x 5:5:5:1 little endian" ) \
2297 X(WL_SHM_FORMAT_ARGB1555 , 2 , "16-bit ARGB 1555 format, [15:0] A:R:G:B 1:5:5:5 little endian" ) \
2298 X(WL_SHM_FORMAT_ABGR1555 , 2 , "16-bit ABGR 1555 format, [15:0] A:B:G:R 1:5:5:5 little endian" ) \
2299 X(WL_SHM_FORMAT_RGBA5551 , 2 , "16-bit RGBA 5551 format, [15:0] R:G:B:A 5:5:5:1 little endian" ) \
2300 X(WL_SHM_FORMAT_BGRA5551 , 2 , "16-bit BGRA 5551 format, [15:0] B:G:R:A 5:5:5:1 little endian" ) \
2301 X(WL_SHM_FORMAT_RGB565 , 2 , "16-bit RGB 565 format, [15:0] R:G:B 5:6:5 little endian" ) \
2302 X(WL_SHM_FORMAT_BGR565 , 2 , "16-bit BGR 565 format, [15:0] B:G:R 5:6:5 little endian" ) \
2303 X(WL_SHM_FORMAT_RGB888 , 3 , "24-bit RGB format, [23:0] R:G:B little endian" ) \
2304 X(WL_SHM_FORMAT_BGR888 , 3 , "24-bit BGR format, [23:0] B:G:R little endian" ) \
2305 X(WL_SHM_FORMAT_XBGR8888 , 4 , "32-bit xBGR format, [31:0] x:B:G:R 8:8:8:8 little endian" ) \
2306 X(WL_SHM_FORMAT_RGBX8888 , 4 , "32-bit RGBx format, [31:0] R:G:B:x 8:8:8:8 little endian" ) \
2307 X(WL_SHM_FORMAT_BGRX8888 , 4 , "32-bit BGRx format, [31:0] B:G:R:x 8:8:8:8 little endian" ) \
2308 X(WL_SHM_FORMAT_ABGR8888 , 4 , "32-bit ABGR format, [31:0] A:B:G:R 8:8:8:8 little endian" ) \
2309 X(WL_SHM_FORMAT_RGBA8888 , 4 , "32-bit RGBA format, [31:0] R:G:B:A 8:8:8:8 little endian" ) \
2310 X(WL_SHM_FORMAT_BGRA8888 , 4 , "32-bit BGRA format, [31:0] B:G:R:A 8:8:8:8 little endian" ) \
2311 X(WL_SHM_FORMAT_XRGB2101010 , 4 , "32-bit xRGB format, [31:0] x:R:G:B 2:10:10:10 little endian" ) \
2312 X(WL_SHM_FORMAT_XBGR2101010 , 4 , "32-bit xBGR format, [31:0] x:B:G:R 2:10:10:10 little endian" ) \
2313 X(WL_SHM_FORMAT_RGBX1010102 , 4 , "32-bit RGBx format, [31:0] R:G:B:x 10:10:10:2 little endian" ) \
2314 X(WL_SHM_FORMAT_BGRX1010102 , 4 , "32-bit BGRx format, [31:0] B:G:R:x 10:10:10:2 little endian" ) \
2315 X(WL_SHM_FORMAT_ARGB2101010 , 4 , "32-bit ARGB format, [31:0] A:R:G:B 2:10:10:10 little endian" ) \
2316 X(WL_SHM_FORMAT_ABGR2101010 , 4 , "32-bit ABGR format, [31:0] A:B:G:R 2:10:10:10 little endian" ) \
2317 X(WL_SHM_FORMAT_RGBA1010102 , 4 , "32-bit RGBA format, [31:0] R:G:B:A 10:10:10:2 little endian" ) \
2318 X(WL_SHM_FORMAT_BGRA1010102 , 4 , "32-bit BGRA format, [31:0] B:G:R:A 10:10:10:2 little endian" ) \
2319 X(WL_SHM_FORMAT_YUYV , 4 , "packed YCbCr format, [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian" ) \
2320 X(WL_SHM_FORMAT_YVYU , 4 , "packed YCbCr format, [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian" ) \
2321 X(WL_SHM_FORMAT_UYVY , 4 , "packed YCbCr format, [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian" ) \
2322 X(WL_SHM_FORMAT_VYUY , 4 , "packed YCbCr format, [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian" ) \
2323 X(WL_SHM_FORMAT_AYUV , 4 , "packed AYCbCr format, [31:0] A:Y:Cb:Cr 8:8:8:8 little endian" ) \
2324 X(WL_SHM_FORMAT_NV12 , 8 , "2 plane YCbCr Cr:Cb format, 2x2 subsampled Cr:Cb plane" ) \
2325 X(WL_SHM_FORMAT_NV21 , 8 , "2 plane YCbCr Cb:Cr format, 2x2 subsampled Cb:Cr plane" ) \
2326 X(WL_SHM_FORMAT_NV16 , 8 , "2 plane YCbCr Cr:Cb format, 2x1 subsampled Cr:Cb plane" ) \
2327 X(WL_SHM_FORMAT_NV61 , 8 , "2 plane YCbCr Cb:Cr format, 2x1 subsampled Cb:Cr plane" ) \
2328 X(WL_SHM_FORMAT_YUV410 , 8 , "3 plane YCbCr format, 4x4 subsampled Cb (1) and Cr (2) planes" ) \
2329 X(WL_SHM_FORMAT_YVU410 , 8 , "3 plane YCbCr format, 4x4 subsampled Cr (1) and Cb (2) planes" ) \
2330 X(WL_SHM_FORMAT_YUV411 , 8 , "3 plane YCbCr format, 4x1 subsampled Cb (1) and Cr (2) planes" ) \
2331 X(WL_SHM_FORMAT_YVU411 , 8 , "3 plane YCbCr format, 4x1 subsampled Cr (1) and Cb (2) planes" ) \
2332 X(WL_SHM_FORMAT_YUV420 , 8 , "3 plane YCbCr format, 2x2 subsampled Cb (1) and Cr (2) planes" ) \
2333 X(WL_SHM_FORMAT_YVU420 , 8 , "3 plane YCbCr format, 2x2 subsampled Cr (1) and Cb (2) planes" ) \
2334 X(WL_SHM_FORMAT_YUV422 , 8 , "3 plane YCbCr format, 2x1 subsampled Cb (1) and Cr (2) planes" ) \
2335 X(WL_SHM_FORMAT_YVU422 , 8 , "3 plane YCbCr format, 2x1 subsampled Cr (1) and Cb (2) planes" ) \
2336 X(WL_SHM_FORMAT_YUV444 , 8 , "3 plane YCbCr format, non-subsampled Cb (1) and Cr (2) planes" ) \
2337 X(WL_SHM_FORMAT_YVU444 , 8 , "3 plane YCbCr format, non-subsampled Cr (1) and Cb (2) planes" ) \
2338 X(WL_SHM_FORMAT_R8 , 1 , "[7:0] R" ) \
2339 X(WL_SHM_FORMAT_R16 , 2 , "[15:0] R little endian" ) \
2340 X(WL_SHM_FORMAT_RG88 , 2 , "[15:0] R:G 8:8 little endian" ) \
2341 X(WL_SHM_FORMAT_GR88 , 2 , "[15:0] G:R 8:8 little endian" ) \
2342 X(WL_SHM_FORMAT_RG1616 , 4 , "[31:0] R:G 16:16 little endian" ) \
2343 X(WL_SHM_FORMAT_GR1616 , 4 , "[31:0] G:R 16:16 little endian" ) \
2344 X(WL_SHM_FORMAT_XRGB16161616F , 8 , "[63:0] x:R:G:B 16:16:16:16 little endian" ) \
2345 X(WL_SHM_FORMAT_XBGR16161616F , 8 , "[63:0] x:B:G:R 16:16:16:16 little endian" ) \
2346 X(WL_SHM_FORMAT_ARGB16161616F , 8 , "[63:0] A:R:G:B 16:16:16:16 little endian" ) \
2347 X(WL_SHM_FORMAT_ABGR16161616F , 8 , "[63:0] A:B:G:R 16:16:16:16 little endian" ) \
2348 X(WL_SHM_FORMAT_XYUV8888 , 4 , "[31:0] X:Y:Cb:Cr 8:8:8:8 little endian" ) \
2349 X(WL_SHM_FORMAT_VUY888 , 3 , "[23:0] Cr:Cb:Y 8:8:8 little endian" ) \
2350 X(WL_SHM_FORMAT_VUY101010 , 4 , "Y followed by U then V, 10:10:10. Non-linear modifier only" ) \
2351 X(WL_SHM_FORMAT_Y210 , 8 , "[63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 10:6:10:6:10:6:10:6 little endian per 2 Y pixels" ) \
2352 X(WL_SHM_FORMAT_Y212 , 8 , "[63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 12:4:12:4:12:4:12:4 little endian per 2 Y pixels" ) \
2353 X(WL_SHM_FORMAT_Y216 , 8 , "[63:0] Cr0:Y1:Cb0:Y0 16:16:16:16 little endian per 2 Y pixels" ) \
2354 X(WL_SHM_FORMAT_Y410 , 4 , "[31:0] A:Cr:Y:Cb 2:10:10:10 little endian" ) \
2355 X(WL_SHM_FORMAT_Y412 , 8 , "[63:0] A:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian" ) \
2356 X(WL_SHM_FORMAT_Y416 , 8 , "[63:0] A:Cr:Y:Cb 16:16:16:16 little endian" ) \
2357 X(WL_SHM_FORMAT_XVYU2101010 , 4 , "[31:0] X:Cr:Y:Cb 2:10:10:10 little endian" ) \
2358 X(WL_SHM_FORMAT_XVYU12_16161616 , 8 , "[63:0] X:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian" ) \
2359 X(WL_SHM_FORMAT_XVYU16161616 , 8 , "[63:0] X:Cr:Y:Cb 16:16:16:16 little endian" ) \
2360 X(WL_SHM_FORMAT_Y0L0 , 8 , "[63:0] A3:A2:Y3:0:Cr0:0:Y2:0:A1:A0:Y1:0:Cb0:0:Y0:0 1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian" ) \
2361 X(WL_SHM_FORMAT_X0L0 , 8 , "[63:0] X3:X2:Y3:0:Cr0:0:Y2:0:X1:X0:Y1:0:Cb0:0:Y0:0 1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian" ) \
2362 X(WL_SHM_FORMAT_Y0L2 , 8 , "[63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian" ) \
2363 X(WL_SHM_FORMAT_X0L2 , 8 , "[63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian" ) \
2364 X(WL_SHM_FORMAT_YUV420_8BIT , 8 , "[63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian" ) \
2365 X(WL_SHM_FORMAT_YUV420_10BIT , 8 , "[63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian" ) \
2366 X(WL_SHM_FORMAT_XRGB8888_A8 , 8 , "[63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian" ) \
2367 X(WL_SHM_FORMAT_XBGR8888_A8 , 8 , "[63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian" ) \
2368 X(WL_SHM_FORMAT_RGBX8888_A8 , 8 , "[63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian" ) \
2369 X(WL_SHM_FORMAT_BGRX8888_A8 , 8 , "[63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian" ) \
2370 X(WL_SHM_FORMAT_RGB888_A8 , 8 , "[63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian" ) \
2371 X(WL_SHM_FORMAT_BGR888_A8 , 8 , "[63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian" ) \
2372 X(WL_SHM_FORMAT_RGB565_A8 , 8 , "[63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian" ) \
2373 X(WL_SHM_FORMAT_BGR565_A8 , 8 , "[63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian" ) \
2374 X(WL_SHM_FORMAT_NV24 , 0 , "[UNKNOWN SIZE] non-subsampled Cr:Cb plane" ) \
2375 X(WL_SHM_FORMAT_NV42 , 0 , "[UNKNOWN SIZE] non-subsampled Cb:Cr plane" ) \
2376 X(WL_SHM_FORMAT_P210 , 0 , "[UNKNOWN SIZE] 2x1 subsampled Cr:Cb plane, 10 bits per channel" ) \
2377 X(WL_SHM_FORMAT_P010 , 0 , "[UNKNOWN SIZE] 2x2 subsampled Cr:Cb plane, 10 bits per channel" ) \
2378 X(WL_SHM_FORMAT_P012 , 0 , "[UNKNOWN SIZE] 2x2 subsampled Cr:Cb plane, 12 bits per channel" ) \
2379 X(WL_SHM_FORMAT_P016 , 0 , "[UNKNOWN SIZE] 2x2 subsampled Cr:Cb plane, 16 bits per channel" ) \
2387 #define ZAKERO_YETANI__OUTPUT_SUBPIXEL \
2388 X(WL_OUTPUT_SUBPIXEL_UNKNOWN , "Unkown Subpixel Format" ) \
2389 X(WL_OUTPUT_SUBPIXEL_NONE , "No Subpixels" ) \
2390 X(WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB , "Horizontal RGB" ) \
2391 X(WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR , "Horizontal BGR" ) \
2392 X(WL_OUTPUT_SUBPIXEL_VERTICAL_RGB , "Vertical RGB" ) \
2393 X(WL_OUTPUT_SUBPIXEL_VERTICAL_BGR , "Vertical BGR" ) \
2401 #define ZAKERO_YETANI__OUTPUT_TRANSFORM \
2402 X(WL_OUTPUT_TRANSFORM_NORMAL , "No Transform" ) \
2403 X(WL_OUTPUT_TRANSFORM_90 , "90 degrees Counter-Clockwise" ) \
2404 X(WL_OUTPUT_TRANSFORM_180 , "180 degrees Counter-Clockwise" ) \
2405 X(WL_OUTPUT_TRANSFORM_270 , "270 degrees Counter-Clockwise" ) \
2406 X(WL_OUTPUT_TRANSFORM_FLIPPED , "180 degree flip around a vertical axis" ) \
2407 X(WL_OUTPUT_TRANSFORM_FLIPPED_90 , "Flig and rotate 90 degrees counter-clockwise" ) \
2408 X(WL_OUTPUT_TRANSFORM_FLIPPED_180 , "Flig and rotate 180 degrees counter-clockwise" ) \
2434 #define ZAKERO_YETANI__ARRAY_FOR_EACH(type_, pos_, array_) \
2435 for(type_ pos_ = (type_)(array_)->data \
2436 ; (const char*)pos_ < ((const char*)(array_)->data + (array_)->size) \
2600 class YetaniErrorCategory_
2601 :
public std::error_category
2604 constexpr YetaniErrorCategory_() noexcept
2608 const char* name()
const noexcept
override
2610 return "zakero.Yetani";
2613 std::string message(
int condition
2614 )
const noexcept
override
2618 #define X(name_, val_, mesg_) \
2619 case val_: return mesg_;
2620 ZAKERO_YETANI__ERROR_DATA
2624 return "Unknown error condition";
2626 } YetaniErrorCategory;
2634 Yetani::LambdaKey LambdaKey_DoNothing = [](
const Yetani::Key&,
const Yetani::KeyModifier&) noexcept {};
2635 Yetani::LambdaAxis LambdaAxis_DoNothing = [](
const Yetani::PointerAxis&,
const Yetani::KeyModifier&) noexcept {};
2636 Yetani::LambdaButtonMm LambdaButtonMm_DoNothing = [](
const Yetani::PointerButton&,
const Yetani::PointMm&,
const Yetani::KeyModifier&) noexcept {};
2637 Yetani::LambdaButtonPercent LambdaButtonPercent_DoNothing = [](
const Yetani::PointerButton&,
const Yetani::PointPercent&,
const Yetani::KeyModifier&) noexcept {};
2638 Yetani::LambdaButtonPixel LambdaButtonPixel_DoNothing = [](
const Yetani::PointerButton&,
const Yetani::PointPixel&,
const Yetani::KeyModifier&) noexcept {};
2639 Yetani::LambdaPointMm LambdaPointMm_DoNothing = [](
const Yetani::PointMm&,
const Yetani::KeyModifier&) noexcept {};
2640 Yetani::LambdaPointPercent LambdaPointPercent_DoNothing = [](
const Yetani::PointPercent&,
const Yetani::KeyModifier&) noexcept {};
2641 Yetani::LambdaPointPixel LambdaPointPixel_DoNothing = [](
const Yetani::PointPixel&,
const Yetani::KeyModifier&) noexcept {};
2643 Yetani::LambdaOutputId LambdaOutputId_DoNothing = [](
const Yetani::OutputId) noexcept {};
2666 inline size_t sizeInBytes(
const Yetani::SizePixel& size
2667 ,
const wl_shm_format format
2692 std::error_code validateMinMax(
const Type& min
2702 return ZAKERO_YETANI__ERROR(Yetani::Error_Window_Size_Too_Small);
2707 && (min.width > max.width)
2710 return ZAKERO_YETANI__ERROR(Yetani::Error_Minimum_Size_Greater_Than_Maximum_Size);
2715 && (min.height > max.height)
2718 return ZAKERO_YETANI__ERROR(Yetani::Error_Minimum_Size_Greater_Than_Maximum_Size);
2721 return ZAKERO_YETANI__ERROR(Yetani::Error_None);
3135 struct wl_buffer_listener Yetani::buffer_listener =
3136 { .release = &Yetani::handlerBufferRelease
3139 struct wl_callback_listener Yetani::frame_callback_listener =
3140 { .done = &Yetani::handlerSwapBuffers
3143 struct wl_keyboard_listener Yetani::keyboard_listener =
3144 { .keymap = &Yetani::handlerKeyboardKeymap
3145 , .enter = &Yetani::handlerKeyboardEnter
3146 , .leave = &Yetani::handlerKeyboardLeave
3147 , .key = &Yetani::handlerKeyboardKey
3148 , .modifiers = &Yetani::handlerKeyboardModifiers
3149 , .repeat_info = &Yetani::handlerKeyboardRepeatInfo
3152 struct wl_output_listener Yetani::output_listener =
3153 { .geometry = &Yetani::handlerOutputGeometry
3154 , .mode = &Yetani::handlerOutputMode
3155 , .done = &Yetani::handlerOutputDone
3156 , .scale = &Yetani::handlerOutputScale
3159 struct wl_pointer_listener Yetani::pointer_listener =
3160 { .enter = &Yetani::handlerPointerEnter
3161 , .leave = &Yetani::handlerPointerLeave
3162 , .motion = &Yetani::handlerPointerMotion
3163 , .button = &Yetani::handlerPointerButton
3164 , .axis = &Yetani::handlerPointerAxis
3165 , .frame = &Yetani::handlerPointerFrame
3166 , .axis_source = &Yetani::handlerPointerAxisSource
3167 , .axis_stop = &Yetani::handlerPointerAxisStop
3168 , .axis_discrete = &Yetani::handlerPointerAxisDiscrete
3171 struct wl_registry_listener Yetani::registry_listener =
3172 { .global = &Yetani::handlerRegistryGlobal
3173 , .global_remove = &Yetani::handlerRegistryRemove
3176 struct wl_seat_listener Yetani::seat_listener =
3177 { .capabilities = &Yetani::handlerSeatCapabilities
3178 , .name = &Yetani::handlerSeatName
3181 struct wl_shm_listener Yetani::shm_listener =
3182 { .format = &Yetani::handlerShmFormat
3185 struct wl_surface_listener Yetani::surface_listener =
3186 { .enter = &Yetani::handlerSurfaceEnter
3187 , .leave = &Yetani::handlerSurfaceLeave
3195 struct xdg_wm_base_listener Yetani::xdg_wm_base_listener =
3196 { .ping = &Yetani::handlerXdgWmBasePing
3199 struct xdg_surface_listener Yetani::xdg_surface_listener =
3200 { .configure = &Yetani::handlerXdgSurfaceConfigure
3203 struct xdg_toplevel_listener Yetani::xdg_toplevel_listener =
3204 { .configure = &Yetani::handlerXdgToplevelConfigure
3205 , .close = &Yetani::handlerXdgToplevelClose
3211 struct zxdg_toplevel_decoration_v1_listener Yetani::xdg_toplevel_decoration_listener =
3212 { .configure = &Yetani::handlerXdgToplevelDecorationConfigure
3224 Yetani::Yetani() noexcept
3226 , cursor_surface_map()
3227 , cursor_memory_pool(
3228 std::string(
"Zakero.Yetani.")
3232 , cursor_shm_pool(
nullptr)
3233 , cursor_pointer(
nullptr)
3235 , event_loop_is_running(
false)
3236 , compositor(
nullptr)
3240 , shm_format_vector()
3247 , on_output_add(LambdaOutputId_DoNothing)
3248 , on_output_change(LambdaOutputId_DoNothing)
3249 , on_output_remove(LambdaOutputId_DoNothing)
3250 , output_changes_map()
3251 , output_state_map()
3252 , output_notify_surface_vector()
3254 , surface_event_map()
3255 , surface_extent_map()
3256 , surface_extent_mutex()
3257 , surface_frame_map()
3258 , surface_size_map()
3259 , surface_resize_mutex_map()
3261 , window_vector_mutex()
3262 , xdg_state_change_map()
3263 , xdg_state_change_mutex()
3264 , xdg_wm_base(
nullptr)
3266 , xdg_toplevel_map()
3267 , xdg_decoration_map()
3268 , decoration_manager(
nullptr)
3284 if(event_loop_is_running || event_loop.joinable())
3286 event_loop.request_stop();
3320 std::error_code error;
3353 std::error_code error;
3422 , std::error_code& error
3427 const char* display_name =
nullptr;
3429 if(display.empty() ==
false)
3431 display_name = display.c_str();
3435 yetani->display = wl_display_connect(display_name);
3436 if(yetani->display ==
nullptr)
3440 const char* session = getenv(
"XDG_SESSION_TYPE");
3442 if(session !=
nullptr
3443 && strcasecmp(session,
"wayland") != 0
3446 error = ZAKERO_YETANI__ERROR(Error_Wayland_Not_Available);
3448 else if(display.empty())
3450 error = ZAKERO_YETANI__ERROR(Error_Connection_Failed);
3454 error = ZAKERO_YETANI__ERROR(Error_Invalid_Display_Name);
3461 yetani->registry = wl_display_get_registry(yetani->display);
3462 if(yetani->registry ==
nullptr)
3466 error = ZAKERO_YETANI__ERROR(Error_Registry_Not_Available);
3471 wl_registry_add_listener(yetani->registry, ®istry_listener, yetani);
3474 wl_display_dispatch(yetani->display);
3475 wl_display_roundtrip(yetani->display);
3478 if(yetani->compositor ==
nullptr)
3482 error = ZAKERO_YETANI__ERROR(Error_Compositor_Was_Not_Found);
3487 if(yetani->shm ==
nullptr)
3491 error = ZAKERO_YETANI__ERROR(Error_Shm_Was_Not_Found);
3496 if(yetani->xdg_wm_base ==
nullptr)
3500 error = ZAKERO_YETANI__ERROR(Error_Xdg_WM_Base_Was_Not_Found);
3505 yetani->cursorSetup();
3507 yetani->eventLoopStart();
3509 error = ZAKERO_YETANI__ERROR(Error_None);
3524 void Yetani::disconnect() noexcept
3528 if(decoration_manager !=
nullptr)
3530 zxdg_decoration_manager_v1_destroy(decoration_manager);
3531 decoration_manager =
nullptr;
3534 if(xdg_wm_base !=
nullptr)
3536 xdg_wm_base_destroy(xdg_wm_base);
3537 xdg_wm_base =
nullptr;
3542 wl_shm_destroy(shm);
3549 while(seat_map.empty() ==
false)
3551 auto iter = std::begin(seat_map);
3553 struct wl_seat* wl_seat = iter->first;
3555 seatDestroy(wl_seat);
3560 std::lock_guard<std::mutex> lock(output_data.mutex);
3562 for(
auto& iter : output_data.output_map)
3564 struct wl_output* wayland_output = iter.first;
3566 wl_output_destroy(wayland_output);
3569 output_changes_map.clear();
3570 output_state_map.clear();
3571 output_data.output_map.clear();
3572 output_data.wloutput_to_outputid.clear();
3573 output_data.outputid_to_wloutput.clear();
3576 if(registry !=
nullptr)
3578 wl_registry_destroy(registry);
3582 if(compositor !=
nullptr)
3584 wl_compositor_destroy(compositor);
3585 compositor =
nullptr;
3588 if(display !=
nullptr)
3590 wl_display_disconnect(display);
3732 void Yetani::cursorAnimate() noexcept
3736 std::lock_guard<std::mutex> lock(cursor_mutex);
3738 for(
auto& iter : cursor_map)
3740 Yetani::Cursor& cursor = iter.second;
3742 if(cursor.next_frame_time <= time_now)
3744 const int64_t time_over = time_now - cursor.next_frame_time;
3745 cursor.next_frame_time = time_now + cursor.time_per_frame - time_over;
3747 cursor.buffer_index = (cursor.buffer_index + 1) % cursor.buffer_vector.size();
3749 wl_surface_attach(cursor.wl_surface, cursor.buffer_vector[cursor.buffer_index], 0, 0);
3750 wl_surface_damage(cursor.wl_surface
3752 , cursor.width, cursor.height
3755 wl_surface_commit(cursor.wl_surface);
3807 return ZAKERO_YETANI__ERROR(Error_Cursor_Name_Is_Invalid);
3810 if(cursor_map.contains(name) ==
true)
3812 return ZAKERO_YETANI__ERROR(Error_Cursor_Already_Exists);
3815 if(config.size.width <= 0 || config.size.height <= 0)
3817 return ZAKERO_YETANI__ERROR(Error_Cursor_Size_Too_Small);
3820 if(config.image_data.empty())
3822 return ZAKERO_YETANI__ERROR(Error_Cursor_Image_Data_Is_Empty);
3824 else if(config.image_data.size() > 1)
3826 if(config.time_per_frame.count() <= 0)
3828 return ZAKERO_YETANI__ERROR(Error_Cursor_Frame_Time_Too_Small);
3831 if(config.time_per_frame.count() > Size_Max)
3833 return ZAKERO_YETANI__ERROR(Error_Cursor_Frame_Time_Too_Large);
3837 std::error_code error = cursorCreateCursor(name, config);
3853 std::error_code Yetani::cursorCreateCursor(
const std::string& cursor_name
3857 const uint8_t bytes_per_pixel = shmFormatBytesPerPixel(cursor_config.format);
3858 const size_t frame_count = cursor_config.image_data.size();
3860 Yetani::Cursor cursor =
3861 { .wl_surface = wl_compositor_create_surface(compositor)
3862 , .buffer_vector = { frame_count,
nullptr }
3863 , .format = cursor_config.format
3866 , .time_per_frame = uint32_t(cursor_config.time_per_frame.count())
3867 , .width = cursor_config.size.width
3868 , .height = cursor_config.size.height
3869 , .hotspot_x = cursor_config.hotspot_x
3870 , .hotspot_y = cursor_config.hotspot_y
3873 if(cursor.time_per_frame == 0)
3875 cursor.time_per_frame = Size_Max;
3878 const int stride = cursor.width * bytes_per_pixel;
3879 const size_t image_size = stride * cursor.height;
3881 for(
size_t i = 0; i < frame_count; i++)
3883 std::error_code error;
3885 off_t offset = cursor_memory_pool.alloc(image_size, error);
3892 struct wl_buffer* buffer = cursor.buffer_vector[i];
3893 cursor.buffer_vector[i] =
nullptr;
3895 off_t offset = (off_t)wl_buffer_get_user_data(buffer);
3896 wl_buffer_destroy(buffer);
3898 cursor_memory_pool.free(offset);
3904 uint32_t* p = (uint32_t*)cursor_memory_pool.addressOf(offset);
3905 memcpy(p, (uint8_t*)cursor_config.image_data[i], image_size);
3907 cursor.buffer_vector[i] = wl_shm_pool_create_buffer(cursor_shm_pool
3915 wl_buffer_set_user_data(cursor.buffer_vector[i], (
void*)offset);
3918 wl_surface_attach(cursor.wl_surface, cursor.buffer_vector[0], 0, 0);
3919 wl_surface_commit(cursor.wl_surface);
3921 std::lock_guard<std::mutex> lock(cursor_mutex);
3923 cursor_map[cursor_name] = cursor;
3925 return ZAKERO_YETANI__ERROR(Error_None);
3942 Yetani::Cursor cursor;
3945 std::lock_guard<std::mutex> lock(cursor_mutex);
3947 if(cursor_map.contains(name) ==
false)
3949 return ZAKERO_YETANI__ERROR(Error_Cursor_Does_Not_Exist);
3952 cursor = cursor_map[name];
3954 cursor_map.erase(name);
3957 auto iter = std::begin(cursor_surface_map);
3958 auto iter_end = std::end(cursor_surface_map);
3959 while(iter != iter_end)
3961 if(cursor.wl_surface == iter->second.wl_surface)
3963 iter = cursor_surface_map.erase(iter);
3971 if(cursor.wl_surface)
3973 wl_surface_destroy(cursor.wl_surface);
3974 cursor.wl_surface =
nullptr;
3977 for(wl_buffer* buffer : cursor.buffer_vector)
3979 off_t offset = (off_t)wl_buffer_get_user_data(buffer);
3980 wl_buffer_destroy(buffer);
3982 cursor_memory_pool.free(offset);
3985 return ZAKERO_YETANI__ERROR(Error_None);
3997 void Yetani::cursorEnter(wl_pointer* wl_pointer
3999 ,
struct wl_surface* wl_surface
4002 std::lock_guard<std::mutex> lock(cursor_mutex);
4004 cursor_pointer = wl_pointer;
4006 if(cursor_surface_map.contains(wl_surface) ==
false)
4011 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4013 cursor_surface.wl_pointer = wl_pointer;
4014 cursor_surface.serial = serial;
4016 if(cursor_surface.is_visible)
4018 wl_pointer_set_cursor(cursor_surface.wl_pointer
4019 , cursor_surface.serial
4020 , cursor_surface.wl_surface
4021 , cursor_surface.hotspot_x
4022 , cursor_surface.hotspot_y
4027 wl_pointer_set_cursor(cursor_surface.wl_pointer
4028 , cursor_surface.serial
4046 void Yetani::cursorLeave(
struct wl_surface* wl_surface
4049 std::lock_guard<std::mutex> lock(cursor_mutex);
4051 cursor_pointer =
nullptr;
4053 if(cursor_surface_map.contains(wl_surface) ==
false)
4058 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4060 cursor_surface.wl_pointer =
nullptr;
4061 cursor_surface.serial = 0;
4072 void Yetani::cursorHide(
struct wl_surface* wl_surface
4075 std::lock_guard<std::mutex> lock(cursor_mutex);
4077 if(cursor_surface_map.contains(wl_surface) ==
false)
4082 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4084 cursor_surface.is_visible =
false;
4086 if(cursor_surface.wl_pointer !=
nullptr)
4088 wl_pointer_set_cursor(cursor_surface.wl_pointer
4089 , cursor_surface.serial
4105 void Yetani::cursorShow(
struct wl_surface* wl_surface
4108 std::lock_guard<std::mutex> lock(cursor_mutex);
4110 if(cursor_surface_map.contains(wl_surface) ==
false)
4115 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4117 cursor_surface.is_visible =
true;
4119 if(cursor_surface.wl_pointer !=
nullptr)
4121 wl_pointer_set_cursor(cursor_surface.wl_pointer
4122 , cursor_surface.serial
4123 , cursor_surface.wl_surface
4124 , cursor_surface.hotspot_x
4125 , cursor_surface.hotspot_y
4141 bool Yetani::cursorIsHidden(
struct wl_surface* wl_surface
4144 std::lock_guard<std::mutex> lock(cursor_mutex);
4146 if(cursor_surface_map.contains(wl_surface) ==
false)
4151 const Yetani::CursorSurface& cursor_surface = cursor_surface_map.at(wl_surface);
4153 return !(cursor_surface.is_visible);
4164 void Yetani::cursorSetup() noexcept
4168 uint64_t bytes =
zakero::convert((uint64_t)4, zakero::Storage::Kilobyte, zakero::Storage::Byte);
4169 cursor_memory_pool.
init(bytes,
true, zakero::MemoryPool::Alignment::Bits_32);
4173 wl_shm_pool_resize(cursor_shm_pool, new_size);
4176 cursor_shm_pool = wl_shm_create_pool(shm, cursor_memory_pool.
fd(), cursor_memory_pool.
size());
4187 void Yetani::cursorTeardown() noexcept
4189 while(cursor_map.empty() ==
false)
4191 const auto& iter = cursor_map.begin();
4193 const std::string& name = iter->first;
4198 if(cursor_shm_pool !=
nullptr)
4200 wl_shm_pool_destroy(cursor_shm_pool);
4216 std::error_code Yetani::cursorAttach(
const std::string& cursor_name
4217 ,
struct wl_surface* wl_surface
4220 std::lock_guard<std::mutex> lock(cursor_mutex);
4222 if(cursor_map.contains(cursor_name) ==
false)
4224 return ZAKERO_YETANI__ERROR(Error_Cursor_Does_Not_Exist);
4227 if(cursor_surface_map.contains(wl_surface) ==
false)
4229 cursor_surface_map[wl_surface] =
4230 { .wl_pointer = cursor_pointer
4231 , .wl_surface = nullptr
4235 , .is_visible =
true
4239 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4240 Yetani::Cursor& cursor = cursor_map[cursor_name];
4242 cursor_surface.wl_surface = cursor.wl_surface;
4243 cursor_surface.hotspot_x = cursor.hotspot_x;
4244 cursor_surface.hotspot_y = cursor.hotspot_y;
4246 if(cursor_surface.wl_pointer !=
nullptr)
4248 if(cursor_surface.is_visible)
4250 wl_pointer_set_cursor(cursor_surface.wl_pointer
4251 , cursor_surface.serial
4252 , cursor_surface.wl_surface
4253 , cursor_surface.hotspot_x
4254 , cursor_surface.hotspot_y
4259 wl_pointer_set_cursor(cursor_surface.wl_pointer
4260 , cursor_surface.serial
4268 return ZAKERO_YETANI__ERROR(Error_None);
4283 std::error_code Yetani::cursorDetach(
struct wl_surface* wl_surface
4286 std::lock_guard<std::mutex> lock(cursor_mutex);
4288 if(cursor_surface_map.contains(wl_surface) ==
false)
4290 return ZAKERO_YETANI__ERROR(Error_Cursor_Not_Attached);
4293 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4295 if(cursor_surface.wl_pointer !=
nullptr)
4297 wl_pointer_set_cursor(cursor_surface.wl_pointer
4298 , cursor_surface.serial
4305 cursor_surface_map.erase(wl_surface);
4307 return ZAKERO_YETANI__ERROR(Error_None);
4323 void Yetani::eventLoopStart() noexcept
4325 event_loop = std::jthread(&Yetani::eventLoop,
this);
4327 while(event_loop_is_running.load() ==
false)
4330 std::this_thread::sleep_for(std::chrono::nanoseconds(42));
4333 #ifdef ZAKERO_YETANI__ENABLE_THREAD_SCHEDULER
4334 int policy = SCHED_FIFO;
4335 int priority_min = sched_get_priority_min(policy);
4336 int priority_max = sched_get_priority_max(policy);
4339 { .sched_priority = (priority_min + priority_max) / 2
4342 pthread_setschedparam(event_loop.native_handle(), policy, &sched);
4374 void Yetani::eventLoop(std::stop_token thread_token
4378 struct pollfd fd_status =
4379 { .fd = wl_display_get_fd(yetani->display)
4380 , .events = POLLIN | POLLOUT
4384 yetani->event_loop_is_running.store(
true);
4387 while(thread_token.stop_requested() ==
false)
4389 poll(&fd_status, 1, 1);
4391 if(fd_status.revents & POLLIN)
4393 wl_display_dispatch(yetani->display);
4396 yetani->cursorAnimate();
4398 keyboardRepeat(yetani->keyboard);
4400 if(fd_status.revents & POLLOUT)
4402 wl_display_flush(yetani->display);
4405 #ifdef ZAKERO_YETANI__ENABLE_THREAD_SCHEDULER
4406 std::this_thread::yield();
4410 yetani->event_loop_is_running.store(
false);
4428 return shm_format_vector;
4448 #define X(value_, bytes_, desc_) \
4449 case value_: return bytes_;
4450 ZAKERO_YETANI__SHM_FORMAT
4473 #define X(value_, bytes_, desc_) \
4474 case value_: return desc_;
4475 ZAKERO_YETANI__SHM_FORMAT
4496 #define X(value_, bytes_, desc_) \
4497 case value_: return #value_;
4498 ZAKERO_YETANI__SHM_FORMAT
4551 struct wl_buffer* Yetani::bufferCreate(Yetani::SurfaceSize& surface_size
4553 , Yetani::Buffer* buffer
4556 off_t offset = window_memory->memory_pool.alloc(surface_size.in_bytes);
4558 struct wl_buffer* wl_buffer = wl_shm_pool_create_buffer(window_memory->wl_shm_pool
4560 , surface_size.width
4561 , surface_size.height
4562 , surface_size.stride
4563 , surface_size.pixel_format
4566 wl_buffer_set_user_data(wl_buffer, buffer);
4568 buffer->mutex.lock();
4570 buffer->map[wl_buffer] =
4571 { .memory_pool = &window_memory->memory_pool
4575 buffer->mutex.unlock();
4590 void Yetani::bufferDestroy(
struct wl_buffer*& wl_buffer
4593 Yetani::Buffer* buffer = (Yetani::Buffer*)wl_buffer_get_user_data(wl_buffer);
4595 wl_buffer_destroy(wl_buffer);
4597 buffer->mutex.lock();
4599 BufferData& buffer_data = buffer->map[wl_buffer];
4601 buffer_data.memory_pool->free(buffer_data.offset);
4603 buffer->map.erase(wl_buffer);
4605 buffer->mutex.unlock();
4607 wl_buffer =
nullptr;
4711 std::lock_guard<std::mutex> lock(output_data.mutex);
4713 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4715 ZAKERO_YETANI__DEBUG
4716 <<
"Invalid output_id: "
4717 << std::to_string(output_id)
4723 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4725 return output_data.output_map.at(wl_output);
4742 Yetani::VectorOutputId vector;
4744 std::lock_guard<std::mutex> lock(output_data.mutex);
4746 for(
const auto& iter : output_data.outputid_to_wloutput)
4748 vector.push_back(iter.first);
4769 switch(subpixel_format)
4771 #define X(value_, name_) \
4772 case value_: return name_;
4773 ZAKERO_YETANI__OUTPUT_SUBPIXEL
4796 #define X(value_, name_) \
4797 case value_: return name_;
4798 ZAKERO_YETANI__OUTPUT_TRANSFORM
4819 std::lock_guard<std::mutex> lock(output_data.mutex);
4821 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4823 return { point.time, 0, 0 };
4826 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4827 const Yetani::Output& output = output_data.output_map.at(wl_output);
4829 auto p = convertPixelToMm(output, point.
x, point.y);
4831 return { point.time, p.first, p.second };
4849 std::lock_guard<std::mutex> lock(output_data.mutex);
4851 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4853 return { point.time, 0, 0 };
4856 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4857 const Yetani::Output& output = output_data.output_map.at(wl_output);
4859 auto p = convertPixelToPercent(output, point.
x, point.y);
4861 return { point.time, p.first, p.second };
4879 std::lock_guard<std::mutex> lock(output_data.mutex);
4881 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4883 return { point.time, 0, 0 };
4886 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4887 const Yetani::Output& output = output_data.output_map.at(wl_output);
4889 auto p = convertMmToPixel(output, point.
x, point.y);
4891 return { point.time, p.first, p.second };
4909 std::lock_guard<std::mutex> lock(output_data.mutex);
4911 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4913 return { point.time, 0, 0 };
4916 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4917 const Yetani::Output& output = output_data.output_map.at(wl_output);
4919 auto p = convertPercentToPixel(output, point.
x, point.y);
4921 return { point.time, p.first, p.second };
4939 std::lock_guard<std::mutex> lock(output_data.mutex);
4941 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4946 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4947 const Yetani::Output& output = output_data.output_map.at(wl_output);
4949 auto p = convertPixelToMm(output, size.
width, size.height);
4951 return { p.first, p.second };
4969 std::lock_guard<std::mutex> lock(output_data.mutex);
4971 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4976 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4977 const Yetani::Output& output = output_data.output_map.at(wl_output);
4979 auto p = convertPixelToPercent(output, size.
width, size.height);
4981 return { p.first, p.second };
4998 std::lock_guard<std::mutex> lock(output_data.mutex);
5000 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
5005 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
5006 const Yetani::Output& output = output_data.output_map.at(wl_output);
5008 auto p = convertMmToPixel(output, size.
width, size.height);
5010 return { p.first, p.second };
5027 std::lock_guard<std::mutex> lock(output_data.mutex);
5029 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
5034 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
5035 const Yetani::Output& output = output_data.output_map.at(wl_output);
5037 auto p = convertPercentToPixel(output, size.
width, size.height);
5039 return { p.first, p.second };
5055 if(lambda ==
nullptr)
5057 on_output_add = LambdaOutputId_DoNothing;
5061 on_output_add = lambda;
5078 if(lambda ==
nullptr)
5080 on_output_change = LambdaOutputId_DoNothing;
5084 on_output_change = lambda;
5101 if(lambda ==
nullptr)
5103 on_output_remove = LambdaOutputId_DoNothing;
5107 on_output_remove = lambda;
5120 void Yetani::convertPixel(
struct wl_surface* wl_surface
5121 ,
const int32_t pixel_xw
5122 ,
const int32_t pixel_yh
5129 std::lock_guard<std::mutex> lock(output_data.mutex);
5131 const Yetani::VectorWlOutput& vector = output_data.surface_output_map.at(wl_surface);
5132 struct wl_output* wl_output = vector.front();
5133 const Yetani::Output& output = output_data.output_map.at(wl_output);
5135 auto mm = convertPixelToMm(output, pixel_xw, pixel_yh);
5139 auto pc = convertPixelToPercent(output, pixel_xw, pixel_yh);
5156 std::pair<float, float> Yetani::convertPixelToMm(
const Yetani::Output& output
5182 std::pair<float, float> Yetani::convertPixelToPercent(
const Yetani::Output& output
5188 { float(xw) / output.
width
5189 , float(yh) / output.
height
5205 std::pair<int32_t, int32_t> Yetani::convertMmToPixel(
const Yetani::Output& output
5214 { int32_t(xw * ratio_h)
5215 , int32_t(yh * ratio_v)
5231 std::pair<int32_t, int32_t> Yetani::convertPercentToPixel(
const Yetani::Output& output
5237 { int32_t(xw * output.
width)
5238 , int32_t(yh * output.
height)
5254 void Yetani::outputNotifySurface(Yetani* yetani
5255 ,
struct wl_output* wl_output
5256 ,
struct wl_surface* wl_surface
5259 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
5260 if(surface_extent.preferred_unit == Yetani::SizeUnit::Pixel)
5265 Yetani::OutputData& output_data = yetani->output_data;
5267 std::lock_guard<std::mutex> lock(output_data.mutex);
5269 Yetani::VectorWlOutput& output_vector = output_data.surface_output_map[wl_surface];
5271 struct wl_output* output_current = output_vector.front();
5273 if(output_current != wl_output)
5278 Yetani::Output& output = output_data.output_map.at(wl_output);
5279 Yetani::SizePixel new_size = surface_extent.size_pixel;
5281 if(surface_extent.preferred_unit == Yetani::SizeUnit::Millimeter)
5283 auto p = yetani->convertMmToPixel(output, surface_extent.size_mm.width, surface_extent.size_mm.height);
5284 new_size = { p.first, p.second };
5286 else if(surface_extent.preferred_unit == Yetani::SizeUnit::Percent)
5288 auto p = yetani->convertPercentToPixel(output, surface_extent.size_percent.width, surface_extent.size_percent.height);
5289 new_size = { p.first, p.second };
5292 if(new_size.width <= 0)
5297 if(new_size.height <= 0)
5299 new_size.height = 1;
5302 yetani->surface_resize_mutex_map[wl_surface].lock();
5304 surface_extent.size_pixel = new_size;
5305 surfaceCalculateSize(yetani, wl_surface, new_size);
5307 yetani->surface_resize_mutex_map[wl_surface].unlock();
5345 void Yetani::seatDestroy(
struct wl_seat*& wl_seat
5348 Yetani::Seat& seat = seat_map[wl_seat];
5350 if(seat.wl_keyboard !=
nullptr)
5352 wl_keyboard_release(seat.wl_keyboard);
5353 seat.wl_keyboard =
nullptr;
5356 if(seat.wl_pointer !=
nullptr)
5358 wl_pointer_release(seat.wl_pointer);
5359 seat.wl_pointer =
nullptr;
5362 if(seat.wl_touch !=
nullptr)
5364 wl_touch_release(seat.wl_touch);
5365 seat.wl_touch =
nullptr;
5368 seat_map.erase(wl_seat);
5370 wl_seat_release(wl_seat);
5453 return keyboard.repeat_delay;
5467 return 1000 / keyboard.repeat_rate;
5474 void Yetani::keyboardDestroy(Yetani::Keyboard& keyboard
5477 if(keyboard.keymap !=
nullptr)
5479 munmap(keyboard.keymap, keyboard.keymap_size);
5482 keyboard.wl_surface =
nullptr;
5483 keyboard.event =
nullptr;
5484 keyboard.modifier = { 0 };
5485 keyboard.repeat_rate = 0;
5486 keyboard.repeat_delay = {};
5487 keyboard.keymap =
nullptr;
5488 keyboard.keymap_size = 0;
5498 void Yetani::keyboardRepeat(Yetani::Keyboard& keyboard
5501 auto now = std::chrono::steady_clock::now();
5503 for(
auto& iter : keyboard.repeat_map)
5505 Yetani::KeyRepeatData& key_repeat = iter.second;
5507 if(now >= key_repeat.trigger_time)
5509 uint32_t key_code = iter.first;
5512 { .time = key_repeat.base_time
5514 , .state = Yetani::KeyState::Repeat
5517 keyboard.event->on_key(key, keyboard.modifier);
5519 key_repeat.trigger_time = now
5520 + std::chrono::milliseconds(keyboard.repeat_rate)
5521 - (now - key_repeat.trigger_time)
5523 key_repeat.base_time += keyboard.repeat_rate;
5536 void Yetani::keyboardRepeatAdd(Yetani::Keyboard& keyboard
5541 auto trigger_time = std::chrono::steady_clock::now()
5542 + std::chrono::milliseconds(keyboard.repeat_delay)
5545 keyboard.repeat_map[key_code] =
5546 { .trigger_time = trigger_time
5547 , .base_time = time + keyboard.repeat_delay
5558 void Yetani::keyboardRepeatReleaseAll(Yetani::Keyboard& keyboard
5561 while(keyboard.repeat_map.empty() ==
false)
5563 auto iter = keyboard.repeat_map.begin();
5565 uint32_t key_code = iter->first;
5570 , .state = Yetani::KeyState::Released
5573 keyboard.event->on_key(key, keyboard.modifier);
5575 keyboard.repeat_map.erase(iter);
5586 void Yetani::keyboardRepeatRemove(Yetani::Keyboard& keyboard
5590 keyboard.repeat_map.erase(key_code);
5611 void Yetani::pointerClear(Yetani::Pointer& pointer
5614 pointer.enter_surface =
nullptr;
5615 pointer.enter_point = { 0, 0, 0 };
5616 pointer.leave_surface =
nullptr;
5617 pointer.motion_point = { 0, 0, 0 };
5618 pointer.button_event_code = 0;
5619 pointer.button_is_pressed =
false;
5620 pointer.button_time = 0;
5621 pointer.axis.time = 0;
5622 pointer.axis.type = Yetani::PointerAxisType::Unknown;
5623 pointer.axis.distance = 0;
5624 pointer.axis.source = Yetani::PointerAxisSource::Unknown;
5625 pointer.axis.steps = 0;
5668 void Yetani::surfaceCalculateSize(Yetani* yetani
5669 ,
struct wl_surface* wl_surface
5670 ,
const Yetani::SizePixel& size
5673 Yetani::SurfaceSize& surface_size = yetani->surface_size_map[wl_surface];
5674 surface_size.width = size.width;
5675 surface_size.height = size.height;
5676 surface_size.stride = size.width * surface_size.bytes_per_pixel;
5677 surface_size.in_bytes = surface_size.stride * surface_size.height;
5679 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
5680 surface_frame.width = size.width;
5681 surface_frame.height = size.height;
5702 struct wl_surface* Yetani::surfaceCreate(Yetani* yetani
5703 ,
const wl_shm_format pixel_format
5704 ,
const Yetani::SizePixel& size
5705 , Yetani::Window::Memory& window_memory
5708 struct wl_surface* wl_surface = wl_compositor_create_surface(yetani->compositor);
5710 Yetani::SurfaceSize& surface_size = yetani->surface_size_map[wl_surface];
5711 surface_size.pixel_format = pixel_format;
5712 surface_size.bytes_per_pixel = shmFormatBytesPerPixel(pixel_format);
5714 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
5715 surface_frame.wl_surface = wl_surface;
5716 surface_frame.time_ms = 0;
5718 surfaceCalculateSize(yetani, wl_surface, size);
5720 surface_frame.buffer_next = bufferCreate(surface_size, &window_memory, &yetani->buffer);
5723 bool event_keyboard =
true;
5726 yetani->keyboard.event_map[wl_surface] =
5727 { .on_enter = Lambda_DoNothing
5728 , .on_leave = Lambda_DoNothing
5729 , .on_key = LambdaKey_DoNothing
5734 bool event_pointer =
true;
5737 yetani->pointer.event_map[wl_surface] =
5738 { .on_axis = LambdaAxis_DoNothing
5739 , .on_axis_discrete = Lambda_DoNothing
5740 , .on_axis_source = Lambda_DoNothing
5741 , .on_axis_stop = Lambda_DoNothing
5742 , .on_button_mm = LambdaButtonMm_DoNothing
5743 , .on_button_percent = LambdaButtonPercent_DoNothing
5744 , .on_button_pixel = LambdaButtonPixel_DoNothing
5745 , .on_enter_mm = LambdaPointMm_DoNothing
5746 , .on_enter_percent = LambdaPointPercent_DoNothing
5747 , .on_enter_pixel = LambdaPointPixel_DoNothing
5748 , .on_leave = Lambda_DoNothing
5749 , .on_motion_mm = LambdaPointMm_DoNothing
5750 , .on_motion_percent = LambdaPointPercent_DoNothing
5751 , .on_motion_pixel = LambdaPointPixel_DoNothing
5755 yetani->surface_event_map[wl_surface] =
5756 { .on_size_mm_change = LambdaSizeMm_DoNothing
5757 , .on_size_percent_change = LambdaSizePercent_DoNothing
5758 , .on_size_pixel_change = LambdaSizePixel_DoNothing
5761 wl_surface_add_listener(wl_surface
5775 void Yetani::surfaceDestroy(Yetani* yetani
5776 ,
struct wl_surface*& wl_surface
5779 if(wl_surface ==
nullptr)
5784 if(yetani->surface_frame_map.contains(wl_surface))
5786 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
5788 struct wl_buffer* wl_buffer =
nullptr;
5789 wl_buffer = surface_frame.buffer_next.exchange(
nullptr);
5791 if(wl_buffer !=
nullptr)
5793 bufferDestroy(wl_buffer);
5797 if(yetani->keyboard.event_map.contains(wl_surface))
5799 yetani->keyboard.event_map.erase(wl_surface);
5802 if(yetani->pointer.event_map.contains(wl_surface))
5804 yetani->pointer.event_map.erase(wl_surface);
5807 yetani->surface_size_map.erase(wl_surface);
5808 yetani->surface_frame_map.erase(wl_surface);
5809 yetani->surface_event_map.erase(wl_surface);
5811 yetani->cursorDetach(wl_surface);
5813 wl_surface_destroy(wl_surface);
5814 wl_surface =
nullptr;
5832 void Yetani::handlerBufferRelease(
void*
5833 ,
struct wl_buffer* wl_buffer
5836 Yetani::bufferDestroy(wl_buffer);
5845 void Yetani::handlerKeyboardEnter(
void* data
5846 ,
struct wl_keyboard*
5848 ,
struct wl_surface* wl_surface
5849 ,
struct wl_array* key_array
5852 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
5854 if(keyboard.wl_surface !=
nullptr)
5856 keyboardRepeatReleaseAll(keyboard);
5858 keyboard.event->on_leave();
5861 keyboard.wl_surface = wl_surface;
5863 if(keyboard.event_map.contains(wl_surface))
5865 keyboard.event = &(keyboard.event_map[wl_surface]);
5869 keyboard.event = &(keyboard.event_map[
nullptr]);
5872 keyboard.event->on_enter();
5874 if(key_array->size > 0)
5879 , .state = Yetani::KeyState::Pressed
5882 ZAKERO_YETANI__ARRAY_FOR_EACH(uint32_t*, key_iter, key_array)
5884 key.code = *key_iter;
5886 keyboard.event->on_key(key, keyboard.modifier);
5888 keyboardRepeatAdd(keyboard, key.code, 0);
5897 void Yetani::handlerKeyboardKey(
void* data
5898 ,
struct wl_keyboard*
5905 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
5910 , .state = (state == WL_KEYBOARD_KEY_STATE_PRESSED)
5911 ? Yetani::KeyState::Pressed
5912 : Yetani::KeyState::Released
5915 keyboard.event->on_key(key, keyboard.modifier);
5917 if(key.state == Yetani::KeyState::Pressed
5918 && keyboard.repeat_rate > 0
5921 keyboardRepeatAdd(keyboard, key_code, time);
5923 else if(key.state == Yetani::KeyState::Released)
5925 keyboardRepeatRemove(keyboard, key_code);
5933 void Yetani::handlerKeyboardKeymap(
void* data
5934 ,
struct wl_keyboard*
5940 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
5942 if(format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
5944 if(keyboard.keymap !=
nullptr)
5946 munmap(keyboard.keymap
5947 , keyboard.keymap_size
5951 keyboard.keymap = (
char*)mmap(
nullptr
5954 , MAP_NORESERVE | MAP_PRIVATE
5958 keyboard.keymap_size = size;
5962 if(keyboard.keymap !=
nullptr)
5964 munmap(keyboard.keymap
5965 , keyboard.keymap_size
5968 keyboard.keymap =
nullptr;
5969 keyboard.keymap_size = 0;
5978 void Yetani::handlerKeyboardLeave(
void* data
5979 ,
struct wl_keyboard*
5981 ,
struct wl_surface* wl_surface
5984 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
5986 if(keyboard.wl_surface == wl_surface)
5988 keyboardRepeatReleaseAll(keyboard);
5990 keyboard.event->on_leave();
5992 keyboard.event = &(keyboard.event_map[
nullptr]);
5993 keyboard.wl_surface =
nullptr;
6001 void Yetani::handlerKeyboardModifiers(
void* data
6002 ,
struct wl_keyboard*
6004 , uint32_t mods_pressed
6005 , uint32_t mods_latched
6006 , uint32_t mods_locked
6010 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
6012 keyboard.modifier.pressed = mods_pressed;
6013 keyboard.modifier.latched = mods_latched;
6014 keyboard.modifier.locked = mods_locked;
6015 keyboard.modifier.group = group;
6022 void Yetani::handlerKeyboardRepeatInfo(
void* data
6023 ,
struct wl_keyboard*
6028 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
6030 keyboard.repeat_delay = delay;
6031 keyboard.repeat_rate = 1000 / rate;
6040 void Yetani::handlerOutputDone(
void* data
6041 ,
struct wl_output* wl_output
6044 Yetani* yetani = (Yetani*)data;
6045 Yetani::Output& output = yetani->output_data.output_map[wl_output];
6046 Yetani::Output& changes = yetani->output_changes_map[wl_output];
6047 Yetani::OutputId output_id = yetani->output_data.wloutput_to_outputid[wl_output];
6077 output.pixels_per_mm_horizontal = output.width / float(output.physical_width_mm);
6078 output.pixels_per_mm_vertical = output.height / float(output.physical_height_mm);
6080 ZAKERO_YETANI__DEBUG <<
"\n" <<
to_string(output) <<
"\n";
6082 switch(yetani->output_state_map[wl_output])
6084 case Yetani::OutputState::Done:
6088 case Yetani::OutputState::Added:
6089 yetani->on_output_add(output_id);
6092 case Yetani::OutputState::Changed:
6093 yetani->on_output_change(output_id);
6095 for(
auto wl_surface : yetani->output_notify_surface_vector)
6097 outputNotifySurface(yetani, wl_output, wl_surface);
6103 yetani->output_state_map[wl_output] = Yetani::OutputState::Done;
6110 void Yetani::handlerOutputGeometry(
void* data
6111 ,
struct wl_output* wl_output
6114 , int32_t physical_width
6115 , int32_t physical_height
6122 Yetani* yetani = (Yetani*)data;
6123 Yetani::Output& output_changes = yetani->output_changes_map[wl_output];
6125 if(yetani->output_state_map[wl_output] != Yetani::OutputState::Added)
6127 yetani->output_state_map[wl_output] = Yetani::OutputState::Changed;
6130 output_changes.x = x;
6131 output_changes.y = y;
6132 output_changes.physical_width_mm = physical_width;
6133 output_changes.physical_height_mm = physical_height;
6134 output_changes.subpixel = subpixel;
6135 output_changes.make = std::string(make);
6136 output_changes.model = std::string(model);
6137 output_changes.transform = transform;
6144 void Yetani::handlerOutputMode(
void* data
6145 ,
struct wl_output* wl_output
6152 Yetani* yetani = (Yetani*)data;
6153 Yetani::Output& output_changes = yetani->output_changes_map[wl_output];
6155 if(yetani->output_state_map[wl_output] != Yetani::OutputState::Added)
6157 yetani->output_state_map[wl_output] = Yetani::OutputState::Changed;
6160 output_changes.flags = flags;
6161 output_changes.width = width;
6162 output_changes.height = height;
6163 output_changes.refresh_mHz = refresh;
6170 void Yetani::handlerOutputScale(
void* data
6171 ,
struct wl_output* wl_output
6175 Yetani* yetani = (Yetani*)data;
6176 Output& output_changes = yetani->output_changes_map[wl_output];
6178 if(yetani->output_state_map[wl_output] != Yetani::OutputState::Added)
6180 yetani->output_state_map[wl_output] = Yetani::OutputState::Changed;
6183 output_changes.scale_factor = factor;
6192 void Yetani::handlerPointerAxis(
void* data
6193 ,
struct wl_pointer*
6199 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6201 pointer.axis.time = time;
6202 pointer.axis.distance = (float)wl_fixed_to_double(value);
6204 if(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
6206 pointer.axis.type = Yetani::PointerAxisType::Horizontal;
6208 else if(axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
6210 pointer.axis.type = Yetani::PointerAxisType::Vertical;
6214 pointer.axis.type = Yetani::PointerAxisType::Unknown;
6222 void Yetani::handlerPointerAxisDiscrete(
void* data
6223 ,
struct wl_pointer*
6228 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6230 pointer.axis.steps = discrete;
6237 void Yetani::handlerPointerAxisSource(
void* data
6238 ,
struct wl_pointer*
6239 , uint32_t axis_source
6242 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6246 case WL_POINTER_AXIS_SOURCE_WHEEL:
6247 pointer.axis.source = Yetani::PointerAxisSource::Wheel;
6250 case WL_POINTER_AXIS_SOURCE_FINGER:
6251 pointer.axis.source = Yetani::PointerAxisSource::Finger;
6254 case WL_POINTER_AXIS_SOURCE_CONTINUOUS:
6255 pointer.axis.source = Yetani::PointerAxisSource::Continuous;
6258 case WL_POINTER_AXIS_SOURCE_WHEEL_TILT:
6259 pointer.axis.source = Yetani::PointerAxisSource::Wheel_Tilt;
6263 pointer.axis.source = Yetani::PointerAxisSource::Unknown;
6271 void Yetani::handlerPointerAxisStop(
void*
6272 ,
struct wl_pointer*
6293 void Yetani::handlerPointerButton(
void* data
6294 ,
struct wl_pointer*
6301 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6303 pointer.button.code = button;
6304 pointer.button_time = time;
6306 if(state == WL_POINTER_BUTTON_STATE_RELEASED)
6308 pointer.button.state = Yetani::PointerButtonState::Released;
6310 else if(state == WL_POINTER_BUTTON_STATE_PRESSED)
6312 pointer.button.state = Yetani::PointerButtonState::Pressed;
6320 void Yetani::handlerPointerEnter(
void* data
6321 ,
struct wl_pointer*
6323 ,
struct wl_surface* wl_surface
6324 , wl_fixed_t surface_x
6325 , wl_fixed_t surface_y
6328 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6330 pointer.enter_serial = serial;
6331 pointer.enter_surface = wl_surface;
6333 pointer.enter_point =
6335 , .x = wl_fixed_to_int(surface_x)
6336 , .y = wl_fixed_to_int(surface_y)
6344 void Yetani::handlerPointerFrame(
void* data
6345 ,
struct wl_pointer* wl_pointer
6348 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6349 Yetani* yetani = pointer.yetani;
6351 if(pointer.enter_surface !=
nullptr)
6353 if(pointer.wl_surface !=
nullptr)
6355 yetani->cursorLeave(pointer.wl_surface);
6356 pointer.event_map[pointer.wl_surface].on_leave();
6359 yetani->cursorEnter(wl_pointer
6360 , pointer.enter_serial
6361 , pointer.enter_surface
6364 pointer.wl_surface = pointer.enter_surface;
6365 pointer.point_pixel = pointer.enter_point;
6367 if(pointer.event_map.contains(pointer.wl_surface))
6369 pointer.event = &(pointer.event_map[pointer.wl_surface]);
6373 pointer.event = &(pointer.event_map[
nullptr]);
6376 yetani->convertPixel(pointer.enter_surface
6377 , pointer.point_pixel.x , pointer.point_pixel.y
6378 , pointer.point_mm.x , pointer.point_mm.y
6379 , pointer.point_percent.x, pointer.point_percent.y
6382 pointer.event->on_enter_pixel(pointer.point_pixel
6383 , yetani->keyboard.modifier
6385 pointer.event->on_enter_mm(pointer.point_mm
6386 , yetani->keyboard.modifier
6388 pointer.event->on_enter_percent(pointer.point_percent
6389 , yetani->keyboard.modifier
6393 if((pointer.motion_point.time != 0)
6394 && (pointer.wl_surface !=
nullptr)
6397 pointer.point_pixel = pointer.motion_point;
6399 yetani->convertPixel(pointer.wl_surface
6400 , pointer.point_pixel.x , pointer.point_pixel.y
6401 , pointer.point_mm.x , pointer.point_mm.y
6402 , pointer.point_percent.x, pointer.point_percent.y
6404 pointer.point_mm.time = pointer.point_pixel.time;
6405 pointer.point_percent.time = pointer.point_pixel.time;
6407 pointer.event->on_motion_pixel(pointer.point_pixel
6408 , yetani->keyboard.modifier
6410 pointer.event->on_motion_mm(pointer.point_mm
6411 , yetani->keyboard.modifier
6413 pointer.event->on_motion_percent(pointer.point_percent
6414 , yetani->keyboard.modifier
6418 if((pointer.button_time != 0)
6419 && (pointer.wl_surface !=
nullptr)
6422 pointer.point_mm.time = pointer.button_time;
6423 pointer.point_percent.time = pointer.button_time;
6424 pointer.point_pixel.time = pointer.button_time;
6426 pointer.event->on_button_pixel(pointer.button
6427 , pointer.point_pixel
6428 , yetani->keyboard.modifier
6430 pointer.event->on_button_mm(pointer.button
6432 , yetani->keyboard.modifier
6434 pointer.event->on_button_percent(pointer.button
6435 , pointer.point_percent
6436 , yetani->keyboard.modifier
6440 if((pointer.axis.time != 0)
6441 && (pointer.wl_surface !=
nullptr)
6444 pointer.event->on_axis(pointer.axis
6445 , yetani->keyboard.modifier
6449 if((pointer.leave_surface !=
nullptr)
6450 && (pointer.leave_surface == pointer.wl_surface)
6453 yetani->cursorLeave(pointer.leave_surface);
6455 pointer.event->on_leave();
6457 pointer.event = &(pointer.event_map[
nullptr]);
6458 pointer.wl_surface =
nullptr;
6461 pointerClear(pointer);
6468 void Yetani::handlerPointerLeave(
void* data
6469 ,
struct wl_pointer*
6471 ,
struct wl_surface* wl_surface
6474 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6476 pointer.leave_surface = wl_surface;
6483 void Yetani::handlerPointerMotion(
void* data
6484 ,
struct wl_pointer*
6486 , wl_fixed_t surface_x
6487 , wl_fixed_t surface_y
6490 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6492 pointer.motion_point =
6494 , .x = wl_fixed_to_int(surface_x)
6495 , .y = wl_fixed_to_int(surface_y)
6505 void Yetani::handlerRegistryGlobal(
void* data
6506 ,
struct wl_registry* registry
6508 ,
const char* interface
6512 Yetani* yetani = (Yetani*)data;
6514 std::string_view interface_name(interface);
6515 ZAKERO_YETANI__DEBUG_VAR(interface_name);
6517 if(interface_name == wl_compositor_interface.name)
6519 yetani->compositor = (
struct wl_compositor*)
6520 wl_registry_bind(registry
6522 , &wl_compositor_interface
6529 if(interface_name == wl_output_interface.name)
6531 struct wl_output* wl_output = (
struct wl_output*)wl_registry_bind(registry
6533 , &wl_output_interface
6537 yetani->output_data.wloutput_to_outputid[wl_output] = id;
6538 yetani->output_data.outputid_to_wloutput[id] = wl_output;
6539 yetani->output_data.output_map[wl_output] = {};
6540 yetani->output_changes_map[wl_output] = {};
6541 yetani->output_state_map[wl_output] = Yetani::OutputState::Added;
6543 wl_output_add_listener(wl_output
6544 , &Yetani::output_listener
6551 if(interface_name == wl_seat_interface.name)
6553 yetani->seat = (
struct wl_seat*)
6554 wl_registry_bind(registry
6556 , &wl_seat_interface
6560 yetani->id_to_seat[id] = yetani->seat;
6562 wl_seat_add_listener(yetani->seat
6563 , &yetani->seat_listener
6570 if(interface_name == wl_shm_interface.name)
6572 yetani->shm = (
struct wl_shm*)
6573 wl_registry_bind(registry
6579 wl_shm_add_listener(yetani->shm
6580 , &yetani->shm_listener
6587 if(interface_name == xdg_wm_base_interface.name)
6589 yetani->xdg_wm_base = (
struct xdg_wm_base*)
6590 wl_registry_bind(registry
6592 , &xdg_wm_base_interface
6596 xdg_wm_base_add_listener(yetani->xdg_wm_base
6597 , &yetani->xdg_wm_base_listener
6602 if(interface_name == zxdg_decoration_manager_v1_interface.name)
6604 yetani->decoration_manager = (
struct zxdg_decoration_manager_v1*)
6605 wl_registry_bind(registry
6607 , &zxdg_decoration_manager_v1_interface
6610 ZAKERO_YETANI__DEBUG <<
"--- Using UNSTABLE Decoration Manager ---\n";
6618 void Yetani::handlerRegistryRemove(
void* data
6619 ,
struct wl_registry*
6623 Yetani* yetani = (Yetani*)data;
6625 printf(
"Got a registry remove event for id %d\n",
id);
6629 std::lock_guard<std::mutex> lock(yetani->output_data.mutex);
6631 if(yetani->output_data.outputid_to_wloutput.contains(
id))
6633 struct wl_output* wl_output = yetani->output_data.outputid_to_wloutput[id];
6635 yetani->output_data.outputid_to_wloutput.erase(
id);
6636 yetani->output_data.wloutput_to_outputid.erase(wl_output);
6638 yetani->output_changes_map.erase(wl_output);
6639 yetani->output_state_map.erase(wl_output);
6641 yetani->on_output_remove(
id);
6642 yetani->output_data.output_map.erase(wl_output);
6650 if(yetani->id_to_seat.contains(
id))
6652 struct wl_seat* wl_seat = yetani->id_to_seat[id];
6654 yetani->seatDestroy(wl_seat);
6656 yetani->id_to_seat.erase(
id);
6671 void Yetani::handlerSeatCapabilities(
void* data
6672 ,
struct wl_seat* wl_seat
6673 , uint32_t capabilities
6676 ZAKERO_YETANI__DEBUG_VAR((uint64_t)wl_seat);
6678 Yetani* yetani = (Yetani*)data;
6679 Yetani::Seat& seat = yetani->seat_map[wl_seat];
6681 seat.version = wl_seat_get_version(wl_seat);
6683 if(capabilities & WL_SEAT_CAPABILITY_KEYBOARD)
6685 ZAKERO_YETANI__DEBUG <<
"-- Got a keyboard device --\n";
6687 yetani->keyboard.event_map[
nullptr] =
6688 { .on_enter = Lambda_DoNothing
6689 , .on_leave = Lambda_DoNothing
6690 , .on_key = LambdaKey_DoNothing
6693 yetani->keyboard.event = &(yetani->keyboard.event_map[
nullptr]);
6695 seat.wl_keyboard = wl_seat_get_keyboard(wl_seat);
6697 wl_keyboard_add_listener(seat.wl_keyboard
6698 , &Yetani::keyboard_listener
6703 if(capabilities & WL_SEAT_CAPABILITY_POINTER)
6705 ZAKERO_YETANI__DEBUG <<
"-- Got a pointer device --\n";
6707 yetani->pointer.yetani = yetani;
6709 yetani->pointer.event_map[
nullptr] =
6710 { .on_axis = LambdaAxis_DoNothing
6711 , .on_axis_discrete = Lambda_DoNothing
6712 , .on_axis_source = Lambda_DoNothing
6713 , .on_axis_stop = Lambda_DoNothing
6714 , .on_button_mm = LambdaButtonMm_DoNothing
6715 , .on_button_percent = LambdaButtonPercent_DoNothing
6716 , .on_button_pixel = LambdaButtonPixel_DoNothing
6717 , .on_enter_mm = LambdaPointMm_DoNothing
6718 , .on_enter_percent = LambdaPointPercent_DoNothing
6719 , .on_enter_pixel = LambdaPointPixel_DoNothing
6720 , .on_leave = Lambda_DoNothing
6721 , .on_motion_mm = LambdaPointMm_DoNothing
6722 , .on_motion_percent = LambdaPointPercent_DoNothing
6723 , .on_motion_pixel = LambdaPointPixel_DoNothing
6726 yetani->pointer.event = &(yetani->pointer.event_map[
nullptr]);
6728 seat.wl_pointer = wl_seat_get_pointer(wl_seat);
6730 wl_pointer_add_listener(seat.wl_pointer
6731 , &Yetani::pointer_listener
6736 if(capabilities & WL_SEAT_CAPABILITY_TOUCH)
6738 ZAKERO_YETANI__DEBUG <<
"-- Got a touch device --\n";
6739 seat.wl_touch = wl_seat_get_touch(wl_seat);
6752 void Yetani::handlerSeatName(
void* data
6753 ,
struct wl_seat* wl_seat
6757 ZAKERO_YETANI__DEBUG_VAR((uint64_t)wl_seat);
6758 ZAKERO_YETANI__DEBUG_VAR(name);
6760 Yetani* yetani = (Yetani*)data;
6762 yetani->seat_map[wl_seat].name = name;
6771 void Yetani::handlerShmFormat(
void* data
6776 Yetani* yetani = (Yetani*)data;
6778 wl_shm_format format = (wl_shm_format)value;
6785 yetani->shm_format_vector.push_back(format);
6794 void Yetani::handlerSurfaceEnter(
void* data
6795 ,
struct wl_surface* wl_surface
6796 ,
struct wl_output* wl_output
6804 Yetani* yetani = (Yetani*)data;
6805 Yetani::OutputData& output_data = yetani->output_data;
6807 output_data.mutex.lock();
6808 output_data.surface_output_map[wl_surface].push_back(wl_output);
6809 output_data.mutex.unlock();
6816 void Yetani::handlerSurfaceLeave(
void* data
6817 ,
struct wl_surface* wl_surface
6818 ,
struct wl_output* wl_output
6826 Yetani* yetani = (Yetani*)data;
6828 Yetani::OutputData& output_data = yetani->output_data;
6829 std::lock_guard<std::mutex> lock(output_data.mutex);
6831 Yetani::VectorWlOutput& output_vector = output_data.surface_output_map[wl_surface];
6834 struct wl_output* current_output = output_vector.front();
6840 if(current_output == output_vector.front())
6848 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
6850 if(surface_extent.preferred_unit == Yetani::SizeUnit::Pixel)
6858 current_output = output_vector.front();
6860 Yetani::Output& output = output_data.output_map.at(current_output);
6861 Yetani::SizePixel new_size;
6863 if(surface_extent.preferred_unit == Yetani::SizeUnit::Millimeter)
6865 auto p = yetani->convertMmToPixel(output
6866 , surface_extent.size_mm.width
6867 , surface_extent.size_mm.height
6870 new_size = { p.first, p.second };
6874 auto p = yetani->convertPercentToPixel(output
6875 , surface_extent.size_percent.width
6876 , surface_extent.size_percent.height
6879 new_size = { p.first, p.second };
6882 if(new_size.width <= 0)
6887 if(new_size.height <= 0)
6889 new_size.height = 1;
6892 if((new_size.width != surface_extent.size_pixel.width)
6893 && (new_size.height != surface_extent.size_pixel.height)
6896 yetani->surface_resize_mutex_map[wl_surface].lock();
6898 XdgSurface& surface = yetani->xdg_surface_map[wl_surface];
6900 surface_extent.size_pixel = new_size;
6901 surfaceCalculateSize(surface.yetani, surface.wl_surface, new_size);
6903 yetani->surface_resize_mutex_map[wl_surface].unlock();
6905 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
6906 event.on_size_pixel_change(surface_extent.size_pixel);
6916 void Yetani::handlerSwapBuffers(
void* data
6917 ,
struct wl_callback* callback
6921 Yetani::SurfaceFrame* surface_frame = (Yetani::SurfaceFrame*)data;
6923 wl_callback_destroy(callback);
6925 callback = wl_surface_frame(surface_frame->wl_surface);
6927 wl_callback_add_listener(callback
6928 , &frame_callback_listener
6932 struct wl_buffer* wl_buffer = surface_frame->buffer_next.exchange(
nullptr);
6933 if(wl_buffer !=
nullptr)
6935 wl_buffer_add_listener(wl_buffer
6936 , &Yetani::buffer_listener
6937 , wl_buffer_get_user_data(wl_buffer)
6940 surface_frame->time_ms = time_ms;
6942 wl_surface_attach(surface_frame->wl_surface, wl_buffer, 0, 0);
6944 wl_surface_damage(surface_frame->wl_surface
6946 , surface_frame->width, surface_frame->height
6950 wl_surface_commit(surface_frame->wl_surface);
6977 case Yetani::XdgState::Toplevel_Window_Fullscreen:
6978 return Yetani::WindowMode::Fullscreen;
6980 case Yetani::XdgState::Toplevel_Window_Maximized:
6981 return Yetani::WindowMode::Maximized;
6984 case Yetani::XdgState::Toplevel_Window_Normal:
6985 return Yetani::WindowMode::Normal;
7000 case Yetani::WindowMode::Fullscreen:
7001 return Yetani::XdgState::Toplevel_Window_Fullscreen;
7003 case Yetani::WindowMode::Maximized:
7004 return Yetani::XdgState::Toplevel_Window_Maximized;
7007 case Yetani::WindowMode::Normal:
7008 return Yetani::XdgState::Toplevel_Window_Normal;
7035 struct xdg_surface* Yetani::xdgSurfaceCreate(
struct wl_surface* wl_surface
7038 XdgSurface& surface = xdg_surface_map[wl_surface];
7040 surface.yetani =
this;
7041 surface.wl_surface = wl_surface;
7043 surface_extent_mutex.lock();
7045 Yetani::SurfaceExtent& surface_extent = surface_extent_map[wl_surface];
7047 surface_extent.preferred_unit = Yetani::SizeUnit::Pixel;
7048 surface_extent.preferred_mm = { 160, 90 };
7049 surface_extent.preferred_percent = { 0.32, 0.18 };
7050 surface_extent.size_mm = { 160, 90 };
7051 surface_extent.size_percent = { 0.32, 0.18 };
7052 surface_extent.size_pixel = { 800, 450 };
7053 surface_extent.size_pixel_max = { 0, 0 };
7054 surface_extent.size_pixel_min = { 0, 0 };
7056 surface_extent_mutex.unlock();
7058 output_notify_surface_vector.push_back(wl_surface);
7060 struct xdg_surface* xdg_surface = xdg_wm_base_get_xdg_surface(xdg_wm_base
7064 xdg_state_change_mutex.lock();
7066 xdg_state_change_map[xdg_surface] = {};
7068 xdg_state_change_mutex.unlock();
7070 xdg_surface_add_listener(xdg_surface
7071 , &xdg_surface_listener
7087 void Yetani::xdgSurfaceDestroy(
struct wl_surface* wl_surface
7088 ,
struct xdg_surface*& xdg_surface
7093 xdg_surface_destroy(xdg_surface);
7098 if(xdg_surface_map.contains(wl_surface))
7100 xdg_surface_map.erase(wl_surface);
7103 xdg_state_change_mutex.lock();
7105 if(xdg_state_change_map.contains(xdg_surface))
7107 xdg_state_change_map.erase(xdg_surface);
7110 xdg_state_change_mutex.unlock();
7112 surface_extent_mutex.lock();
7114 if(surface_extent_map.contains(wl_surface))
7116 surface_extent_map.erase(wl_surface);
7119 surface_extent_mutex.unlock();
7121 xdg_surface =
nullptr;
7128 void Yetani::xdgSurfaceSetExtent(
struct wl_surface* wl_surface
7129 ,
const Yetani::SizeUnit& size_unit
7130 ,
const Yetani::SizeMm& size_mm
7131 ,
const Yetani::SizePercent& size_percent
7132 ,
const Yetani::SizePixel& size_pixel
7135 Yetani::SurfaceExtent& surface_extent = surface_extent_map[wl_surface];
7137 surface_extent.preferred_unit = size_unit;
7138 surface_extent.preferred_mm = size_mm;
7139 surface_extent.preferred_percent = size_percent;
7140 surface_extent.size_mm = size_mm;
7141 surface_extent.size_percent = size_percent;
7142 surface_extent.size_pixel = size_pixel;
7143 surface_extent.size_pixel_max = { 0, 0 };
7144 surface_extent.size_pixel_min = { 0, 0 };
7188 struct xdg_toplevel* Yetani::xdgToplevelCreate(
struct xdg_surface* xdg_surface
7191 Yetani::XdgToplevel& toplevel = xdg_toplevel_map[xdg_surface];
7193 toplevel.close_request_lambda = Lambda_DoNothing;
7194 toplevel.state_change = &(xdg_state_change_map[xdg_surface]);
7195 toplevel.is_active =
false;
7196 toplevel.window_state = Yetani::XdgState::Toplevel_Window_Normal;
7197 toplevel.is_active_lambda = LambdaBool_DoNothing;
7198 toplevel.window_state_lambda = LambdaWindowMode_DoNothing;
7199 toplevel.previous_size = { 0, 0 };
7200 toplevel.xdg_toplevel =
nullptr;
7207 toplevel.state_change->push_back(Yetani::XdgState::Toplevel_Attach_Buffer);
7209 struct xdg_toplevel* xdg_toplevel =
nullptr;
7211 xdg_toplevel = xdg_surface_get_toplevel(xdg_surface);
7212 toplevel.xdg_toplevel = xdg_toplevel;
7214 xdg_toplevel_add_listener(xdg_toplevel
7215 , &xdg_toplevel_listener
7219 return xdg_toplevel;
7229 void Yetani::xdgToplevelDestroy(
struct xdg_surface* xdg_surface
7230 ,
struct xdg_toplevel*& xdg_toplevel
7233 if(xdg_toplevel !=
nullptr)
7235 xdg_toplevel_destroy(xdg_toplevel);
7238 if(xdg_toplevel_map.contains(xdg_surface))
7240 XdgToplevel& toplevel = xdg_toplevel_map[xdg_surface];
7242 toplevel.close_request_lambda =
nullptr;
7243 toplevel.state_change =
nullptr;
7244 toplevel.window_state = Yetani::XdgState::Unknown;
7245 toplevel.is_active =
false;
7246 toplevel.is_active_lambda =
nullptr;
7247 toplevel.window_state_lambda =
nullptr;
7249 xdg_toplevel_map.erase(xdg_surface);
7252 xdg_toplevel =
nullptr;
7265 void Yetani::xdgToplevelSizeChange(Yetani* yetani
7266 ,
struct wl_surface* wl_surface
7267 ,
const Yetani::SizePixel& size_pixel
7270 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
7271 Yetani::SizePixel new_size = surface_extent.size_pixel;
7273 if(((surface_extent.size_pixel_min.width == 0) || (size_pixel.width >= surface_extent.size_pixel_min.width))
7274 && ((surface_extent.size_pixel_max.width == 0) || (size_pixel.width <= surface_extent.size_pixel_max.width))
7277 new_size.width = size_pixel.width;
7280 if(((surface_extent.size_pixel_min.height == 0) || (size_pixel.height >= surface_extent.size_pixel_min.height))
7281 && ((surface_extent.size_pixel_max.height == 0) || (size_pixel.height <= surface_extent.size_pixel_max.height))
7284 new_size.height = size_pixel.height;
7287 if((new_size.width == surface_extent.size_pixel.width)
7288 && (new_size.height == surface_extent.size_pixel.height)
7295 Yetani::SizeMm size_mm;
7296 Yetani::SizePercent size_percent;
7297 yetani->convertPixel(wl_surface
7298 , size_pixel.width , size_pixel.height
7299 , size_mm.width , size_mm.height
7300 , size_percent.width, size_percent.height
7303 yetani->surface_resize_mutex_map[wl_surface].lock();
7305 surface_extent.size_pixel = new_size;
7306 surfaceCalculateSize(yetani, wl_surface, new_size);
7308 yetani->surface_resize_mutex_map[wl_surface].unlock();
7310 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
7311 event.on_size_pixel_change(surface_extent.size_pixel);
7312 event.on_size_mm_change(surface_extent.size_mm);
7313 event.on_size_percent_change(surface_extent.size_percent);
7320 void Yetani::xdgToplevelSizeMinMaxChange(Yetani* yetani
7321 ,
struct xdg_toplevel* xdg_toplevel
7322 ,
struct wl_surface* wl_surface
7323 ,
const Yetani::SizePixel& size_pixel_min
7324 ,
const Yetani::SizePixel& size_pixel_max
7327 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
7329 Yetani::SizePixel size_pixel = surface_extent.size_pixel;
7330 bool need_to_resize =
false;
7332 if(size_pixel_max.width > 0
7333 && size_pixel_max.width < surface_extent.size_pixel.width
7336 need_to_resize =
true;
7337 size_pixel.width = size_pixel_max.width;
7340 if(size_pixel_max.height > 0
7341 && size_pixel_max.height < surface_extent.size_pixel.height
7344 need_to_resize =
true;
7345 size_pixel.height = size_pixel_max.height;
7348 if(size_pixel_min.width > 0
7349 && size_pixel_min.width > surface_extent.size_pixel.width
7352 need_to_resize =
true;
7353 size_pixel.width = size_pixel_min.width;
7356 if(size_pixel_min.height > 0
7357 && size_pixel_min.height > surface_extent.size_pixel.height
7360 need_to_resize =
true;
7361 size_pixel.height = size_pixel_min.height;
7366 xdg_toplevel_set_max_size(xdg_toplevel, 0, 0);
7367 xdg_toplevel_set_min_size(xdg_toplevel, 0, 0);
7369 yetani->surface_resize_mutex_map[wl_surface].lock();
7371 surface_extent.size_pixel = size_pixel;
7372 surfaceCalculateSize(yetani, wl_surface, size_pixel);
7374 yetani->surface_resize_mutex_map[wl_surface].unlock();
7377 xdg_toplevel_set_min_size(xdg_toplevel
7378 , size_pixel_min.width
7379 , size_pixel_min.height
7382 xdg_toplevel_set_max_size(xdg_toplevel
7383 , size_pixel_max.width
7384 , size_pixel_max.height
7387 surface_extent.size_pixel_min = size_pixel_min;
7388 surface_extent.size_pixel_max = size_pixel_max;
7395 void Yetani::xdgToplevelWindowChange(Yetani* yetani
7396 ,
struct wl_surface* wl_surface
7397 , Yetani::XdgToplevel& toplevel
7398 ,
const Yetani::XdgState window_state
7399 ,
const Yetani::SizePixel& size_pixel
7402 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
7403 Yetani::SizePixel new_size{1, 1};
7405 toplevel.window_state = window_state;
7407 if((toplevel.window_state == Yetani::XdgState::Toplevel_Window_Fullscreen)
7408 || (toplevel.window_state == Yetani::XdgState::Toplevel_Window_Maximized)
7411 if(toplevel.previous_size.width == 0)
7413 xdg_toplevel_set_max_size(toplevel.xdg_toplevel, 0, 0);
7414 xdg_toplevel_set_min_size(toplevel.xdg_toplevel, 0, 0);
7416 toplevel.previous_size = surface_extent.size_pixel;
7419 if((size_pixel.width != 0)
7420 && (size_pixel.height != 0)
7423 new_size = size_pixel;
7426 else if(toplevel.window_state == Yetani::XdgState::Toplevel_Window_Normal)
7428 xdg_toplevel_set_max_size(toplevel.xdg_toplevel
7429 , surface_extent.size_pixel_max.width
7430 , surface_extent.size_pixel_max.height
7433 xdg_toplevel_set_min_size(toplevel.xdg_toplevel
7434 , surface_extent.size_pixel_min.width
7435 , surface_extent.size_pixel_min.height
7438 new_size = toplevel.previous_size;
7439 toplevel.previous_size.width = 0;
7442 if(new_size == surface_extent.size_pixel)
7448 Yetani::SizeMm size_mm;
7449 Yetani::SizePercent size_percent;
7450 yetani->convertPixel(wl_surface
7451 , size_pixel.width , size_pixel.height
7452 , size_mm.width , size_mm.height
7453 , size_percent.width, size_percent.height
7456 yetani->surface_resize_mutex_map[wl_surface].lock();
7458 surface_extent.size_mm = size_mm;
7459 surface_extent.size_percent = size_percent;
7460 surface_extent.size_pixel = new_size;
7461 surfaceCalculateSize(yetani, wl_surface, new_size);
7463 yetani->surface_resize_mutex_map[wl_surface].unlock();
7465 toplevel.window_state_lambda(Yetani::toWindowMode(toplevel.window_state));
7467 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
7468 event.on_size_pixel_change(surface_extent.size_pixel);
7469 event.on_size_mm_change(surface_extent.size_mm);
7470 event.on_size_percent_change(surface_extent.size_percent);
7499 struct zxdg_toplevel_decoration_v1* Yetani::xdgDecorationCreate(
struct xdg_surface* xdg_surface
7500 ,
struct xdg_toplevel* xdg_toplevel
7503 if(decoration_manager ==
nullptr)
7514 zxdg_toplevel_decoration_v1* xdg_decoration =
7515 zxdg_decoration_manager_v1_get_toplevel_decoration(decoration_manager
7519 Yetani::XdgDecoration& decoration = xdg_decoration_map[xdg_surface];
7520 decoration.state_change = &(xdg_state_change_map[xdg_surface]);
7521 decoration.lambda = LambdaWindowDecorations_DoNothing;
7522 decoration.state = 0;
7523 decoration.is_present =
false;
7525 zxdg_toplevel_decoration_v1_add_listener(xdg_decoration
7526 , &xdg_toplevel_decoration_listener
7530 return xdg_decoration;
7539 void Yetani::xdgDecorationDestroy(
struct xdg_surface* xdg_surface
7540 ,
struct xdg_toplevel*
7541 ,
struct zxdg_toplevel_decoration_v1*& xdg_decoration
7544 zxdg_toplevel_decoration_v1_destroy(xdg_decoration);
7546 if(xdg_decoration_map.contains(xdg_surface))
7548 Yetani::XdgDecoration& decoration = xdg_decoration_map[xdg_surface];
7549 decoration.state_change =
nullptr;
7550 decoration.lambda =
nullptr;
7551 decoration.state = 0;
7552 decoration.is_present =
false;
7554 xdg_decoration_map.erase(xdg_surface);
7557 xdg_decoration =
nullptr;
7566 void Yetani::xdgDecorationChange(Yetani::XdgDecoration& decoration
7567 ,
const uint32_t decoration_state
7570 if(decoration_state == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE)
7572 if(decoration.state != decoration_state)
7574 decoration.state = decoration_state;
7575 decoration.is_present =
false;
7578 Yetani::WindowDecorations::Client_Side
7582 else if(decoration_state == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE)
7584 if(decoration.state != decoration_state)
7586 decoration.state = decoration_state;
7587 decoration.is_present =
true;
7591 decoration.is_present = !decoration.is_present;
7594 if(decoration.is_present ==
true)
7597 Yetani::WindowDecorations::Server_Side
7603 Yetani::WindowDecorations::Client_Side
7625 void Yetani::handlerXdgSurfaceConfigure(
void* data
7626 , xdg_surface* xdg_surface
7630 Yetani::XdgSurface& surface = *((Yetani::XdgSurface*)data);
7631 Yetani* yetani = surface.yetani;
7633 xdg_surface_ack_configure(xdg_surface, serial);
7635 VectorXdgStateChange& state_change = yetani->xdg_state_change_map[xdg_surface];
7637 if(state_change.empty())
7642 auto iter = std::begin(state_change);
7643 auto iter_end = std::end(state_change);
7645 while(iter != iter_end)
7649 case Yetani::XdgState::Toplevel_Active:
7651 Yetani::XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
7654 bool is_active = bool(*iter);
7655 if(toplevel.is_active != is_active)
7657 toplevel.is_active = is_active;
7659 toplevel.is_active_lambda(is_active);
7663 case Yetani::XdgState::Toplevel_Attach_Buffer:
7665 struct wl_surface* wl_surface = surface.wl_surface;
7667 SurfaceFrame& surface_frame =
7668 yetani->surface_frame_map[wl_surface];
7670 wl_surface_attach(surface_frame.wl_surface
7671 , surface_frame.buffer_next
7675 struct wl_callback* callback = wl_surface_frame(surface_frame.wl_surface);
7677 wl_callback_add_listener(callback
7678 , &frame_callback_listener
7682 wl_surface_commit(surface_frame.wl_surface);
7685 case Yetani::XdgState::Toplevel_Window_Normal:
7686 case Yetani::XdgState::Toplevel_Window_Maximized:
7687 case Yetani::XdgState::Toplevel_Window_Fullscreen:
7689 struct wl_surface* wl_surface = surface.wl_surface;
7691 Yetani::XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
7693 Yetani::XdgState window_state = XdgState(*iter);
7695 Yetani::SizePixel size_pixel;
7698 size_pixel.width = *iter;
7701 size_pixel.height = *iter;
7703 if(toplevel.window_state != window_state)
7705 xdgToplevelWindowChange(yetani
7714 case Yetani::XdgState::Toplevel_Resizing:
7716 struct wl_surface* wl_surface = surface.wl_surface;
7718 Yetani::SizePixel size_pixel;
7721 size_pixel.width = *iter;
7724 size_pixel.height = *iter;
7726 if(size_pixel.width > 0
7727 && size_pixel.height > 0
7730 xdgToplevelSizeChange(yetani
7737 case Yetani::XdgState::Toplevel_Decoration:
7740 uint32_t decoration_state = *iter;
7742 Yetani::XdgDecoration& decoration = yetani->xdg_decoration_map[xdg_surface];
7744 xdgDecorationChange(decoration, decoration_state);
7751 state_change.clear();
7760 void Yetani::handlerXdgToplevelClose(
void* data
7761 ,
struct xdg_toplevel*
7764 Yetani::XdgToplevel* toplevel = (Yetani::XdgToplevel*)data;
7766 toplevel->close_request_lambda();
7773 void Yetani::handlerXdgToplevelConfigure(
void* data
7774 ,
struct xdg_toplevel*
7777 ,
struct wl_array* state_array
7780 Yetani::XdgToplevel* toplevel = (Yetani::XdgToplevel*)data;
7782 Yetani::XdgState window_state = Yetani::XdgState::Toplevel_Window_Normal;
7783 int32_t is_active = 0;
7785 ZAKERO_YETANI__ARRAY_FOR_EACH(xdg_toplevel_state*, state_iter, state_array)
7787 xdg_toplevel_state state = *state_iter;
7791 case XDG_TOPLEVEL_STATE_MAXIMIZED:
7792 window_state = Yetani::XdgState::Toplevel_Window_Maximized;
7794 case XDG_TOPLEVEL_STATE_FULLSCREEN:
7795 window_state = Yetani::XdgState::Toplevel_Window_Fullscreen;
7797 case XDG_TOPLEVEL_STATE_RESIZING:
7798 toplevel->state_change->push_back(Yetani::XdgState::Toplevel_Resizing);
7799 toplevel->state_change->push_back(width);
7800 toplevel->state_change->push_back(height);
7802 case XDG_TOPLEVEL_STATE_ACTIVATED:
7805 case XDG_TOPLEVEL_STATE_TILED_LEFT:
7807 case XDG_TOPLEVEL_STATE_TILED_RIGHT:
7809 case XDG_TOPLEVEL_STATE_TILED_TOP:
7811 case XDG_TOPLEVEL_STATE_TILED_BOTTOM:
7818 toplevel->state_change->push_back(window_state);
7819 toplevel->state_change->push_back(width);
7820 toplevel->state_change->push_back(height);
7822 toplevel->state_change->push_back(Yetani::XdgState::Toplevel_Active);
7823 toplevel->state_change->push_back(is_active);
7832 void Yetani::handlerXdgWmBasePing(
void*
7833 ,
struct xdg_wm_base* xdg_wm_base
7837 xdg_wm_base_pong(xdg_wm_base, serial);
7846 void Yetani::handlerXdgToplevelDecorationConfigure(
void* data
7847 ,
struct zxdg_toplevel_decoration_v1*
7851 Yetani::XdgDecoration* deco = (Yetani::XdgDecoration*)data;
7853 deco->state_change->push_back(Yetani::XdgState::Toplevel_Decoration);
7854 deco->state_change->push_back(mode);
8025 , std::error_code& error
8028 return windowCreate(Yetani::SizeUnit::Millimeter
8032 , SHM_FORMAT_DEFAULT
8051 ,
const wl_shm_format format
8054 std::error_code error;
8056 return windowCreate(Yetani::SizeUnit::Millimeter
8082 ,
const wl_shm_format format
8083 , std::error_code& error
8086 return windowCreate(Yetani::SizeUnit::Millimeter
8110 , std::error_code& error
8113 return windowCreate(Yetani::SizeUnit::Percent
8117 , SHM_FORMAT_DEFAULT
8136 ,
const wl_shm_format format
8139 std::error_code error;
8141 return windowCreate(Yetani::SizeUnit::Percent
8167 ,
const wl_shm_format format
8168 , std::error_code& error
8171 return windowCreate(Yetani::SizeUnit::Percent
8195 , std::error_code& error
8198 return windowCreate(Yetani::SizeUnit::Pixel
8202 , SHM_FORMAT_DEFAULT
8221 ,
const wl_shm_format format
8224 std::error_code error;
8226 return windowCreate(Yetani::SizeUnit::Pixel
8252 ,
const wl_shm_format format
8253 , std::error_code& error
8256 return windowCreate(Yetani::SizeUnit::Pixel
8277 ,
const wl_shm_format pixel_format
8278 , std::error_code& error
8281 if((size_unit == Yetani::SizeUnit::Millimeter)
8282 && (size_mm.width <= 0 || size_mm.height <= 0)
8285 error = ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
8290 if((size_unit == Yetani::SizeUnit::Percent)
8291 && (size_percent.width <= 0 || size_percent.height <= 0)
8294 error = ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
8299 if((size_unit == Yetani::SizeUnit::Pixel)
8300 && (size_pixel.width <= 0 || size_pixel.height <= 0)
8303 error = ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
8308 const std::string file_name =
"Zakero.Yetani."
8312 struct WindowData window_data =
8315 , .wl_output = nullptr
8316 , .file_name = file_name
8317 , .size_mm = size_mm
8318 , .size_percent = size_percent
8319 , .size_pixel = size_pixel
8320 , .size_unit = size_unit
8321 , .pixel_format = pixel_format
8322 , .error = ZAKERO_YETANI__ERROR(Error_None)
8325 windowDataInit(window_data);
8327 if(window_data.error)
8329 error = window_data.error;
8334 Yetani::Window* window =
new Window(&window_data);
8336 if(window_data.error)
8341 ZAKERO_YETANI__DEBUG <<
to_string(window_data.error) <<
"\n";
8343 error = ZAKERO_YETANI__ERROR(Error_Window_Initialization_Failed);
8348 error = ZAKERO_YETANI__ERROR(Error_None);
8357 void Yetani::windowDataInit(Yetani::WindowData& window_data
8360 windowDataInitOutput(window_data);
8362 if(window_data.error)
8367 window_data.size_pixel.width = std::max(1, window_data.size_pixel.width);
8368 window_data.size_pixel.height = std::max(1, window_data.size_pixel.height);
8370 window_data.error = ZAKERO_YETANI__ERROR(Error_None);
8377 void Yetani::windowDataInitOutput(Yetani::WindowData& window_data
8380 std::lock_guard<std::mutex> lock(output_data.mutex);
8382 if(output_data.output_map.empty())
8384 window_data.error = ZAKERO_YETANI__ERROR(Error_No_Output_Available);
8389 const auto& iter = output_data.output_map.begin();
8391 window_data.wl_output = iter->first;
8392 Yetani::Output& output = iter->second;
8394 if(window_data.size_unit == Yetani::SizeUnit::Millimeter)
8396 auto px = convertMmToPixel(output
8397 , window_data.size_mm.width
8398 , window_data.size_mm.height
8401 auto pc = convertPixelToPercent(output
8406 window_data.size_mm = window_data.size_mm;
8407 window_data.size_percent = { pc.first, pc.second };
8408 window_data.size_pixel = { px.first, px.second };
8410 else if(window_data.size_unit == Yetani::SizeUnit::Percent)
8412 auto px = convertPercentToPixel(output
8413 , window_data.size_percent.width
8414 , window_data.size_percent.height
8417 auto mm = convertPixelToMm(output
8422 window_data.size_mm = { mm.first, mm.second };
8423 window_data.size_percent = window_data.size_percent;
8424 window_data.size_pixel = { px.first, px.second };
8426 else if(window_data.size_unit == Yetani::SizeUnit::Pixel)
8428 auto mm = convertPixelToMm(output
8429 , window_data.size_pixel.width
8430 , window_data.size_pixel.height
8433 auto pc = convertPixelToPercent(output
8434 , window_data.size_pixel.width
8435 , window_data.size_pixel.height
8438 window_data.size_mm = { mm.first, mm.second };
8439 window_data.size_percent = { pc.first, pc.second };
8440 window_data.size_pixel = window_data.size_pixel;
8443 window_data.error = ZAKERO_YETANI__ERROR(Error_None);
8450 void Yetani::windowInitMemory(Yetani::WindowData& window_data
8451 , Yetani::Window::Memory& window_memory
8454 size_t size_in_bytes = sizeInBytes(window_data.size_pixel
8455 , window_data.pixel_format
8458 window_data.error = window_memory.memory_pool.init(size_in_bytes
8460 , zakero::MemoryPool::Alignment::Bits_32
8463 if(window_data.error)
8468 window_memory.wl_shm_pool = wl_shm_create_pool(window_data.wl_shm
8469 , window_memory.memory_pool.fd()
8470 , window_memory.memory_pool.size()
8473 window_memory.memory_pool.sizeOnChange([&](
size_t new_size)
8475 wl_shm_pool_resize(window_memory.wl_shm_pool, new_size);
8478 window_data.error = ZAKERO_YETANI__ERROR(Error_None);
8485 void Yetani::windowInitOutput(Yetani::WindowData& window_data
8486 ,
struct wl_surface* wl_surface
8489 std::lock_guard<std::mutex> lock(output_data.mutex);
8491 output_data.surface_output_map[wl_surface].push_back(window_data.wl_output);
8498 void Yetani::windowEraseMemory(Yetani::Window::Memory& window_memory
8501 if(window_memory.wl_shm_pool)
8503 wl_shm_pool_destroy(window_memory.wl_shm_pool);
8504 window_memory.wl_shm_pool =
nullptr;
8512 void Yetani::windowEraseOutput(
struct wl_surface* wl_surface
8515 std::lock_guard<std::mutex> lock(output_data.mutex);
8517 if(output_data.surface_output_map.contains(wl_surface))
8519 output_data.surface_output_map.erase(wl_surface);
8527 void Yetani::windowEraseSurfaceExtent(
struct wl_surface* wl_surface
8530 std::lock_guard<std::mutex> lock(surface_extent_mutex);
8532 if(surface_extent_map.contains(wl_surface))
8534 surface_extent_map.erase(wl_surface);
8542 void Yetani::windowAdd(Yetani::Window* window
8545 std::lock_guard<std::mutex> lock(window_vector_mutex);
8547 window_vector.push_back(window);
8554 void Yetani::windowRemove(Yetani::Window* window
8557 std::lock_guard<std::mutex> lock(window_vector_mutex);
8762 : yetani {((
Yetani::WindowData*)ptr)->yetani}
8763 , wl_buffer {nullptr}
8764 , wl_surface {nullptr}
8765 , xdg_surface {nullptr}
8766 , xdg_toplevel {nullptr}
8767 , xdg_decoration {nullptr}
8768 , window_memory {nullptr, ((
Yetani::WindowData*)ptr)->file_name}
8769 , pixel_format {((
Yetani::WindowData*)ptr)->pixel_format}
8771 Yetani::WindowData& window_data = *((Yetani::WindowData*)ptr);
8773 yetani->windowInitMemory(window_data, window_memory);
8774 if(window_data.error)
8779 wl_surface = yetani->surfaceCreate(yetani
8781 , window_data.size_pixel
8785 xdg_surface = yetani->xdgSurfaceCreate(wl_surface);
8787 yetani->xdgSurfaceSetExtent(wl_surface
8788 , window_data.size_unit
8789 , window_data.size_mm
8790 , window_data.size_percent
8791 , window_data.size_pixel
8794 xdg_toplevel = yetani->xdgToplevelCreate(xdg_surface);
8796 xdg_decoration = yetani->xdgDecorationCreate(xdg_surface, xdg_toplevel);
8798 wl_surface_commit(wl_surface);
8800 yetani->windowInitOutput(window_data, wl_surface);
8801 if(window_data.error)
8806 yetani->windowAdd(
this);
8815 yetani->windowRemove(
this);
8817 if(xdg_decoration !=
nullptr)
8819 yetani->xdgDecorationDestroy(xdg_surface, xdg_toplevel, xdg_decoration);
8822 if(xdg_toplevel !=
nullptr)
8824 yetani->xdgToplevelDestroy(xdg_surface, xdg_toplevel);
8827 if(xdg_surface !=
nullptr)
8829 yetani->xdgSurfaceDestroy(wl_surface, xdg_surface);
8832 if(wl_surface !=
nullptr)
8834 yetani->windowEraseOutput(wl_surface);
8835 yetani->surfaceDestroy(yetani, wl_surface);
8836 yetani->windowEraseSurfaceExtent(wl_surface);
8839 yetani->windowEraseMemory(window_memory);
8863 return yetani->cursorDetach(wl_surface);
8866 return yetani->cursorAttach(name, wl_surface);
8877 yetani->cursorHide(wl_surface);
8888 yetani->cursorShow(wl_surface);
8913 xdg_toplevel_set_app_id(xdg_toplevel, class_name.c_str());
8926 xdg_toplevel_set_title(xdg_toplevel, title.c_str());
8952 if(yetani->decoration_manager ==
nullptr)
8954 return ZAKERO_YETANI__ERROR(Error_Server_Side_Decorations_Not_Available);
8957 uint32_t decoration_state = decorations == Yetani::WindowDecorations::Server_Side
8958 ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE
8959 : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE
8962 zxdg_toplevel_decoration_v1_set_mode(xdg_decoration
8966 return ZAKERO_YETANI__ERROR(Error_None);
8979 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
8998 XdgState window_state = Yetani::toXdgState(window_mode);
9000 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
9002 if(toplevel.window_state == window_state)
9022 XdgState window_state = Yetani::toXdgState(window_mode);
9024 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
9026 if(toplevel.window_state == window_state)
9033 case WindowMode::Fullscreen:
9034 xdg_toplevel_set_fullscreen(xdg_toplevel,
nullptr);
9037 case WindowMode::Maximized:
9038 xdg_toplevel_set_maximized(xdg_toplevel);
9041 case WindowMode::Normal:
9042 xdg_toplevel_unset_fullscreen(xdg_toplevel);
9043 xdg_toplevel_unset_maximized(xdg_toplevel);
9068 if(size.width <= 0 || size.height <= 0)
9070 return ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
9075 if(size_pixel.
width <= 0)
9077 size_pixel.
width = 1;
9080 if(size_pixel.
height <= 0)
9085 yetani->surface_resize_mutex_map[wl_surface].lock();
9087 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
9089 surface_extent.preferred_unit = Yetani::SizeUnit::Millimeter;
9090 surface_extent.preferred_mm = size;
9091 surface_extent.size_pixel = size_pixel;
9093 surfaceCalculateSize(yetani, wl_surface, size_pixel);
9095 yetani->surface_resize_mutex_map[wl_surface].unlock();
9097 return ZAKERO_YETANI__ERROR(Error_None);
9120 if(size.width <= 0 || size.height <= 0)
9122 return ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
9127 if(size_pixel.
width <= 0)
9129 size_pixel.
width = 1;
9132 if(size_pixel.
height <= 0)
9137 yetani->surface_resize_mutex_map[wl_surface].lock();
9139 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
9141 surface_extent.preferred_unit = Yetani::SizeUnit::Percent;
9142 surface_extent.preferred_percent = size;
9143 surface_extent.size_pixel = size_pixel;
9145 surfaceCalculateSize(yetani, wl_surface, size_pixel);
9147 yetani->surface_resize_mutex_map[wl_surface].unlock();
9149 return ZAKERO_YETANI__ERROR(Error_None);
9172 if(size.width <= 0 || size.height <= 0)
9174 return ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
9177 yetani->surface_resize_mutex_map[wl_surface].lock();
9179 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
9181 surface_extent.preferred_unit = Yetani::SizeUnit::Pixel;
9182 surface_extent.size_pixel = size;
9184 surfaceCalculateSize(yetani, wl_surface, size);
9186 yetani->surface_resize_mutex_map[wl_surface].unlock();
9188 return ZAKERO_YETANI__ERROR(Error_None);
9207 std::error_code error = validateMinMax<Yetani::SizeMm>(size_min, size_max);
9217 Yetani::OutputData& output_data = yetani->output_data;
9219 std::lock_guard<std::mutex> lock(output_data.mutex);
9221 Yetani::VectorWlOutput& vector = output_data.surface_output_map[wl_surface];
9222 struct wl_output* wl_output = vector.front();
9225 auto min = yetani->convertMmToPixel(
output, size_min.
width, size_min.height);
9226 size_pixel_min = { min.first, min.second };
9228 auto max = yetani->convertMmToPixel(
output, size_max.
width, size_max.height);
9229 size_pixel_max = { max.first, max.second };
9232 yetani->xdgToplevelSizeMinMaxChange(yetani
9239 return ZAKERO_YETANI__ERROR(Error_None);
9258 std::error_code error = validateMinMax<Yetani::SizePercent>(size_min, size_max);
9268 Yetani::OutputData& output_data = yetani->output_data;
9270 std::lock_guard<std::mutex> lock(output_data.mutex);
9272 Yetani::VectorWlOutput& vector = output_data.surface_output_map[wl_surface];
9273 struct wl_output* wl_output = vector.front();
9276 auto min = yetani->convertPercentToPixel(
output, size_min.
width, size_min.height);
9277 size_pixel_min = { min.first, min.second };
9279 auto max = yetani->convertPercentToPixel(
output, size_max.
width, size_max.height);
9280 size_pixel_max = { max.first, max.second };
9283 yetani->xdgToplevelSizeMinMaxChange(yetani
9290 return ZAKERO_YETANI__ERROR(Error_None);
9309 std::error_code error = validateMinMax<Yetani::SizePixel>(size_min, size_max);
9315 yetani->xdgToplevelSizeMinMaxChange(yetani
9322 return ZAKERO_YETANI__ERROR(Error_None);
9368 if(wl_buffer !=
nullptr)
9370 bufferDestroy(wl_buffer);
9373 Yetani::SurfaceSize& surface_size = yetani->surface_size_map[wl_surface];
9375 yetani->surface_resize_mutex_map[wl_surface].lock();
9377 wl_buffer = bufferCreate(surface_size
9382 yetani->surface_resize_mutex_map[wl_surface].unlock();
9384 image = window_memory.memory_pool.addressOf(
9385 yetani->buffer.map[wl_buffer].offset
9388 size = { surface_size.width, surface_size.height };
9390 return ZAKERO_YETANI__ERROR(Error_None);
9402 if(wl_buffer ==
nullptr)
9414 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
9416 wl_buffer = surface_frame.buffer_next.exchange(wl_buffer);
9434 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
9436 return surface_frame.time_ms;
9452 return yetani->shmFormatBytesPerPixel(pixel_format);
9465 xdg_toplevel_set_minimized(xdg_toplevel);
9481 const Yetani::OutputData& output_data = yetani->output_data;
9483 std::lock_guard<std::mutex> lock(output_data.mutex);
9485 struct wl_output* wl_output = output_data.surface_output_map.at(wl_surface).front();
9488 auto p = yetani->convertPixelToMm(
output, point.
x, point.y);
9490 return { point.time, p.first, p.second };
9504 const Yetani::OutputData& output_data = yetani->output_data;
9506 std::lock_guard<std::mutex> lock(output_data.mutex);
9508 struct wl_output* wl_output = output_data.surface_output_map.at(wl_surface).front();
9511 auto p = yetani->convertPixelToPercent(
output, point.
x, point.y);
9513 return { point.time, p.first, p.second };
9527 Yetani::OutputData& output_data = yetani->output_data;
9529 std::lock_guard<std::mutex> lock(output_data.mutex);
9531 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9534 auto p = yetani->convertMmToPixel(
output, point.
x, point.y);
9536 return { point.time, p.first, p.second };
9550 Yetani::OutputData& output_data = yetani->output_data;
9552 std::lock_guard<std::mutex> lock(output_data.mutex);
9554 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9557 auto p = yetani->convertPercentToPixel(
output, point.
x, point.y);
9559 return { point.time, p.first, p.second };
9573 Yetani::OutputData& output_data = yetani->output_data;
9575 std::lock_guard<std::mutex> lock(output_data.mutex);
9577 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9580 auto p = yetani->convertPixelToMm(
output, size.
width, size.height);
9582 return { p.first, p.second };
9596 Yetani::OutputData& output_data = yetani->output_data;
9598 std::lock_guard<std::mutex> lock(output_data.mutex);
9600 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9603 auto p = yetani->convertPixelToPercent(
output, size.
width, size.height);
9605 return { p.first, p.second };
9619 Yetani::OutputData& output_data = yetani->output_data;
9621 std::lock_guard<std::mutex> lock(output_data.mutex);
9623 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9626 auto p = yetani->convertMmToPixel(
output, size.
width, size.height);
9628 return { p.first, p.second };
9642 Yetani::OutputData& output_data = yetani->output_data;
9644 std::lock_guard<std::mutex> lock(output_data.mutex);
9646 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9649 auto p = yetani->convertPercentToPixel(
output, size.
width, size.height);
9651 return { p.first, p.second };
9671 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
9673 if(lambda ==
nullptr)
9675 toplevel.close_request_lambda = Lambda_DoNothing;
9679 toplevel.close_request_lambda = lambda;
9696 XdgDecoration& decoration = yetani->xdg_decoration_map[xdg_surface];
9698 if(lambda ==
nullptr)
9700 decoration.lambda = LambdaWindowDecorations_DoNothing;
9704 decoration.lambda = lambda;
9725 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
9727 if(lambda ==
nullptr)
9729 toplevel.is_active_lambda = LambdaBool_DoNothing;
9733 toplevel.is_active_lambda = lambda;
9746 if(yetani->keyboard.event_map.contains(wl_surface) ==
false)
9751 Yetani::KeyboardEvent&
event = yetani->keyboard.event_map[wl_surface];
9753 if(lambda ==
nullptr)
9755 event.on_enter = Lambda_DoNothing;
9759 event.on_enter = lambda;
9772 if(yetani->keyboard.event_map.contains(wl_surface) ==
false)
9777 Yetani::KeyboardEvent&
event = yetani->keyboard.event_map[wl_surface];
9779 if(lambda ==
nullptr)
9781 event.on_leave = Lambda_DoNothing;
9785 event.on_leave = lambda;
9800 if(yetani->keyboard.event_map.contains(wl_surface) ==
false)
9805 Yetani::KeyboardEvent&
event = yetani->keyboard.event_map[wl_surface];
9807 if(lambda ==
nullptr)
9809 event.on_key = LambdaKey_DoNothing;
9813 event.on_key = lambda;
9827 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
9829 if(lambda ==
nullptr)
9831 toplevel.window_state_lambda = LambdaWindowMode_DoNothing;
9835 toplevel.window_state_lambda = lambda;
9856 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
9858 if(lambda ==
nullptr)
9860 event.on_size_mm_change = LambdaSizeMm_DoNothing;
9864 event.on_size_mm_change = lambda;
9885 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
9887 if(lambda ==
nullptr)
9889 event.on_size_percent_change = LambdaSizePercent_DoNothing;
9893 event.on_size_percent_change = lambda;
9914 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
9916 if(lambda ==
nullptr)
9918 event.on_size_pixel_change = LambdaSizePixel_DoNothing;
9922 event.on_size_pixel_change = lambda;
9937 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
9942 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
9944 if(lambda ==
nullptr)
9946 event.on_button_mm = LambdaButtonMm_DoNothing;
9950 event.on_button_mm = lambda;
9965 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
9970 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
9972 if(lambda ==
nullptr)
9974 event.on_button_percent = LambdaButtonPercent_DoNothing;
9978 event.on_button_percent = lambda;
9993 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
9998 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10000 if(lambda ==
nullptr)
10002 event.on_button_pixel = LambdaButtonPixel_DoNothing;
10006 event.on_button_pixel = lambda;
10024 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10029 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10031 if(lambda ==
nullptr)
10033 event.on_enter_mm = LambdaPointMm_DoNothing;
10037 event.on_enter_mm = lambda;
10055 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10060 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10062 if(lambda ==
nullptr)
10064 event.on_enter_percent = LambdaPointPercent_DoNothing;
10068 event.on_enter_percent = lambda;
10086 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10091 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10093 if(lambda ==
nullptr)
10095 event.on_enter_pixel = LambdaPointPixel_DoNothing;
10099 event.on_enter_pixel = lambda;
10114 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10119 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10121 if(lambda ==
nullptr)
10123 event.on_leave = Lambda_DoNothing;
10127 event.on_leave = lambda;
10142 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10147 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10149 if(lambda ==
nullptr)
10151 event.on_motion_mm = LambdaPointMm_DoNothing;
10155 event.on_motion_mm = lambda;
10170 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10175 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10177 if(lambda ==
nullptr)
10179 event.on_motion_percent = LambdaPointPercent_DoNothing;
10183 event.on_motion_percent = lambda;
10198 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10203 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10205 if(lambda ==
nullptr)
10207 event.on_motion_pixel = LambdaPointPixel_DoNothing;
10211 event.on_motion_pixel = lambda;
10225 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10230 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10232 if(lambda ==
nullptr)
10234 event.on_axis = LambdaAxis_DoNothing;
10238 event.on_axis = lambda;
10252 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10257 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10259 if(lambda ==
nullptr)
10261 event.on_axis_source = Lambda_DoNothing;
10265 event.on_axis_source = lambda;
10279 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10284 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10286 if(lambda ==
nullptr)
10288 event.on_axis_stop = Lambda_DoNothing;
10292 event.on_axis_stop = lambda;
10306 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10311 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10313 if(lambda ==
nullptr)
10315 event.on_axis_discrete = Lambda_DoNothing;
10319 event.on_axis_discrete = lambda;
10354 return std::string()
10355 +
"{ \"time\": " + std::to_string(key.time)
10356 +
", \"code\": " + std::to_string(key.code)
10373 auto mod_to_str = [](std::string& s, uint32_t m)
10376 std::string delim =
"";
10380 s += delim +
"\"Shift\"";
10386 s += delim +
"\"CapsLock\"";
10392 s += delim +
"\"Control\"";
10398 s += delim +
"\"Alt\"";
10402 if(m & Yetani::KeyModifier_NumLock)
10404 s += delim +
"\"NumLock\"";
10409 s += delim +
"\"Meta\"";
10415 std::string str =
"{ \"pressed\": ";
10416 mod_to_str(str, key_modifier.pressed);
10418 str +=
", \"latched\": ";
10419 mod_to_str(str, key_modifier.latched);
10421 str +=
", \"locked\": ";
10422 mod_to_str(str, key_modifier.locked);
10442 case Yetani::KeyState::Pressed:
return "Pressed";
10443 case Yetani::KeyState::Released:
return "Released";
10444 case Yetani::KeyState::Repeat:
return "Repeat";
10445 default:
return "";
10460 return std::string()
10461 +
"{ \"x\": " + std::to_string(
output.
x)
10462 +
", \"y\": " + std::to_string(
output.
y)
10492 return std::string()
10493 +
"{ \"time\": " + std::to_string(point.time)
10494 +
", \"x\": " + std::to_string(point.x)
10495 +
", \"y\": " + std::to_string(point.y)
10510 return std::string()
10511 +
"{ \"time\": " + std::to_string(point.time)
10512 +
", \"x\": " + std::to_string(point.x)
10513 +
", \"y\": " + std::to_string(point.y)
10528 return std::string()
10529 +
"{ \"time\": " + std::to_string(point.time)
10530 +
", \"x\": " + std::to_string(point.x)
10531 +
", \"y\": " + std::to_string(point.y)
10546 return std::string()
10547 +
"{ \"time\": " + std::to_string(axis.time)
10548 +
", \"steps\": " + std::to_string(axis.steps)
10549 +
", \"distance\": " + std::to_string(axis.distance)
10568 case Yetani::PointerAxisSource::Continuous:
return "Continuous";
10569 case Yetani::PointerAxisSource::Finger:
return "Finger";
10570 case Yetani::PointerAxisSource::Wheel:
return "Wheel";
10571 case Yetani::PointerAxisSource::Wheel_Tilt:
return "Wheel Tilt";
10572 case Yetani::PointerAxisSource::Unknown: [[fallthrough]];
10573 default:
return "";
10590 case Yetani::PointerAxisType::Horizontal:
return "Horizontal";
10591 case Yetani::PointerAxisType::Vertical:
return "Vertical";
10592 case Yetani::PointerAxisType::Unknown: [[fallthrough]];
10593 default:
return "";
10608 return std::string()
10609 +
"{ \"code\": " + std::to_string(button.code)
10625 switch(button_state)
10627 case Yetani::PointerButtonState::Pressed:
return "Pressed";
10628 case Yetani::PointerButtonState::Released:
return "Released";
10629 default:
return "";
10644 return std::string()
10645 +
"{ \"width\": " + std::to_string(size.width)
10646 +
", \"height\": " + std::to_string(size.height)
10661 return std::string()
10662 +
"{ \"width\": " + std::to_string(size.width)
10663 +
", \"height\": " + std::to_string(size.height)
10678 return std::string()
10679 +
"{ \"width\": " + std::to_string(size.width)
10680 +
", \"height\": " + std::to_string(size.height)
10695 switch(window_mode)
10697 case Yetani::WindowMode::Fullscreen:
return "Fullscreen";
10698 case Yetani::WindowMode::Maximized:
return "Maximized";
10699 case Yetani::WindowMode::Normal:
return "Normal";
10700 default:
return "";
10765 return (lhs.x == rhs.x) && (lhs.y == rhs.y);
10823 return (lhs.width == rhs.width) && (lhs.height == rhs.height);
std::string to_string(const bool value) noexcept
Convert a bool into a string.
Definition: Zakero_Base.h:561
#define ZAKERO_STEADY_TIME_NOW(unit_)
Get the current time.
Definition: Zakero_Base.h:231
auto vectorErase(std::vector< Type > &vector, const Type &value) noexcept
Erase the contents of a std::vector.
Definition: Zakero_Base.h:503
bool vectorContains(const std::vector< Type > &vector, const Type &value) noexcept
Check the contents of a std::vector.
Definition: Zakero_Base.h:431
uint64_t convert(const uint64_t size, const zakero::Storage from, const zakero::Storage to) noexcept
Convert storage sizes.
Definition: Zakero_Base.h:319
bool equalish(const float a, const float b, const float delta) noexcept
Compare two floats.
Definition: Zakero_Base.h:375
bool operator==(const zakero::messagepack::Object &lhs, const zakero::messagepack::Object &rhs) noexcept
Compare two Objects for equality.
Definition: Zakero_MessagePack.h:8964
A pool of memory.
Definition: Zakero_MemoryPool.h:273
std::error_code init(const size_t, const bool=false, const MemoryPool::Alignment=MemoryPool::Alignment::Bits_64) noexcept
Initialize the MemoryPool.
Definition: Zakero_MemoryPool.h:648
size_t size() const noexcept
The size of the memory pool.
Definition: Zakero_MemoryPool.h:755
int fd() const noexcept
The backing file descriptor.
Definition: Zakero_MemoryPool.h:742
void sizeOnChange(MemoryPool::LambdaSize) noexcept
Set the Size Event callback.
Definition: Zakero_MemoryPool.h:790
A Window.
Definition: Zakero_Yetani.h:1320
std::error_code sizeSet(const Yetani::SizeMm &) noexcept
Set the window size.
Definition: Zakero_Yetani.h:9065
void imagePresent() noexcept
Render the image.
Definition: Zakero_Yetani.h:9400
struct wl_shm_pool * wl_shm_pool
A pointer to the Wayland Shared Memory Pool.
Definition: Zakero_Yetani.h:1424
zakero::MemoryPool memory_pool
The Window's Memory Pool.
Definition: Zakero_Yetani.h:1425
void onCloseRequest(Yetani::Lambda) noexcept
Respond to "Close Request" events.
Definition: Zakero_Yetani.h:9668
void pointerOnEnter(Yetani::LambdaPointMm) noexcept
Respond to "Pointer Enter" events.
Definition: Zakero_Yetani.h:10021
void onFocusChange(Yetani::LambdaBool) noexcept
Respond to "Active" change events.
Definition: Zakero_Yetani.h:9722
uint32_t time() const noexcept
When the last frame was rendered.
Definition: Zakero_Yetani.h:9432
Yetani::PointPixel convertToPixel(const Yetani::PointMm &) const noexcept
Unit conversion.
Definition: Zakero_Yetani.h:9524
std::error_code decorationsSet(const Yetani::WindowDecorations) noexcept
Use the Desktop Environment borders.
Definition: Zakero_Yetani.h:8949
void windowModeOnChange(Yetani::LambdaWindowMode) noexcept
Respond to "Window Mode" events.
Definition: Zakero_Yetani.h:9824
virtual ~Window()
Destroy a Window.
Definition: Zakero_Yetani.h:8813
void pointerOnLeave(Yetani::Lambda) noexcept
Respond to "Pointer Leave" events.
Definition: Zakero_Yetani.h:10111
void cursorShow() noexcept
Show the cursor.
Definition: Zakero_Yetani.h:8886
void pointerOnButton(Yetani::LambdaButtonMm) noexcept
Respond to "Pointer Button" events.
Definition: Zakero_Yetani.h:9934
void pointerOnAxisSource(Yetani::Lambda) noexcept
Respond to "Pointer Axis Source" events.
Definition: Zakero_Yetani.h:10249
uint8_t bytesPerPixel() const noexcept
Get the number of bytes per pixel.
Definition: Zakero_Yetani.h:9450
void sizeOnChange(Yetani::LambdaSizeMm) noexcept
Respond to "Resize" events.
Definition: Zakero_Yetani.h:9853
std::error_code cursorUse(const std::string &) noexcept
Use a cursor.
Definition: Zakero_Yetani.h:8858
void keyboardOnEnter(Yetani::Lambda) noexcept
Respond to "Keyboard Enter" events.
Definition: Zakero_Yetani.h:9743
bool windowModeIs(const Yetani::WindowMode) noexcept
Check the WindowMode.
Definition: Zakero_Yetani.h:8995
std::error_code sizeSetMinMax(const Yetani::SizeMm &, const Yetani::SizeMm &) noexcept
Set the minimum window size.
Definition: Zakero_Yetani.h:9203
void titleSet(const std::string &) noexcept
Change the window title.
Definition: Zakero_Yetani.h:8923
void pointerOnMotion(Yetani::LambdaPointMm) noexcept
Respond to "Pointer Motion" events.
Definition: Zakero_Yetani.h:10139
Yetani::PointPercent convertToPercent(const Yetani::PointPixel &) const noexcept
Unit conversion.
Definition: Zakero_Yetani.h:9501
void classSet(const std::string &) noexcept
Change the window class.
Definition: Zakero_Yetani.h:8910
void pointerOnAxisDiscrete(Yetani::Lambda) noexcept
Respond to "Pointer Axis Discrete" events.
Definition: Zakero_Yetani.h:10303
void windowModeSet(const Yetani::WindowMode) noexcept
Change the window mode.
Definition: Zakero_Yetani.h:9019
Yetani::WindowMode windowMode() noexcept
Get the current WindowMode.
Definition: Zakero_Yetani.h:8977
std::error_code imageNext(uint8_t *&, Yetani::SizePixel &) noexcept
Get an image buffer.
Definition: Zakero_Yetani.h:9364
void pointerOnAxisStop(Yetani::Lambda) noexcept
Respond to "Pointer Axis Stop" events.
Definition: Zakero_Yetani.h:10276
void decorationsOnChange(Yetani::LambdaWindowDecorations) noexcept
Respond to "Decoration Change" events.
Definition: Zakero_Yetani.h:9693
Window(void *)
Construct a Window.
Definition: Zakero_Yetani.h:8760
void keyboardOnKey(Yetani::LambdaKey) noexcept
Respond to "Keyboard Key" events.
Definition: Zakero_Yetani.h:9797
void cursorHide() noexcept
Hide the cursor.
Definition: Zakero_Yetani.h:8875
void minimize() noexcept
Minimize the window.
Definition: Zakero_Yetani.h:9463
Yetani::PointMm convertToMm(const Yetani::PointPixel &) const noexcept
Unit conversion.
Definition: Zakero_Yetani.h:9478
void pointerOnAxis(Yetani::LambdaAxis) noexcept
Respond to "Pointer Axis" events.
Definition: Zakero_Yetani.h:10222
void keyboardOnLeave(Yetani::Lambda) noexcept
Respond to "Keyboard Leave" events.
Definition: Zakero_Yetani.h:9769
The shared memory.
Definition: Zakero_Yetani.h:1423
A wrapper class for Wayland.
Definition: Zakero_Yetani.h:1033
uint32_t code
The key code of the event.
Definition: Zakero_Yetani.h:1053
std::string make
Description of the manufacturer.
Definition: Zakero_Yetani.h:1206
static std::string outputTransformName(int32_t) noexcept
Get a human readable string.
Definition: Zakero_Yetani.h:4791
float pixels_per_mm_vertical
A pre-calculated value.
Definition: Zakero_Yetani.h:1220
std::function< void(const Yetani::Key &, const Yetani::KeyModifier &)> LambdaKey
A Lambda that has parameters: Key and KeyModifier.
Definition: Zakero_Yetani.h:1302
static std::string outputSubpixelName(int32_t) noexcept
Get a human readable string.
Definition: Zakero_Yetani.h:4766
float pixels_per_mm_horizontal
A pre-calculated value.
Definition: Zakero_Yetani.h:1219
float distance
The distance traveled.
Definition: Zakero_Yetani.h:1123
const std::vector< void * > & image_data
A collection of image data.
Definition: Zakero_Yetani.h:1187
std::function< void(const Yetani::PointerButton &, const Yetani::PointPercent &, const Yetani::KeyModifier &)> LambdaButtonPercent
A Lambda that has parameters: PointerButton, PointPercent and KeyModifier.
Definition: Zakero_Yetani.h:1305
static std::string shmFormatName(const wl_shm_format) noexcept
Get the name of the format.
Definition: Zakero_Yetani.h:4491
Yetani::VectorOutputId outputVector() const noexcept
Get a list of the Output Id's.
Definition: Zakero_Yetani.h:4740
int32_t height
The height of the device in hardware units.
Definition: Zakero_Yetani.h:1211
int32_t keyRepeatDelay() const noexcept
The key repeat delay.
Definition: Zakero_Yetani.h:5451
static constexpr uint32_t KeyModifier_Alt
Key Modifier flag.
Definition: Zakero_Yetani.h:1060
uint32_t pressed
A collection of pressed modifiers.
Definition: Zakero_Yetani.h:1066
void outputOnAdd(Yetani::LambdaOutputId) noexcept
Notification of adding an Output device.
Definition: Zakero_Yetani.h:5052
Yetani::PointPixel outputConvertToPixel(const Yetani::OutputId, const Yetani::PointMm &) const noexcept
Convert Millimeter to Pixel.
Definition: Zakero_Yetani.h:4875
Yetani::PointerAxisType type
The type of Axis.
Definition: Zakero_Yetani.h:1125
static constexpr uint32_t KeyModifier_Meta
Key Modifier flag.
Definition: Zakero_Yetani.h:1062
Yetani::PointPercent outputConvertToPercent(const Yetani::OutputId, const Yetani::PointPixel &) const noexcept
Convert Pixel to a Percentage.
Definition: Zakero_Yetani.h:4845
Yetani::Output output(const Yetani::OutputId) const noexcept
Get a copy of the Output information.
Definition: Zakero_Yetani.h:4708
int32_t y
The Y position within the global compositor.
Definition: Zakero_Yetani.h:1209
Yetani::Window * windowCreate(const Yetani::SizeMm &, std::error_code &) noexcept
Create a window.
Definition: Zakero_Yetani.h:8024
PointerAxisType
The direction of the axis movement.
Definition: Zakero_Yetani.h:1114
void outputOnChange(Yetani::LambdaOutputId) noexcept
Notification that an Output device has changed.
Definition: Zakero_Yetani.h:5075
Yetani::PointerButtonState state
The button state.
Definition: Zakero_Yetani.h:1139
PointerButtonState
Mouse button state.
Definition: Zakero_Yetani.h:1132
uint32_t time
When the key event happened.
Definition: Zakero_Yetani.h:1052
std::function< void(Yetani::WindowMode)> LambdaWindowMode
A Lambda that has a parameter: WindowMode.
Definition: Zakero_Yetani.h:1312
std::function< void(const Yetani::PointerButton &, const Yetani::PointPixel &, const Yetani::KeyModifier &)> LambdaButtonPixel
A Lambda that has parameters: PointerButton, PointPixel and KeyModifier.
Definition: Zakero_Yetani.h:1306
uint32_t flags
wl_output_mode bitfield properties.
Definition: Zakero_Yetani.h:1218
static constexpr wl_shm_format SHM_FORMAT_DEFAULT
The default pixel format.
Definition: Zakero_Yetani.h:1444
static constexpr uint32_t KeyModifier_CapsLock
Key Modifier flag.
Definition: Zakero_Yetani.h:1058
void outputOnRemove(Yetani::LambdaOutputId) noexcept
Notification of removing an Output device.
Definition: Zakero_Yetani.h:5098
PointerAxisSource
Where the axis information came from.
Definition: Zakero_Yetani.h:1106
std::function< void(const Yetani::PointerAxis &, const Yetani::KeyModifier &)> LambdaAxis
A Lambda that has parameters: PointerAxis and KeyModifier.
Definition: Zakero_Yetani.h:1303
std::function< void(const Yetani::PointMm &, const Yetani::KeyModifier &)> LambdaPointMm
A Lambda that has parameters: PointMm and KeyModifier.
Definition: Zakero_Yetani.h:1307
uint32_t latched
A collection of latched modifiers.
Definition: Zakero_Yetani.h:1067
static Yetani * connect() noexcept
Establish a connection with the Wayland Compositor.
Definition: Zakero_Yetani.h:3318
std::error_code cursorCreate(const std::string &, const Yetani::CursorConfig &) noexcept
Create a cursor.
Definition: Zakero_Yetani.h:3801
std::function< void(const Yetani::PointPercent &, const Yetani::KeyModifier &)> LambdaPointPercent
A Lambda that has parameters: PointPercent and KeyModifier.
Definition: Zakero_Yetani.h:1308
std::function< void()> Lambda
A Lambda that has no parameters.
Definition: Zakero_Yetani.h:1301
uint32_t physical_height_mm
The height of the device in millimeters.
Definition: Zakero_Yetani.h:1213
uint32_t physical_width_mm
The width of the device in millimeters.
Definition: Zakero_Yetani.h:1212
int32_t keyRepeatRate() const noexcept
The key repeat rate.
Definition: Zakero_Yetani.h:5465
std::function< void(const Yetani::SizeMm &)> LambdaSizeMm
A Lambda that has a parameter: SizeMm.
Definition: Zakero_Yetani.h:1313
std::string model
Description of the model.
Definition: Zakero_Yetani.h:1207
const Yetani::VectorShmFormat & shmFormatAvailable() const noexcept
Get all the support color formats.
Definition: Zakero_Yetani.h:4426
std::error_code cursorDestroy(const std::string &) noexcept
Destroy a cursor.
Definition: Zakero_Yetani.h:3939
std::function< void(const Yetani::SizePercent &)> LambdaSizePercent
A Lambda that has a parameter: SizePercent.
Definition: Zakero_Yetani.h:1314
WindowDecorations
Who is responsible for rendering the decorations.
Definition: Zakero_Yetani.h:1289
KeyState
Keyboard key state
Definition: Zakero_Yetani.h:1045
int32_t refresh_mHz
The current refresh rate of the device.
Definition: Zakero_Yetani.h:1215
uint32_t time
When the event occurred.
Definition: Zakero_Yetani.h:1121
int32_t x
The X position within the global compositor.
Definition: Zakero_Yetani.h:1208
int32_t width
The width of the device in hardware units.
Definition: Zakero_Yetani.h:1210
uint32_t group
The keyboard layout.
Definition: Zakero_Yetani.h:1069
std::function< void(const Yetani::PointPixel &, const Yetani::KeyModifier &)> LambdaPointPixel
A Lambda that has parameters: PointPixel and KeyModifier.
Definition: Zakero_Yetani.h:1309
int32_t scale_factor
The scaling factor between the device and compositor.
Definition: Zakero_Yetani.h:1216
std::function< void(bool)> LambdaBool
A Lambda that has a parameter: bool.
Definition: Zakero_Yetani.h:1310
virtual ZAKERO_YETANI__ERROR_DATA ~Yetani() noexcept
Destructor.
Definition: Zakero_Yetani.h:3282
std::function< void(const Yetani::PointerButton &, const Yetani::PointMm &, const Yetani::KeyModifier &)> LambdaButtonMm
A Lambda that has parameters: PointerButton, PointMm and KeyModifier.
Definition: Zakero_Yetani.h:1304
WindowMode
Definition: Zakero_Yetani.h:1294
int32_t steps
The number of rotation steps.
Definition: Zakero_Yetani.h:1122
KeyState state
The state of the key.
Definition: Zakero_Yetani.h:1054
std::function< void(const Yetani::SizePixel &)> LambdaSizePixel
A Lambda that has a parameter: SizePixel.
Definition: Zakero_Yetani.h:1315
int32_t subpixel
The device's subpixel orientation.
Definition: Zakero_Yetani.h:1214
std::function< void(Yetani::WindowDecorations)> LambdaWindowDecorations
A Lambda that has a parameter: WindowDecorations.
Definition: Zakero_Yetani.h:1311
static constexpr uint32_t KeyModifier_Control
Key Modifier flag.
Definition: Zakero_Yetani.h:1059
static uint8_t shmFormatBytesPerPixel(const wl_shm_format) noexcept
Determine bytes-per-pixel.
Definition: Zakero_Yetani.h:4443
static constexpr uint32_t KeyModifier_Shift
Key Modifier flag.
Definition: Zakero_Yetani.h:1057
uint32_t code
The event code.
Definition: Zakero_Yetani.h:1138
Yetani::PointMm outputConvertToMm(const Yetani::OutputId, const Yetani::PointPixel &) const noexcept
Convert Pixel to Millimeter.
Definition: Zakero_Yetani.h:4815
Yetani::PointerAxisSource source
The source of the event.
Definition: Zakero_Yetani.h:1124
int32_t transform
Transform that maps framebuffer to output.
Definition: Zakero_Yetani.h:1217
static std::string shmFormatDescription(const wl_shm_format) noexcept
Get a description of the format.
Definition: Zakero_Yetani.h:4468
uint32_t locked
A collection of locked modifiers.
Definition: Zakero_Yetani.h:1068
Cursor configuration.
Definition: Zakero_Yetani.h:1181
Key event information.
Definition: Zakero_Yetani.h:1051
A collection modifier flags.
Definition: Zakero_Yetani.h:1065
Information about a output device.
Definition: Zakero_Yetani.h:1205
Information about an Axis event.
Definition: Zakero_Yetani.h:1120
A location that uses millimeters.
Definition: Zakero_Yetani.h:1076
float x
Where in the X-Axis the point is.
Definition: Zakero_Yetani.h:1078
uint32_t time
Where in time the point is (if > 0).
Definition: Zakero_Yetani.h:1077
float y
Where in the Y-Axis the point is.
Definition: Zakero_Yetani.h:1079
friend bool operator==(Yetani::PointMm &, Yetani::PointMm &) noexcept
Compare two Point objects.
Definition: Zakero_Yetani.h:10718
A location that uses percentages.
Definition: Zakero_Yetani.h:1085
uint32_t time
Where in time the point is (if > 0).
Definition: Zakero_Yetani.h:1086
float x
Where in the X-Axis the point is.
Definition: Zakero_Yetani.h:1087
friend bool operator==(Yetani::PointPercent &, Yetani::PointPercent &) noexcept
Compare two Point objects.
Definition: Zakero_Yetani.h:10741
float y
Where in the Y-Axis the point is.
Definition: Zakero_Yetani.h:1088
A location that uses pixels.
Definition: Zakero_Yetani.h:1094
friend bool operator==(Yetani::PointPixel &, Yetani::PointPixel &) noexcept
Compare two Point objects.
Definition: Zakero_Yetani.h:10761
uint32_t time
Where in time the point is (if > 0).
Definition: Zakero_Yetani.h:1095
int32_t x
Where in the X-Axis the point is.
Definition: Zakero_Yetani.h:1096
int32_t y
Where in the Y-Axis the point is.
Definition: Zakero_Yetani.h:1097
Size measured in millimeters.
Definition: Zakero_Yetani.h:1146
friend bool operator==(Yetani::SizeMm &, Yetani::SizeMm &) noexcept
Compare two Point objects.
Definition: Zakero_Yetani.h:10780
float width
The width.
Definition: Zakero_Yetani.h:1147
float height
The height.
Definition: Zakero_Yetani.h:1148
Size measured as a percentage of the Output (Monitor) resolution.
Definition: Zakero_Yetani.h:1154
float width
The width.
Definition: Zakero_Yetani.h:1155
float height
The height.
Definition: Zakero_Yetani.h:1156
friend bool operator==(Yetani::SizePercent &, Yetani::SizePercent &) noexcept
Compare two Point objects.
Definition: Zakero_Yetani.h:10801
Size measured in pixels.
Definition: Zakero_Yetani.h:1162
friend bool operator==(Yetani::SizePixel &, Yetani::SizePixel &) noexcept
Compare two Size objects.
Definition: Zakero_Yetani.h:10819
int32_t width
The width.
Definition: Zakero_Yetani.h:1163
int32_t height
The height.
Definition: Zakero_Yetani.h:1164