9 #ifndef zakero_Yetani_h
10 #define zakero_Yetani_h
222 #include <linux/input-event-codes.h>
225 #include <wayland/wayland-client.h>
254 #define ZAKERO_YETANI__ERROR_DATA \
255 X(Error_None , 0 , "No Error" ) \
256 X(Error_Compositor_Was_Not_Found , 1 , "Could not find the Compositor object in the Global Repository." ) \
257 X(Error_Connection_Failed , 2 , "Failed to connect to the Wayland Server." ) \
258 X(Error_Cursor_Already_Exists , 3 , "A cursor with that name already exists." ) \
259 X(Error_Cursor_Does_Not_Exist , 4 , "No cursors exists with that name." ) \
260 X(Error_Cursor_Frame_Time_Too_Large , 5 , "The cursor time per frame is too large, must be <= Size_Max." ) \
261 X(Error_Cursor_Frame_Time_Too_Small , 6 , "The cursor time per frame is too small, must be greater than 0." ) \
262 X(Error_Cursor_Image_Data_Is_Empty , 7 , "The cursor image data can not be empty." ) \
263 X(Error_Cursor_Name_Is_Invalid , 8 , "The cursor name is invalid." ) \
264 X(Error_Cursor_Not_Attached , 9 , "The specified cursor is not attached/in-use." ) \
265 X(Error_Cursor_Size_Too_Small , 10 , "The cursor size, both width and height must be greater than 0." ) \
266 X(Error_Invalid_Display_Name , 11 , "An invalid dispaly name was given to the Wayland Server." ) \
267 X(Error_Minimum_Size_Greater_Than_Maximum_Size , 12 , "The minimum window size is larger than the maximum window size." ) \
268 X(Error_No_Output_Available , 13 , "No output devices are available." ) \
269 X(Error_Registry_Not_Available , 14 , "Unable to get the registery." ) \
270 X(Error_Server_Side_Decorations_Not_Available , 15 , "The Wayland Compositor does not support Server Side Decorations." ) \
271 X(Error_Shm_Was_Not_Found , 16 , "Could not find the Shm object in the Global Repository." ) \
272 X(Error_Wayland_Not_Available , 17 , "Could not find the Wayland Server." ) \
273 X(Error_Window_Initialization_Failed , 18 , "The window was not able to be initialized." ) \
274 X(Error_Window_Size_Too_Small , 19 , "The window size was too small." ) \
275 X(Error_Xdg_WM_Base_Was_Not_Found , 20 , "Could not find the XDG WM Base object the Global Repository." ) \
316 struct zxdg_decoration_manager_v1;
317 struct zxdg_toplevel_decoration_v1;
318 extern const struct wl_interface zxdg_decoration_manager_v1_interface;
319 extern const struct wl_interface zxdg_toplevel_decoration_v1_interface;
321 zxdg_decoration_manager_v1_set_user_data(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1,
void *user_data)
323 wl_proxy_set_user_data((
struct wl_proxy *) zxdg_decoration_manager_v1, user_data);
326 zxdg_decoration_manager_v1_get_user_data(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
328 return wl_proxy_get_user_data((
struct wl_proxy *) zxdg_decoration_manager_v1);
330 static inline uint32_t
331 zxdg_decoration_manager_v1_get_version(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
333 return wl_proxy_get_version((
struct wl_proxy *) zxdg_decoration_manager_v1);
336 zxdg_decoration_manager_v1_destroy(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
338 wl_proxy_marshal((
struct wl_proxy *) zxdg_decoration_manager_v1,
340 wl_proxy_destroy((
struct wl_proxy *) zxdg_decoration_manager_v1);
342 static inline struct zxdg_toplevel_decoration_v1 *
343 zxdg_decoration_manager_v1_get_toplevel_decoration(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1,
struct xdg_toplevel *toplevel)
346 id = wl_proxy_marshal_constructor((
struct wl_proxy *) zxdg_decoration_manager_v1,
347 1, &zxdg_toplevel_decoration_v1_interface, NULL, toplevel);
348 return (
struct zxdg_toplevel_decoration_v1 *) id;
350 enum zxdg_toplevel_decoration_v1_error {
351 ZXDG_TOPLEVEL_DECORATION_V1_ERROR_UNCONFIGURED_BUFFER = 0,
352 ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ALREADY_CONSTRUCTED = 1,
353 ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ORPHANED = 2,
355 enum zxdg_toplevel_decoration_v1_mode {
356 ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE = 1,
357 ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE = 2,
359 struct zxdg_toplevel_decoration_v1_listener {
360 void (*configure)(
void *data,
361 struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
365 zxdg_toplevel_decoration_v1_add_listener(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
366 const struct zxdg_toplevel_decoration_v1_listener *listener,
void *data)
368 return wl_proxy_add_listener((
struct wl_proxy *) zxdg_toplevel_decoration_v1,
369 (
void (**)(
void)) listener, data);
372 zxdg_toplevel_decoration_v1_set_user_data(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
void *user_data)
374 wl_proxy_set_user_data((
struct wl_proxy *) zxdg_toplevel_decoration_v1, user_data);
377 zxdg_toplevel_decoration_v1_get_user_data(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
379 return wl_proxy_get_user_data((
struct wl_proxy *) zxdg_toplevel_decoration_v1);
381 static inline uint32_t
382 zxdg_toplevel_decoration_v1_get_version(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
384 return wl_proxy_get_version((
struct wl_proxy *) zxdg_toplevel_decoration_v1);
387 zxdg_toplevel_decoration_v1_destroy(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
389 wl_proxy_marshal((
struct wl_proxy *) zxdg_toplevel_decoration_v1,
391 wl_proxy_destroy((
struct wl_proxy *) zxdg_toplevel_decoration_v1);
394 zxdg_toplevel_decoration_v1_set_mode(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, uint32_t mode)
396 wl_proxy_marshal((
struct wl_proxy *) zxdg_toplevel_decoration_v1,
400 zxdg_toplevel_decoration_v1_unset_mode(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
402 wl_proxy_marshal((
struct wl_proxy *) zxdg_toplevel_decoration_v1,
405 extern const struct wl_interface xdg_toplevel_interface;
406 extern const struct wl_interface zxdg_toplevel_decoration_v1_interface;
407 static const struct wl_interface *xdg_decoration_unstable_v1_types[] = {
409 &zxdg_toplevel_decoration_v1_interface,
410 &xdg_toplevel_interface,
412 static const struct wl_message zxdg_decoration_manager_v1_requests[] = {
413 {
"destroy",
"", xdg_decoration_unstable_v1_types + 0 },
414 {
"get_toplevel_decoration",
"no", xdg_decoration_unstable_v1_types + 1 },
416 const struct wl_interface zxdg_decoration_manager_v1_interface = {
417 "zxdg_decoration_manager_v1", 1,
418 2, zxdg_decoration_manager_v1_requests,
421 static const struct wl_message zxdg_toplevel_decoration_v1_requests[] = {
422 {
"destroy",
"", xdg_decoration_unstable_v1_types + 0 },
423 {
"set_mode",
"u", xdg_decoration_unstable_v1_types + 0 },
424 {
"unset_mode",
"", xdg_decoration_unstable_v1_types + 0 },
426 static const struct wl_message zxdg_toplevel_decoration_v1_events[] = {
427 {
"configure",
"u", xdg_decoration_unstable_v1_types + 0 },
429 const struct wl_interface zxdg_toplevel_decoration_v1_interface = {
430 "zxdg_toplevel_decoration_v1", 1,
431 3, zxdg_toplevel_decoration_v1_requests,
432 1, zxdg_toplevel_decoration_v1_events,
440 struct xdg_positioner;
444 extern const struct wl_interface xdg_wm_base_interface;
445 extern const struct wl_interface xdg_positioner_interface;
446 extern const struct wl_interface xdg_surface_interface;
447 extern const struct wl_interface xdg_toplevel_interface;
448 extern const struct wl_interface xdg_popup_interface;
449 enum xdg_wm_base_error {
450 XDG_WM_BASE_ERROR_ROLE = 0,
451 XDG_WM_BASE_ERROR_DEFUNCT_SURFACES = 1,
452 XDG_WM_BASE_ERROR_NOT_THE_TOPMOST_POPUP = 2,
453 XDG_WM_BASE_ERROR_INVALID_POPUP_PARENT = 3,
454 XDG_WM_BASE_ERROR_INVALID_SURFACE_STATE = 4,
455 XDG_WM_BASE_ERROR_INVALID_POSITIONER = 5,
457 struct xdg_wm_base_listener {
458 void (*ping)(
void *data,
459 struct xdg_wm_base *xdg_wm_base,
463 xdg_wm_base_add_listener(
struct xdg_wm_base *xdg_wm_base,
464 const struct xdg_wm_base_listener *listener,
void *data)
466 return wl_proxy_add_listener((
struct wl_proxy *) xdg_wm_base,
467 (
void (**)(
void)) listener, data);
470 xdg_wm_base_set_user_data(
struct xdg_wm_base *xdg_wm_base,
void *user_data)
472 wl_proxy_set_user_data((
struct wl_proxy *) xdg_wm_base, user_data);
475 xdg_wm_base_get_user_data(
struct xdg_wm_base *xdg_wm_base)
477 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_wm_base);
479 static inline uint32_t
480 xdg_wm_base_get_version(
struct xdg_wm_base *xdg_wm_base)
482 return wl_proxy_get_version((
struct wl_proxy *) xdg_wm_base);
485 xdg_wm_base_destroy(
struct xdg_wm_base *xdg_wm_base)
487 wl_proxy_marshal((
struct wl_proxy *) xdg_wm_base,
489 wl_proxy_destroy((
struct wl_proxy *) xdg_wm_base);
491 static inline struct xdg_positioner *
492 xdg_wm_base_create_positioner(
struct xdg_wm_base *xdg_wm_base)
495 id = wl_proxy_marshal_constructor((
struct wl_proxy *) xdg_wm_base,
496 1, &xdg_positioner_interface, NULL);
497 return (
struct xdg_positioner *) id;
499 static inline struct xdg_surface *
500 xdg_wm_base_get_xdg_surface(
struct xdg_wm_base *xdg_wm_base,
struct wl_surface *surface)
503 id = wl_proxy_marshal_constructor((
struct wl_proxy *) xdg_wm_base,
504 2, &xdg_surface_interface, NULL, surface);
505 return (
struct xdg_surface *) id;
508 xdg_wm_base_pong(
struct xdg_wm_base *xdg_wm_base, uint32_t serial)
510 wl_proxy_marshal((
struct wl_proxy *) xdg_wm_base,
513 enum xdg_positioner_error {
514 XDG_POSITIONER_ERROR_INVALID_INPUT = 0,
516 enum xdg_positioner_anchor {
517 XDG_POSITIONER_ANCHOR_NONE = 0,
518 XDG_POSITIONER_ANCHOR_TOP = 1,
519 XDG_POSITIONER_ANCHOR_BOTTOM = 2,
520 XDG_POSITIONER_ANCHOR_LEFT = 3,
521 XDG_POSITIONER_ANCHOR_RIGHT = 4,
522 XDG_POSITIONER_ANCHOR_TOP_LEFT = 5,
523 XDG_POSITIONER_ANCHOR_BOTTOM_LEFT = 6,
524 XDG_POSITIONER_ANCHOR_TOP_RIGHT = 7,
525 XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT = 8,
527 enum xdg_positioner_gravity {
528 XDG_POSITIONER_GRAVITY_NONE = 0,
529 XDG_POSITIONER_GRAVITY_TOP = 1,
530 XDG_POSITIONER_GRAVITY_BOTTOM = 2,
531 XDG_POSITIONER_GRAVITY_LEFT = 3,
532 XDG_POSITIONER_GRAVITY_RIGHT = 4,
533 XDG_POSITIONER_GRAVITY_TOP_LEFT = 5,
534 XDG_POSITIONER_GRAVITY_BOTTOM_LEFT = 6,
535 XDG_POSITIONER_GRAVITY_TOP_RIGHT = 7,
536 XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT = 8,
538 enum xdg_positioner_constraint_adjustment {
539 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE = 0,
540 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X = 1,
541 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y = 2,
542 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X = 4,
543 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y = 8,
544 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X = 16,
545 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32,
548 xdg_positioner_set_user_data(
struct xdg_positioner *xdg_positioner,
void *user_data)
550 wl_proxy_set_user_data((
struct wl_proxy *) xdg_positioner, user_data);
553 xdg_positioner_get_user_data(
struct xdg_positioner *xdg_positioner)
555 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_positioner);
557 static inline uint32_t
558 xdg_positioner_get_version(
struct xdg_positioner *xdg_positioner)
560 return wl_proxy_get_version((
struct wl_proxy *) xdg_positioner);
563 xdg_positioner_destroy(
struct xdg_positioner *xdg_positioner)
565 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
567 wl_proxy_destroy((
struct wl_proxy *) xdg_positioner);
570 xdg_positioner_set_size(
struct xdg_positioner *xdg_positioner, int32_t width, int32_t height)
572 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
576 xdg_positioner_set_anchor_rect(
struct xdg_positioner *xdg_positioner, int32_t x, int32_t y, int32_t width, int32_t height)
578 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
579 2, x, y, width, height);
582 xdg_positioner_set_anchor(
struct xdg_positioner *xdg_positioner, uint32_t anchor)
584 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
588 xdg_positioner_set_gravity(
struct xdg_positioner *xdg_positioner, uint32_t gravity)
590 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
594 xdg_positioner_set_constraint_adjustment(
struct xdg_positioner *xdg_positioner, uint32_t constraint_adjustment)
596 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
597 5, constraint_adjustment);
600 xdg_positioner_set_offset(
struct xdg_positioner *xdg_positioner, int32_t x, int32_t y)
602 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
606 xdg_positioner_set_reactive(
struct xdg_positioner *xdg_positioner)
608 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
612 xdg_positioner_set_parent_size(
struct xdg_positioner *xdg_positioner, int32_t parent_width, int32_t parent_height)
614 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
615 8, parent_width, parent_height);
618 xdg_positioner_set_parent_configure(
struct xdg_positioner *xdg_positioner, uint32_t serial)
620 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
623 enum xdg_surface_error {
624 XDG_SURFACE_ERROR_NOT_CONSTRUCTED = 1,
625 XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED = 2,
626 XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER = 3,
628 struct xdg_surface_listener {
629 void (*configure)(
void *data,
630 struct xdg_surface *xdg_surface,
634 xdg_surface_add_listener(
struct xdg_surface *xdg_surface,
635 const struct xdg_surface_listener *listener,
void *data)
637 return wl_proxy_add_listener((
struct wl_proxy *) xdg_surface,
638 (
void (**)(
void)) listener, data);
641 xdg_surface_set_user_data(
struct xdg_surface *xdg_surface,
void *user_data)
643 wl_proxy_set_user_data((
struct wl_proxy *) xdg_surface, user_data);
646 xdg_surface_get_user_data(
struct xdg_surface *xdg_surface)
648 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_surface);
650 static inline uint32_t
651 xdg_surface_get_version(
struct xdg_surface *xdg_surface)
653 return wl_proxy_get_version((
struct wl_proxy *) xdg_surface);
656 xdg_surface_destroy(
struct xdg_surface *xdg_surface)
658 wl_proxy_marshal((
struct wl_proxy *) xdg_surface,
660 wl_proxy_destroy((
struct wl_proxy *) xdg_surface);
662 static inline struct xdg_toplevel *
663 xdg_surface_get_toplevel(
struct xdg_surface *xdg_surface)
666 id = wl_proxy_marshal_constructor((
struct wl_proxy *) xdg_surface,
667 1, &xdg_toplevel_interface, NULL);
668 return (
struct xdg_toplevel *) id;
670 static inline struct xdg_popup *
671 xdg_surface_get_popup(
struct xdg_surface *xdg_surface,
struct xdg_surface *parent,
struct xdg_positioner *positioner)
674 id = wl_proxy_marshal_constructor((
struct wl_proxy *) xdg_surface,
675 2, &xdg_popup_interface, NULL, parent, positioner);
676 return (
struct xdg_popup *) id;
679 xdg_surface_set_window_geometry(
struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height)
681 wl_proxy_marshal((
struct wl_proxy *) xdg_surface,
682 3, x, y, width, height);
685 xdg_surface_ack_configure(
struct xdg_surface *xdg_surface, uint32_t serial)
687 wl_proxy_marshal((
struct wl_proxy *) xdg_surface,
690 enum xdg_toplevel_resize_edge {
691 XDG_TOPLEVEL_RESIZE_EDGE_NONE = 0,
692 XDG_TOPLEVEL_RESIZE_EDGE_TOP = 1,
693 XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM = 2,
694 XDG_TOPLEVEL_RESIZE_EDGE_LEFT = 4,
695 XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT = 5,
696 XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT = 6,
697 XDG_TOPLEVEL_RESIZE_EDGE_RIGHT = 8,
698 XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT = 9,
699 XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT = 10,
701 enum xdg_toplevel_state {
702 XDG_TOPLEVEL_STATE_MAXIMIZED = 1,
703 XDG_TOPLEVEL_STATE_FULLSCREEN = 2,
704 XDG_TOPLEVEL_STATE_RESIZING = 3,
705 XDG_TOPLEVEL_STATE_ACTIVATED = 4,
706 XDG_TOPLEVEL_STATE_TILED_LEFT = 5,
707 XDG_TOPLEVEL_STATE_TILED_RIGHT = 6,
708 XDG_TOPLEVEL_STATE_TILED_TOP = 7,
709 XDG_TOPLEVEL_STATE_TILED_BOTTOM = 8,
711 struct xdg_toplevel_listener {
712 void (*configure)(
void *data,
713 struct xdg_toplevel *xdg_toplevel,
716 struct wl_array *states);
717 void (*close)(
void *data,
718 struct xdg_toplevel *xdg_toplevel);
721 xdg_toplevel_add_listener(
struct xdg_toplevel *xdg_toplevel,
722 const struct xdg_toplevel_listener *listener,
void *data)
724 return wl_proxy_add_listener((
struct wl_proxy *) xdg_toplevel,
725 (
void (**)(
void)) listener, data);
728 xdg_toplevel_set_user_data(
struct xdg_toplevel *xdg_toplevel,
void *user_data)
730 wl_proxy_set_user_data((
struct wl_proxy *) xdg_toplevel, user_data);
733 xdg_toplevel_get_user_data(
struct xdg_toplevel *xdg_toplevel)
735 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_toplevel);
737 static inline uint32_t
738 xdg_toplevel_get_version(
struct xdg_toplevel *xdg_toplevel)
740 return wl_proxy_get_version((
struct wl_proxy *) xdg_toplevel);
743 xdg_toplevel_destroy(
struct xdg_toplevel *xdg_toplevel)
745 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
747 wl_proxy_destroy((
struct wl_proxy *) xdg_toplevel);
750 xdg_toplevel_set_parent(
struct xdg_toplevel *xdg_toplevel,
struct xdg_toplevel *parent)
752 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
756 xdg_toplevel_set_title(
struct xdg_toplevel *xdg_toplevel,
const char *title)
758 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
762 xdg_toplevel_set_app_id(
struct xdg_toplevel *xdg_toplevel,
const char *app_id)
764 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
768 xdg_toplevel_show_window_menu(
struct xdg_toplevel *xdg_toplevel,
struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
770 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
771 4, seat, serial, x, y);
774 xdg_toplevel_move(
struct xdg_toplevel *xdg_toplevel,
struct wl_seat *seat, uint32_t serial)
776 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
780 xdg_toplevel_resize(
struct xdg_toplevel *xdg_toplevel,
struct wl_seat *seat, uint32_t serial, uint32_t edges)
782 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
783 6, seat, serial, edges);
786 xdg_toplevel_set_max_size(
struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height)
788 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
792 xdg_toplevel_set_min_size(
struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height)
794 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
798 xdg_toplevel_set_maximized(
struct xdg_toplevel *xdg_toplevel)
800 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
804 xdg_toplevel_unset_maximized(
struct xdg_toplevel *xdg_toplevel)
806 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
810 xdg_toplevel_set_fullscreen(
struct xdg_toplevel *xdg_toplevel,
struct wl_output *output)
812 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
816 xdg_toplevel_unset_fullscreen(
struct xdg_toplevel *xdg_toplevel)
818 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
822 xdg_toplevel_set_minimized(
struct xdg_toplevel *xdg_toplevel)
824 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
827 enum xdg_popup_error {
828 XDG_POPUP_ERROR_INVALID_GRAB = 0,
830 struct xdg_popup_listener {
831 void (*configure)(
void *data,
832 struct xdg_popup *xdg_popup,
837 void (*popup_done)(
void *data,
838 struct xdg_popup *xdg_popup);
839 void (*repositioned)(
void *data,
840 struct xdg_popup *xdg_popup,
844 xdg_popup_add_listener(
struct xdg_popup *xdg_popup,
845 const struct xdg_popup_listener *listener,
void *data)
847 return wl_proxy_add_listener((
struct wl_proxy *) xdg_popup,
848 (
void (**)(
void)) listener, data);
851 xdg_popup_set_user_data(
struct xdg_popup *xdg_popup,
void *user_data)
853 wl_proxy_set_user_data((
struct wl_proxy *) xdg_popup, user_data);
856 xdg_popup_get_user_data(
struct xdg_popup *xdg_popup)
858 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_popup);
860 static inline uint32_t
861 xdg_popup_get_version(
struct xdg_popup *xdg_popup)
863 return wl_proxy_get_version((
struct wl_proxy *) xdg_popup);
866 xdg_popup_destroy(
struct xdg_popup *xdg_popup)
868 wl_proxy_marshal((
struct wl_proxy *) xdg_popup,
870 wl_proxy_destroy((
struct wl_proxy *) xdg_popup);
873 xdg_popup_grab(
struct xdg_popup *xdg_popup,
struct wl_seat *seat, uint32_t serial)
875 wl_proxy_marshal((
struct wl_proxy *) xdg_popup,
879 xdg_popup_reposition(
struct xdg_popup *xdg_popup,
struct xdg_positioner *positioner, uint32_t token)
881 wl_proxy_marshal((
struct wl_proxy *) xdg_popup,
882 2, positioner, token);
884 extern const struct wl_interface wl_output_interface;
885 extern const struct wl_interface wl_seat_interface;
886 extern const struct wl_interface wl_surface_interface;
887 extern const struct wl_interface xdg_popup_interface;
888 extern const struct wl_interface xdg_positioner_interface;
889 extern const struct wl_interface xdg_surface_interface;
890 extern const struct wl_interface xdg_toplevel_interface;
891 static const struct wl_interface *xdg_shell_types[] = {
896 &xdg_positioner_interface,
897 &xdg_surface_interface,
898 &wl_surface_interface,
899 &xdg_toplevel_interface,
900 &xdg_popup_interface,
901 &xdg_surface_interface,
902 &xdg_positioner_interface,
903 &xdg_toplevel_interface,
913 &wl_output_interface,
916 &xdg_positioner_interface,
919 static const struct wl_message xdg_wm_base_requests[] = {
920 {
"destroy",
"", xdg_shell_types + 0 },
921 {
"create_positioner",
"n", xdg_shell_types + 4 },
922 {
"get_xdg_surface",
"no", xdg_shell_types + 5 },
923 {
"pong",
"u", xdg_shell_types + 0 },
925 static const struct wl_message xdg_wm_base_events[] = {
926 {
"ping",
"u", xdg_shell_types + 0 },
928 const struct wl_interface xdg_wm_base_interface = {
930 4, xdg_wm_base_requests,
931 1, xdg_wm_base_events,
933 static const struct wl_message xdg_positioner_requests[] = {
934 {
"destroy",
"", xdg_shell_types + 0 },
935 {
"set_size",
"ii", xdg_shell_types + 0 },
936 {
"set_anchor_rect",
"iiii", xdg_shell_types + 0 },
937 {
"set_anchor",
"u", xdg_shell_types + 0 },
938 {
"set_gravity",
"u", xdg_shell_types + 0 },
939 {
"set_constraint_adjustment",
"u", xdg_shell_types + 0 },
940 {
"set_offset",
"ii", xdg_shell_types + 0 },
941 {
"set_reactive",
"3", xdg_shell_types + 0 },
942 {
"set_parent_size",
"3ii", xdg_shell_types + 0 },
943 {
"set_parent_configure",
"3u", xdg_shell_types + 0 },
945 const struct wl_interface xdg_positioner_interface = {
947 10, xdg_positioner_requests,
950 static const struct wl_message xdg_surface_requests[] = {
951 {
"destroy",
"", xdg_shell_types + 0 },
952 {
"get_toplevel",
"n", xdg_shell_types + 7 },
953 {
"get_popup",
"n?oo", xdg_shell_types + 8 },
954 {
"set_window_geometry",
"iiii", xdg_shell_types + 0 },
955 {
"ack_configure",
"u", xdg_shell_types + 0 },
957 static const struct wl_message xdg_surface_events[] = {
958 {
"configure",
"u", xdg_shell_types + 0 },
960 const struct wl_interface xdg_surface_interface = {
962 5, xdg_surface_requests,
963 1, xdg_surface_events,
965 static const struct wl_message xdg_toplevel_requests[] = {
966 {
"destroy",
"", xdg_shell_types + 0 },
967 {
"set_parent",
"?o", xdg_shell_types + 11 },
968 {
"set_title",
"s", xdg_shell_types + 0 },
969 {
"set_app_id",
"s", xdg_shell_types + 0 },
970 {
"show_window_menu",
"ouii", xdg_shell_types + 12 },
971 {
"move",
"ou", xdg_shell_types + 16 },
972 {
"resize",
"ouu", xdg_shell_types + 18 },
973 {
"set_max_size",
"ii", xdg_shell_types + 0 },
974 {
"set_min_size",
"ii", xdg_shell_types + 0 },
975 {
"set_maximized",
"", xdg_shell_types + 0 },
976 {
"unset_maximized",
"", xdg_shell_types + 0 },
977 {
"set_fullscreen",
"?o", xdg_shell_types + 21 },
978 {
"unset_fullscreen",
"", xdg_shell_types + 0 },
979 {
"set_minimized",
"", xdg_shell_types + 0 },
981 static const struct wl_message xdg_toplevel_events[] = {
982 {
"configure",
"iia", xdg_shell_types + 0 },
983 {
"close",
"", xdg_shell_types + 0 },
985 const struct wl_interface xdg_toplevel_interface = {
987 14, xdg_toplevel_requests,
988 2, xdg_toplevel_events,
990 static const struct wl_message xdg_popup_requests[] = {
991 {
"destroy",
"", xdg_shell_types + 0 },
992 {
"grab",
"ou", xdg_shell_types + 22 },
993 {
"reposition",
"3ou", xdg_shell_types + 24 },
995 static const struct wl_message xdg_popup_events[] = {
996 {
"configure",
"iiii", xdg_shell_types + 0 },
997 {
"popup_done",
"", xdg_shell_types + 0 },
998 {
"repositioned",
"3u", xdg_shell_types + 0 },
1000 const struct wl_interface xdg_popup_interface = {
1002 3, xdg_popup_requests,
1003 3, xdg_popup_events,
1019 #define X(name_, val_, mesg_) \
1020 static constexpr int name_ = val_;
1021 ZAKERO_YETANI__ERROR_DATA
1119 struct PointerButton
1158 static
Yetani*
connect(const std::
string&, std::error_code&) noexcept;
1166 wl_shm_format format = WL_SHM_FORMAT_ARGB8888;
1167 int32_t hotspot_x = 0;
1168 int32_t hotspot_y = 0;
1169 std::chrono::milliseconds time_per_frame = std::chrono::milliseconds(0);
1170 const std::vector<void*>& image_data;
1189 std::string make =
"";
1190 std::string model =
"";
1195 int32_t physical_width_mm = 0;
1196 int32_t physical_height_mm = 0;
1197 int32_t subpixel = 0;
1198 int32_t refresh_mHz = 0;
1199 int32_t scale_factor = 0;
1200 int32_t transform = 0;
1202 float pixels_per_mm_horizontal = 0.0;
1203 float pixels_per_mm_vertical = 0.0;
1208 using OutputId = uint32_t;
1210 using LambdaOutputId = std::function<void(
const Yetani::OutputId)>;
1212 using VectorOutputId = std::vector<OutputId>;
1259 using VectorShmFormat = std::vector<wl_shm_format>;
1266 static std::
string shmFormatName(const wl_shm_format) noexcept;
1284 using Lambda = std::function<void()>;
1293 using LambdaBool = std::function<void(
bool)>;
1337 uint32_t
time() const noexcept;
1355 std::error_code
cursorUse(const std::
string&) noexcept;
1398 struct wl_shm_pool* wl_shm_pool;
1404 struct wl_buffer* wl_buffer;
1405 struct wl_surface* wl_surface;
1406 struct xdg_surface* xdg_surface;
1407 struct xdg_toplevel* xdg_toplevel;
1408 struct zxdg_toplevel_decoration_v1* xdg_decoration;
1410 wl_shm_format pixel_format;
1432 static constexpr uint32_t Size_Max = (uint32_t)std::numeric_limits<int32_t>::max();
1438 using VectorWlSurface = std::vector<struct wl_surface*>;
1443 void disconnect() noexcept;
1450 struct wl_surface* wl_surface;
1451 std::vector<::wl_buffer*> buffer_vector;
1452 wl_shm_format format;
1453 int64_t next_frame_time;
1454 size_t buffer_index;
1455 uint32_t time_per_frame;
1462 using MapStringCursor = std::unordered_map<std::string, Yetani::Cursor>;
1464 MapStringCursor cursor_map;
1468 struct CursorSurface
1470 struct wl_pointer* wl_pointer;
1471 struct wl_surface* wl_surface;
1478 using MapCursorSurface = std::unordered_map<struct wl_surface*, Yetani::CursorSurface>;
1480 MapCursorSurface cursor_surface_map;
1485 mutable std::mutex cursor_mutex;
1486 struct wl_shm_pool* cursor_shm_pool;
1487 struct wl_pointer* cursor_pointer;
1491 void cursorAnimate() noexcept;
1492 std::error_code cursorCreateCursor(const std::
string&, const Yetani::CursorConfig&) noexcept;
1493 void cursorEnter(struct wl_pointer*, uint32_t, struct wl_surface*) noexcept;
1494 void cursorLeave(struct wl_surface*) noexcept;
1495 void cursorHide(struct wl_surface*) noexcept;
1496 void cursorShow(struct wl_surface*) noexcept;
1497 bool cursorIsHidden(struct wl_surface*) const noexcept;
1498 void cursorSetup() noexcept;
1499 void cursorTeardown() noexcept;
1500 std::error_code cursorAttach(const std::
string&, struct wl_surface*) noexcept;
1501 std::error_code cursorDetach(struct wl_surface*) noexcept;
1506 std::jthread event_loop;
1507 std::atomic<
bool> event_loop_is_running;
1511 void eventLoopStart() noexcept;
1512 static
void eventLoop(std::stop_token, Yetani*) noexcept;
1517 struct wl_compositor* compositor;
1518 struct wl_display* display;
1519 struct wl_registry* registry;
1521 Yetani::VectorShmFormat shm_format_vector;
1528 struct wl_keyboard* wl_keyboard =
nullptr;
1529 struct wl_pointer* wl_pointer =
nullptr;
1530 struct wl_touch* wl_touch =
nullptr;
1531 std::string name =
"";
1532 uint32_t version = 0;
1535 using MapSeat = std::map<struct wl_seat*, Seat>;
1536 using MapIdWlSeat = std::map<uint32_t, struct wl_seat*>;
1538 Yetani::MapSeat seat_map;
1539 Yetani::MapIdWlSeat id_to_seat;
1543 struct wl_seat* seat;
1547 void seatDestroy(
struct wl_seat*&) noexcept;
1552 struct KeyRepeatData
1554 std::chrono::time_point<std::chrono::steady_clock> trigger_time;
1558 using KeyRepeatMap = std::map<uint32_t, Yetani::KeyRepeatData>;
1562 struct KeyboardEvent
1569 using MapKeyboardEvent = std::unordered_map<struct wl_surface*, Yetani::KeyboardEvent>;
1575 struct wl_surface* wl_surface =
nullptr;
1576 Yetani::KeyboardEvent*
event =
nullptr;
1577 Yetani::MapKeyboardEvent event_map = {};
1578 Yetani::KeyModifier modifier = { 0 };
1579 Yetani::KeyRepeatMap repeat_map = {};
1580 char* keymap =
nullptr;
1581 uint32_t keymap_size = 0;
1582 int32_t repeat_delay = 0;
1583 int32_t repeat_rate = 0;
1586 Yetani::Keyboard keyboard;
1590 static void keyboardDestroy(Yetani::Keyboard&) noexcept;
1591 static void keyboardRepeat(Yetani::Keyboard&) noexcept;
1592 static void keyboardRepeatAdd(Yetani::Keyboard&, uint32_t, uint32_t) noexcept;
1593 static void keyboardRepeatReleaseAll(Yetani::Keyboard&) noexcept;
1594 static void keyboardRepeatRemove(Yetani::Keyboard&, uint32_t) noexcept;
1617 using MapPointerEvent = std::unordered_map<struct wl_surface*, Yetani::PointerEvent>;
1624 Yetani* yetani =
nullptr;
1625 struct wl_surface* wl_surface =
nullptr;
1626 struct wl_pointer* wl_pointer =
nullptr;
1627 Yetani::PointerEvent*
event =
nullptr;
1628 Yetani::MapPointerEvent event_map = {};
1631 Yetani::PointMm point_mm = {};
1632 Yetani::PointPercent point_percent = {};
1633 Yetani::PointPixel point_pixel = {};
1636 Yetani::PointerAxis axis = {};
1639 Yetani::PointerButton button = {};
1640 uint32_t button_event_code = 0;
1641 bool button_is_pressed =
false;
1642 uint32_t button_time = {};
1645 struct wl_surface* enter_surface =
nullptr;
1646 Yetani::PointPixel enter_point = {};
1647 uint32_t enter_serial = 0;
1650 struct wl_surface* leave_surface =
nullptr;
1653 Yetani::PointPixel motion_point = {};
1656 Yetani::Pointer pointer;
1660 static void pointerClear(
struct Pointer&) noexcept;
1665 enum struct OutputState
1673 using VectorWlOutput = std::vector<struct wl_output*>;
1675 using MapWlOutputOutputState = std::unordered_map<struct wl_output*, Yetani::OutputState>;
1676 using MapOutputIdWlOutput = std::unordered_map<Yetani::OutputId, struct wl_output*>;
1677 using MapWlOutputOutputId = std::unordered_map<struct wl_output*, Yetani::OutputId>;
1678 using MapWlSurfaceVectorWlOutput = std::unordered_map<struct wl_surface*, Yetani::VectorWlOutput>;
1679 using MapWlOutputOutput = std::unordered_map<struct wl_output*, Output>;
1685 Yetani::MapWlSurfaceVectorWlOutput surface_output_map = {};
1686 Yetani::MapOutputIdWlOutput outputid_to_wloutput = {};
1687 Yetani::MapWlOutputOutput output_map = {};
1688 Yetani::MapWlOutputOutputId wloutput_to_outputid = {};
1689 mutable std::mutex mutex = {};
1692 Yetani::OutputData output_data;
1696 Yetani::LambdaOutputId on_output_add;
1697 Yetani::LambdaOutputId on_output_change;
1698 Yetani::LambdaOutputId on_output_remove;
1700 Yetani::MapWlOutputOutput output_changes_map;
1701 Yetani::MapWlOutputOutputState output_state_map;
1703 Yetani::VectorWlSurface output_notify_surface_vector;
1707 void convertPixel(
struct wl_surface*,
const int32_t,
const int32_t,
float&,
float&,
float&,
float&)
const noexcept;
1709 std::pair<float, float> convertPixelToMm(
const Yetani::Output&, int32_t, int32_t)
const noexcept;
1710 std::pair<float, float> convertPixelToPercent(
const Yetani::Output&, int32_t, int32_t)
const noexcept;
1711 std::pair<int32_t, int32_t> convertMmToPixel(
const Yetani::Output&,
float,
float)
const noexcept;
1712 std::pair<int32_t, int32_t> convertPercentToPixel(
const Yetani::Output&,
float,
float)
const noexcept;
1714 static void outputNotifySurface(Yetani*,
struct wl_output*,
struct wl_surface*) noexcept;
1723 MemoryPool* memory_pool;
1727 using MapBufferData = std::unordered_map<struct wl_buffer*, BufferData>;
1741 static wl_buffer* bufferCreate(Yetani::SurfaceSize&, Yetani::Window::Memory*, Yetani::Buffer*) noexcept;
1742 static wl_buffer* bufferCreateAndRelease(Yetani*, Yetani::SurfaceSize&, Yetani::Window::Memory*) noexcept;
1743 static void bufferDestroy(
struct wl_buffer*&) noexcept;
1755 using MapSurfaceEvent = std::map<struct wl_surface*, Yetani::SurfaceEvent>;
1757 MapSurfaceEvent surface_event_map;
1761 enum struct SizeUnit
1769 struct SurfaceExtent
1771 Yetani::SizeUnit preferred_unit;
1772 Yetani::SizeMm preferred_mm;
1773 Yetani::SizePercent preferred_percent;
1774 Yetani::SizeMm size_mm;
1775 Yetani::SizePercent size_percent;
1776 Yetani::SizePixel size_pixel;
1777 Yetani::SizePixel size_pixel_max;
1778 Yetani::SizePixel size_pixel_min;
1781 using MapSurfaceExtent = std::unordered_map<struct wl_surface*, Yetani::SurfaceExtent>;
1783 MapSurfaceExtent surface_extent_map;
1784 std::mutex surface_extent_mutex;
1790 struct wl_callback* callback;
1791 struct wl_surface* wl_surface;
1792 std::atomic<wl_buffer*> buffer_next;
1798 using MapSurfaceFrame = std::unordered_map<struct wl_surface*, Yetani::SurfaceFrame>;
1800 MapSurfaceFrame surface_frame_map;
1810 wl_shm_format pixel_format;
1811 uint8_t bytes_per_pixel;
1814 using MapSurfaceSize = std::unordered_map<struct wl_surface*, Yetani::SurfaceSize>;
1816 MapSurfaceSize surface_size_map;
1820 using MapSurfaceResizeMutex = std::unordered_map<struct wl_surface*, std::mutex>;
1822 MapSurfaceResizeMutex surface_resize_mutex_map;
1826 static void surfaceCalculateSize(Yetani*,
struct wl_surface*,
const Yetani::SizePixel&) noexcept;
1827 static struct wl_surface* surfaceCreate(Yetani*,
const wl_shm_format,
const Yetani::SizePixel&,
const bool, Yetani::Window::Memory&) noexcept;
1828 static void surfaceDestroy(Yetani*,
struct wl_surface*&) noexcept;
1836 struct wl_shm* wl_shm;
1837 struct wl_output* wl_output;
1838 std::string file_name;
1839 Yetani::SizeMm size_mm;
1840 Yetani::SizePercent size_percent;
1841 Yetani::SizePixel size_pixel;
1842 Yetani::SizeUnit size_unit;
1843 wl_shm_format pixel_format;
1844 std::error_code error;
1849 Yetani::Window*
windowCreate(
const Yetani::SizeUnit,
const Yetani::SizeMm&,
const Yetani::SizePercent&,
const Yetani::SizePixel&,
const wl_shm_format, std::error_code&) noexcept;
1850 void windowDataInit(Yetani::WindowData&) noexcept;
1851 void windowDataInitOutput(Yetani::WindowData&) noexcept;
1852 void windowInitMemory(Yetani::WindowData&, Yetani::Window::Memory&) noexcept;
1853 void windowInitOutput(Yetani::WindowData&,
struct wl_surface*) noexcept;
1854 void windowEraseMemory(Yetani::Window::Memory&) noexcept;
1855 void windowEraseOutput(
struct wl_surface*) noexcept;
1856 void windowEraseSurfaceExtent(
struct wl_surface*) noexcept;
1861 std::vector<Yetani::Window*> window_vector;
1862 std::mutex window_vector_mutex;
1866 void windowAdd(Yetani::Window*) noexcept;
1867 void windowRemove(Yetani::Window*) noexcept;
1872 enum XdgState : int32_t
1874 , Toplevel_Active = 1
1875 , Toplevel_Attach_Buffer = 2
1876 , Toplevel_Resizing = 3
1877 , Toplevel_Window_Fullscreen = 4
1878 , Toplevel_Window_Maximized = 5
1879 , Toplevel_Window_Normal = 6
1880 , Toplevel_Decoration = 7
1883 using VectorXdgStateChange = std::vector<int32_t>;
1884 using MapXdgStateChange = std::unordered_map<struct xdg_surface*, Yetani::VectorXdgStateChange>;
1886 Yetani::MapXdgStateChange xdg_state_change_map;
1887 std::mutex xdg_state_change_mutex;
1891 struct xdg_wm_base* xdg_wm_base;
1903 Yetani* yetani =
nullptr;
1904 struct wl_surface* wl_surface =
nullptr;
1907 using MapXdgSurface = std::unordered_map<struct wl_surface*, Yetani::XdgSurface>;
1909 Yetani::MapXdgSurface xdg_surface_map;
1913 struct xdg_surface* xdgSurfaceCreate(
struct wl_surface*) noexcept;
1914 void xdgSurfaceDestroy(
struct wl_surface*,
struct xdg_surface*&) noexcept;
1915 void xdgSurfaceSetExtent(
struct wl_surface*,
const Yetani::SizeUnit&,
const Yetani::SizeMm&,
const Yetani::SizePercent&,
const Yetani::SizePixel&) noexcept;
1922 Yetani::VectorXdgStateChange* state_change;
1926 Yetani::XdgState window_state;
1928 Yetani::SizePixel previous_size;
1929 struct xdg_toplevel* xdg_toplevel;
1932 using MapXdgToplevel = std::unordered_map<struct xdg_surface*, Yetani::XdgToplevel>;
1934 MapXdgToplevel xdg_toplevel_map;
1938 struct xdg_toplevel* xdgToplevelCreate(
struct xdg_surface*) noexcept;
1939 void xdgToplevelDestroy(
struct xdg_surface*,
struct xdg_toplevel*&) noexcept;
1940 static void xdgToplevelSizeChange(Yetani*,
struct wl_surface*,
const Yetani::SizePixel&) noexcept;
1941 static void xdgToplevelSizeMinMaxChange(Yetani*,
struct xdg_toplevel*,
struct wl_surface*,
const Yetani::SizePixel&,
const Yetani::SizePixel&) noexcept;
1942 static void xdgToplevelWindowChange(Yetani*,
struct wl_surface*, Yetani::XdgToplevel&,
const Yetani::XdgState,
const Yetani::SizePixel&) noexcept;
1947 struct XdgDecoration
1949 Yetani::VectorXdgStateChange* state_change;
1956 using MapXdgDecoration = std::unordered_map<struct xdg_surface*, Yetani::XdgDecoration>;
1958 MapXdgDecoration xdg_decoration_map;
1962 struct zxdg_decoration_manager_v1* decoration_manager;
1966 struct zxdg_toplevel_decoration_v1* xdgDecorationCreate(
struct xdg_surface*,
struct xdg_toplevel*) noexcept;
1967 void xdgDecorationDestroy(
struct xdg_surface*,
struct xdg_toplevel*,
struct zxdg_toplevel_decoration_v1*&) noexcept;
1968 static void xdgDecorationChange(Yetani::XdgDecoration&,
const uint32_t) noexcept;
1973 static struct wl_buffer_listener buffer_listener;
1974 static struct wl_callback_listener frame_callback_listener;
1975 static struct wl_keyboard_listener keyboard_listener;
1976 static struct wl_output_listener output_listener;
1977 static struct wl_pointer_listener pointer_listener;
1978 static struct wl_registry_listener registry_listener;
1979 static struct wl_seat_listener seat_listener;
1980 static struct wl_shm_listener shm_listener;
1981 static struct wl_surface_listener surface_listener;
1985 static void handlerBufferRelease(
void*,
struct wl_buffer*) noexcept;
1987 static void handlerKeyboardEnter(
void*,
struct wl_keyboard*, uint32_t,
struct wl_surface*,
struct wl_array*) noexcept;
1988 static void handlerKeyboardKey(
void*,
struct wl_keyboard*, uint32_t, uint32_t, uint32_t, uint32_t) noexcept;
1989 static void handlerKeyboardKeymap(
void*,
struct wl_keyboard*, uint32_t, int32_t, uint32_t) noexcept;
1990 static void handlerKeyboardLeave(
void*,
struct wl_keyboard*, uint32_t,
struct wl_surface*) noexcept;
1991 static void handlerKeyboardModifiers(
void*,
struct wl_keyboard*, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t) noexcept;
1992 static void handlerKeyboardRepeatInfo(
void*,
struct wl_keyboard*, int32_t, int32_t) noexcept;
1994 static void handlerOutputDone(
void*,
struct wl_output*) noexcept;
1995 static void handlerOutputGeometry(
void*,
struct wl_output*, int32_t, int32_t, int32_t, int32_t, int32_t,
const char*,
const char*, int32_t) noexcept;
1996 static void handlerOutputMode(
void*,
struct wl_output*, uint32_t, int32_t, int32_t, int32_t) noexcept;
1997 static void handlerOutputScale(
void*,
struct wl_output*, int32_t) noexcept;
1998 static void handlerPointerAxis(
void*,
struct wl_pointer*, uint32_t, uint32_t, wl_fixed_t) noexcept;
1999 static void handlerPointerAxisDiscrete(
void*,
struct wl_pointer*, uint32_t, int32_t) noexcept;
2000 static void handlerPointerAxisSource(
void*,
struct wl_pointer*, uint32_t) noexcept;
2001 static void handlerPointerAxisStop(
void*,
struct wl_pointer*, uint32_t, uint32_t) noexcept;
2002 static void handlerPointerButton(
void*,
struct wl_pointer*, uint32_t, uint32_t, uint32_t, uint32_t) noexcept;
2003 static void handlerPointerEnter(
void*,
struct wl_pointer*, uint32_t,
struct wl_surface*, wl_fixed_t, wl_fixed_t) noexcept;
2004 static void handlerPointerFrame(
void*,
struct wl_pointer*) noexcept;
2005 static void handlerPointerLeave(
void*,
struct wl_pointer*, uint32_t,
struct wl_surface*) noexcept;
2006 static void handlerPointerMotion(
void*,
struct wl_pointer*, uint32_t, wl_fixed_t, wl_fixed_t) noexcept;
2007 static void handlerRegistryGlobal(
void*,
struct wl_registry*, uint32_t,
const char*, uint32_t) noexcept;
2008 static void handlerRegistryRemove(
void*,
struct wl_registry*, uint32_t) noexcept;
2009 static void handlerSeatCapabilities(
void*,
struct wl_seat*, uint32_t) noexcept;
2010 static void handlerSeatName(
void*,
struct wl_seat*,
const char*) noexcept;
2011 static void handlerShmFormat(
void*,
struct wl_shm*, uint32_t) noexcept;
2012 static void handlerSurfaceEnter(
void*,
struct wl_surface*,
struct wl_output*) noexcept;
2013 static void handlerSurfaceLeave(
void*,
struct wl_surface*,
struct wl_output*) noexcept;
2014 static void handlerSwapBuffers(
void*,
struct wl_callback*, uint32_t) noexcept;
2021 static struct xdg_wm_base_listener xdg_wm_base_listener;
2022 static struct xdg_surface_listener xdg_surface_listener;
2023 static struct xdg_toplevel_listener xdg_toplevel_listener;
2027 static void handlerXdgSurfaceConfigure(
void*,
struct xdg_surface*, uint32_t) noexcept;
2028 static void handlerXdgToplevelClose(
void*,
struct xdg_toplevel*) noexcept;
2029 static void handlerXdgToplevelConfigure(
void*,
struct xdg_toplevel*, int32_t, int32_t,
struct wl_array*) noexcept;
2030 static void handlerXdgWmBasePing(
void*,
struct xdg_wm_base*, uint32_t) noexcept;
2035 static struct zxdg_toplevel_decoration_v1_listener xdg_toplevel_decoration_listener;
2039 static void handlerXdgToplevelDecorationConfigure(
void*,
struct zxdg_toplevel_decoration_v1*, uint32_t mode) noexcept;
2047 std::string
to_string(
const wl_shm_format) noexcept;
2048 std::string
to_string(
const std::error_code&) noexcept;
2049 std::string
to_string(
const Yetani::KeyModifier&) noexcept;
2051 std::string
to_string(
const Yetani::Output&) noexcept;
2062 #ifdef ZAKERO_YETANI_IMPLEMENTATION
2068 #ifdef ZAKERO__DOXYGEN_DEFINE_DOCS
2083 #define ZAKERO_YETANI_IMPLEMENTATION
2093 #define ZAKERO_YETANI_ENABLE_DEBUG
2103 #define ZAKERO_YETANI_ENABLE_SAFE_MODE
2105 #endif // ZAKERO__DOXYGEN_DEFINE_DOCS
2124 #ifdef ZAKERO_YETANI_ENABLE_DEBUG
2125 #define ZAKERO_YETANI__DEBUG_DISABLED false
2127 #define ZAKERO_YETANI__DEBUG_DISABLED true
2143 #ifndef ZAKERO_YETANI_ENABLE_DEBUG_STREAM
2144 #define ZAKERO_YETANI_ENABLE_DEBUG_STREAM std::cerr
2165 #define ZAKERO_YETANI__DEBUG \
2166 if(ZAKERO_YETANI__DEBUG_DISABLED) {} \
2167 else ZAKERO_YETANI_ENABLE_DEBUG_STREAM \
2169 << std::to_string(__LINE__) \
2171 << __PRETTY_FUNCTION__ \
2190 #define ZAKERO_YETANI__DEBUG_VAR(var_) \
2191 ZAKERO_YETANI__DEBUG \
2192 << #var_ << ": " << var_ \
2210 #define ZAKERO_YETANI__DEBUG_BOOL(var_) \
2211 ZAKERO_YETANI__DEBUG \
2212 << #var_ << ": " << std::boolalpha << var_ \
2225 #define ZAKERO_YETANI__ERROR(err_) std::error_code(err_, YetaniErrorCategory)
2244 #define ZAKERO_YETANI__SHM_FORMAT \
2245 X(WL_SHM_FORMAT_ARGB8888 , 4 , "32-bit ARGB format, [31:0] A:R:G:B 8:8:8:8 little endian" ) \
2246 X(WL_SHM_FORMAT_XRGB8888 , 4 , "32-bit RGB format, [31:0] x:R:G:B 8:8:8:8 little endian" ) \
2247 X(WL_SHM_FORMAT_C8 , 1 , "8-bit color index format, [7:0] C" ) \
2248 X(WL_SHM_FORMAT_RGB332 , 1 , "8-bit RGB format, [7:0] R:G:B 3:3:2" ) \
2249 X(WL_SHM_FORMAT_BGR233 , 1 , "8-bit BGR format, [7:0] B:G:R 2:3:3" ) \
2250 X(WL_SHM_FORMAT_XRGB4444 , 2 , "16-bit xRGB format, [15:0] x:R:G:B 4:4:4:4 little endian" ) \
2251 X(WL_SHM_FORMAT_XBGR4444 , 2 , "16-bit xBGR format, [15:0] x:B:G:R 4:4:4:4 little endian" ) \
2252 X(WL_SHM_FORMAT_RGBX4444 , 2 , "16-bit RGBx format, [15:0] R:G:B:x 4:4:4:4 little endian" ) \
2253 X(WL_SHM_FORMAT_BGRX4444 , 2 , "16-bit BGRx format, [15:0] B:G:R:x 4:4:4:4 little endian" ) \
2254 X(WL_SHM_FORMAT_ARGB4444 , 2 , "16-bit ARGB format, [15:0] A:R:G:B 4:4:4:4 little endian" ) \
2255 X(WL_SHM_FORMAT_ABGR4444 , 2 , "16-bit ABGR format, [15:0] A:B:G:R 4:4:4:4 little endian" ) \
2256 X(WL_SHM_FORMAT_RGBA4444 , 2 , "16-bit RBGA format, [15:0] R:G:B:A 4:4:4:4 little endian" ) \
2257 X(WL_SHM_FORMAT_BGRA4444 , 2 , "16-bit BGRA format, [15:0] B:G:R:A 4:4:4:4 little endian" ) \
2258 X(WL_SHM_FORMAT_XRGB1555 , 2 , "16-bit xRGB format, [15:0] x:R:G:B 1:5:5:5 little endian" ) \
2259 X(WL_SHM_FORMAT_XBGR1555 , 2 , "16-bit xBGR 1555 format, [15:0] x:B:G:R 1:5:5:5 little endian" ) \
2260 X(WL_SHM_FORMAT_RGBX5551 , 2 , "16-bit RGBx 5551 format, [15:0] R:G:B:x 5:5:5:1 little endian" ) \
2261 X(WL_SHM_FORMAT_BGRX5551 , 2 , "16-bit BGRx 5551 format, [15:0] B:G:R:x 5:5:5:1 little endian" ) \
2262 X(WL_SHM_FORMAT_ARGB1555 , 2 , "16-bit ARGB 1555 format, [15:0] A:R:G:B 1:5:5:5 little endian" ) \
2263 X(WL_SHM_FORMAT_ABGR1555 , 2 , "16-bit ABGR 1555 format, [15:0] A:B:G:R 1:5:5:5 little endian" ) \
2264 X(WL_SHM_FORMAT_RGBA5551 , 2 , "16-bit RGBA 5551 format, [15:0] R:G:B:A 5:5:5:1 little endian" ) \
2265 X(WL_SHM_FORMAT_BGRA5551 , 2 , "16-bit BGRA 5551 format, [15:0] B:G:R:A 5:5:5:1 little endian" ) \
2266 X(WL_SHM_FORMAT_RGB565 , 2 , "16-bit RGB 565 format, [15:0] R:G:B 5:6:5 little endian" ) \
2267 X(WL_SHM_FORMAT_BGR565 , 2 , "16-bit BGR 565 format, [15:0] B:G:R 5:6:5 little endian" ) \
2268 X(WL_SHM_FORMAT_RGB888 , 3 , "24-bit RGB format, [23:0] R:G:B little endian" ) \
2269 X(WL_SHM_FORMAT_BGR888 , 3 , "24-bit BGR format, [23:0] B:G:R little endian" ) \
2270 X(WL_SHM_FORMAT_XBGR8888 , 4 , "32-bit xBGR format, [31:0] x:B:G:R 8:8:8:8 little endian" ) \
2271 X(WL_SHM_FORMAT_RGBX8888 , 4 , "32-bit RGBx format, [31:0] R:G:B:x 8:8:8:8 little endian" ) \
2272 X(WL_SHM_FORMAT_BGRX8888 , 4 , "32-bit BGRx format, [31:0] B:G:R:x 8:8:8:8 little endian" ) \
2273 X(WL_SHM_FORMAT_ABGR8888 , 4 , "32-bit ABGR format, [31:0] A:B:G:R 8:8:8:8 little endian" ) \
2274 X(WL_SHM_FORMAT_RGBA8888 , 4 , "32-bit RGBA format, [31:0] R:G:B:A 8:8:8:8 little endian" ) \
2275 X(WL_SHM_FORMAT_BGRA8888 , 4 , "32-bit BGRA format, [31:0] B:G:R:A 8:8:8:8 little endian" ) \
2276 X(WL_SHM_FORMAT_XRGB2101010 , 4 , "32-bit xRGB format, [31:0] x:R:G:B 2:10:10:10 little endian" ) \
2277 X(WL_SHM_FORMAT_XBGR2101010 , 4 , "32-bit xBGR format, [31:0] x:B:G:R 2:10:10:10 little endian" ) \
2278 X(WL_SHM_FORMAT_RGBX1010102 , 4 , "32-bit RGBx format, [31:0] R:G:B:x 10:10:10:2 little endian" ) \
2279 X(WL_SHM_FORMAT_BGRX1010102 , 4 , "32-bit BGRx format, [31:0] B:G:R:x 10:10:10:2 little endian" ) \
2280 X(WL_SHM_FORMAT_ARGB2101010 , 4 , "32-bit ARGB format, [31:0] A:R:G:B 2:10:10:10 little endian" ) \
2281 X(WL_SHM_FORMAT_ABGR2101010 , 4 , "32-bit ABGR format, [31:0] A:B:G:R 2:10:10:10 little endian" ) \
2282 X(WL_SHM_FORMAT_RGBA1010102 , 4 , "32-bit RGBA format, [31:0] R:G:B:A 10:10:10:2 little endian" ) \
2283 X(WL_SHM_FORMAT_BGRA1010102 , 4 , "32-bit BGRA format, [31:0] B:G:R:A 10:10:10:2 little endian" ) \
2284 X(WL_SHM_FORMAT_YUYV , 4 , "packed YCbCr format, [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian" ) \
2285 X(WL_SHM_FORMAT_YVYU , 4 , "packed YCbCr format, [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian" ) \
2286 X(WL_SHM_FORMAT_UYVY , 4 , "packed YCbCr format, [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian" ) \
2287 X(WL_SHM_FORMAT_VYUY , 4 , "packed YCbCr format, [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian" ) \
2288 X(WL_SHM_FORMAT_AYUV , 4 , "packed AYCbCr format, [31:0] A:Y:Cb:Cr 8:8:8:8 little endian" ) \
2289 X(WL_SHM_FORMAT_NV12 , 8 , "2 plane YCbCr Cr:Cb format, 2x2 subsampled Cr:Cb plane" ) \
2290 X(WL_SHM_FORMAT_NV21 , 8 , "2 plane YCbCr Cb:Cr format, 2x2 subsampled Cb:Cr plane" ) \
2291 X(WL_SHM_FORMAT_NV16 , 8 , "2 plane YCbCr Cr:Cb format, 2x1 subsampled Cr:Cb plane" ) \
2292 X(WL_SHM_FORMAT_NV61 , 8 , "2 plane YCbCr Cb:Cr format, 2x1 subsampled Cb:Cr plane" ) \
2293 X(WL_SHM_FORMAT_YUV410 , 8 , "3 plane YCbCr format, 4x4 subsampled Cb (1) and Cr (2) planes" ) \
2294 X(WL_SHM_FORMAT_YVU410 , 8 , "3 plane YCbCr format, 4x4 subsampled Cr (1) and Cb (2) planes" ) \
2295 X(WL_SHM_FORMAT_YUV411 , 8 , "3 plane YCbCr format, 4x1 subsampled Cb (1) and Cr (2) planes" ) \
2296 X(WL_SHM_FORMAT_YVU411 , 8 , "3 plane YCbCr format, 4x1 subsampled Cr (1) and Cb (2) planes" ) \
2297 X(WL_SHM_FORMAT_YUV420 , 8 , "3 plane YCbCr format, 2x2 subsampled Cb (1) and Cr (2) planes" ) \
2298 X(WL_SHM_FORMAT_YVU420 , 8 , "3 plane YCbCr format, 2x2 subsampled Cr (1) and Cb (2) planes" ) \
2299 X(WL_SHM_FORMAT_YUV422 , 8 , "3 plane YCbCr format, 2x1 subsampled Cb (1) and Cr (2) planes" ) \
2300 X(WL_SHM_FORMAT_YVU422 , 8 , "3 plane YCbCr format, 2x1 subsampled Cr (1) and Cb (2) planes" ) \
2301 X(WL_SHM_FORMAT_YUV444 , 8 , "3 plane YCbCr format, non-subsampled Cb (1) and Cr (2) planes" ) \
2302 X(WL_SHM_FORMAT_YVU444 , 8 , "3 plane YCbCr format, non-subsampled Cr (1) and Cb (2) planes" ) \
2303 X(WL_SHM_FORMAT_R8 , 1 , "[7:0] R" ) \
2304 X(WL_SHM_FORMAT_R16 , 2 , "[15:0] R little endian" ) \
2305 X(WL_SHM_FORMAT_RG88 , 2 , "[15:0] R:G 8:8 little endian" ) \
2306 X(WL_SHM_FORMAT_GR88 , 2 , "[15:0] G:R 8:8 little endian" ) \
2307 X(WL_SHM_FORMAT_RG1616 , 4 , "[31:0] R:G 16:16 little endian" ) \
2308 X(WL_SHM_FORMAT_GR1616 , 4 , "[31:0] G:R 16:16 little endian" ) \
2309 X(WL_SHM_FORMAT_XRGB16161616F , 8 , "[63:0] x:R:G:B 16:16:16:16 little endian" ) \
2310 X(WL_SHM_FORMAT_XBGR16161616F , 8 , "[63:0] x:B:G:R 16:16:16:16 little endian" ) \
2311 X(WL_SHM_FORMAT_ARGB16161616F , 8 , "[63:0] A:R:G:B 16:16:16:16 little endian" ) \
2312 X(WL_SHM_FORMAT_ABGR16161616F , 8 , "[63:0] A:B:G:R 16:16:16:16 little endian" ) \
2313 X(WL_SHM_FORMAT_XYUV8888 , 4 , "[31:0] X:Y:Cb:Cr 8:8:8:8 little endian" ) \
2314 X(WL_SHM_FORMAT_VUY888 , 3 , "[23:0] Cr:Cb:Y 8:8:8 little endian" ) \
2315 X(WL_SHM_FORMAT_VUY101010 , 4 , "Y followed by U then V, 10:10:10. Non-linear modifier only" ) \
2316 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" ) \
2317 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" ) \
2318 X(WL_SHM_FORMAT_Y216 , 8 , "[63:0] Cr0:Y1:Cb0:Y0 16:16:16:16 little endian per 2 Y pixels" ) \
2319 X(WL_SHM_FORMAT_Y410 , 4 , "[31:0] A:Cr:Y:Cb 2:10:10:10 little endian" ) \
2320 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" ) \
2321 X(WL_SHM_FORMAT_Y416 , 8 , "[63:0] A:Cr:Y:Cb 16:16:16:16 little endian" ) \
2322 X(WL_SHM_FORMAT_XVYU2101010 , 4 , "[31:0] X:Cr:Y:Cb 2:10:10:10 little endian" ) \
2323 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" ) \
2324 X(WL_SHM_FORMAT_XVYU16161616 , 8 , "[63:0] X:Cr:Y:Cb 16:16:16:16 little endian" ) \
2325 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" ) \
2326 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" ) \
2327 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" ) \
2328 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" ) \
2329 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" ) \
2330 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" ) \
2331 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" ) \
2332 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" ) \
2333 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" ) \
2334 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" ) \
2335 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" ) \
2336 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" ) \
2337 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" ) \
2338 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" ) \
2339 X(WL_SHM_FORMAT_NV24 , 0 , "[UNKNOWN SIZE] non-subsampled Cr:Cb plane" ) \
2340 X(WL_SHM_FORMAT_NV42 , 0 , "[UNKNOWN SIZE] non-subsampled Cb:Cr plane" ) \
2341 X(WL_SHM_FORMAT_P210 , 0 , "[UNKNOWN SIZE] 2x1 subsampled Cr:Cb plane, 10 bits per channel" ) \
2342 X(WL_SHM_FORMAT_P010 , 0 , "[UNKNOWN SIZE] 2x2 subsampled Cr:Cb plane, 10 bits per channel" ) \
2343 X(WL_SHM_FORMAT_P012 , 0 , "[UNKNOWN SIZE] 2x2 subsampled Cr:Cb plane, 12 bits per channel" ) \
2344 X(WL_SHM_FORMAT_P016 , 0 , "[UNKNOWN SIZE] 2x2 subsampled Cr:Cb plane, 16 bits per channel" ) \
2352 #define ZAKERO_YETANI__OUTPUT_SUBPIXEL \
2353 X(WL_OUTPUT_SUBPIXEL_UNKNOWN , "Unkown Geometry" ) \
2354 X(WL_OUTPUT_SUBPIXEL_NONE , "No Geometry" ) \
2355 X(WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB , "Horizontal RGB" ) \
2356 X(WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR , "Horizontal BGR" ) \
2357 X(WL_OUTPUT_SUBPIXEL_VERTICAL_RGB , "Vertical RGB" ) \
2358 X(WL_OUTPUT_SUBPIXEL_VERTICAL_BGR , "Vertical BGR" ) \
2366 #define ZAKERO_YETANI__OUTPUT_TRANSFORM \
2367 X(WL_OUTPUT_TRANSFORM_NORMAL , "No Transform" ) \
2368 X(WL_OUTPUT_TRANSFORM_90 , "90 degrees Counter-Clockwise" ) \
2369 X(WL_OUTPUT_TRANSFORM_180 , "180 degrees Counter-Clockwise" ) \
2370 X(WL_OUTPUT_TRANSFORM_270 , "270 degrees Counter-Clockwise" ) \
2371 X(WL_OUTPUT_TRANSFORM_FLIPPED , "180 degree flip around a vertical axis" ) \
2372 X(WL_OUTPUT_TRANSFORM_FLIPPED_90 , "Flig and rotate 90 degrees counter-clockwise" ) \
2373 X(WL_OUTPUT_TRANSFORM_FLIPPED_180 , "Flig and rotate 180 degrees counter-clockwise" ) \
2399 #define ZAKERO_YETANI__ARRAY_FOR_EACH(type_, pos_, array_) \
2400 for(type_ pos_ = (type_)(array_)->data \
2401 ; (const char*)pos_ < ((const char*)(array_)->data + (array_)->size) \
2565 class YetaniErrorCategory_
2566 :
public std::error_category
2569 constexpr YetaniErrorCategory_() noexcept
2573 const char* name()
const noexcept
override
2575 return "zakero.Yetani";
2578 std::string message(
int condition)
const override
2582 #define X(name_, val_, mesg_) \
2583 case val_: return mesg_;
2584 ZAKERO_YETANI__ERROR_DATA
2588 return "Unknown error condition";
2590 } YetaniErrorCategory;
2598 Yetani::LambdaKey LambdaKey_DoNothing = [](
const Yetani::Key&,
const Yetani::KeyModifier&){};
2599 Yetani::LambdaAxis LambdaAxis_DoNothing = [](
const Yetani::PointerAxis&,
const Yetani::KeyModifier&){};
2600 Yetani::LambdaButtonMm LambdaButtonMm_DoNothing = [](
const Yetani::PointerButton&,
const Yetani::PointMm&,
const Yetani::KeyModifier&){};
2601 Yetani::LambdaButtonPercent LambdaButtonPercent_DoNothing = [](
const Yetani::PointerButton&,
const Yetani::PointPercent&,
const Yetani::KeyModifier&){};
2602 Yetani::LambdaButtonPixel LambdaButtonPixel_DoNothing = [](
const Yetani::PointerButton&,
const Yetani::PointPixel&,
const Yetani::KeyModifier&){};
2603 Yetani::LambdaPointMm LambdaPointMm_DoNothing = [](
const Yetani::PointMm&,
const Yetani::KeyModifier&){};
2607 Yetani::LambdaOutputId LambdaOutputId_DoNothing = [](
const Yetani::OutputId){};
2629 bool equalish(
const float a
2634 return (std::abs(a - b) < delta);
2650 inline size_t sizeInBytes(
const Yetani::SizePixel& size
2651 ,
const wl_shm_format format
2676 std::error_code validateMinMax(
const Type& min
2686 return ZAKERO_YETANI__ERROR(Yetani::Error_Window_Size_Too_Small);
2691 && (min.width > max.width)
2694 return ZAKERO_YETANI__ERROR(Yetani::Error_Minimum_Size_Greater_Than_Maximum_Size);
2699 && (min.height > max.height)
2702 return ZAKERO_YETANI__ERROR(Yetani::Error_Minimum_Size_Greater_Than_Maximum_Size);
2705 return ZAKERO_YETANI__ERROR(Yetani::Error_None);
3081 struct wl_buffer_listener Yetani::buffer_listener =
3082 { .release = &Yetani::handlerBufferRelease
3085 struct wl_callback_listener Yetani::frame_callback_listener =
3086 { .done = &Yetani::handlerSwapBuffers
3089 struct wl_keyboard_listener Yetani::keyboard_listener =
3090 { .keymap = &Yetani::handlerKeyboardKeymap
3091 , .enter = &Yetani::handlerKeyboardEnter
3092 , .leave = &Yetani::handlerKeyboardLeave
3093 , .key = &Yetani::handlerKeyboardKey
3094 , .modifiers = &Yetani::handlerKeyboardModifiers
3095 , .repeat_info = &Yetani::handlerKeyboardRepeatInfo
3098 struct wl_output_listener Yetani::output_listener =
3099 { .geometry = &Yetani::handlerOutputGeometry
3100 , .mode = &Yetani::handlerOutputMode
3101 , .done = &Yetani::handlerOutputDone
3102 , .scale = &Yetani::handlerOutputScale
3105 struct wl_pointer_listener Yetani::pointer_listener =
3106 { .enter = &Yetani::handlerPointerEnter
3107 , .leave = &Yetani::handlerPointerLeave
3108 , .motion = &Yetani::handlerPointerMotion
3109 , .button = &Yetani::handlerPointerButton
3110 , .axis = &Yetani::handlerPointerAxis
3111 , .frame = &Yetani::handlerPointerFrame
3112 , .axis_source = &Yetani::handlerPointerAxisSource
3113 , .axis_stop = &Yetani::handlerPointerAxisStop
3114 , .axis_discrete = &Yetani::handlerPointerAxisDiscrete
3117 struct wl_registry_listener Yetani::registry_listener =
3118 { .global = &Yetani::handlerRegistryGlobal
3119 , .global_remove = &Yetani::handlerRegistryRemove
3122 struct wl_seat_listener Yetani::seat_listener =
3123 { .capabilities = &Yetani::handlerSeatCapabilities
3124 , .name = &Yetani::handlerSeatName
3127 struct wl_shm_listener Yetani::shm_listener =
3128 { .format = &Yetani::handlerShmFormat
3131 struct wl_surface_listener Yetani::surface_listener =
3132 { .enter = &Yetani::handlerSurfaceEnter
3133 , .leave = &Yetani::handlerSurfaceLeave
3141 struct xdg_wm_base_listener Yetani::xdg_wm_base_listener =
3142 { .ping = &Yetani::handlerXdgWmBasePing
3145 struct xdg_surface_listener Yetani::xdg_surface_listener =
3146 { .configure = &Yetani::handlerXdgSurfaceConfigure
3149 struct xdg_toplevel_listener Yetani::xdg_toplevel_listener =
3150 { .configure = &Yetani::handlerXdgToplevelConfigure
3151 , .close = &Yetani::handlerXdgToplevelClose
3157 struct zxdg_toplevel_decoration_v1_listener Yetani::xdg_toplevel_decoration_listener =
3158 { .configure = &Yetani::handlerXdgToplevelDecorationConfigure
3170 Yetani::Yetani() noexcept
3172 , cursor_surface_map()
3173 , cursor_memory_pool(
3174 std::string(
"Zakero.Yetani.")
3178 , cursor_shm_pool(
nullptr)
3179 , cursor_pointer(
nullptr)
3181 , event_loop_is_running(
false)
3182 , compositor(
nullptr)
3186 , shm_format_vector()
3193 , on_output_add(LambdaOutputId_DoNothing)
3194 , on_output_change(LambdaOutputId_DoNothing)
3195 , on_output_remove(LambdaOutputId_DoNothing)
3196 , output_changes_map()
3197 , output_state_map()
3198 , output_notify_surface_vector()
3200 , surface_event_map()
3201 , surface_extent_map()
3202 , surface_extent_mutex()
3203 , surface_frame_map()
3204 , surface_size_map()
3205 , surface_resize_mutex_map()
3207 , window_vector_mutex()
3208 , xdg_state_change_map()
3209 , xdg_state_change_mutex()
3210 , xdg_wm_base(
nullptr)
3212 , xdg_toplevel_map()
3213 , xdg_decoration_map()
3214 , decoration_manager(
nullptr)
3230 if(event_loop_is_running || event_loop.joinable())
3232 event_loop.request_stop();
3266 std::error_code error;
3299 std::error_code error;
3368 , std::error_code& error
3373 const char* display_name =
nullptr;
3375 if(display.empty() ==
false)
3377 display_name = display.c_str();
3381 yetani->display = wl_display_connect(display_name);
3382 if(yetani->display ==
nullptr)
3386 const char* session = getenv(
"XDG_SESSION_TYPE");
3388 if(session !=
nullptr
3389 && strcasecmp(session,
"wayland") != 0
3392 error = ZAKERO_YETANI__ERROR(Error_Wayland_Not_Available);
3394 else if(display.empty())
3396 error = ZAKERO_YETANI__ERROR(Error_Connection_Failed);
3400 error = ZAKERO_YETANI__ERROR(Error_Invalid_Display_Name);
3407 yetani->registry = wl_display_get_registry(yetani->display);
3408 if(yetani->registry ==
nullptr)
3412 error = ZAKERO_YETANI__ERROR(Error_Registry_Not_Available);
3417 wl_registry_add_listener(yetani->registry, ®istry_listener, yetani);
3420 wl_display_dispatch(yetani->display);
3421 wl_display_roundtrip(yetani->display);
3424 if(yetani->compositor ==
nullptr)
3428 error = ZAKERO_YETANI__ERROR(Error_Compositor_Was_Not_Found);
3433 if(yetani->shm ==
nullptr)
3437 error = ZAKERO_YETANI__ERROR(Error_Shm_Was_Not_Found);
3442 if(yetani->xdg_wm_base ==
nullptr)
3446 error = ZAKERO_YETANI__ERROR(Error_Xdg_WM_Base_Was_Not_Found);
3451 yetani->cursorSetup();
3453 yetani->eventLoopStart();
3455 error = ZAKERO_YETANI__ERROR(Error_None);
3470 void Yetani::disconnect() noexcept
3474 if(decoration_manager !=
nullptr)
3476 zxdg_decoration_manager_v1_destroy(decoration_manager);
3477 decoration_manager =
nullptr;
3480 if(xdg_wm_base !=
nullptr)
3482 xdg_wm_base_destroy(xdg_wm_base);
3483 xdg_wm_base =
nullptr;
3488 wl_shm_destroy(shm);
3495 while(seat_map.empty() ==
false)
3497 auto iter = std::begin(seat_map);
3499 struct wl_seat* wl_seat = iter->first;
3501 seatDestroy(wl_seat);
3506 std::lock_guard<std::mutex> lock(output_data.mutex);
3508 for(
auto& iter : output_data.output_map)
3510 struct wl_output* wayland_output = iter.first;
3512 wl_output_destroy(wayland_output);
3515 output_changes_map.clear();
3516 output_state_map.clear();
3517 output_data.output_map.clear();
3518 output_data.wloutput_to_outputid.clear();
3519 output_data.outputid_to_wloutput.clear();
3522 if(registry !=
nullptr)
3524 wl_registry_destroy(registry);
3528 if(compositor !=
nullptr)
3530 wl_compositor_destroy(compositor);
3531 compositor =
nullptr;
3534 if(display !=
nullptr)
3536 wl_display_disconnect(display);
3678 void Yetani::cursorAnimate() noexcept
3682 std::lock_guard<std::mutex> lock(cursor_mutex);
3684 for(
auto& iter : cursor_map)
3686 Yetani::Cursor& cursor = iter.second;
3688 if(cursor.next_frame_time <= time_now)
3690 const int64_t time_over = time_now - cursor.next_frame_time;
3691 cursor.next_frame_time = time_now + cursor.time_per_frame - time_over;
3693 cursor.buffer_index = (cursor.buffer_index + 1) % cursor.buffer_vector.size();
3695 wl_surface_attach(cursor.wl_surface, cursor.buffer_vector[cursor.buffer_index], 0, 0);
3696 wl_surface_damage(cursor.wl_surface
3698 , cursor.width, cursor.height
3701 wl_surface_commit(cursor.wl_surface);
3753 return ZAKERO_YETANI__ERROR(Error_Cursor_Name_Is_Invalid);
3756 if(cursor_map.contains(name) ==
true)
3758 return ZAKERO_YETANI__ERROR(Error_Cursor_Already_Exists);
3761 if(config.size.width <= 0 || config.size.height <= 0)
3763 return ZAKERO_YETANI__ERROR(Error_Cursor_Size_Too_Small);
3766 if(config.image_data.empty())
3768 return ZAKERO_YETANI__ERROR(Error_Cursor_Image_Data_Is_Empty);
3770 else if(config.image_data.size() > 1)
3772 if(config.time_per_frame.count() <= 0)
3774 return ZAKERO_YETANI__ERROR(Error_Cursor_Frame_Time_Too_Small);
3777 if(config.time_per_frame.count() > Size_Max)
3779 return ZAKERO_YETANI__ERROR(Error_Cursor_Frame_Time_Too_Large);
3783 std::error_code error = cursorCreateCursor(name, config);
3799 std::error_code Yetani::cursorCreateCursor(
const std::string& cursor_name
3803 const uint8_t bytes_per_pixel = shmFormatBytesPerPixel(cursor_config.format);
3804 const size_t frame_count = cursor_config.image_data.size();
3806 Yetani::Cursor cursor =
3807 { .buffer_vector = { frame_count,
nullptr }
3808 , .format = cursor_config.format
3811 , .time_per_frame = uint32_t(cursor_config.time_per_frame.count())
3812 , .width = cursor_config.size.width
3813 , .height = cursor_config.size.height
3814 , .hotspot_x = cursor_config.hotspot_x
3815 , .hotspot_y = cursor_config.hotspot_y
3818 if(cursor.time_per_frame == 0)
3820 cursor.time_per_frame = Size_Max;
3823 cursor.wl_surface = wl_compositor_create_surface(compositor);
3825 const int stride = cursor.width * bytes_per_pixel;
3826 const size_t image_size = stride * cursor.height;
3828 for(
size_t i = 0; i < frame_count; i++)
3830 std::error_code error;
3832 off_t offset = cursor_memory_pool.alloc(image_size, error);
3839 struct wl_buffer* buffer = cursor.buffer_vector[i];
3840 cursor.buffer_vector[i] =
nullptr;
3842 off_t offset = (off_t)wl_buffer_get_user_data(buffer);
3843 wl_buffer_destroy(buffer);
3845 cursor_memory_pool.free(offset);
3851 uint32_t* p = (uint32_t*)cursor_memory_pool.addressOf(offset);
3852 memcpy(p, (uint8_t*)cursor_config.image_data[i], image_size);
3854 cursor.buffer_vector[i] = wl_shm_pool_create_buffer(cursor_shm_pool
3862 wl_buffer_set_user_data(cursor.buffer_vector[i], (
void*)offset);
3865 wl_surface_attach(cursor.wl_surface, cursor.buffer_vector[0], 0, 0);
3866 wl_surface_commit(cursor.wl_surface);
3868 std::lock_guard<std::mutex> lock(cursor_mutex);
3870 cursor_map[cursor_name] = cursor;
3872 return ZAKERO_YETANI__ERROR(Error_None);
3889 Yetani::Cursor cursor;
3892 std::lock_guard<std::mutex> lock(cursor_mutex);
3894 if(cursor_map.contains(name) ==
false)
3896 return ZAKERO_YETANI__ERROR(Error_Cursor_Does_Not_Exist);
3899 cursor = cursor_map[name];
3901 cursor_map.erase(name);
3904 auto iter = std::begin(cursor_surface_map);
3905 auto iter_end = std::end(cursor_surface_map);
3906 while(iter != iter_end)
3908 if(cursor.wl_surface == iter->second.wl_surface)
3910 iter = cursor_surface_map.erase(iter);
3918 if(cursor.wl_surface)
3920 wl_surface_destroy(cursor.wl_surface);
3921 cursor.wl_surface =
nullptr;
3924 for(wl_buffer* buffer : cursor.buffer_vector)
3926 off_t offset = (off_t)wl_buffer_get_user_data(buffer);
3927 wl_buffer_destroy(buffer);
3929 cursor_memory_pool.free(offset);
3932 return ZAKERO_YETANI__ERROR(Error_None);
3944 void Yetani::cursorEnter(wl_pointer* wl_pointer
3946 ,
struct wl_surface* wl_surface
3949 std::lock_guard<std::mutex> lock(cursor_mutex);
3951 cursor_pointer = wl_pointer;
3953 if(cursor_surface_map.contains(wl_surface) ==
false)
3958 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
3960 cursor_surface.wl_pointer = wl_pointer;
3961 cursor_surface.serial = serial;
3963 if(cursor_surface.is_visible)
3965 wl_pointer_set_cursor(cursor_surface.wl_pointer
3966 , cursor_surface.serial
3967 , cursor_surface.wl_surface
3968 , cursor_surface.hotspot_x
3969 , cursor_surface.hotspot_y
3974 wl_pointer_set_cursor(cursor_surface.wl_pointer
3975 , cursor_surface.serial
3993 void Yetani::cursorLeave(
struct wl_surface* wl_surface
3996 std::lock_guard<std::mutex> lock(cursor_mutex);
3998 cursor_pointer =
nullptr;
4000 if(cursor_surface_map.contains(wl_surface) ==
false)
4005 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4007 cursor_surface.wl_pointer =
nullptr;
4008 cursor_surface.serial = 0;
4019 void Yetani::cursorHide(
struct wl_surface* wl_surface
4022 std::lock_guard<std::mutex> lock(cursor_mutex);
4024 if(cursor_surface_map.contains(wl_surface) ==
false)
4029 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4031 cursor_surface.is_visible =
false;
4033 if(cursor_surface.wl_pointer !=
nullptr)
4035 wl_pointer_set_cursor(cursor_surface.wl_pointer
4036 , cursor_surface.serial
4052 void Yetani::cursorShow(
struct wl_surface* wl_surface
4055 std::lock_guard<std::mutex> lock(cursor_mutex);
4057 if(cursor_surface_map.contains(wl_surface) ==
false)
4062 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4064 cursor_surface.is_visible =
true;
4066 if(cursor_surface.wl_pointer !=
nullptr)
4068 wl_pointer_set_cursor(cursor_surface.wl_pointer
4069 , cursor_surface.serial
4070 , cursor_surface.wl_surface
4071 , cursor_surface.hotspot_x
4072 , cursor_surface.hotspot_y
4088 bool Yetani::cursorIsHidden(
struct wl_surface* wl_surface
4091 std::lock_guard<std::mutex> lock(cursor_mutex);
4093 if(cursor_surface_map.contains(wl_surface) ==
false)
4098 const Yetani::CursorSurface& cursor_surface = cursor_surface_map.at(wl_surface);
4100 return !(cursor_surface.is_visible);
4111 void Yetani::cursorSetup() noexcept
4115 uint64_t bytes =
zakero::convert((uint64_t)4, zakero::Storage::Kilobyte, zakero::Storage::Byte);
4116 cursor_memory_pool.
init(bytes,
true, zakero::MemoryPool::Alignment::Bits_32);
4120 wl_shm_pool_resize(cursor_shm_pool, new_size);
4123 cursor_shm_pool = wl_shm_create_pool(shm, cursor_memory_pool.
fd(), cursor_memory_pool.
size());
4134 void Yetani::cursorTeardown() noexcept
4136 while(cursor_map.empty() ==
false)
4138 const auto& iter = cursor_map.begin();
4140 const std::string& name = iter->first;
4145 if(cursor_shm_pool !=
nullptr)
4147 wl_shm_pool_destroy(cursor_shm_pool);
4163 std::error_code Yetani::cursorAttach(
const std::string& cursor_name
4164 ,
struct wl_surface* wl_surface
4167 std::lock_guard<std::mutex> lock(cursor_mutex);
4169 if(cursor_map.contains(cursor_name) ==
false)
4171 return ZAKERO_YETANI__ERROR(Error_Cursor_Does_Not_Exist);
4174 if(cursor_surface_map.contains(wl_surface) ==
false)
4176 cursor_surface_map[wl_surface] =
4177 { .wl_pointer = cursor_pointer
4178 , .wl_surface = nullptr
4182 , .is_visible =
true
4186 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4187 Yetani::Cursor& cursor = cursor_map[cursor_name];
4189 cursor_surface.wl_surface = cursor.wl_surface;
4190 cursor_surface.hotspot_x = cursor.hotspot_x;
4191 cursor_surface.hotspot_y = cursor.hotspot_y;
4193 if(cursor_surface.wl_pointer !=
nullptr)
4195 if(cursor_surface.is_visible)
4197 wl_pointer_set_cursor(cursor_surface.wl_pointer
4198 , cursor_surface.serial
4199 , cursor_surface.wl_surface
4200 , cursor_surface.hotspot_x
4201 , cursor_surface.hotspot_y
4206 wl_pointer_set_cursor(cursor_surface.wl_pointer
4207 , cursor_surface.serial
4215 return ZAKERO_YETANI__ERROR(Error_None);
4230 std::error_code Yetani::cursorDetach(
struct wl_surface* wl_surface
4233 std::lock_guard<std::mutex> lock(cursor_mutex);
4235 if(cursor_surface_map.contains(wl_surface) ==
false)
4237 return ZAKERO_YETANI__ERROR(Error_Cursor_Not_Attached);
4240 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4242 if(cursor_surface.wl_pointer !=
nullptr)
4244 wl_pointer_set_cursor(cursor_surface.wl_pointer
4245 , cursor_surface.serial
4252 cursor_surface_map.erase(wl_surface);
4254 return ZAKERO_YETANI__ERROR(Error_None);
4270 void Yetani::eventLoopStart() noexcept
4272 event_loop = std::jthread(&Yetani::eventLoop,
this);
4274 while(event_loop_is_running.load() ==
false)
4277 std::this_thread::sleep_for(std::chrono::nanoseconds(42));
4280 #ifdef ZAKERO_YETANI__ENABLE_THREAD_SCHEDULER
4281 int policy = SCHED_FIFO;
4282 int priority_min = sched_get_priority_min(policy);
4283 int priority_max = sched_get_priority_max(policy);
4286 { .sched_priority = (priority_min + priority_max) / 2
4289 pthread_setschedparam(event_loop.native_handle(), policy, &sched);
4321 void Yetani::eventLoop(std::stop_token thread_token
4325 struct pollfd fd_status =
4326 { .fd = wl_display_get_fd(yetani->display)
4327 , .events = POLLIN | POLLOUT
4331 yetani->event_loop_is_running.store(
true);
4334 while(thread_token.stop_requested() ==
false)
4336 poll(&fd_status, 1, 1);
4338 if(fd_status.revents & POLLIN)
4340 wl_display_dispatch(yetani->display);
4343 yetani->cursorAnimate();
4345 keyboardRepeat(yetani->keyboard);
4347 if(fd_status.revents & POLLOUT)
4349 wl_display_flush(yetani->display);
4352 #ifdef ZAKERO_YETANI__ENABLE_THREAD_SCHEDULER
4353 std::this_thread::yield();
4357 yetani->event_loop_is_running.store(
false);
4375 return shm_format_vector;
4395 #define X(value_, bytes_, desc_) \
4396 case value_: return bytes_;
4397 ZAKERO_YETANI__SHM_FORMAT
4420 #define X(value_, bytes_, desc_) \
4421 case value_: return desc_;
4422 ZAKERO_YETANI__SHM_FORMAT
4443 #define X(value_, bytes_, desc_) \
4444 case value_: return #value_;
4445 ZAKERO_YETANI__SHM_FORMAT
4498 struct wl_buffer* Yetani::bufferCreate(Yetani::SurfaceSize& surface_size
4500 , Yetani::Buffer* buffer
4503 off_t offset = window_memory->memory_pool.alloc(surface_size.in_bytes);
4505 struct wl_buffer* wl_buffer = wl_shm_pool_create_buffer(window_memory->wl_shm_pool
4507 , surface_size.width
4508 , surface_size.height
4509 , surface_size.stride
4510 , surface_size.pixel_format
4513 wl_buffer_set_user_data(wl_buffer, buffer);
4515 buffer->mutex.lock();
4517 buffer->map[wl_buffer] =
4518 { .memory_pool = &window_memory->memory_pool
4522 buffer->mutex.unlock();
4539 struct wl_buffer* Yetani::bufferCreateAndRelease(Yetani* yetani
4540 , Yetani::SurfaceSize& surface_size
4541 , Yetani::Window::Memory* window_memory
4544 struct wl_buffer* wl_buffer = bufferCreate(surface_size, window_memory, &yetani->buffer);
4546 wl_buffer_add_listener(wl_buffer
4547 , &Yetani::buffer_listener
4564 void Yetani::bufferDestroy(
struct wl_buffer*& wl_buffer
4567 Yetani::Buffer* buffer = (Yetani::Buffer*)wl_buffer_get_user_data(wl_buffer);
4569 wl_buffer_destroy(wl_buffer);
4571 buffer->mutex.lock();
4573 BufferData& buffer_data = buffer->map[wl_buffer];
4575 buffer_data.memory_pool->free(buffer_data.offset);
4577 buffer->map.erase(wl_buffer);
4579 buffer->mutex.unlock();
4581 wl_buffer =
nullptr;
4685 std::lock_guard<std::mutex> lock(output_data.mutex);
4687 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4689 ZAKERO_YETANI__DEBUG
4690 <<
"Invalid output_id: "
4691 << std::to_string(output_id)
4697 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4699 return output_data.output_map.at(wl_output);
4716 Yetani::VectorOutputId vector;
4718 std::lock_guard<std::mutex> lock(output_data.mutex);
4720 for(
const auto& iter : output_data.outputid_to_wloutput)
4722 vector.push_back(iter.first);
4743 switch(subpixel_format)
4745 #define X(value_, name_) \
4746 case value_: return name_;
4747 ZAKERO_YETANI__OUTPUT_SUBPIXEL
4770 #define X(value_, name_) \
4771 case value_: return name_;
4772 ZAKERO_YETANI__OUTPUT_TRANSFORM
4793 std::lock_guard<std::mutex> lock(output_data.mutex);
4795 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4800 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4801 const Yetani::Output& output = output_data.output_map.at(wl_output);
4803 auto p = convertPixelToMm(output, point.
x, point.y);
4805 return { point.time, p.first, p.second };
4823 std::lock_guard<std::mutex> lock(output_data.mutex);
4825 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4830 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4831 const Yetani::Output& output = output_data.output_map.at(wl_output);
4833 auto p = convertPixelToPercent(output, point.
x, point.y);
4835 return { point.time, p.first, p.second };
4853 std::lock_guard<std::mutex> lock(output_data.mutex);
4855 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4860 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4861 const Yetani::Output& output = output_data.output_map.at(wl_output);
4863 auto p = convertMmToPixel(output, point.
x, point.y);
4865 return { point.time, p.first, p.second };
4883 std::lock_guard<std::mutex> lock(output_data.mutex);
4885 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4890 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4891 const Yetani::Output& output = output_data.output_map.at(wl_output);
4893 auto p = convertPercentToPixel(output, point.
x, point.y);
4895 return { point.time, p.first, p.second };
4913 std::lock_guard<std::mutex> lock(output_data.mutex);
4915 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4920 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4921 const Yetani::Output& output = output_data.output_map.at(wl_output);
4923 auto p = convertPixelToMm(output, size.
width, size.height);
4925 return { p.first, p.second };
4943 std::lock_guard<std::mutex> lock(output_data.mutex);
4945 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4950 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4951 const Yetani::Output& output = output_data.output_map.at(wl_output);
4953 auto p = convertPixelToPercent(output, size.
width, size.height);
4955 return { p.first, p.second };
4972 std::lock_guard<std::mutex> lock(output_data.mutex);
4974 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4979 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4980 const Yetani::Output& output = output_data.output_map.at(wl_output);
4982 auto p = convertMmToPixel(output, size.
width, size.height);
4984 return { p.first, p.second };
5001 std::lock_guard<std::mutex> lock(output_data.mutex);
5003 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
5008 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
5009 const Yetani::Output& output = output_data.output_map.at(wl_output);
5011 auto p = convertPercentToPixel(output, size.
width, size.height);
5013 return { p.first, p.second };
5029 if(lambda ==
nullptr)
5031 on_output_add = LambdaOutputId_DoNothing;
5035 on_output_add = lambda;
5052 if(lambda ==
nullptr)
5054 on_output_change = LambdaOutputId_DoNothing;
5058 on_output_change = lambda;
5075 if(lambda ==
nullptr)
5077 on_output_remove = LambdaOutputId_DoNothing;
5081 on_output_remove = lambda;
5094 void Yetani::convertPixel(
struct wl_surface* wl_surface
5095 ,
const int32_t pixel_xw
5096 ,
const int32_t pixel_yh
5103 std::lock_guard<std::mutex> lock(output_data.mutex);
5105 const Yetani::VectorWlOutput& vector = output_data.surface_output_map.at(wl_surface);
5106 struct wl_output* wl_output = vector.front();
5107 const Yetani::Output& output = output_data.output_map.at(wl_output);
5109 auto mm = convertPixelToMm(output, pixel_xw, pixel_yh);
5113 auto pc = convertPixelToPercent(output, pixel_xw, pixel_yh);
5130 std::pair<float, float> Yetani::convertPixelToMm(
const Yetani::Output& output
5156 std::pair<float, float> Yetani::convertPixelToPercent(
const Yetani::Output& output
5162 { float(xw) / output.
width
5163 , float(yh) / output.
height
5179 std::pair<int32_t, int32_t> Yetani::convertMmToPixel(
const Yetani::Output& output
5188 { int32_t(xw * ratio_h)
5189 , int32_t(yh * ratio_v)
5205 std::pair<int32_t, int32_t> Yetani::convertPercentToPixel(
const Yetani::Output& output
5211 { int32_t(xw * output.
width)
5212 , int32_t(yh * output.
height)
5228 void Yetani::outputNotifySurface(Yetani* yetani
5229 ,
struct wl_output* wl_output
5230 ,
struct wl_surface* wl_surface
5233 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
5234 if(surface_extent.preferred_unit == Yetani::SizeUnit::Pixel)
5239 Yetani::OutputData& output_data = yetani->output_data;
5241 std::lock_guard<std::mutex> lock(output_data.mutex);
5243 Yetani::VectorWlOutput& output_vector = output_data.surface_output_map[wl_surface];
5245 struct wl_output* output_current = output_vector.front();
5247 if(output_current != wl_output)
5252 Yetani::Output& output = output_data.output_map.at(wl_output);
5253 Yetani::SizePixel new_size = surface_extent.size_pixel;
5255 if(surface_extent.preferred_unit == Yetani::SizeUnit::Millimeter)
5257 auto p = yetani->convertMmToPixel(output, surface_extent.size_mm.width, surface_extent.size_mm.height);
5258 new_size = { p.first, p.second };
5260 else if(surface_extent.preferred_unit == Yetani::SizeUnit::Percent)
5262 auto p = yetani->convertPercentToPixel(output, surface_extent.size_percent.width, surface_extent.size_percent.height);
5263 new_size = { p.first, p.second };
5266 if(new_size.width <= 0)
5271 if(new_size.height <= 0)
5273 new_size.height = 1;
5276 yetani->surface_resize_mutex_map[wl_surface].lock();
5278 surface_extent.size_pixel = new_size;
5279 surfaceCalculateSize(yetani, wl_surface, new_size);
5281 yetani->surface_resize_mutex_map[wl_surface].unlock();
5319 void Yetani::seatDestroy(
struct wl_seat*& wl_seat
5322 Yetani::Seat& seat = seat_map[wl_seat];
5324 if(seat.wl_keyboard !=
nullptr)
5326 wl_keyboard_release(seat.wl_keyboard);
5327 seat.wl_keyboard =
nullptr;
5330 if(seat.wl_pointer !=
nullptr)
5332 wl_pointer_release(seat.wl_pointer);
5333 seat.wl_pointer =
nullptr;
5336 if(seat.wl_touch !=
nullptr)
5338 wl_touch_release(seat.wl_touch);
5339 seat.wl_touch =
nullptr;
5342 seat_map.erase(wl_seat);
5344 wl_seat_release(wl_seat);
5427 return keyboard.repeat_delay;
5441 return 1000 / keyboard.repeat_rate;
5448 void Yetani::keyboardDestroy(Yetani::Keyboard& keyboard
5451 if(keyboard.keymap !=
nullptr)
5453 munmap(keyboard.keymap, keyboard.keymap_size);
5456 keyboard.wl_surface =
nullptr;
5457 keyboard.event =
nullptr;
5458 keyboard.modifier = { 0 };
5459 keyboard.repeat_rate = 0;
5460 keyboard.repeat_delay = {};
5461 keyboard.keymap =
nullptr;
5462 keyboard.keymap_size = 0;
5472 void Yetani::keyboardRepeat(Yetani::Keyboard& keyboard
5475 auto now = std::chrono::steady_clock::now();
5477 for(
auto& iter : keyboard.repeat_map)
5479 Yetani::KeyRepeatData& key_repeat = iter.second;
5481 if(now >= key_repeat.trigger_time)
5483 uint32_t key_code = iter.first;
5486 { .time = key_repeat.base_time
5488 , .state = Yetani::KeyState::Repeat
5491 keyboard.event->on_key(key, keyboard.modifier);
5493 key_repeat.trigger_time = now
5494 + std::chrono::milliseconds(keyboard.repeat_rate)
5495 - (now - key_repeat.trigger_time)
5497 key_repeat.base_time += keyboard.repeat_rate;
5510 void Yetani::keyboardRepeatAdd(Yetani::Keyboard& keyboard
5515 auto trigger_time = std::chrono::steady_clock::now()
5516 + std::chrono::milliseconds(keyboard.repeat_delay)
5519 keyboard.repeat_map[key_code] =
5520 { .trigger_time = trigger_time
5521 , .base_time = time + keyboard.repeat_delay
5532 void Yetani::keyboardRepeatReleaseAll(Yetani::Keyboard& keyboard
5535 while(keyboard.repeat_map.empty() ==
false)
5537 auto iter = keyboard.repeat_map.begin();
5539 uint32_t key_code = iter->first;
5547 keyboard.event->on_key(key, keyboard.modifier);
5549 keyboard.repeat_map.erase(iter);
5560 void Yetani::keyboardRepeatRemove(Yetani::Keyboard& keyboard
5564 keyboard.repeat_map.erase(key_code);
5585 void Yetani::pointerClear(Yetani::Pointer& pointer
5588 pointer.enter_surface =
nullptr;
5589 pointer.enter_point = { 0, 0, 0 };
5590 pointer.leave_surface =
nullptr;
5591 pointer.motion_point = { 0, 0, 0 };
5592 pointer.button_event_code = 0;
5593 pointer.button_is_pressed =
false;
5594 pointer.button_time = 0;
5595 pointer.axis.time = 0;
5596 pointer.axis.type = Yetani::PointerAxisType::Unknown;
5597 pointer.axis.distance = 0;
5598 pointer.axis.source = Yetani::PointerAxisSource::Unknown;
5599 pointer.axis.steps = 0;
5642 void Yetani::surfaceCalculateSize(Yetani* yetani
5643 ,
struct wl_surface* wl_surface
5644 ,
const Yetani::SizePixel& size
5647 Yetani::SurfaceSize& surface_size = yetani->surface_size_map[wl_surface];
5648 surface_size.width = size.width;
5649 surface_size.height = size.height;
5650 surface_size.stride = size.width * surface_size.bytes_per_pixel;
5651 surface_size.in_bytes = surface_size.stride * surface_size.height;
5653 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
5654 surface_frame.width = size.width;
5655 surface_frame.height = size.height;
5666 struct wl_surface* Yetani::surfaceCreate(Yetani* yetani
5667 ,
const wl_shm_format pixel_format
5668 ,
const Yetani::SizePixel& size
5669 ,
const bool attach_buffer
5670 , Yetani::Window::Memory& window_memory
5673 struct wl_surface* wl_surface = wl_compositor_create_surface(yetani->compositor);
5675 Yetani::SurfaceSize& surface_size = yetani->surface_size_map[wl_surface];
5676 surface_size.pixel_format = pixel_format;
5677 surface_size.bytes_per_pixel = shmFormatBytesPerPixel(pixel_format);
5679 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
5680 surface_frame.callback =
nullptr;
5681 surface_frame.wl_surface = wl_surface;
5682 surface_frame.time_ms = 0;
5684 surfaceCalculateSize(yetani, wl_surface, size);
5686 surface_frame.buffer_next = bufferCreateAndRelease(yetani, surface_size, &window_memory);
5690 wl_surface_attach(surface_frame.wl_surface, surface_frame.buffer_next, 0, 0);
5692 surface_frame.callback = wl_surface_frame(wl_surface);
5694 wl_callback_add_listener(surface_frame.callback
5695 , &frame_callback_listener
5699 wl_surface_commit(wl_surface);
5703 bool event_keyboard =
true;
5706 yetani->keyboard.event_map[wl_surface] =
5707 { .on_enter = Lambda_DoNothing
5708 , .on_leave = Lambda_DoNothing
5709 , .on_key = LambdaKey_DoNothing
5714 bool event_pointer =
true;
5717 yetani->pointer.event_map[wl_surface] =
5718 { .on_axis = LambdaAxis_DoNothing
5719 , .on_axis_discrete = Lambda_DoNothing
5720 , .on_axis_source = Lambda_DoNothing
5721 , .on_axis_stop = Lambda_DoNothing
5722 , .on_button_mm = LambdaButtonMm_DoNothing
5723 , .on_button_percent = LambdaButtonPercent_DoNothing
5724 , .on_button_pixel = LambdaButtonPixel_DoNothing
5725 , .on_enter_mm = LambdaPointMm_DoNothing
5726 , .on_enter_percent = LambdaPointPercent_DoNothing
5727 , .on_enter_pixel = LambdaPointPixel_DoNothing
5728 , .on_leave = Lambda_DoNothing
5729 , .on_motion_mm = LambdaPointMm_DoNothing
5730 , .on_motion_percent = LambdaPointPercent_DoNothing
5731 , .on_motion_pixel = LambdaPointPixel_DoNothing
5735 yetani->surface_event_map[wl_surface] =
5736 { .on_size_mm_change = LambdaSizeMm_DoNothing
5737 , .on_size_percent_change = LambdaSizePercent_DoNothing
5738 , .on_size_pixel_change = LambdaSizePixel_DoNothing
5741 wl_surface_add_listener(wl_surface
5755 void Yetani::surfaceDestroy(Yetani* yetani
5756 ,
struct wl_surface*& wl_surface
5759 if(wl_surface ==
nullptr)
5764 if(yetani->surface_frame_map.contains(wl_surface))
5766 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
5768 if(surface_frame.callback !=
nullptr)
5770 wl_callback_destroy(surface_frame.callback);
5771 surface_frame.callback =
nullptr;
5774 struct wl_buffer* wl_buffer =
nullptr;
5775 wl_buffer = surface_frame.buffer_next.exchange(
nullptr);
5777 if(wl_buffer !=
nullptr)
5779 bufferDestroy(wl_buffer);
5783 if(yetani->keyboard.event_map.contains(wl_surface))
5785 yetani->keyboard.event_map.erase(wl_surface);
5788 if(yetani->pointer.event_map.contains(wl_surface))
5790 yetani->pointer.event_map.erase(wl_surface);
5793 yetani->surface_size_map.erase(wl_surface);
5794 yetani->surface_frame_map.erase(wl_surface);
5795 yetani->surface_event_map.erase(wl_surface);
5797 yetani->cursorDetach(wl_surface);
5799 wl_surface_destroy(wl_surface);
5800 wl_surface =
nullptr;
5818 void Yetani::handlerBufferRelease(
void*
5819 ,
struct wl_buffer* wl_buffer
5822 Yetani::bufferDestroy(wl_buffer);
5831 void Yetani::handlerKeyboardEnter(
void* data
5832 ,
struct wl_keyboard*
5834 ,
struct wl_surface* wl_surface
5835 ,
struct wl_array* key_array
5838 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
5840 if(keyboard.wl_surface !=
nullptr)
5842 keyboardRepeatReleaseAll(keyboard);
5844 keyboard.event->on_leave();
5847 keyboard.wl_surface = wl_surface;
5849 if(keyboard.event_map.contains(wl_surface))
5851 keyboard.event = &(keyboard.event_map[wl_surface]);
5855 keyboard.event = &(keyboard.event_map[
nullptr]);
5858 keyboard.event->on_enter();
5860 if(key_array->size > 0)
5868 ZAKERO_YETANI__ARRAY_FOR_EACH(uint32_t*, key_iter, key_array)
5870 key.code = *key_iter;
5872 keyboard.event->on_key(key, keyboard.modifier);
5874 keyboardRepeatAdd(keyboard, key.code, 0);
5883 void Yetani::handlerKeyboardKey(
void* data
5884 ,
struct wl_keyboard*
5891 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
5896 , .state = (state == WL_KEYBOARD_KEY_STATE_PRESSED)
5901 keyboard.event->on_key(key, keyboard.modifier);
5904 && keyboard.repeat_rate > 0
5907 keyboardRepeatAdd(keyboard, key_code, time);
5911 keyboardRepeatRemove(keyboard, key_code);
5919 void Yetani::handlerKeyboardKeymap(
void* data
5920 ,
struct wl_keyboard*
5926 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
5928 if(format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
5930 if(keyboard.keymap !=
nullptr)
5932 munmap(keyboard.keymap
5933 , keyboard.keymap_size
5937 keyboard.keymap = (
char*)mmap(
nullptr
5940 , MAP_NORESERVE | MAP_PRIVATE
5944 keyboard.keymap_size = size;
5948 if(keyboard.keymap !=
nullptr)
5950 munmap(keyboard.keymap
5951 , keyboard.keymap_size
5954 keyboard.keymap =
nullptr;
5955 keyboard.keymap_size = 0;
5964 void Yetani::handlerKeyboardLeave(
void* data
5965 ,
struct wl_keyboard*
5967 ,
struct wl_surface* wl_surface
5970 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
5972 if(keyboard.wl_surface == wl_surface)
5974 keyboardRepeatReleaseAll(keyboard);
5976 keyboard.event->on_leave();
5978 keyboard.event = &(keyboard.event_map[
nullptr]);
5979 keyboard.wl_surface =
nullptr;
5987 void Yetani::handlerKeyboardModifiers(
void* data
5988 ,
struct wl_keyboard*
5990 , uint32_t mods_pressed
5991 , uint32_t mods_latched
5992 , uint32_t mods_locked
5996 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
5998 keyboard.modifier.pressed = mods_pressed;
5999 keyboard.modifier.latched = mods_latched;
6000 keyboard.modifier.locked = mods_locked;
6001 keyboard.modifier.group = group;
6008 void Yetani::handlerKeyboardRepeatInfo(
void* data
6009 ,
struct wl_keyboard*
6014 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
6016 keyboard.repeat_delay = delay;
6017 keyboard.repeat_rate = 1000 / rate;
6026 void Yetani::handlerOutputDone(
void* data
6027 ,
struct wl_output* wl_output
6030 Yetani* yetani = (Yetani*)data;
6031 Yetani::Output& output = yetani->output_data.output_map[wl_output];
6032 Yetani::Output& changes = yetani->output_changes_map[wl_output];
6033 Yetani::OutputId output_id = yetani->output_data.wloutput_to_outputid[wl_output];
6063 output.pixels_per_mm_horizontal = output.width / float(output.physical_width_mm);
6064 output.pixels_per_mm_vertical = output.height / float(output.physical_height_mm);
6066 ZAKERO_YETANI__DEBUG <<
"\n" <<
to_string(output) <<
"\n";
6068 switch(yetani->output_state_map[wl_output])
6070 case Yetani::OutputState::Done:
6074 case Yetani::OutputState::Added:
6075 yetani->on_output_add(output_id);
6078 case Yetani::OutputState::Changed:
6079 yetani->on_output_change(output_id);
6081 for(
auto wl_surface : yetani->output_notify_surface_vector)
6083 outputNotifySurface(yetani, wl_output, wl_surface);
6089 yetani->output_state_map[wl_output] = Yetani::OutputState::Done;
6096 void Yetani::handlerOutputGeometry(
void* data
6097 ,
struct wl_output* wl_output
6100 , int32_t physical_width
6101 , int32_t physical_height
6108 Yetani* yetani = (Yetani*)data;
6109 Yetani::Output& output_changes = yetani->output_changes_map[wl_output];
6111 if(yetani->output_state_map[wl_output] != Yetani::OutputState::Added)
6113 yetani->output_state_map[wl_output] = Yetani::OutputState::Changed;
6116 output_changes.x = x;
6117 output_changes.y = y;
6118 output_changes.physical_width_mm = physical_width;
6119 output_changes.physical_height_mm = physical_height;
6120 output_changes.subpixel = subpixel;
6121 output_changes.make = std::string(make);
6122 output_changes.model = std::string(model);
6123 output_changes.transform = transform;
6130 void Yetani::handlerOutputMode(
void* data
6131 ,
struct wl_output* wl_output
6138 Yetani* yetani = (Yetani*)data;
6139 Yetani::Output& output_changes = yetani->output_changes_map[wl_output];
6141 if(yetani->output_state_map[wl_output] != Yetani::OutputState::Added)
6143 yetani->output_state_map[wl_output] = Yetani::OutputState::Changed;
6146 output_changes.flags = flags;
6147 output_changes.width = width;
6148 output_changes.height = height;
6149 output_changes.refresh_mHz = refresh;
6156 void Yetani::handlerOutputScale(
void* data
6157 ,
struct wl_output* wl_output
6161 Yetani* yetani = (Yetani*)data;
6162 Output& output_changes = yetani->output_changes_map[wl_output];
6164 if(yetani->output_state_map[wl_output] != Yetani::OutputState::Added)
6166 yetani->output_state_map[wl_output] = Yetani::OutputState::Changed;
6169 output_changes.scale_factor = factor;
6178 void Yetani::handlerPointerAxis(
void* data
6179 ,
struct wl_pointer* wl_pointer
6185 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6187 pointer.axis.time = time;
6188 pointer.axis.distance = (float)wl_fixed_to_double(value);
6190 if(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
6194 else if(axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
6200 pointer.axis.type = Yetani::PointerAxisType::Unknown;
6208 void Yetani::handlerPointerAxisDiscrete(
void* data
6209 ,
struct wl_pointer* wl_pointer
6214 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6216 pointer.axis.steps = discrete;
6223 void Yetani::handlerPointerAxisSource(
void* data
6224 ,
struct wl_pointer* wl_pointer
6225 , uint32_t axis_source
6228 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6232 case WL_POINTER_AXIS_SOURCE_WHEEL:
6236 case WL_POINTER_AXIS_SOURCE_FINGER:
6240 case WL_POINTER_AXIS_SOURCE_CONTINUOUS:
6244 case WL_POINTER_AXIS_SOURCE_WHEEL_TILT:
6249 pointer.axis.source = Yetani::PointerAxisSource::Unknown;
6257 void Yetani::handlerPointerAxisStop(
void*
6258 ,
struct wl_pointer*
6279 void Yetani::handlerPointerButton(
void* data
6280 ,
struct wl_pointer* wl_pointer
6287 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6289 pointer.button.code = button;
6290 pointer.button_time = time;
6292 if(state == WL_POINTER_BUTTON_STATE_RELEASED)
6294 pointer.button.state = Yetani::PointerButtonState::Released;
6296 else if(state == WL_POINTER_BUTTON_STATE_PRESSED)
6298 pointer.button.state = Yetani::PointerButtonState::Pressed;
6306 void Yetani::handlerPointerEnter(
void* data
6307 ,
struct wl_pointer* wl_pointer
6309 ,
struct wl_surface* wl_surface
6310 , wl_fixed_t surface_x
6311 , wl_fixed_t surface_y
6314 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6316 pointer.enter_serial = serial;
6317 pointer.enter_surface = wl_surface;
6319 pointer.enter_point =
6321 , .x = wl_fixed_to_int(surface_x)
6322 , .y = wl_fixed_to_int(surface_y)
6330 void Yetani::handlerPointerFrame(
void* data
6331 ,
struct wl_pointer* wl_pointer
6334 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6335 Yetani* yetani = pointer.yetani;
6337 if(pointer.enter_surface !=
nullptr)
6339 if(pointer.wl_surface !=
nullptr)
6341 yetani->cursorLeave(pointer.wl_surface);
6342 pointer.event_map[pointer.wl_surface].on_leave();
6345 yetani->cursorEnter(wl_pointer
6346 , pointer.enter_serial
6347 , pointer.enter_surface
6350 pointer.wl_surface = pointer.enter_surface;
6351 pointer.point_pixel = pointer.enter_point;
6353 if(pointer.event_map.contains(pointer.wl_surface))
6355 pointer.event = &(pointer.event_map[pointer.wl_surface]);
6359 pointer.event = &(pointer.event_map[
nullptr]);
6362 yetani->convertPixel(pointer.enter_surface
6363 , pointer.point_pixel.x , pointer.point_pixel.y
6364 , pointer.point_mm.x , pointer.point_mm.y
6365 , pointer.point_percent.x, pointer.point_percent.y
6368 pointer.event->on_enter_pixel(pointer.point_pixel
6369 , yetani->keyboard.modifier
6371 pointer.event->on_enter_mm(pointer.point_mm
6372 , yetani->keyboard.modifier
6374 pointer.event->on_enter_percent(pointer.point_percent
6375 , yetani->keyboard.modifier
6379 if((pointer.motion_point.time != 0)
6380 && (pointer.wl_surface !=
nullptr)
6383 pointer.point_pixel = pointer.motion_point;
6385 yetani->convertPixel(pointer.wl_surface
6386 , pointer.point_pixel.x , pointer.point_pixel.y
6387 , pointer.point_mm.x , pointer.point_mm.y
6388 , pointer.point_percent.x, pointer.point_percent.y
6390 pointer.point_mm.time = pointer.point_pixel.time;
6391 pointer.point_percent.time = pointer.point_pixel.time;
6393 pointer.event->on_motion_pixel(pointer.point_pixel
6394 , yetani->keyboard.modifier
6396 pointer.event->on_motion_mm(pointer.point_mm
6397 , yetani->keyboard.modifier
6399 pointer.event->on_motion_percent(pointer.point_percent
6400 , yetani->keyboard.modifier
6404 if((pointer.button_time != 0)
6405 && (pointer.wl_surface !=
nullptr)
6408 pointer.point_mm.time = pointer.button_time;
6409 pointer.point_percent.time = pointer.button_time;
6410 pointer.point_pixel.time = pointer.button_time;
6412 pointer.event->on_button_pixel(pointer.button
6413 , pointer.point_pixel
6414 , yetani->keyboard.modifier
6416 pointer.event->on_button_mm(pointer.button
6418 , yetani->keyboard.modifier
6420 pointer.event->on_button_percent(pointer.button
6421 , pointer.point_percent
6422 , yetani->keyboard.modifier
6426 if((pointer.axis.time != 0)
6427 && (pointer.wl_surface !=
nullptr)
6430 pointer.event->on_axis(pointer.axis
6431 , yetani->keyboard.modifier
6435 if((pointer.leave_surface !=
nullptr)
6436 && (pointer.leave_surface == pointer.wl_surface)
6439 yetani->cursorLeave(pointer.leave_surface);
6441 pointer.event->on_leave();
6443 pointer.event = &(pointer.event_map[
nullptr]);
6444 pointer.wl_surface =
nullptr;
6447 pointerClear(pointer);
6454 void Yetani::handlerPointerLeave(
void* data
6455 ,
struct wl_pointer* wl_pointer
6457 ,
struct wl_surface* wl_surface
6460 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6462 pointer.leave_surface = wl_surface;
6469 void Yetani::handlerPointerMotion(
void* data
6470 ,
struct wl_pointer* wl_pointer
6472 , wl_fixed_t surface_x
6473 , wl_fixed_t surface_y
6476 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6478 pointer.motion_point =
6480 , .x = wl_fixed_to_int(surface_x)
6481 , .y = wl_fixed_to_int(surface_y)
6491 void Yetani::handlerRegistryGlobal(
void* data
6492 ,
struct wl_registry* registry
6494 ,
const char* interface
6498 Yetani* yetani = (Yetani*)data;
6500 std::string_view interface_name(interface);
6501 ZAKERO_YETANI__DEBUG_VAR(interface_name);
6503 if(interface_name == wl_compositor_interface.name)
6505 yetani->compositor = (
struct wl_compositor*)
6506 wl_registry_bind(registry
6508 , &wl_compositor_interface
6515 if(interface_name == wl_output_interface.name)
6517 struct wl_output* wl_output = (
struct wl_output*)wl_registry_bind(registry
6519 , &wl_output_interface
6523 yetani->output_data.wloutput_to_outputid[wl_output] = id;
6524 yetani->output_data.outputid_to_wloutput[id] = wl_output;
6525 yetani->output_data.output_map[wl_output] = {};
6526 yetani->output_changes_map[wl_output] = {};
6527 yetani->output_state_map[wl_output] = Yetani::OutputState::Added;
6529 wl_output_add_listener(wl_output
6530 , &Yetani::output_listener
6537 if(interface_name == wl_seat_interface.name)
6539 yetani->seat = (
struct wl_seat*)
6540 wl_registry_bind(registry
6542 , &wl_seat_interface
6546 yetani->id_to_seat[id] = yetani->seat;
6548 wl_seat_add_listener(yetani->seat
6549 , &yetani->seat_listener
6556 if(interface_name == wl_shm_interface.name)
6558 yetani->shm = (
struct wl_shm*)
6559 wl_registry_bind(registry
6565 wl_shm_add_listener(yetani->shm
6566 , &yetani->shm_listener
6573 if(interface_name == xdg_wm_base_interface.name)
6575 yetani->xdg_wm_base = (
struct xdg_wm_base*)
6576 wl_registry_bind(registry
6578 , &xdg_wm_base_interface
6582 xdg_wm_base_add_listener(yetani->xdg_wm_base
6583 , &yetani->xdg_wm_base_listener
6588 if(interface_name == zxdg_decoration_manager_v1_interface.name)
6590 yetani->decoration_manager = (
struct zxdg_decoration_manager_v1*)
6591 wl_registry_bind(registry
6593 , &zxdg_decoration_manager_v1_interface
6596 ZAKERO_YETANI__DEBUG <<
"--- Using UNSTABLE Decoration Manager ---\n";
6604 void Yetani::handlerRegistryRemove(
void* data
6605 ,
struct wl_registry* registry
6609 Yetani* yetani = (Yetani*)data;
6611 printf(
"Got a registry remove event for id %d\n",
id);
6615 std::lock_guard<std::mutex> lock(yetani->output_data.mutex);
6617 if(yetani->output_data.outputid_to_wloutput.contains(
id))
6619 struct wl_output* wl_output = yetani->output_data.outputid_to_wloutput[id];
6621 yetani->output_data.outputid_to_wloutput.erase(
id);
6622 yetani->output_data.wloutput_to_outputid.erase(wl_output);
6624 yetani->output_changes_map.erase(wl_output);
6625 yetani->output_state_map.erase(wl_output);
6627 yetani->on_output_remove(
id);
6628 yetani->output_data.output_map.erase(wl_output);
6636 if(yetani->id_to_seat.contains(
id))
6638 struct wl_seat* wl_seat = yetani->id_to_seat[id];
6640 yetani->seatDestroy(wl_seat);
6642 yetani->id_to_seat.erase(
id);
6657 void Yetani::handlerSeatCapabilities(
void* data
6658 ,
struct wl_seat* wl_seat
6659 , uint32_t capabilities
6662 ZAKERO_YETANI__DEBUG_VAR((uint64_t)wl_seat);
6664 Yetani* yetani = (Yetani*)data;
6665 Yetani::Seat& seat = yetani->seat_map[wl_seat];
6667 seat.version = wl_seat_get_version(wl_seat);
6669 if(capabilities & WL_SEAT_CAPABILITY_KEYBOARD)
6671 ZAKERO_YETANI__DEBUG <<
"-- Got a keyboard device --\n";
6673 yetani->keyboard.event_map[
nullptr] =
6674 { .on_enter = Lambda_DoNothing
6675 , .on_leave = Lambda_DoNothing
6676 , .on_key = LambdaKey_DoNothing
6679 yetani->keyboard.event = &(yetani->keyboard.event_map[
nullptr]);
6681 seat.wl_keyboard = wl_seat_get_keyboard(wl_seat);
6683 wl_keyboard_add_listener(seat.wl_keyboard
6684 , &Yetani::keyboard_listener
6689 if(capabilities & WL_SEAT_CAPABILITY_POINTER)
6691 ZAKERO_YETANI__DEBUG <<
"-- Got a pointer device --\n";
6693 yetani->pointer.yetani = yetani;
6695 yetani->pointer.event_map[
nullptr] =
6696 { .on_axis = LambdaAxis_DoNothing
6697 , .on_axis_discrete = Lambda_DoNothing
6698 , .on_axis_source = Lambda_DoNothing
6699 , .on_axis_stop = Lambda_DoNothing
6700 , .on_button_mm = LambdaButtonMm_DoNothing
6701 , .on_button_percent = LambdaButtonPercent_DoNothing
6702 , .on_button_pixel = LambdaButtonPixel_DoNothing
6703 , .on_enter_mm = LambdaPointMm_DoNothing
6704 , .on_enter_percent = LambdaPointPercent_DoNothing
6705 , .on_enter_pixel = LambdaPointPixel_DoNothing
6706 , .on_leave = Lambda_DoNothing
6707 , .on_motion_mm = LambdaPointMm_DoNothing
6708 , .on_motion_percent = LambdaPointPercent_DoNothing
6709 , .on_motion_pixel = LambdaPointPixel_DoNothing
6712 yetani->pointer.event = &(yetani->pointer.event_map[
nullptr]);
6714 seat.wl_pointer = wl_seat_get_pointer(wl_seat);
6716 wl_pointer_add_listener(seat.wl_pointer
6717 , &Yetani::pointer_listener
6722 if(capabilities & WL_SEAT_CAPABILITY_TOUCH)
6724 ZAKERO_YETANI__DEBUG <<
"-- Got a touch device --\n";
6725 seat.wl_touch = wl_seat_get_touch(wl_seat);
6738 void Yetani::handlerSeatName(
void* data
6739 ,
struct wl_seat* wl_seat
6743 ZAKERO_YETANI__DEBUG_VAR((uint64_t)wl_seat);
6744 ZAKERO_YETANI__DEBUG_VAR(name);
6746 Yetani* yetani = (Yetani*)data;
6748 yetani->seat_map[wl_seat].name = name;
6757 void Yetani::handlerShmFormat(
void* data
6762 Yetani* yetani = (Yetani*)data;
6764 wl_shm_format format = (wl_shm_format)value;
6771 yetani->shm_format_vector.push_back(format);
6780 void Yetani::handlerSurfaceEnter(
void* data
6781 ,
struct wl_surface* wl_surface
6782 ,
struct wl_output* wl_output
6790 Yetani* yetani = (Yetani*)data;
6791 Yetani::OutputData& output_data = yetani->output_data;
6793 output_data.mutex.lock();
6794 output_data.surface_output_map[wl_surface].push_back(wl_output);
6795 output_data.mutex.unlock();
6802 void Yetani::handlerSurfaceLeave(
void* data
6803 ,
struct wl_surface* wl_surface
6804 ,
struct wl_output* wl_output
6812 Yetani* yetani = (Yetani*)data;
6814 Yetani::OutputData& output_data = yetani->output_data;
6815 std::lock_guard<std::mutex> lock(output_data.mutex);
6817 Yetani::VectorWlOutput& output_vector = output_data.surface_output_map[wl_surface];
6820 struct wl_output* current_output = output_vector.front();
6826 if(current_output == output_vector.front())
6834 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
6836 if(surface_extent.preferred_unit == Yetani::SizeUnit::Pixel)
6844 current_output = output_vector.front();
6846 Yetani::Output& output = output_data.output_map.at(current_output);
6847 Yetani::SizePixel new_size;
6849 if(surface_extent.preferred_unit == Yetani::SizeUnit::Millimeter)
6851 auto p = yetani->convertMmToPixel(output
6852 , surface_extent.size_mm.width
6853 , surface_extent.size_mm.height
6856 new_size = { p.first, p.second };
6860 auto p = yetani->convertPercentToPixel(output
6861 , surface_extent.size_percent.width
6862 , surface_extent.size_percent.height
6865 new_size = { p.first, p.second };
6868 if(new_size.width <= 0)
6873 if(new_size.height <= 0)
6875 new_size.height = 1;
6878 if((new_size.width != surface_extent.size_pixel.width)
6879 && (new_size.height != surface_extent.size_pixel.height)
6882 yetani->surface_resize_mutex_map[wl_surface].lock();
6884 XdgSurface& surface = yetani->xdg_surface_map[wl_surface];
6886 surface_extent.size_pixel = new_size;
6887 surfaceCalculateSize(surface.yetani, surface.wl_surface, new_size);
6889 yetani->surface_resize_mutex_map[wl_surface].unlock();
6891 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
6892 event.on_size_pixel_change(surface_extent.size_pixel);
6902 void Yetani::handlerSwapBuffers(
void* data
6903 ,
struct wl_callback* callback
6907 Yetani::SurfaceFrame* surface_frame = (Yetani::SurfaceFrame*)data;
6909 wl_callback_destroy(callback);
6911 surface_frame->callback = wl_surface_frame(surface_frame->wl_surface);
6913 wl_callback_add_listener(surface_frame->callback
6914 , &frame_callback_listener
6918 struct wl_buffer* wl_buffer = surface_frame->buffer_next.exchange(
nullptr);
6919 if(wl_buffer !=
nullptr)
6921 surface_frame->time_ms = time_ms;
6923 wl_surface_attach(surface_frame->wl_surface, wl_buffer, 0, 0);
6925 wl_surface_damage(surface_frame->wl_surface
6927 , surface_frame->width, surface_frame->height
6931 wl_surface_commit(surface_frame->wl_surface);
6958 case Yetani::XdgState::Toplevel_Window_Fullscreen:
6961 case Yetani::XdgState::Toplevel_Window_Maximized:
6965 case Yetani::XdgState::Toplevel_Window_Normal:
6982 return Yetani::XdgState::Toplevel_Window_Fullscreen;
6985 return Yetani::XdgState::Toplevel_Window_Maximized;
6989 return Yetani::XdgState::Toplevel_Window_Normal;
7016 struct xdg_surface* Yetani::xdgSurfaceCreate(
struct wl_surface* wl_surface
7019 XdgSurface& surface = xdg_surface_map[wl_surface];
7021 surface.yetani =
this;
7022 surface.wl_surface = wl_surface;
7024 surface_extent_mutex.lock();
7026 Yetani::SurfaceExtent& surface_extent = surface_extent_map[wl_surface];
7028 surface_extent.preferred_unit = Yetani::SizeUnit::Pixel;
7029 surface_extent.preferred_mm = { 160, 90 };
7030 surface_extent.preferred_percent = { 0.32, 0.18 };
7031 surface_extent.size_mm = { 160, 90 };
7032 surface_extent.size_percent = { 0.32, 0.18 };
7033 surface_extent.size_pixel = { 800, 450 };
7034 surface_extent.size_pixel_max = { 0, 0 };
7035 surface_extent.size_pixel_min = { 0, 0 };
7037 surface_extent_mutex.unlock();
7039 output_notify_surface_vector.push_back(wl_surface);
7041 struct xdg_surface* xdg_surface = xdg_wm_base_get_xdg_surface(xdg_wm_base
7045 xdg_state_change_mutex.lock();
7047 xdg_state_change_map[xdg_surface] = {};
7049 xdg_state_change_mutex.unlock();
7051 xdg_surface_add_listener(xdg_surface
7052 , &xdg_surface_listener
7068 void Yetani::xdgSurfaceDestroy(
struct wl_surface* wl_surface
7069 ,
struct xdg_surface*& xdg_surface
7074 xdg_surface_destroy(xdg_surface);
7079 if(xdg_surface_map.contains(wl_surface))
7081 xdg_surface_map.erase(wl_surface);
7084 xdg_state_change_mutex.lock();
7086 if(xdg_state_change_map.contains(xdg_surface))
7088 xdg_state_change_map.erase(xdg_surface);
7091 xdg_state_change_mutex.unlock();
7093 surface_extent_mutex.lock();
7095 if(surface_extent_map.contains(wl_surface))
7097 surface_extent_map.erase(wl_surface);
7100 surface_extent_mutex.unlock();
7102 xdg_surface =
nullptr;
7109 void Yetani::xdgSurfaceSetExtent(
struct wl_surface* wl_surface
7110 ,
const Yetani::SizeUnit& size_unit
7111 ,
const Yetani::SizeMm& size_mm
7112 ,
const Yetani::SizePercent& size_percent
7113 ,
const Yetani::SizePixel& size_pixel
7116 Yetani::SurfaceExtent& surface_extent = surface_extent_map[wl_surface];
7118 surface_extent.preferred_unit = size_unit;
7119 surface_extent.preferred_mm = size_mm;
7120 surface_extent.preferred_percent = size_percent;
7121 surface_extent.size_mm = size_mm;
7122 surface_extent.size_percent = size_percent;
7123 surface_extent.size_pixel = size_pixel;
7124 surface_extent.size_pixel_max = { 0, 0 };
7125 surface_extent.size_pixel_min = { 0, 0 };
7169 struct xdg_toplevel* Yetani::xdgToplevelCreate(
struct xdg_surface* xdg_surface
7172 Yetani::XdgToplevel& toplevel = xdg_toplevel_map[xdg_surface];
7174 toplevel.close_request_lambda = Lambda_DoNothing;
7175 toplevel.state_change = &(xdg_state_change_map[xdg_surface]);
7176 toplevel.is_active =
false;
7177 toplevel.window_state = Yetani::XdgState::Toplevel_Window_Normal;
7178 toplevel.is_active_lambda = LambdaBool_DoNothing;
7179 toplevel.window_state_lambda = LambdaWindowMode_DoNothing;
7180 toplevel.previous_size = { 0, 0 };
7181 toplevel.xdg_toplevel =
nullptr;
7188 toplevel.state_change->push_back(Yetani::XdgState::Toplevel_Attach_Buffer);
7190 struct xdg_toplevel* xdg_toplevel =
nullptr;
7192 xdg_toplevel = xdg_surface_get_toplevel(xdg_surface);
7193 toplevel.xdg_toplevel = xdg_toplevel;
7195 xdg_toplevel_add_listener(xdg_toplevel
7196 , &xdg_toplevel_listener
7200 return xdg_toplevel;
7210 void Yetani::xdgToplevelDestroy(
struct xdg_surface* xdg_surface
7211 ,
struct xdg_toplevel*& xdg_toplevel
7214 if(xdg_toplevel !=
nullptr)
7216 xdg_toplevel_destroy(xdg_toplevel);
7219 if(xdg_toplevel_map.contains(xdg_surface))
7221 XdgToplevel& toplevel = xdg_toplevel_map[xdg_surface];
7223 toplevel.close_request_lambda =
nullptr;
7224 toplevel.state_change =
nullptr;
7225 toplevel.window_state = Yetani::XdgState::Unknown;
7226 toplevel.is_active =
false;
7227 toplevel.is_active_lambda =
nullptr;
7228 toplevel.window_state_lambda =
nullptr;
7230 xdg_toplevel_map.erase(xdg_surface);
7233 xdg_toplevel =
nullptr;
7246 void Yetani::xdgToplevelSizeChange(Yetani* yetani
7247 ,
struct wl_surface* wl_surface
7248 ,
const Yetani::SizePixel& size_pixel
7251 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
7252 Yetani::SizePixel new_size = surface_extent.size_pixel;
7254 if(((surface_extent.size_pixel_min.width == 0) || (size_pixel.width >= surface_extent.size_pixel_min.width))
7255 && ((surface_extent.size_pixel_max.width == 0) || (size_pixel.width <= surface_extent.size_pixel_max.width))
7258 new_size.width = size_pixel.width;
7261 if(((surface_extent.size_pixel_min.height == 0) || (size_pixel.height >= surface_extent.size_pixel_min.height))
7262 && ((surface_extent.size_pixel_max.height == 0) || (size_pixel.height <= surface_extent.size_pixel_max.height))
7265 new_size.height = size_pixel.height;
7268 if((new_size.width == surface_extent.size_pixel.width)
7269 && (new_size.height == surface_extent.size_pixel.height)
7276 Yetani::SizeMm size_mm;
7277 Yetani::SizePercent size_percent;
7278 yetani->convertPixel(wl_surface
7279 , size_pixel.width , size_pixel.height
7280 , size_mm.width , size_mm.height
7281 , size_percent.width, size_percent.height
7284 yetani->surface_resize_mutex_map[wl_surface].lock();
7286 surface_extent.size_pixel = new_size;
7287 surfaceCalculateSize(yetani, wl_surface, new_size);
7289 yetani->surface_resize_mutex_map[wl_surface].unlock();
7291 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
7292 event.on_size_pixel_change(surface_extent.size_pixel);
7293 event.on_size_mm_change(surface_extent.size_mm);
7294 event.on_size_percent_change(surface_extent.size_percent);
7301 void Yetani::xdgToplevelSizeMinMaxChange(Yetani* yetani
7302 ,
struct xdg_toplevel* xdg_toplevel
7303 ,
struct wl_surface* wl_surface
7304 ,
const Yetani::SizePixel& size_pixel_min
7305 ,
const Yetani::SizePixel& size_pixel_max
7308 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
7310 Yetani::SizePixel size_pixel = surface_extent.size_pixel;
7311 bool need_to_resize =
false;
7313 if(size_pixel_max.width > 0
7314 && size_pixel_max.width < surface_extent.size_pixel.width
7317 need_to_resize =
true;
7318 size_pixel.width = size_pixel_max.width;
7321 if(size_pixel_max.height > 0
7322 && size_pixel_max.height < surface_extent.size_pixel.height
7325 need_to_resize =
true;
7326 size_pixel.height = size_pixel_max.height;
7329 if(size_pixel_min.width > 0
7330 && size_pixel_min.width > surface_extent.size_pixel.width
7333 need_to_resize =
true;
7334 size_pixel.width = size_pixel_min.width;
7337 if(size_pixel_min.height > 0
7338 && size_pixel_min.height > surface_extent.size_pixel.height
7341 need_to_resize =
true;
7342 size_pixel.height = size_pixel_min.height;
7347 xdg_toplevel_set_max_size(xdg_toplevel, 0, 0);
7348 xdg_toplevel_set_min_size(xdg_toplevel, 0, 0);
7350 yetani->surface_resize_mutex_map[wl_surface].lock();
7352 surface_extent.size_pixel = size_pixel;
7353 surfaceCalculateSize(yetani, wl_surface, size_pixel);
7355 yetani->surface_resize_mutex_map[wl_surface].unlock();
7358 xdg_toplevel_set_min_size(xdg_toplevel
7359 , size_pixel_min.width
7360 , size_pixel_min.height
7363 xdg_toplevel_set_max_size(xdg_toplevel
7364 , size_pixel_max.width
7365 , size_pixel_max.height
7368 surface_extent.size_pixel_min = size_pixel_min;
7369 surface_extent.size_pixel_max = size_pixel_max;
7376 void Yetani::xdgToplevelWindowChange(Yetani* yetani
7377 ,
struct wl_surface* wl_surface
7378 , Yetani::XdgToplevel& toplevel
7379 ,
const Yetani::XdgState window_state
7380 ,
const Yetani::SizePixel& size_pixel
7383 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
7384 Yetani::SizePixel new_size(1, 1);
7386 toplevel.window_state = window_state;
7388 if((toplevel.window_state == Yetani::XdgState::Toplevel_Window_Fullscreen)
7389 || (toplevel.window_state == Yetani::XdgState::Toplevel_Window_Maximized)
7392 if(toplevel.previous_size.width == 0)
7394 xdg_toplevel_set_max_size(toplevel.xdg_toplevel, 0, 0);
7395 xdg_toplevel_set_min_size(toplevel.xdg_toplevel, 0, 0);
7397 toplevel.previous_size = surface_extent.size_pixel;
7400 if((size_pixel.width != 0)
7401 && (size_pixel.height != 0)
7404 new_size = size_pixel;
7407 else if(toplevel.window_state == Yetani::XdgState::Toplevel_Window_Normal)
7409 xdg_toplevel_set_max_size(toplevel.xdg_toplevel
7410 , surface_extent.size_pixel_max.width
7411 , surface_extent.size_pixel_max.height
7414 xdg_toplevel_set_min_size(toplevel.xdg_toplevel
7415 , surface_extent.size_pixel_min.width
7416 , surface_extent.size_pixel_min.height
7419 new_size = toplevel.previous_size;
7420 toplevel.previous_size.width = 0;
7423 if(new_size == surface_extent.size_pixel)
7429 Yetani::SizeMm size_mm;
7430 Yetani::SizePercent size_percent;
7431 yetani->convertPixel(wl_surface
7432 , size_pixel.width , size_pixel.height
7433 , size_mm.width , size_mm.height
7434 , size_percent.width, size_percent.height
7437 yetani->surface_resize_mutex_map[wl_surface].lock();
7439 surface_extent.size_mm = size_mm;
7440 surface_extent.size_percent = size_percent;
7441 surface_extent.size_pixel = new_size;
7442 surfaceCalculateSize(yetani, wl_surface, new_size);
7444 yetani->surface_resize_mutex_map[wl_surface].unlock();
7446 toplevel.window_state_lambda(Yetani::toWindowMode(toplevel.window_state));
7448 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
7449 event.on_size_pixel_change(surface_extent.size_pixel);
7450 event.on_size_mm_change(surface_extent.size_mm);
7451 event.on_size_percent_change(surface_extent.size_percent);
7480 struct zxdg_toplevel_decoration_v1* Yetani::xdgDecorationCreate(
struct xdg_surface* xdg_surface
7481 ,
struct xdg_toplevel* xdg_toplevel
7484 if(decoration_manager ==
nullptr)
7495 zxdg_toplevel_decoration_v1* xdg_decoration =
7496 zxdg_decoration_manager_v1_get_toplevel_decoration(decoration_manager
7500 Yetani::XdgDecoration& decoration = xdg_decoration_map[xdg_surface];
7501 decoration.state_change = &(xdg_state_change_map[xdg_surface]);
7502 decoration.lambda = LambdaWindowDecorations_DoNothing;
7503 decoration.state = 0;
7504 decoration.is_present =
false;
7506 zxdg_toplevel_decoration_v1_add_listener(xdg_decoration
7507 , &xdg_toplevel_decoration_listener
7511 return xdg_decoration;
7520 void Yetani::xdgDecorationDestroy(
struct xdg_surface* xdg_surface
7521 ,
struct xdg_toplevel* xdg_toplevel
7522 ,
struct zxdg_toplevel_decoration_v1*& xdg_decoration
7525 zxdg_toplevel_decoration_v1_destroy(xdg_decoration);
7527 if(xdg_decoration_map.contains(xdg_surface))
7529 Yetani::XdgDecoration& decoration = xdg_decoration_map[xdg_surface];
7530 decoration.state_change =
nullptr;
7531 decoration.lambda =
nullptr;
7532 decoration.state = 0;
7533 decoration.is_present =
false;
7535 xdg_decoration_map.erase(xdg_surface);
7538 xdg_decoration =
nullptr;
7547 void Yetani::xdgDecorationChange(Yetani::XdgDecoration& decoration
7548 ,
const uint32_t decoration_state
7551 if(decoration_state == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE)
7553 if(decoration.state != decoration_state)
7555 decoration.state = decoration_state;
7556 decoration.is_present =
false;
7563 else if(decoration_state == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE)
7565 if(decoration.state != decoration_state)
7567 decoration.state = decoration_state;
7568 decoration.is_present =
true;
7572 decoration.is_present = !decoration.is_present;
7575 if(decoration.is_present ==
true)
7606 void Yetani::handlerXdgSurfaceConfigure(
void* data
7607 , xdg_surface* xdg_surface
7611 Yetani::XdgSurface& surface = *((Yetani::XdgSurface*)data);
7612 Yetani* yetani = surface.yetani;
7614 xdg_surface_ack_configure(xdg_surface, serial);
7616 VectorXdgStateChange& state_change = yetani->xdg_state_change_map[xdg_surface];
7618 if(state_change.empty())
7623 auto iter = std::begin(state_change);
7624 auto iter_end = std::end(state_change);
7626 while(iter != iter_end)
7630 case Yetani::XdgState::Toplevel_Active:
7632 Yetani::XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
7635 bool is_active = bool(*iter);
7636 if(toplevel.is_active != is_active)
7638 toplevel.is_active = is_active;
7640 toplevel.is_active_lambda(is_active);
7644 case Yetani::XdgState::Toplevel_Attach_Buffer:
7646 struct wl_surface* wl_surface = surface.wl_surface;
7648 SurfaceFrame& surface_frame =
7649 yetani->surface_frame_map[wl_surface];
7651 wl_surface_attach(surface_frame.wl_surface
7652 , surface_frame.buffer_next
7656 surface_frame.callback = wl_surface_frame(surface_frame.wl_surface);
7658 wl_callback_add_listener(surface_frame.callback
7659 , &frame_callback_listener
7663 wl_surface_commit(surface_frame.wl_surface);
7666 case Yetani::XdgState::Toplevel_Window_Normal:
7667 case Yetani::XdgState::Toplevel_Window_Maximized:
7668 case Yetani::XdgState::Toplevel_Window_Fullscreen:
7670 struct wl_surface* wl_surface = surface.wl_surface;
7672 Yetani::XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
7674 Yetani::XdgState window_state = XdgState(*iter);
7676 Yetani::SizePixel size_pixel;
7679 size_pixel.width = *iter;
7682 size_pixel.height = *iter;
7684 if(toplevel.window_state != window_state)
7686 xdgToplevelWindowChange(yetani
7695 case Yetani::XdgState::Toplevel_Resizing:
7697 struct wl_surface* wl_surface = surface.wl_surface;
7699 Yetani::SizePixel size_pixel;
7702 size_pixel.width = *iter;
7705 size_pixel.height = *iter;
7707 if(size_pixel.width > 0
7708 && size_pixel.height > 0
7711 xdgToplevelSizeChange(yetani
7718 case Yetani::XdgState::Toplevel_Decoration:
7721 uint32_t decoration_state = *iter;
7723 Yetani::XdgDecoration& decoration = yetani->xdg_decoration_map[xdg_surface];
7725 xdgDecorationChange(decoration, decoration_state);
7732 state_change.clear();
7741 void Yetani::handlerXdgToplevelClose(
void* data
7742 ,
struct xdg_toplevel* xdg_toplevel
7745 Yetani::XdgToplevel* toplevel = (Yetani::XdgToplevel*)data;
7747 toplevel->close_request_lambda();
7754 void Yetani::handlerXdgToplevelConfigure(
void* data
7755 ,
struct xdg_toplevel* xdg_toplevel
7758 ,
struct wl_array* state_array
7761 Yetani::XdgToplevel* toplevel = (Yetani::XdgToplevel*)data;
7763 Yetani::XdgState window_state = Yetani::XdgState::Toplevel_Window_Normal;
7764 int32_t is_active = 0;
7766 ZAKERO_YETANI__ARRAY_FOR_EACH(xdg_toplevel_state*, state_iter, state_array)
7768 xdg_toplevel_state state = *state_iter;
7772 case XDG_TOPLEVEL_STATE_MAXIMIZED:
7773 window_state = Yetani::XdgState::Toplevel_Window_Maximized;
7775 case XDG_TOPLEVEL_STATE_FULLSCREEN:
7776 window_state = Yetani::XdgState::Toplevel_Window_Fullscreen;
7778 case XDG_TOPLEVEL_STATE_RESIZING:
7779 toplevel->state_change->push_back(Yetani::XdgState::Toplevel_Resizing);
7780 toplevel->state_change->push_back(width);
7781 toplevel->state_change->push_back(height);
7783 case XDG_TOPLEVEL_STATE_ACTIVATED:
7786 case XDG_TOPLEVEL_STATE_TILED_LEFT:
7788 case XDG_TOPLEVEL_STATE_TILED_RIGHT:
7790 case XDG_TOPLEVEL_STATE_TILED_TOP:
7792 case XDG_TOPLEVEL_STATE_TILED_BOTTOM:
7799 toplevel->state_change->push_back(window_state);
7800 toplevel->state_change->push_back(width);
7801 toplevel->state_change->push_back(height);
7803 toplevel->state_change->push_back(Yetani::XdgState::Toplevel_Active);
7804 toplevel->state_change->push_back(is_active);
7813 void Yetani::handlerXdgWmBasePing(
void* data
7814 ,
struct xdg_wm_base* xdg_wm_base
7818 xdg_wm_base_pong(xdg_wm_base, serial);
7827 void Yetani::handlerXdgToplevelDecorationConfigure(
void* data
7828 ,
struct zxdg_toplevel_decoration_v1* decoration
7832 Yetani::XdgDecoration* deco = (Yetani::XdgDecoration*)data;
7834 deco->state_change->push_back(Yetani::XdgState::Toplevel_Decoration);
7835 deco->state_change->push_back(mode);
8002 , std::error_code& error
8005 return windowCreate(Yetani::SizeUnit::Millimeter
8009 , SHM_FORMAT_DEFAULT
8028 ,
const wl_shm_format format
8031 std::error_code error;
8033 return windowCreate(Yetani::SizeUnit::Millimeter
8059 ,
const wl_shm_format format
8060 , std::error_code& error
8063 return windowCreate(Yetani::SizeUnit::Millimeter
8087 , std::error_code& error
8090 return windowCreate(Yetani::SizeUnit::Percent
8094 , SHM_FORMAT_DEFAULT
8113 ,
const wl_shm_format format
8116 std::error_code error;
8118 return windowCreate(Yetani::SizeUnit::Percent
8144 ,
const wl_shm_format format
8145 , std::error_code& error
8148 return windowCreate(Yetani::SizeUnit::Percent
8172 , std::error_code& error
8175 return windowCreate(Yetani::SizeUnit::Pixel
8179 , SHM_FORMAT_DEFAULT
8198 ,
const wl_shm_format format
8201 std::error_code error;
8203 return windowCreate(Yetani::SizeUnit::Pixel
8229 ,
const wl_shm_format format
8230 , std::error_code& error
8233 return windowCreate(Yetani::SizeUnit::Pixel
8254 ,
const wl_shm_format pixel_format
8255 , std::error_code& error
8258 if((size_unit == Yetani::SizeUnit::Millimeter)
8259 && (size_mm.width <= 0 || size_mm.height <= 0)
8262 error = ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
8267 if((size_unit == Yetani::SizeUnit::Percent)
8268 && (size_percent.width <= 0 || size_percent.height <= 0)
8271 error = ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
8276 if((size_unit == Yetani::SizeUnit::Pixel)
8277 && (size_pixel.width <= 0 || size_pixel.height <= 0)
8280 error = ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
8285 const std::string file_name =
"Zakero.Yetani."
8289 struct WindowData window_data =
8292 , .wl_output = nullptr
8293 , .file_name = file_name
8294 , .size_mm = size_mm
8295 , .size_percent = size_percent
8296 , .size_pixel = size_pixel
8297 , .size_unit = size_unit
8298 , .pixel_format = pixel_format
8299 , .error = ZAKERO_YETANI__ERROR(Error_None)
8302 windowDataInit(window_data);
8304 if(window_data.error)
8306 error = window_data.error;
8311 Yetani::Window* window =
new Window(&window_data);
8313 if(window_data.error)
8318 ZAKERO_YETANI__DEBUG <<
to_string(window_data.error) <<
"\n";
8320 error = ZAKERO_YETANI__ERROR(Error_Window_Initialization_Failed);
8325 error = ZAKERO_YETANI__ERROR(Error_None);
8334 void Yetani::windowDataInit(Yetani::WindowData& window_data
8337 windowDataInitOutput(window_data);
8339 if(window_data.error)
8344 window_data.size_pixel.width = std::max(1, window_data.size_pixel.width);
8345 window_data.size_pixel.height = std::max(1, window_data.size_pixel.height);
8347 window_data.error = ZAKERO_YETANI__ERROR(Error_None);
8354 void Yetani::windowDataInitOutput(Yetani::WindowData& window_data
8357 std::lock_guard<std::mutex> lock(output_data.mutex);
8359 if(output_data.output_map.empty())
8361 window_data.error = ZAKERO_YETANI__ERROR(Error_No_Output_Available);
8366 const auto& iter = output_data.output_map.begin();
8368 window_data.wl_output = iter->first;
8369 Yetani::Output& output = iter->second;
8371 if(window_data.size_unit == Yetani::SizeUnit::Millimeter)
8373 auto px = convertMmToPixel(output
8374 , window_data.size_mm.width
8375 , window_data.size_mm.height
8378 auto pc = convertPixelToPercent(output
8383 window_data.size_mm = window_data.size_mm;
8384 window_data.size_percent = { pc.first, pc.second };
8385 window_data.size_pixel = { px.first, px.second };
8387 else if(window_data.size_unit == Yetani::SizeUnit::Percent)
8389 auto px = convertPercentToPixel(output
8390 , window_data.size_percent.width
8391 , window_data.size_percent.height
8394 auto mm = convertPixelToMm(output
8399 window_data.size_mm = { mm.first, mm.second };
8400 window_data.size_percent = window_data.size_percent;
8401 window_data.size_pixel = { px.first, px.second };
8403 else if(window_data.size_unit == Yetani::SizeUnit::Pixel)
8405 auto mm = convertPixelToMm(output
8406 , window_data.size_pixel.width
8407 , window_data.size_pixel.height
8410 auto pc = convertPixelToPercent(output
8411 , window_data.size_pixel.width
8412 , window_data.size_pixel.height
8415 window_data.size_mm = { mm.first, mm.second };
8416 window_data.size_percent = { pc.first, pc.second };
8417 window_data.size_pixel = window_data.size_pixel;
8420 window_data.error = ZAKERO_YETANI__ERROR(Error_None);
8427 void Yetani::windowInitMemory(Yetani::WindowData& window_data
8428 , Yetani::Window::Memory& window_memory
8431 size_t size_in_bytes = sizeInBytes(window_data.size_pixel
8432 , window_data.pixel_format
8435 window_data.error = window_memory.memory_pool.init(size_in_bytes
8437 , zakero::MemoryPool::Alignment::Bits_32
8440 if(window_data.error)
8445 window_memory.wl_shm_pool = wl_shm_create_pool(window_data.wl_shm
8446 , window_memory.memory_pool.fd()
8447 , window_memory.memory_pool.size()
8450 window_memory.memory_pool.sizeOnChange([&](
size_t new_size)
8452 wl_shm_pool_resize(window_memory.wl_shm_pool, new_size);
8455 window_data.error = ZAKERO_YETANI__ERROR(Error_None);
8462 void Yetani::windowInitOutput(Yetani::WindowData& window_data
8463 ,
struct wl_surface* wl_surface
8466 std::lock_guard<std::mutex> lock(output_data.mutex);
8468 output_data.surface_output_map[wl_surface].push_back(window_data.wl_output);
8475 void Yetani::windowEraseMemory(Yetani::Window::Memory& window_memory
8478 if(window_memory.wl_shm_pool)
8480 wl_shm_pool_destroy(window_memory.wl_shm_pool);
8481 window_memory.wl_shm_pool =
nullptr;
8489 void Yetani::windowEraseOutput(
struct wl_surface* wl_surface
8492 std::lock_guard<std::mutex> lock(output_data.mutex);
8494 if(output_data.surface_output_map.contains(wl_surface))
8496 output_data.surface_output_map.erase(wl_surface);
8504 void Yetani::windowEraseSurfaceExtent(
struct wl_surface* wl_surface
8507 std::lock_guard<std::mutex> lock(surface_extent_mutex);
8509 if(surface_extent_map.contains(wl_surface))
8511 surface_extent_map.erase(wl_surface);
8519 void Yetani::windowAdd(Yetani::Window* window
8522 std::lock_guard<std::mutex> lock(window_vector_mutex);
8524 window_vector.push_back(window);
8531 void Yetani::windowRemove(Yetani::Window* window
8534 std::lock_guard<std::mutex> lock(window_vector_mutex);
8739 : yetani {((Yetani::WindowData*)ptr)->yetani}
8740 , wl_buffer {
nullptr}
8741 , wl_surface {
nullptr}
8742 , xdg_surface {
nullptr}
8743 , xdg_toplevel {
nullptr}
8744 , xdg_decoration {
nullptr}
8745 , window_memory {
nullptr, ((Yetani::WindowData*)ptr)->file_name}
8746 , pixel_format {((Yetani::WindowData*)ptr)->pixel_format}
8748 Yetani::WindowData& window_data = *((Yetani::WindowData*)ptr);
8750 yetani->windowInitMemory(window_data, window_memory);
8751 if(window_data.error)
8756 wl_surface = yetani->surfaceCreate(yetani
8758 , window_data.size_pixel
8763 xdg_surface = yetani->xdgSurfaceCreate(wl_surface);
8765 yetani->xdgSurfaceSetExtent(wl_surface
8766 , window_data.size_unit
8767 , window_data.size_mm
8768 , window_data.size_percent
8769 , window_data.size_pixel
8772 xdg_toplevel = yetani->xdgToplevelCreate(xdg_surface);
8774 xdg_decoration = yetani->xdgDecorationCreate(xdg_surface, xdg_toplevel);
8776 wl_surface_commit(wl_surface);
8778 yetani->windowInitOutput(window_data, wl_surface);
8779 if(window_data.error)
8784 yetani->windowAdd(
this);
8793 yetani->windowRemove(
this);
8795 if(xdg_decoration !=
nullptr)
8797 yetani->xdgDecorationDestroy(xdg_surface, xdg_toplevel, xdg_decoration);
8800 if(xdg_toplevel !=
nullptr)
8802 yetani->xdgToplevelDestroy(xdg_surface, xdg_toplevel);
8805 if(xdg_surface !=
nullptr)
8807 yetani->xdgSurfaceDestroy(wl_surface, xdg_surface);
8810 if(wl_surface !=
nullptr)
8812 yetani->windowEraseOutput(wl_surface);
8813 yetani->surfaceDestroy(yetani, wl_surface);
8814 yetani->windowEraseSurfaceExtent(wl_surface);
8817 yetani->windowEraseMemory(window_memory);
8841 return yetani->cursorDetach(wl_surface);
8844 return yetani->cursorAttach(name, wl_surface);
8855 yetani->cursorHide(wl_surface);
8866 yetani->cursorShow(wl_surface);
8891 xdg_toplevel_set_app_id(xdg_toplevel, class_name.c_str());
8904 xdg_toplevel_set_title(xdg_toplevel, title.c_str());
8930 if(yetani->decoration_manager ==
nullptr)
8932 return ZAKERO_YETANI__ERROR(Error_Server_Side_Decorations_Not_Available);
8936 ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE
8937 : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE
8940 zxdg_toplevel_decoration_v1_set_mode(xdg_decoration
8944 return ZAKERO_YETANI__ERROR(Error_None);
8957 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
8976 XdgState window_state = Yetani::toXdgState(window_mode);
8978 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
8980 if(toplevel.window_state == window_state)
9000 XdgState window_state = Yetani::toXdgState(window_mode);
9002 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
9004 if(toplevel.window_state == window_state)
9012 xdg_toplevel_set_fullscreen(xdg_toplevel,
nullptr);
9016 xdg_toplevel_set_maximized(xdg_toplevel);
9020 xdg_toplevel_unset_fullscreen(xdg_toplevel);
9021 xdg_toplevel_unset_maximized(xdg_toplevel);
9046 if(size.width <= 0 || size.height <= 0)
9048 return ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
9053 if(size_pixel.
width <= 0)
9055 size_pixel.
width = 1;
9058 if(size_pixel.
height <= 0)
9063 yetani->surface_resize_mutex_map[wl_surface].lock();
9065 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
9067 surface_extent.preferred_unit = Yetani::SizeUnit::Millimeter;
9068 surface_extent.preferred_mm = size;
9069 surface_extent.size_pixel = size_pixel;
9071 surfaceCalculateSize(yetani, wl_surface, size_pixel);
9073 yetani->surface_resize_mutex_map[wl_surface].unlock();
9075 return ZAKERO_YETANI__ERROR(Error_None);
9098 if(size.width <= 0 || size.height <= 0)
9100 return ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
9105 if(size_pixel.
width <= 0)
9107 size_pixel.
width = 1;
9110 if(size_pixel.
height <= 0)
9115 yetani->surface_resize_mutex_map[wl_surface].lock();
9117 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
9119 surface_extent.preferred_unit = Yetani::SizeUnit::Percent;
9120 surface_extent.preferred_percent = size;
9121 surface_extent.size_pixel = size_pixel;
9123 surfaceCalculateSize(yetani, wl_surface, size_pixel);
9125 yetani->surface_resize_mutex_map[wl_surface].unlock();
9127 return ZAKERO_YETANI__ERROR(Error_None);
9150 if(size.width <= 0 || size.height <= 0)
9152 return ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
9155 yetani->surface_resize_mutex_map[wl_surface].lock();
9157 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
9159 surface_extent.preferred_unit = Yetani::SizeUnit::Pixel;
9160 surface_extent.size_pixel = size;
9162 surfaceCalculateSize(yetani, wl_surface, size);
9164 yetani->surface_resize_mutex_map[wl_surface].unlock();
9166 return ZAKERO_YETANI__ERROR(Error_None);
9185 std::error_code error = validateMinMax<Yetani::SizeMm>(size_min, size_max);
9195 Yetani::OutputData& output_data = yetani->output_data;
9197 std::lock_guard<std::mutex> lock(output_data.mutex);
9199 Yetani::VectorWlOutput& vector = output_data.surface_output_map[wl_surface];
9200 struct wl_output* wl_output = vector.front();
9203 auto min = yetani->convertMmToPixel(
output, size_min.
width, size_min.height);
9204 size_pixel_min = { min.first, min.second };
9206 auto max = yetani->convertMmToPixel(
output, size_max.
width, size_max.height);
9207 size_pixel_max = { max.first, max.second };
9210 yetani->xdgToplevelSizeMinMaxChange(yetani
9217 return ZAKERO_YETANI__ERROR(Error_None);
9236 std::error_code error = validateMinMax<Yetani::SizePercent>(size_min, size_max);
9246 Yetani::OutputData& output_data = yetani->output_data;
9248 std::lock_guard<std::mutex> lock(output_data.mutex);
9250 Yetani::VectorWlOutput& vector = output_data.surface_output_map[wl_surface];
9251 struct wl_output* wl_output = vector.front();
9254 auto min = yetani->convertPercentToPixel(
output, size_min.
width, size_min.height);
9255 size_pixel_min = { min.first, min.second };
9257 auto max = yetani->convertPercentToPixel(
output, size_max.
width, size_max.height);
9258 size_pixel_max = { max.first, max.second };
9261 yetani->xdgToplevelSizeMinMaxChange(yetani
9268 return ZAKERO_YETANI__ERROR(Error_None);
9287 std::error_code error = validateMinMax<Yetani::SizePixel>(size_min, size_max);
9293 yetani->xdgToplevelSizeMinMaxChange(yetani
9300 return ZAKERO_YETANI__ERROR(Error_None);
9346 if(wl_buffer !=
nullptr)
9348 bufferDestroy(wl_buffer);
9351 Yetani::SurfaceSize& surface_size = yetani->surface_size_map[wl_surface];
9353 yetani->surface_resize_mutex_map[wl_surface].lock();
9355 wl_buffer = bufferCreateAndRelease(yetani
9360 yetani->surface_resize_mutex_map[wl_surface].unlock();
9362 image = window_memory.memory_pool.addressOf(
9363 yetani->buffer.map[wl_buffer].offset
9366 size = { surface_size.width, surface_size.height };
9368 return ZAKERO_YETANI__ERROR(Error_None);
9380 if(wl_buffer ==
nullptr)
9392 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
9394 wl_buffer = surface_frame.buffer_next.exchange(wl_buffer);
9412 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
9414 return surface_frame.time_ms;
9430 return yetani->shmFormatBytesPerPixel(pixel_format);
9443 xdg_toplevel_set_minimized(xdg_toplevel);
9459 const Yetani::OutputData& output_data = yetani->output_data;
9461 std::lock_guard<std::mutex> lock(output_data.mutex);
9463 struct wl_output* wl_output = output_data.surface_output_map.at(wl_surface).front();
9466 auto p = yetani->convertPixelToMm(
output, point.
x, point.y);
9468 return { point.time, p.first, p.second };
9482 const Yetani::OutputData& output_data = yetani->output_data;
9484 std::lock_guard<std::mutex> lock(output_data.mutex);
9486 struct wl_output* wl_output = output_data.surface_output_map.at(wl_surface).front();
9489 auto p = yetani->convertPixelToPercent(
output, point.
x, point.y);
9491 return { point.time, p.first, p.second };
9505 Yetani::OutputData& output_data = yetani->output_data;
9507 std::lock_guard<std::mutex> lock(output_data.mutex);
9509 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9512 auto p = yetani->convertMmToPixel(
output, point.
x, point.y);
9514 return { point.time, p.first, p.second };
9528 Yetani::OutputData& output_data = yetani->output_data;
9530 std::lock_guard<std::mutex> lock(output_data.mutex);
9532 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9535 auto p = yetani->convertPercentToPixel(
output, point.
x, point.y);
9537 return { point.time, p.first, p.second };
9551 Yetani::OutputData& output_data = yetani->output_data;
9553 std::lock_guard<std::mutex> lock(output_data.mutex);
9555 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9558 auto p = yetani->convertPixelToMm(
output, size.
width, size.height);
9560 return { p.first, p.second };
9574 Yetani::OutputData& output_data = yetani->output_data;
9576 std::lock_guard<std::mutex> lock(output_data.mutex);
9578 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9581 auto p = yetani->convertPixelToPercent(
output, size.
width, size.height);
9583 return { p.first, p.second };
9597 Yetani::OutputData& output_data = yetani->output_data;
9599 std::lock_guard<std::mutex> lock(output_data.mutex);
9601 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9604 auto p = yetani->convertMmToPixel(
output, size.
width, size.height);
9606 return { p.first, p.second };
9620 Yetani::OutputData& output_data = yetani->output_data;
9622 std::lock_guard<std::mutex> lock(output_data.mutex);
9624 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9627 auto p = yetani->convertPercentToPixel(
output, size.
width, size.height);
9629 return { p.first, p.second };
9649 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
9651 if(lambda ==
nullptr)
9653 toplevel.close_request_lambda = Lambda_DoNothing;
9657 toplevel.close_request_lambda = lambda;
9674 XdgDecoration& decoration = yetani->xdg_decoration_map[xdg_surface];
9676 if(lambda ==
nullptr)
9678 decoration.lambda = LambdaWindowDecorations_DoNothing;
9682 decoration.lambda = lambda;
9703 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
9705 if(lambda ==
nullptr)
9707 toplevel.is_active_lambda = LambdaBool_DoNothing;
9711 toplevel.is_active_lambda = lambda;
9724 if(yetani->keyboard.event_map.contains(wl_surface) ==
false)
9729 Yetani::KeyboardEvent&
event = yetani->keyboard.event_map[wl_surface];
9731 if(lambda ==
nullptr)
9733 event.on_enter = Lambda_DoNothing;
9737 event.on_enter = lambda;
9750 if(yetani->keyboard.event_map.contains(wl_surface) ==
false)
9755 Yetani::KeyboardEvent&
event = yetani->keyboard.event_map[wl_surface];
9757 if(lambda ==
nullptr)
9759 event.on_leave = Lambda_DoNothing;
9763 event.on_leave = lambda;
9778 if(yetani->keyboard.event_map.contains(wl_surface) ==
false)
9783 Yetani::KeyboardEvent&
event = yetani->keyboard.event_map[wl_surface];
9785 if(lambda ==
nullptr)
9787 event.on_key = LambdaKey_DoNothing;
9791 event.on_key = lambda;
9805 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
9807 if(lambda ==
nullptr)
9809 toplevel.window_state_lambda = LambdaWindowMode_DoNothing;
9813 toplevel.window_state_lambda = lambda;
9834 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
9836 if(lambda ==
nullptr)
9838 event.on_size_mm_change = LambdaSizeMm_DoNothing;
9842 event.on_size_mm_change = lambda;
9863 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
9865 if(lambda ==
nullptr)
9867 event.on_size_percent_change = LambdaSizePercent_DoNothing;
9871 event.on_size_percent_change = lambda;
9892 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
9894 if(lambda ==
nullptr)
9896 event.on_size_pixel_change = LambdaSizePixel_DoNothing;
9900 event.on_size_pixel_change = lambda;
9915 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
9920 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
9922 if(lambda ==
nullptr)
9924 event.on_button_mm = LambdaButtonMm_DoNothing;
9928 event.on_button_mm = lambda;
9943 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
9948 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
9950 if(lambda ==
nullptr)
9952 event.on_button_percent = LambdaButtonPercent_DoNothing;
9956 event.on_button_percent = lambda;
9971 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
9976 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
9978 if(lambda ==
nullptr)
9980 event.on_button_pixel = LambdaButtonPixel_DoNothing;
9984 event.on_button_pixel = lambda;
10002 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10007 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10009 if(lambda ==
nullptr)
10011 event.on_enter_mm = LambdaPointMm_DoNothing;
10015 event.on_enter_mm = lambda;
10033 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10038 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10040 if(lambda ==
nullptr)
10042 event.on_enter_percent = LambdaPointPercent_DoNothing;
10046 event.on_enter_percent = lambda;
10064 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10069 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10071 if(lambda ==
nullptr)
10073 event.on_enter_pixel = LambdaPointPixel_DoNothing;
10077 event.on_enter_pixel = lambda;
10092 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10097 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10099 if(lambda ==
nullptr)
10101 event.on_leave = Lambda_DoNothing;
10105 event.on_leave = lambda;
10120 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10125 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10127 if(lambda ==
nullptr)
10129 event.on_motion_mm = LambdaPointMm_DoNothing;
10133 event.on_motion_mm = lambda;
10148 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10153 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10155 if(lambda ==
nullptr)
10157 event.on_motion_percent = LambdaPointPercent_DoNothing;
10161 event.on_motion_percent = lambda;
10176 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10181 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10183 if(lambda ==
nullptr)
10185 event.on_motion_pixel = LambdaPointPixel_DoNothing;
10189 event.on_motion_pixel = lambda;
10203 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10208 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10210 if(lambda ==
nullptr)
10212 event.on_axis = LambdaAxis_DoNothing;
10216 event.on_axis = lambda;
10230 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10235 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10237 if(lambda ==
nullptr)
10239 event.on_axis_source = Lambda_DoNothing;
10243 event.on_axis_source = lambda;
10257 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10262 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10264 if(lambda ==
nullptr)
10266 event.on_axis_stop = Lambda_DoNothing;
10270 event.on_axis_stop = lambda;
10284 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10289 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10291 if(lambda ==
nullptr)
10293 event.on_axis_discrete = Lambda_DoNothing;
10297 event.on_axis_discrete = lambda;
10318 std::string str = std::string(error.category().name())
10319 +
":" + std::to_string(error.value())
10320 +
":" + std::string(error.message())
10352 auto mod_to_str = [](std::string& s, uint32_t m)
10355 std::string delim =
"";
10359 s += delim +
"\"Shift\"";
10365 s += delim +
"\"CapsLock\"";
10371 s += delim +
"\"Control\"";
10377 s += delim +
"\"Alt\"";
10383 s += delim +
"\"Meta\"";
10389 std::string str =
"{ \"pressed\": ";
10390 mod_to_str(str, key_modifier.pressed);
10392 str +=
", \"latched\": ";
10393 mod_to_str(str, key_modifier.latched);
10395 str +=
", \"locked\": ";
10396 mod_to_str(str, key_modifier.locked);
10418 case Yetani::KeyState::Repeat:
return "Repeat";
10419 default:
return "";
10434 return "{\tx: " + std::to_string(
output.
x)
10435 +
"\n,\ty: " + std::to_string(
output.
y)
10471 case Yetani::PointerAxisSource::Unknown: [[fallthrough]];
10472 default:
return "";
10491 case Yetani::PointerAxisType::Unknown: [[fallthrough]];
10492 default:
return "";
10507 switch(button_state)
10509 case Yetani::PointerButtonState::Pressed:
return "Pressed";
10510 case Yetani::PointerButtonState::Released:
return "Released";
10511 default:
return "";
10526 switch(window_mode)
10531 default:
return "";
10553 return equalish(lhs.x, rhs.x, 0.001)
10554 && equalish(lhs.y, rhs.y, 0.001)
10576 return equalish(lhs.x, rhs.x, 0.00001)
10577 && equalish(lhs.y, rhs.y, 0.00001)
10596 return (lhs.x == rhs.x) && (lhs.y == rhs.y);
10615 return equalish(lhs.width, rhs.width, 0.001)
10616 && equalish(lhs.height, rhs.height, 0.001)
10636 return equalish(lhs.width, rhs.width, 0.00001)
10637 && equalish(lhs.height, rhs.height, 0.00001)
10654 return (lhs.width == rhs.width) && (lhs.height == rhs.height);
10661 #endif // ZAKERO_YETANI_IMPLEMENTATION
10665 #endif // zakero_Yetani_h