9 #ifndef zakero_Yetani_h
10 #define zakero_Yetani_h
227 #include <linux/input-event-codes.h>
230 #include <wayland/wayland-client.h>
259 #define ZAKERO_YETANI__ERROR_DATA \
260 X(Error_None , 0 , "No Error" ) \
261 X(Error_Compositor_Was_Not_Found , 1 , "Could not find the Compositor object in the Global Repository." ) \
262 X(Error_Connection_Failed , 2 , "Failed to connect to the Wayland Server." ) \
263 X(Error_Cursor_Already_Exists , 3 , "A cursor with that name already exists." ) \
264 X(Error_Cursor_Does_Not_Exist , 4 , "No cursors exists with that name." ) \
265 X(Error_Cursor_Frame_Time_Too_Large , 5 , "The cursor time per frame is too large, must be <= Size_Max." ) \
266 X(Error_Cursor_Frame_Time_Too_Small , 6 , "The cursor time per frame is too small, must be greater than 0." ) \
267 X(Error_Cursor_Image_Data_Is_Empty , 7 , "The cursor image data can not be empty." ) \
268 X(Error_Cursor_Name_Is_Invalid , 8 , "The cursor name is invalid." ) \
269 X(Error_Cursor_Not_Attached , 9 , "The specified cursor is not attached/in-use." ) \
270 X(Error_Cursor_Size_Too_Small , 10 , "The cursor size, both width and height must be greater than 0." ) \
271 X(Error_Invalid_Display_Name , 11 , "An invalid dispaly name was given to the Wayland Server." ) \
272 X(Error_Minimum_Size_Greater_Than_Maximum_Size , 12 , "The minimum window size is larger than the maximum window size." ) \
273 X(Error_No_Output_Available , 13 , "No output devices are available." ) \
274 X(Error_Registry_Not_Available , 14 , "Unable to get the registery." ) \
275 X(Error_Server_Side_Decorations_Not_Available , 15 , "The Wayland Compositor does not support Server Side Decorations." ) \
276 X(Error_Shm_Was_Not_Found , 16 , "Could not find the Shm object in the Global Repository." ) \
277 X(Error_Wayland_Not_Available , 17 , "Could not find the Wayland Server." ) \
278 X(Error_Window_Initialization_Failed , 18 , "The window was not able to be initialized." ) \
279 X(Error_Window_Size_Too_Small , 19 , "The window size was too small." ) \
280 X(Error_Xdg_WM_Base_Was_Not_Found , 20 , "Could not find the XDG WM Base object the Global Repository." ) \
322 struct zxdg_decoration_manager_v1;
323 struct zxdg_toplevel_decoration_v1;
324 extern const struct wl_interface zxdg_decoration_manager_v1_interface;
325 extern const struct wl_interface zxdg_toplevel_decoration_v1_interface;
327 zxdg_decoration_manager_v1_set_user_data(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1,
void *user_data)
329 wl_proxy_set_user_data((
struct wl_proxy *) zxdg_decoration_manager_v1, user_data);
332 zxdg_decoration_manager_v1_get_user_data(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
334 return wl_proxy_get_user_data((
struct wl_proxy *) zxdg_decoration_manager_v1);
336 static inline uint32_t
337 zxdg_decoration_manager_v1_get_version(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
339 return wl_proxy_get_version((
struct wl_proxy *) zxdg_decoration_manager_v1);
342 zxdg_decoration_manager_v1_destroy(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
344 wl_proxy_marshal((
struct wl_proxy *) zxdg_decoration_manager_v1,
346 wl_proxy_destroy((
struct wl_proxy *) zxdg_decoration_manager_v1);
348 static inline struct zxdg_toplevel_decoration_v1 *
349 zxdg_decoration_manager_v1_get_toplevel_decoration(
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1,
struct xdg_toplevel *toplevel)
352 id = wl_proxy_marshal_constructor((
struct wl_proxy *) zxdg_decoration_manager_v1,
353 1, &zxdg_toplevel_decoration_v1_interface, NULL, toplevel);
354 return (
struct zxdg_toplevel_decoration_v1 *) id;
356 enum zxdg_toplevel_decoration_v1_error {
357 ZXDG_TOPLEVEL_DECORATION_V1_ERROR_UNCONFIGURED_BUFFER = 0,
358 ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ALREADY_CONSTRUCTED = 1,
359 ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ORPHANED = 2,
361 enum zxdg_toplevel_decoration_v1_mode {
362 ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE = 1,
363 ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE = 2,
365 struct zxdg_toplevel_decoration_v1_listener {
366 void (*configure)(
void *data,
367 struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
371 zxdg_toplevel_decoration_v1_add_listener(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
372 const struct zxdg_toplevel_decoration_v1_listener *listener,
void *data)
374 return wl_proxy_add_listener((
struct wl_proxy *) zxdg_toplevel_decoration_v1,
375 (
void (**)(
void)) listener, data);
378 zxdg_toplevel_decoration_v1_set_user_data(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
void *user_data)
380 wl_proxy_set_user_data((
struct wl_proxy *) zxdg_toplevel_decoration_v1, user_data);
383 zxdg_toplevel_decoration_v1_get_user_data(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
385 return wl_proxy_get_user_data((
struct wl_proxy *) zxdg_toplevel_decoration_v1);
387 static inline uint32_t
388 zxdg_toplevel_decoration_v1_get_version(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
390 return wl_proxy_get_version((
struct wl_proxy *) zxdg_toplevel_decoration_v1);
393 zxdg_toplevel_decoration_v1_destroy(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
395 wl_proxy_marshal((
struct wl_proxy *) zxdg_toplevel_decoration_v1,
397 wl_proxy_destroy((
struct wl_proxy *) zxdg_toplevel_decoration_v1);
400 zxdg_toplevel_decoration_v1_set_mode(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, uint32_t mode)
402 wl_proxy_marshal((
struct wl_proxy *) zxdg_toplevel_decoration_v1,
406 zxdg_toplevel_decoration_v1_unset_mode(
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
408 wl_proxy_marshal((
struct wl_proxy *) zxdg_toplevel_decoration_v1,
411 #ifdef ZAKERO_YETANI_IMPLEMENTATION
412 extern const struct wl_interface xdg_toplevel_interface;
413 extern const struct wl_interface zxdg_toplevel_decoration_v1_interface;
414 static const struct wl_interface *xdg_decoration_unstable_v1_types[] = {
416 &zxdg_toplevel_decoration_v1_interface,
417 &xdg_toplevel_interface,
419 static const struct wl_message zxdg_decoration_manager_v1_requests[] = {
420 {
"destroy",
"", xdg_decoration_unstable_v1_types + 0 },
421 {
"get_toplevel_decoration",
"no", xdg_decoration_unstable_v1_types + 1 },
423 const struct wl_interface zxdg_decoration_manager_v1_interface = {
424 "zxdg_decoration_manager_v1", 1,
425 2, zxdg_decoration_manager_v1_requests,
428 static const struct wl_message zxdg_toplevel_decoration_v1_requests[] = {
429 {
"destroy",
"", xdg_decoration_unstable_v1_types + 0 },
430 {
"set_mode",
"u", xdg_decoration_unstable_v1_types + 0 },
431 {
"unset_mode",
"", xdg_decoration_unstable_v1_types + 0 },
433 static const struct wl_message zxdg_toplevel_decoration_v1_events[] = {
434 {
"configure",
"u", xdg_decoration_unstable_v1_types + 0 },
436 const struct wl_interface zxdg_toplevel_decoration_v1_interface = {
437 "zxdg_toplevel_decoration_v1", 1,
438 3, zxdg_toplevel_decoration_v1_requests,
439 1, zxdg_toplevel_decoration_v1_events,
448 struct xdg_positioner;
452 extern const struct wl_interface xdg_wm_base_interface;
453 extern const struct wl_interface xdg_positioner_interface;
454 extern const struct wl_interface xdg_surface_interface;
455 extern const struct wl_interface xdg_toplevel_interface;
456 extern const struct wl_interface xdg_popup_interface;
457 enum xdg_wm_base_error {
458 XDG_WM_BASE_ERROR_ROLE = 0,
459 XDG_WM_BASE_ERROR_DEFUNCT_SURFACES = 1,
460 XDG_WM_BASE_ERROR_NOT_THE_TOPMOST_POPUP = 2,
461 XDG_WM_BASE_ERROR_INVALID_POPUP_PARENT = 3,
462 XDG_WM_BASE_ERROR_INVALID_SURFACE_STATE = 4,
463 XDG_WM_BASE_ERROR_INVALID_POSITIONER = 5,
465 struct xdg_wm_base_listener {
466 void (*ping)(
void *data,
467 struct xdg_wm_base *xdg_wm_base,
471 xdg_wm_base_add_listener(
struct xdg_wm_base *xdg_wm_base,
472 const struct xdg_wm_base_listener *listener,
void *data)
474 return wl_proxy_add_listener((
struct wl_proxy *) xdg_wm_base,
475 (
void (**)(
void)) listener, data);
478 xdg_wm_base_set_user_data(
struct xdg_wm_base *xdg_wm_base,
void *user_data)
480 wl_proxy_set_user_data((
struct wl_proxy *) xdg_wm_base, user_data);
483 xdg_wm_base_get_user_data(
struct xdg_wm_base *xdg_wm_base)
485 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_wm_base);
487 static inline uint32_t
488 xdg_wm_base_get_version(
struct xdg_wm_base *xdg_wm_base)
490 return wl_proxy_get_version((
struct wl_proxy *) xdg_wm_base);
493 xdg_wm_base_destroy(
struct xdg_wm_base *xdg_wm_base)
495 wl_proxy_marshal((
struct wl_proxy *) xdg_wm_base,
497 wl_proxy_destroy((
struct wl_proxy *) xdg_wm_base);
499 static inline struct xdg_positioner *
500 xdg_wm_base_create_positioner(
struct xdg_wm_base *xdg_wm_base)
503 id = wl_proxy_marshal_constructor((
struct wl_proxy *) xdg_wm_base,
504 1, &xdg_positioner_interface, NULL);
505 return (
struct xdg_positioner *) id;
507 static inline struct xdg_surface *
508 xdg_wm_base_get_xdg_surface(
struct xdg_wm_base *xdg_wm_base,
struct wl_surface *surface)
511 id = wl_proxy_marshal_constructor((
struct wl_proxy *) xdg_wm_base,
512 2, &xdg_surface_interface, NULL, surface);
513 return (
struct xdg_surface *) id;
516 xdg_wm_base_pong(
struct xdg_wm_base *xdg_wm_base, uint32_t serial)
518 wl_proxy_marshal((
struct wl_proxy *) xdg_wm_base,
521 enum xdg_positioner_error {
522 XDG_POSITIONER_ERROR_INVALID_INPUT = 0,
524 enum xdg_positioner_anchor {
525 XDG_POSITIONER_ANCHOR_NONE = 0,
526 XDG_POSITIONER_ANCHOR_TOP = 1,
527 XDG_POSITIONER_ANCHOR_BOTTOM = 2,
528 XDG_POSITIONER_ANCHOR_LEFT = 3,
529 XDG_POSITIONER_ANCHOR_RIGHT = 4,
530 XDG_POSITIONER_ANCHOR_TOP_LEFT = 5,
531 XDG_POSITIONER_ANCHOR_BOTTOM_LEFT = 6,
532 XDG_POSITIONER_ANCHOR_TOP_RIGHT = 7,
533 XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT = 8,
535 enum xdg_positioner_gravity {
536 XDG_POSITIONER_GRAVITY_NONE = 0,
537 XDG_POSITIONER_GRAVITY_TOP = 1,
538 XDG_POSITIONER_GRAVITY_BOTTOM = 2,
539 XDG_POSITIONER_GRAVITY_LEFT = 3,
540 XDG_POSITIONER_GRAVITY_RIGHT = 4,
541 XDG_POSITIONER_GRAVITY_TOP_LEFT = 5,
542 XDG_POSITIONER_GRAVITY_BOTTOM_LEFT = 6,
543 XDG_POSITIONER_GRAVITY_TOP_RIGHT = 7,
544 XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT = 8,
546 enum xdg_positioner_constraint_adjustment {
547 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE = 0,
548 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X = 1,
549 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y = 2,
550 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X = 4,
551 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y = 8,
552 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X = 16,
553 XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32,
556 xdg_positioner_set_user_data(
struct xdg_positioner *xdg_positioner,
void *user_data)
558 wl_proxy_set_user_data((
struct wl_proxy *) xdg_positioner, user_data);
561 xdg_positioner_get_user_data(
struct xdg_positioner *xdg_positioner)
563 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_positioner);
565 static inline uint32_t
566 xdg_positioner_get_version(
struct xdg_positioner *xdg_positioner)
568 return wl_proxy_get_version((
struct wl_proxy *) xdg_positioner);
571 xdg_positioner_destroy(
struct xdg_positioner *xdg_positioner)
573 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
575 wl_proxy_destroy((
struct wl_proxy *) xdg_positioner);
578 xdg_positioner_set_size(
struct xdg_positioner *xdg_positioner, int32_t width, int32_t height)
580 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
584 xdg_positioner_set_anchor_rect(
struct xdg_positioner *xdg_positioner, int32_t x, int32_t y, int32_t width, int32_t height)
586 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
587 2, x, y, width, height);
590 xdg_positioner_set_anchor(
struct xdg_positioner *xdg_positioner, uint32_t anchor)
592 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
596 xdg_positioner_set_gravity(
struct xdg_positioner *xdg_positioner, uint32_t gravity)
598 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
602 xdg_positioner_set_constraint_adjustment(
struct xdg_positioner *xdg_positioner, uint32_t constraint_adjustment)
604 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
605 5, constraint_adjustment);
608 xdg_positioner_set_offset(
struct xdg_positioner *xdg_positioner, int32_t x, int32_t y)
610 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
614 xdg_positioner_set_reactive(
struct xdg_positioner *xdg_positioner)
616 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
620 xdg_positioner_set_parent_size(
struct xdg_positioner *xdg_positioner, int32_t parent_width, int32_t parent_height)
622 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
623 8, parent_width, parent_height);
626 xdg_positioner_set_parent_configure(
struct xdg_positioner *xdg_positioner, uint32_t serial)
628 wl_proxy_marshal((
struct wl_proxy *) xdg_positioner,
631 enum xdg_surface_error {
632 XDG_SURFACE_ERROR_NOT_CONSTRUCTED = 1,
633 XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED = 2,
634 XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER = 3,
636 struct xdg_surface_listener {
637 void (*configure)(
void *data,
638 struct xdg_surface *xdg_surface,
642 xdg_surface_add_listener(
struct xdg_surface *xdg_surface,
643 const struct xdg_surface_listener *listener,
void *data)
645 return wl_proxy_add_listener((
struct wl_proxy *) xdg_surface,
646 (
void (**)(
void)) listener, data);
649 xdg_surface_set_user_data(
struct xdg_surface *xdg_surface,
void *user_data)
651 wl_proxy_set_user_data((
struct wl_proxy *) xdg_surface, user_data);
654 xdg_surface_get_user_data(
struct xdg_surface *xdg_surface)
656 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_surface);
658 static inline uint32_t
659 xdg_surface_get_version(
struct xdg_surface *xdg_surface)
661 return wl_proxy_get_version((
struct wl_proxy *) xdg_surface);
664 xdg_surface_destroy(
struct xdg_surface *xdg_surface)
666 wl_proxy_marshal((
struct wl_proxy *) xdg_surface,
668 wl_proxy_destroy((
struct wl_proxy *) xdg_surface);
670 static inline struct xdg_toplevel *
671 xdg_surface_get_toplevel(
struct xdg_surface *xdg_surface)
674 id = wl_proxy_marshal_constructor((
struct wl_proxy *) xdg_surface,
675 1, &xdg_toplevel_interface, NULL);
676 return (
struct xdg_toplevel *) id;
678 static inline struct xdg_popup *
679 xdg_surface_get_popup(
struct xdg_surface *xdg_surface,
struct xdg_surface *parent,
struct xdg_positioner *positioner)
682 id = wl_proxy_marshal_constructor((
struct wl_proxy *) xdg_surface,
683 2, &xdg_popup_interface, NULL, parent, positioner);
684 return (
struct xdg_popup *) id;
687 xdg_surface_set_window_geometry(
struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height)
689 wl_proxy_marshal((
struct wl_proxy *) xdg_surface,
690 3, x, y, width, height);
693 xdg_surface_ack_configure(
struct xdg_surface *xdg_surface, uint32_t serial)
695 wl_proxy_marshal((
struct wl_proxy *) xdg_surface,
698 enum xdg_toplevel_resize_edge {
699 XDG_TOPLEVEL_RESIZE_EDGE_NONE = 0,
700 XDG_TOPLEVEL_RESIZE_EDGE_TOP = 1,
701 XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM = 2,
702 XDG_TOPLEVEL_RESIZE_EDGE_LEFT = 4,
703 XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT = 5,
704 XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT = 6,
705 XDG_TOPLEVEL_RESIZE_EDGE_RIGHT = 8,
706 XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT = 9,
707 XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT = 10,
709 enum xdg_toplevel_state {
710 XDG_TOPLEVEL_STATE_MAXIMIZED = 1,
711 XDG_TOPLEVEL_STATE_FULLSCREEN = 2,
712 XDG_TOPLEVEL_STATE_RESIZING = 3,
713 XDG_TOPLEVEL_STATE_ACTIVATED = 4,
714 XDG_TOPLEVEL_STATE_TILED_LEFT = 5,
715 XDG_TOPLEVEL_STATE_TILED_RIGHT = 6,
716 XDG_TOPLEVEL_STATE_TILED_TOP = 7,
717 XDG_TOPLEVEL_STATE_TILED_BOTTOM = 8,
719 struct xdg_toplevel_listener {
720 void (*configure)(
void *data,
721 struct xdg_toplevel *xdg_toplevel,
724 struct wl_array *states);
725 void (*close)(
void *data,
726 struct xdg_toplevel *xdg_toplevel);
729 xdg_toplevel_add_listener(
struct xdg_toplevel *xdg_toplevel,
730 const struct xdg_toplevel_listener *listener,
void *data)
732 return wl_proxy_add_listener((
struct wl_proxy *) xdg_toplevel,
733 (
void (**)(
void)) listener, data);
736 xdg_toplevel_set_user_data(
struct xdg_toplevel *xdg_toplevel,
void *user_data)
738 wl_proxy_set_user_data((
struct wl_proxy *) xdg_toplevel, user_data);
741 xdg_toplevel_get_user_data(
struct xdg_toplevel *xdg_toplevel)
743 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_toplevel);
745 static inline uint32_t
746 xdg_toplevel_get_version(
struct xdg_toplevel *xdg_toplevel)
748 return wl_proxy_get_version((
struct wl_proxy *) xdg_toplevel);
751 xdg_toplevel_destroy(
struct xdg_toplevel *xdg_toplevel)
753 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
755 wl_proxy_destroy((
struct wl_proxy *) xdg_toplevel);
758 xdg_toplevel_set_parent(
struct xdg_toplevel *xdg_toplevel,
struct xdg_toplevel *parent)
760 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
764 xdg_toplevel_set_title(
struct xdg_toplevel *xdg_toplevel,
const char *title)
766 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
770 xdg_toplevel_set_app_id(
struct xdg_toplevel *xdg_toplevel,
const char *app_id)
772 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
776 xdg_toplevel_show_window_menu(
struct xdg_toplevel *xdg_toplevel,
struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
778 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
779 4, seat, serial, x, y);
782 xdg_toplevel_move(
struct xdg_toplevel *xdg_toplevel,
struct wl_seat *seat, uint32_t serial)
784 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
788 xdg_toplevel_resize(
struct xdg_toplevel *xdg_toplevel,
struct wl_seat *seat, uint32_t serial, uint32_t edges)
790 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
791 6, seat, serial, edges);
794 xdg_toplevel_set_max_size(
struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height)
796 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
800 xdg_toplevel_set_min_size(
struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height)
802 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
806 xdg_toplevel_set_maximized(
struct xdg_toplevel *xdg_toplevel)
808 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
812 xdg_toplevel_unset_maximized(
struct xdg_toplevel *xdg_toplevel)
814 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
818 xdg_toplevel_set_fullscreen(
struct xdg_toplevel *xdg_toplevel,
struct wl_output *output)
820 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
824 xdg_toplevel_unset_fullscreen(
struct xdg_toplevel *xdg_toplevel)
826 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
830 xdg_toplevel_set_minimized(
struct xdg_toplevel *xdg_toplevel)
832 wl_proxy_marshal((
struct wl_proxy *) xdg_toplevel,
835 enum xdg_popup_error {
836 XDG_POPUP_ERROR_INVALID_GRAB = 0,
838 struct xdg_popup_listener {
839 void (*configure)(
void *data,
840 struct xdg_popup *xdg_popup,
845 void (*popup_done)(
void *data,
846 struct xdg_popup *xdg_popup);
847 void (*repositioned)(
void *data,
848 struct xdg_popup *xdg_popup,
852 xdg_popup_add_listener(
struct xdg_popup *xdg_popup,
853 const struct xdg_popup_listener *listener,
void *data)
855 return wl_proxy_add_listener((
struct wl_proxy *) xdg_popup,
856 (
void (**)(
void)) listener, data);
859 xdg_popup_set_user_data(
struct xdg_popup *xdg_popup,
void *user_data)
861 wl_proxy_set_user_data((
struct wl_proxy *) xdg_popup, user_data);
864 xdg_popup_get_user_data(
struct xdg_popup *xdg_popup)
866 return wl_proxy_get_user_data((
struct wl_proxy *) xdg_popup);
868 static inline uint32_t
869 xdg_popup_get_version(
struct xdg_popup *xdg_popup)
871 return wl_proxy_get_version((
struct wl_proxy *) xdg_popup);
874 xdg_popup_destroy(
struct xdg_popup *xdg_popup)
876 wl_proxy_marshal((
struct wl_proxy *) xdg_popup,
878 wl_proxy_destroy((
struct wl_proxy *) xdg_popup);
881 xdg_popup_grab(
struct xdg_popup *xdg_popup,
struct wl_seat *seat, uint32_t serial)
883 wl_proxy_marshal((
struct wl_proxy *) xdg_popup,
887 xdg_popup_reposition(
struct xdg_popup *xdg_popup,
struct xdg_positioner *positioner, uint32_t token)
889 wl_proxy_marshal((
struct wl_proxy *) xdg_popup,
890 2, positioner, token);
892 #ifdef ZAKERO_YETANI_IMPLEMENTATION
893 extern const struct wl_interface wl_output_interface;
894 extern const struct wl_interface wl_seat_interface;
895 extern const struct wl_interface wl_surface_interface;
896 extern const struct wl_interface xdg_popup_interface;
897 extern const struct wl_interface xdg_positioner_interface;
898 extern const struct wl_interface xdg_surface_interface;
899 extern const struct wl_interface xdg_toplevel_interface;
900 static const struct wl_interface *xdg_shell_types[] = {
905 &xdg_positioner_interface,
906 &xdg_surface_interface,
907 &wl_surface_interface,
908 &xdg_toplevel_interface,
909 &xdg_popup_interface,
910 &xdg_surface_interface,
911 &xdg_positioner_interface,
912 &xdg_toplevel_interface,
922 &wl_output_interface,
925 &xdg_positioner_interface,
928 static const struct wl_message xdg_wm_base_requests[] = {
929 {
"destroy",
"", xdg_shell_types + 0 },
930 {
"create_positioner",
"n", xdg_shell_types + 4 },
931 {
"get_xdg_surface",
"no", xdg_shell_types + 5 },
932 {
"pong",
"u", xdg_shell_types + 0 },
934 static const struct wl_message xdg_wm_base_events[] = {
935 {
"ping",
"u", xdg_shell_types + 0 },
937 const struct wl_interface xdg_wm_base_interface = {
939 4, xdg_wm_base_requests,
940 1, xdg_wm_base_events,
942 static const struct wl_message xdg_positioner_requests[] = {
943 {
"destroy",
"", xdg_shell_types + 0 },
944 {
"set_size",
"ii", xdg_shell_types + 0 },
945 {
"set_anchor_rect",
"iiii", xdg_shell_types + 0 },
946 {
"set_anchor",
"u", xdg_shell_types + 0 },
947 {
"set_gravity",
"u", xdg_shell_types + 0 },
948 {
"set_constraint_adjustment",
"u", xdg_shell_types + 0 },
949 {
"set_offset",
"ii", xdg_shell_types + 0 },
950 {
"set_reactive",
"3", xdg_shell_types + 0 },
951 {
"set_parent_size",
"3ii", xdg_shell_types + 0 },
952 {
"set_parent_configure",
"3u", xdg_shell_types + 0 },
954 const struct wl_interface xdg_positioner_interface = {
956 10, xdg_positioner_requests,
959 static const struct wl_message xdg_surface_requests[] = {
960 {
"destroy",
"", xdg_shell_types + 0 },
961 {
"get_toplevel",
"n", xdg_shell_types + 7 },
962 {
"get_popup",
"n?oo", xdg_shell_types + 8 },
963 {
"set_window_geometry",
"iiii", xdg_shell_types + 0 },
964 {
"ack_configure",
"u", xdg_shell_types + 0 },
966 static const struct wl_message xdg_surface_events[] = {
967 {
"configure",
"u", xdg_shell_types + 0 },
969 const struct wl_interface xdg_surface_interface = {
971 5, xdg_surface_requests,
972 1, xdg_surface_events,
974 static const struct wl_message xdg_toplevel_requests[] = {
975 {
"destroy",
"", xdg_shell_types + 0 },
976 {
"set_parent",
"?o", xdg_shell_types + 11 },
977 {
"set_title",
"s", xdg_shell_types + 0 },
978 {
"set_app_id",
"s", xdg_shell_types + 0 },
979 {
"show_window_menu",
"ouii", xdg_shell_types + 12 },
980 {
"move",
"ou", xdg_shell_types + 16 },
981 {
"resize",
"ouu", xdg_shell_types + 18 },
982 {
"set_max_size",
"ii", xdg_shell_types + 0 },
983 {
"set_min_size",
"ii", xdg_shell_types + 0 },
984 {
"set_maximized",
"", xdg_shell_types + 0 },
985 {
"unset_maximized",
"", xdg_shell_types + 0 },
986 {
"set_fullscreen",
"?o", xdg_shell_types + 21 },
987 {
"unset_fullscreen",
"", xdg_shell_types + 0 },
988 {
"set_minimized",
"", xdg_shell_types + 0 },
990 static const struct wl_message xdg_toplevel_events[] = {
991 {
"configure",
"iia", xdg_shell_types + 0 },
992 {
"close",
"", xdg_shell_types + 0 },
994 const struct wl_interface xdg_toplevel_interface = {
996 14, xdg_toplevel_requests,
997 2, xdg_toplevel_events,
999 static const struct wl_message xdg_popup_requests[] = {
1000 {
"destroy",
"", xdg_shell_types + 0 },
1001 {
"grab",
"ou", xdg_shell_types + 22 },
1002 {
"reposition",
"3ou", xdg_shell_types + 24 },
1004 static const struct wl_message xdg_popup_events[] = {
1005 {
"configure",
"iiii", xdg_shell_types + 0 },
1006 {
"popup_done",
"", xdg_shell_types + 0 },
1007 {
"repositioned",
"3u", xdg_shell_types + 0 },
1009 const struct wl_interface xdg_popup_interface = {
1011 3, xdg_popup_requests,
1012 3, xdg_popup_events,
1029 #define X(name_, val_, mesg_) \
1030 static constexpr int name_ = val_;
1031 ZAKERO_YETANI__ERROR_DATA
1055 static constexpr uint32_t KeyModifier_NumLock = 0x00000010;
1169 static
Yetani*
connect(const std::
string&, std::error_code&) noexcept;
1177 wl_shm_format format = WL_SHM_FORMAT_ARGB8888;
1178 int32_t hotspot_x = 0;
1179 int32_t hotspot_y = 0;
1180 std::chrono::milliseconds time_per_frame = std::chrono::milliseconds(0);
1200 std::string make =
"";
1201 std::string model =
"";
1206 uint32_t physical_width_mm = 0;
1207 uint32_t physical_height_mm = 0;
1208 int32_t subpixel = 0;
1209 int32_t refresh_mHz = 0;
1210 int32_t scale_factor = 0;
1211 int32_t transform = 0;
1213 float pixels_per_mm_horizontal = 0.0;
1214 float pixels_per_mm_vertical = 0.0;
1219 using OutputId = uint32_t;
1221 using LambdaOutputId = std::function<void(
const Yetani::OutputId)>;
1223 using VectorOutputId = std::vector<OutputId>;
1270 using VectorShmFormat = std::vector<wl_shm_format>;
1277 static std::
string shmFormatName(const wl_shm_format) noexcept;
1321 void classSet(
const std::string&) noexcept;
1322 void titleSet(
const std::string&) noexcept;
1358 uint32_t
time()
const noexcept;
1377 std::error_code
cursorUse(
const std::string&) noexcept;
1424 struct wl_buffer* wl_buffer;
1425 struct wl_surface* wl_surface;
1426 struct xdg_surface* xdg_surface;
1427 struct xdg_toplevel* xdg_toplevel;
1428 struct zxdg_toplevel_decoration_v1* xdg_decoration;
1430 wl_shm_format pixel_format;
1455 static constexpr uint32_t Size_Max = (uint32_t)std::numeric_limits<int32_t>::max();
1461 using VectorWlSurface = std::vector<struct wl_surface*>;
1466 void disconnect() noexcept;
1473 struct wl_surface* wl_surface =
nullptr;
1474 std::vector<::wl_buffer*> buffer_vector = {};
1475 wl_shm_format format = WL_SHM_FORMAT_ARGB8888;
1476 int64_t next_frame_time = 0;
1477 size_t buffer_index = 0;
1478 uint32_t time_per_frame = 0;
1481 int32_t hotspot_x = 0;
1482 int32_t hotspot_y = 0;
1485 using MapStringCursor = std::unordered_map<std::string, Yetani::Cursor>;
1487 MapStringCursor cursor_map;
1491 struct CursorSurface
1493 struct wl_pointer* wl_pointer;
1494 struct wl_surface* wl_surface;
1501 using MapCursorSurface = std::unordered_map<struct wl_surface*, Yetani::CursorSurface>;
1503 MapCursorSurface cursor_surface_map;
1508 mutable std::mutex cursor_mutex;
1509 struct wl_shm_pool* cursor_shm_pool;
1510 struct wl_pointer* cursor_pointer;
1514 void cursorAnimate() noexcept;
1515 std::error_code cursorCreateCursor(const std::
string&, const Yetani::CursorConfig&) noexcept;
1516 void cursorEnter(struct wl_pointer*, uint32_t, struct wl_surface*) noexcept;
1517 void cursorLeave(struct wl_surface*) noexcept;
1518 void cursorHide(struct wl_surface*) noexcept;
1519 void cursorShow(struct wl_surface*) noexcept;
1520 bool cursorIsHidden(struct wl_surface*) const noexcept;
1521 void cursorSetup() noexcept;
1522 void cursorTeardown() noexcept;
1523 std::error_code cursorAttach(const std::
string&, struct wl_surface*) noexcept;
1524 std::error_code cursorDetach(struct wl_surface*) noexcept;
1529 std::jthread event_loop;
1530 std::atomic<
bool> event_loop_is_running;
1534 void eventLoopStart() noexcept;
1535 static
void eventLoop(std::stop_token, Yetani*) noexcept;
1540 struct wl_compositor* compositor;
1541 struct wl_display* display;
1542 struct wl_registry* registry;
1544 Yetani::VectorShmFormat shm_format_vector;
1551 struct wl_keyboard* wl_keyboard =
nullptr;
1552 struct wl_pointer* wl_pointer =
nullptr;
1553 struct wl_touch* wl_touch =
nullptr;
1554 std::string name =
"";
1555 uint32_t version = 0;
1558 using MapSeat = std::map<struct wl_seat*, Seat>;
1559 using MapIdWlSeat = std::map<uint32_t, struct wl_seat*>;
1561 Yetani::MapSeat seat_map;
1562 Yetani::MapIdWlSeat id_to_seat;
1566 struct wl_seat* seat;
1570 void seatDestroy(
struct wl_seat*&) noexcept;
1575 struct KeyRepeatData
1577 std::chrono::time_point<std::chrono::steady_clock> trigger_time = {};
1578 uint32_t base_time = 0;
1581 using KeyRepeatMap = std::map<uint32_t, Yetani::KeyRepeatData>;
1585 struct KeyboardEvent
1592 using MapKeyboardEvent = std::unordered_map<struct wl_surface*, Yetani::KeyboardEvent>;
1598 struct wl_surface* wl_surface =
nullptr;
1599 Yetani::KeyboardEvent*
event =
nullptr;
1600 Yetani::MapKeyboardEvent event_map = {};
1601 Yetani::KeyModifier modifier = {};
1602 Yetani::KeyRepeatMap repeat_map = {};
1603 char* keymap =
nullptr;
1604 uint32_t keymap_size = 0;
1605 int32_t repeat_delay = 0;
1606 int32_t repeat_rate = 0;
1609 Yetani::Keyboard keyboard;
1613 static void keyboardDestroy(Yetani::Keyboard&) noexcept;
1614 static void keyboardRepeat(Yetani::Keyboard&) noexcept;
1615 static void keyboardRepeatAdd(Yetani::Keyboard&, uint32_t, uint32_t) noexcept;
1616 static void keyboardRepeatReleaseAll(Yetani::Keyboard&) noexcept;
1617 static void keyboardRepeatRemove(Yetani::Keyboard&, uint32_t) noexcept;
1640 using MapPointerEvent = std::unordered_map<struct wl_surface*, Yetani::PointerEvent>;
1647 Yetani* yetani =
nullptr;
1648 struct wl_surface* wl_surface =
nullptr;
1649 struct wl_pointer* wl_pointer =
nullptr;
1650 Yetani::PointerEvent*
event =
nullptr;
1651 Yetani::MapPointerEvent event_map = {};
1654 Yetani::PointMm point_mm = {};
1655 Yetani::PointPercent point_percent = {};
1656 Yetani::PointPixel point_pixel = {};
1659 Yetani::PointerAxis axis = {};
1662 Yetani::PointerButton button = {};
1663 uint32_t button_event_code = 0;
1664 bool button_is_pressed =
false;
1665 uint32_t button_time = {};
1668 struct wl_surface* enter_surface =
nullptr;
1669 Yetani::PointPixel enter_point = {};
1670 uint32_t enter_serial = 0;
1673 struct wl_surface* leave_surface =
nullptr;
1676 Yetani::PointPixel motion_point = {};
1679 Yetani::Pointer pointer;
1683 static void pointerClear(
struct Pointer&) noexcept;
1688 enum struct OutputState
1696 using VectorWlOutput = std::vector<struct wl_output*>;
1698 using MapWlOutputOutputState = std::unordered_map<struct wl_output*, Yetani::OutputState>;
1699 using MapOutputIdWlOutput = std::unordered_map<Yetani::OutputId, struct wl_output*>;
1700 using MapWlOutputOutputId = std::unordered_map<struct wl_output*, Yetani::OutputId>;
1701 using MapWlSurfaceVectorWlOutput = std::unordered_map<struct wl_surface*, Yetani::VectorWlOutput>;
1702 using MapWlOutputOutput = std::unordered_map<struct wl_output*, Output>;
1708 Yetani::MapWlSurfaceVectorWlOutput surface_output_map = {};
1709 Yetani::MapOutputIdWlOutput outputid_to_wloutput = {};
1710 Yetani::MapWlOutputOutput output_map = {};
1711 Yetani::MapWlOutputOutputId wloutput_to_outputid = {};
1712 mutable std::mutex mutex = {};
1715 Yetani::OutputData output_data;
1719 Yetani::LambdaOutputId on_output_add;
1720 Yetani::LambdaOutputId on_output_change;
1721 Yetani::LambdaOutputId on_output_remove;
1723 Yetani::MapWlOutputOutput output_changes_map;
1724 Yetani::MapWlOutputOutputState output_state_map;
1726 Yetani::VectorWlSurface output_notify_surface_vector;
1730 void convertPixel(
struct wl_surface*,
const int32_t,
const int32_t,
float&,
float&,
float&,
float&)
const noexcept;
1732 std::pair<float, float> convertPixelToMm(
const Yetani::Output&, int32_t, int32_t)
const noexcept;
1733 std::pair<float, float> convertPixelToPercent(
const Yetani::Output&, int32_t, int32_t)
const noexcept;
1734 std::pair<int32_t, int32_t> convertMmToPixel(
const Yetani::Output&,
float,
float)
const noexcept;
1735 std::pair<int32_t, int32_t> convertPercentToPixel(
const Yetani::Output&,
float,
float)
const noexcept;
1737 static void outputNotifySurface(Yetani*,
struct wl_output*,
struct wl_surface*) noexcept;
1746 MemoryPool* memory_pool =
nullptr;
1750 using MapBufferData = std::unordered_map<struct wl_buffer*, BufferData>;
1756 MapBufferData map = {};
1757 std::mutex mutex = {};
1764 static wl_buffer* bufferCreate(Yetani::SurfaceSize&, Yetani::Window::Memory*, Yetani::Buffer*) noexcept;
1765 static void bufferDestroy(
struct wl_buffer*&) noexcept;
1777 using MapSurfaceEvent = std::map<struct wl_surface*, Yetani::SurfaceEvent>;
1779 MapSurfaceEvent surface_event_map;
1783 enum struct SizeUnit
1791 struct SurfaceExtent
1793 Yetani::SizeUnit preferred_unit = {};
1794 Yetani::SizeMm preferred_mm = {};
1795 Yetani::SizePercent preferred_percent = {};
1796 Yetani::SizeMm size_mm = {};
1797 Yetani::SizePercent size_percent = {};
1798 Yetani::SizePixel size_pixel = {};
1799 Yetani::SizePixel size_pixel_max = {};
1800 Yetani::SizePixel size_pixel_min = {};
1803 using MapSurfaceExtent = std::unordered_map<struct wl_surface*, Yetani::SurfaceExtent>;
1805 MapSurfaceExtent surface_extent_map;
1806 std::mutex surface_extent_mutex;
1812 struct wl_surface* wl_surface =
nullptr;
1813 std::atomic<wl_buffer*> buffer_next = {};
1815 uint32_t height = 0;
1816 uint32_t time_ms = 0;
1819 using MapSurfaceFrame = std::unordered_map<struct wl_surface*, Yetani::SurfaceFrame>;
1821 MapSurfaceFrame surface_frame_map;
1831 wl_shm_format pixel_format;
1832 uint8_t bytes_per_pixel;
1835 using MapSurfaceSize = std::unordered_map<struct wl_surface*, Yetani::SurfaceSize>;
1837 MapSurfaceSize surface_size_map;
1841 using MapSurfaceResizeMutex = std::unordered_map<struct wl_surface*, std::mutex>;
1843 MapSurfaceResizeMutex surface_resize_mutex_map;
1847 static void surfaceCalculateSize(Yetani*,
struct wl_surface*,
const Yetani::SizePixel&) noexcept;
1848 static struct wl_surface* surfaceCreate(Yetani*,
const wl_shm_format,
const Yetani::SizePixel&, Yetani::Window::Memory&) noexcept;
1849 static void surfaceDestroy(Yetani*,
struct wl_surface*&) noexcept;
1857 struct wl_shm* wl_shm;
1858 struct wl_output* wl_output;
1859 std::string file_name;
1860 Yetani::SizeMm size_mm;
1861 Yetani::SizePercent size_percent;
1862 Yetani::SizePixel size_pixel;
1863 Yetani::SizeUnit size_unit;
1864 wl_shm_format pixel_format;
1865 std::error_code error;
1870 Yetani::Window*
windowCreate(
const Yetani::SizeUnit,
const Yetani::SizeMm&,
const Yetani::SizePercent&,
const Yetani::SizePixel&,
const wl_shm_format, std::error_code&) noexcept;
1871 void windowDataInit(Yetani::WindowData&) noexcept;
1872 void windowDataInitOutput(Yetani::WindowData&) noexcept;
1873 void windowInitMemory(Yetani::WindowData&, Yetani::Window::Memory&) noexcept;
1874 void windowInitOutput(Yetani::WindowData&,
struct wl_surface*) noexcept;
1875 void windowEraseMemory(Yetani::Window::Memory&) noexcept;
1876 void windowEraseOutput(
struct wl_surface*) noexcept;
1877 void windowEraseSurfaceExtent(
struct wl_surface*) noexcept;
1882 std::vector<Yetani::Window*> window_vector;
1883 std::mutex window_vector_mutex;
1887 void windowAdd(Yetani::Window*) noexcept;
1888 void windowRemove(Yetani::Window*) noexcept;
1893 enum XdgState : int32_t
1895 , Toplevel_Active = 1
1896 , Toplevel_Attach_Buffer = 2
1897 , Toplevel_Resizing = 3
1898 , Toplevel_Window_Fullscreen = 4
1899 , Toplevel_Window_Maximized = 5
1900 , Toplevel_Window_Normal = 6
1901 , Toplevel_Decoration = 7
1904 using VectorXdgStateChange = std::vector<int32_t>;
1905 using MapXdgStateChange = std::unordered_map<struct xdg_surface*, Yetani::VectorXdgStateChange>;
1907 Yetani::MapXdgStateChange xdg_state_change_map;
1908 std::mutex xdg_state_change_mutex;
1912 struct xdg_wm_base* xdg_wm_base;
1924 Yetani* yetani =
nullptr;
1925 struct wl_surface* wl_surface =
nullptr;
1928 using MapXdgSurface = std::unordered_map<struct wl_surface*, Yetani::XdgSurface>;
1930 Yetani::MapXdgSurface xdg_surface_map;
1934 struct xdg_surface* xdgSurfaceCreate(
struct wl_surface*) noexcept;
1935 void xdgSurfaceDestroy(
struct wl_surface*,
struct xdg_surface*&) noexcept;
1936 void xdgSurfaceSetExtent(
struct wl_surface*,
const Yetani::SizeUnit&,
const Yetani::SizeMm&,
const Yetani::SizePercent&,
const Yetani::SizePixel&) noexcept;
1943 Yetani::VectorXdgStateChange* state_change =
nullptr;
1946 bool is_active =
false;
1947 Yetani::XdgState window_state = XdgState::Unknown;
1949 Yetani::SizePixel previous_size = {};
1950 struct xdg_toplevel* xdg_toplevel =
nullptr;
1953 using MapXdgToplevel = std::unordered_map<struct xdg_surface*, Yetani::XdgToplevel>;
1955 MapXdgToplevel xdg_toplevel_map;
1959 struct xdg_toplevel* xdgToplevelCreate(
struct xdg_surface*) noexcept;
1960 void xdgToplevelDestroy(
struct xdg_surface*,
struct xdg_toplevel*&) noexcept;
1961 static void xdgToplevelSizeChange(Yetani*,
struct wl_surface*,
const Yetani::SizePixel&) noexcept;
1962 static void xdgToplevelSizeMinMaxChange(Yetani*,
struct xdg_toplevel*,
struct wl_surface*,
const Yetani::SizePixel&,
const Yetani::SizePixel&) noexcept;
1963 static void xdgToplevelWindowChange(Yetani*,
struct wl_surface*, Yetani::XdgToplevel&,
const Yetani::XdgState,
const Yetani::SizePixel&) noexcept;
1968 struct XdgDecoration
1970 Yetani::VectorXdgStateChange* state_change =
nullptr;
1973 bool is_present =
false;
1977 using MapXdgDecoration = std::unordered_map<struct xdg_surface*, Yetani::XdgDecoration>;
1979 MapXdgDecoration xdg_decoration_map;
1983 struct zxdg_decoration_manager_v1* decoration_manager;
1987 struct zxdg_toplevel_decoration_v1* xdgDecorationCreate(
struct xdg_surface*,
struct xdg_toplevel*) noexcept;
1988 void xdgDecorationDestroy(
struct xdg_surface*,
struct xdg_toplevel*,
struct zxdg_toplevel_decoration_v1*&) noexcept;
1989 static void xdgDecorationChange(Yetani::XdgDecoration&,
const uint32_t) noexcept;
1994 static struct wl_buffer_listener buffer_listener;
1995 static struct wl_callback_listener frame_callback_listener;
1996 static struct wl_keyboard_listener keyboard_listener;
1997 static struct wl_output_listener output_listener;
1998 static struct wl_pointer_listener pointer_listener;
1999 static struct wl_registry_listener registry_listener;
2000 static struct wl_seat_listener seat_listener;
2001 static struct wl_shm_listener shm_listener;
2002 static struct wl_surface_listener surface_listener;
2006 static void handlerBufferRelease(
void*,
struct wl_buffer*) noexcept;
2008 static void handlerKeyboardEnter(
void*,
struct wl_keyboard*, uint32_t,
struct wl_surface*,
struct wl_array*) noexcept;
2009 static void handlerKeyboardKey(
void*,
struct wl_keyboard*, uint32_t, uint32_t, uint32_t, uint32_t) noexcept;
2010 static void handlerKeyboardKeymap(
void*,
struct wl_keyboard*, uint32_t, int32_t, uint32_t) noexcept;
2011 static void handlerKeyboardLeave(
void*,
struct wl_keyboard*, uint32_t,
struct wl_surface*) noexcept;
2012 static void handlerKeyboardModifiers(
void*,
struct wl_keyboard*, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t) noexcept;
2013 static void handlerKeyboardRepeatInfo(
void*,
struct wl_keyboard*, int32_t, int32_t) noexcept;
2015 static void handlerOutputDone(
void*,
struct wl_output*) noexcept;
2016 static void handlerOutputGeometry(
void*,
struct wl_output*, int32_t, int32_t, int32_t, int32_t, int32_t,
const char*,
const char*, int32_t) noexcept;
2017 static void handlerOutputMode(
void*,
struct wl_output*, uint32_t, int32_t, int32_t, int32_t) noexcept;
2018 static void handlerOutputScale(
void*,
struct wl_output*, int32_t) noexcept;
2019 static void handlerPointerAxis(
void*,
struct wl_pointer*, uint32_t, uint32_t, wl_fixed_t) noexcept;
2020 static void handlerPointerAxisDiscrete(
void*,
struct wl_pointer*, uint32_t, int32_t) noexcept;
2021 static void handlerPointerAxisSource(
void*,
struct wl_pointer*, uint32_t) noexcept;
2022 static void handlerPointerAxisStop(
void*,
struct wl_pointer*, uint32_t, uint32_t) noexcept;
2023 static void handlerPointerButton(
void*,
struct wl_pointer*, uint32_t, uint32_t, uint32_t, uint32_t) noexcept;
2024 static void handlerPointerEnter(
void*,
struct wl_pointer*, uint32_t,
struct wl_surface*, wl_fixed_t, wl_fixed_t) noexcept;
2025 static void handlerPointerFrame(
void*,
struct wl_pointer*) noexcept;
2026 static void handlerPointerLeave(
void*,
struct wl_pointer*, uint32_t,
struct wl_surface*) noexcept;
2027 static void handlerPointerMotion(
void*,
struct wl_pointer*, uint32_t, wl_fixed_t, wl_fixed_t) noexcept;
2028 static void handlerRegistryGlobal(
void*,
struct wl_registry*, uint32_t,
const char*, uint32_t) noexcept;
2029 static void handlerRegistryRemove(
void*,
struct wl_registry*, uint32_t) noexcept;
2030 static void handlerSeatCapabilities(
void*,
struct wl_seat*, uint32_t) noexcept;
2031 static void handlerSeatName(
void*,
struct wl_seat*,
const char*) noexcept;
2032 static void handlerShmFormat(
void*,
struct wl_shm*, uint32_t) noexcept;
2033 static void handlerSurfaceEnter(
void*,
struct wl_surface*,
struct wl_output*) noexcept;
2034 static void handlerSurfaceLeave(
void*,
struct wl_surface*,
struct wl_output*) noexcept;
2035 static void handlerSwapBuffers(
void*,
struct wl_callback*, uint32_t) noexcept;
2042 static struct xdg_wm_base_listener xdg_wm_base_listener;
2043 static struct xdg_surface_listener xdg_surface_listener;
2044 static struct xdg_toplevel_listener xdg_toplevel_listener;
2048 static void handlerXdgSurfaceConfigure(
void*,
struct xdg_surface*, uint32_t) noexcept;
2049 static void handlerXdgToplevelClose(
void*,
struct xdg_toplevel*) noexcept;
2050 static void handlerXdgToplevelConfigure(
void*,
struct xdg_toplevel*, int32_t, int32_t,
struct wl_array*) noexcept;
2051 static void handlerXdgWmBasePing(
void*,
struct xdg_wm_base*, uint32_t) noexcept;
2056 static struct zxdg_toplevel_decoration_v1_listener xdg_toplevel_decoration_listener;
2060 static void handlerXdgToplevelDecorationConfigure(
void*,
struct zxdg_toplevel_decoration_v1*, uint32_t mode) noexcept;
2064 Yetani(
const Yetani&) =
delete;
2065 Yetani& operator=(
const Yetani&) =
delete;
2071 std::string
to_string(
const wl_shm_format&) noexcept;
2072 std::string
to_string(
const std::error_code&) noexcept;
2073 std::string
to_string(
const Yetani::Key&) noexcept;
2074 std::string
to_string(
const Yetani::KeyModifier&) noexcept;
2076 std::string
to_string(
const Yetani::Output&) noexcept;
2077 std::string
to_string(
const Yetani::PointMm&) noexcept;
2078 std::string
to_string(
const Yetani::PointPercent&) noexcept;
2079 std::string
to_string(
const Yetani::PointPixel&) noexcept;
2080 std::string
to_string(
const Yetani::PointerAxis&) noexcept;
2091 #ifdef ZAKERO_YETANI_IMPLEMENTATION
2097 #ifdef ZAKERO__DOXYGEN_DEFINE_DOCS
2112 #define ZAKERO_YETANI_IMPLEMENTATION
2122 #define ZAKERO_YETANI_ENABLE_DEBUG
2132 #define ZAKERO_YETANI_ENABLE_SAFE_MODE
2153 #ifdef ZAKERO_YETANI_ENABLE_DEBUG
2154 #define ZAKERO_YETANI__DEBUG_DISABLED false
2156 #define ZAKERO_YETANI__DEBUG_DISABLED true
2172 #ifndef ZAKERO_YETANI_ENABLE_DEBUG_STREAM
2173 #define ZAKERO_YETANI_ENABLE_DEBUG_STREAM std::cerr
2194 #define ZAKERO_YETANI__DEBUG \
2195 if(ZAKERO_YETANI__DEBUG_DISABLED) {} \
2196 else ZAKERO_YETANI_ENABLE_DEBUG_STREAM \
2198 << std::to_string(__LINE__) \
2200 << __PRETTY_FUNCTION__ \
2219 #define ZAKERO_YETANI__DEBUG_VAR(var_) \
2220 ZAKERO_YETANI__DEBUG \
2221 << #var_ << ": " << var_ \
2239 #define ZAKERO_YETANI__DEBUG_BOOL(var_) \
2240 ZAKERO_YETANI__DEBUG \
2241 << #var_ << ": " << std::boolalpha << var_ \
2254 #define ZAKERO_YETANI__ERROR(err_) std::error_code(err_, YetaniErrorCategory)
2273 #define ZAKERO_YETANI__SHM_FORMAT \
2274 X(WL_SHM_FORMAT_ARGB8888 , 4 , "32-bit ARGB format, [31:0] A:R:G:B 8:8:8:8 little endian" ) \
2275 X(WL_SHM_FORMAT_XRGB8888 , 4 , "32-bit RGB format, [31:0] x:R:G:B 8:8:8:8 little endian" ) \
2276 X(WL_SHM_FORMAT_C8 , 1 , "8-bit color index format, [7:0] C" ) \
2277 X(WL_SHM_FORMAT_RGB332 , 1 , "8-bit RGB format, [7:0] R:G:B 3:3:2" ) \
2278 X(WL_SHM_FORMAT_BGR233 , 1 , "8-bit BGR format, [7:0] B:G:R 2:3:3" ) \
2279 X(WL_SHM_FORMAT_XRGB4444 , 2 , "16-bit xRGB format, [15:0] x:R:G:B 4:4:4:4 little endian" ) \
2280 X(WL_SHM_FORMAT_XBGR4444 , 2 , "16-bit xBGR format, [15:0] x:B:G:R 4:4:4:4 little endian" ) \
2281 X(WL_SHM_FORMAT_RGBX4444 , 2 , "16-bit RGBx format, [15:0] R:G:B:x 4:4:4:4 little endian" ) \
2282 X(WL_SHM_FORMAT_BGRX4444 , 2 , "16-bit BGRx format, [15:0] B:G:R:x 4:4:4:4 little endian" ) \
2283 X(WL_SHM_FORMAT_ARGB4444 , 2 , "16-bit ARGB format, [15:0] A:R:G:B 4:4:4:4 little endian" ) \
2284 X(WL_SHM_FORMAT_ABGR4444 , 2 , "16-bit ABGR format, [15:0] A:B:G:R 4:4:4:4 little endian" ) \
2285 X(WL_SHM_FORMAT_RGBA4444 , 2 , "16-bit RBGA format, [15:0] R:G:B:A 4:4:4:4 little endian" ) \
2286 X(WL_SHM_FORMAT_BGRA4444 , 2 , "16-bit BGRA format, [15:0] B:G:R:A 4:4:4:4 little endian" ) \
2287 X(WL_SHM_FORMAT_XRGB1555 , 2 , "16-bit xRGB format, [15:0] x:R:G:B 1:5:5:5 little endian" ) \
2288 X(WL_SHM_FORMAT_XBGR1555 , 2 , "16-bit xBGR 1555 format, [15:0] x:B:G:R 1:5:5:5 little endian" ) \
2289 X(WL_SHM_FORMAT_RGBX5551 , 2 , "16-bit RGBx 5551 format, [15:0] R:G:B:x 5:5:5:1 little endian" ) \
2290 X(WL_SHM_FORMAT_BGRX5551 , 2 , "16-bit BGRx 5551 format, [15:0] B:G:R:x 5:5:5:1 little endian" ) \
2291 X(WL_SHM_FORMAT_ARGB1555 , 2 , "16-bit ARGB 1555 format, [15:0] A:R:G:B 1:5:5:5 little endian" ) \
2292 X(WL_SHM_FORMAT_ABGR1555 , 2 , "16-bit ABGR 1555 format, [15:0] A:B:G:R 1:5:5:5 little endian" ) \
2293 X(WL_SHM_FORMAT_RGBA5551 , 2 , "16-bit RGBA 5551 format, [15:0] R:G:B:A 5:5:5:1 little endian" ) \
2294 X(WL_SHM_FORMAT_BGRA5551 , 2 , "16-bit BGRA 5551 format, [15:0] B:G:R:A 5:5:5:1 little endian" ) \
2295 X(WL_SHM_FORMAT_RGB565 , 2 , "16-bit RGB 565 format, [15:0] R:G:B 5:6:5 little endian" ) \
2296 X(WL_SHM_FORMAT_BGR565 , 2 , "16-bit BGR 565 format, [15:0] B:G:R 5:6:5 little endian" ) \
2297 X(WL_SHM_FORMAT_RGB888 , 3 , "24-bit RGB format, [23:0] R:G:B little endian" ) \
2298 X(WL_SHM_FORMAT_BGR888 , 3 , "24-bit BGR format, [23:0] B:G:R little endian" ) \
2299 X(WL_SHM_FORMAT_XBGR8888 , 4 , "32-bit xBGR format, [31:0] x:B:G:R 8:8:8:8 little endian" ) \
2300 X(WL_SHM_FORMAT_RGBX8888 , 4 , "32-bit RGBx format, [31:0] R:G:B:x 8:8:8:8 little endian" ) \
2301 X(WL_SHM_FORMAT_BGRX8888 , 4 , "32-bit BGRx format, [31:0] B:G:R:x 8:8:8:8 little endian" ) \
2302 X(WL_SHM_FORMAT_ABGR8888 , 4 , "32-bit ABGR format, [31:0] A:B:G:R 8:8:8:8 little endian" ) \
2303 X(WL_SHM_FORMAT_RGBA8888 , 4 , "32-bit RGBA format, [31:0] R:G:B:A 8:8:8:8 little endian" ) \
2304 X(WL_SHM_FORMAT_BGRA8888 , 4 , "32-bit BGRA format, [31:0] B:G:R:A 8:8:8:8 little endian" ) \
2305 X(WL_SHM_FORMAT_XRGB2101010 , 4 , "32-bit xRGB format, [31:0] x:R:G:B 2:10:10:10 little endian" ) \
2306 X(WL_SHM_FORMAT_XBGR2101010 , 4 , "32-bit xBGR format, [31:0] x:B:G:R 2:10:10:10 little endian" ) \
2307 X(WL_SHM_FORMAT_RGBX1010102 , 4 , "32-bit RGBx format, [31:0] R:G:B:x 10:10:10:2 little endian" ) \
2308 X(WL_SHM_FORMAT_BGRX1010102 , 4 , "32-bit BGRx format, [31:0] B:G:R:x 10:10:10:2 little endian" ) \
2309 X(WL_SHM_FORMAT_ARGB2101010 , 4 , "32-bit ARGB format, [31:0] A:R:G:B 2:10:10:10 little endian" ) \
2310 X(WL_SHM_FORMAT_ABGR2101010 , 4 , "32-bit ABGR format, [31:0] A:B:G:R 2:10:10:10 little endian" ) \
2311 X(WL_SHM_FORMAT_RGBA1010102 , 4 , "32-bit RGBA format, [31:0] R:G:B:A 10:10:10:2 little endian" ) \
2312 X(WL_SHM_FORMAT_BGRA1010102 , 4 , "32-bit BGRA format, [31:0] B:G:R:A 10:10:10:2 little endian" ) \
2313 X(WL_SHM_FORMAT_YUYV , 4 , "packed YCbCr format, [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian" ) \
2314 X(WL_SHM_FORMAT_YVYU , 4 , "packed YCbCr format, [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian" ) \
2315 X(WL_SHM_FORMAT_UYVY , 4 , "packed YCbCr format, [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian" ) \
2316 X(WL_SHM_FORMAT_VYUY , 4 , "packed YCbCr format, [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian" ) \
2317 X(WL_SHM_FORMAT_AYUV , 4 , "packed AYCbCr format, [31:0] A:Y:Cb:Cr 8:8:8:8 little endian" ) \
2318 X(WL_SHM_FORMAT_NV12 , 8 , "2 plane YCbCr Cr:Cb format, 2x2 subsampled Cr:Cb plane" ) \
2319 X(WL_SHM_FORMAT_NV21 , 8 , "2 plane YCbCr Cb:Cr format, 2x2 subsampled Cb:Cr plane" ) \
2320 X(WL_SHM_FORMAT_NV16 , 8 , "2 plane YCbCr Cr:Cb format, 2x1 subsampled Cr:Cb plane" ) \
2321 X(WL_SHM_FORMAT_NV61 , 8 , "2 plane YCbCr Cb:Cr format, 2x1 subsampled Cb:Cr plane" ) \
2322 X(WL_SHM_FORMAT_YUV410 , 8 , "3 plane YCbCr format, 4x4 subsampled Cb (1) and Cr (2) planes" ) \
2323 X(WL_SHM_FORMAT_YVU410 , 8 , "3 plane YCbCr format, 4x4 subsampled Cr (1) and Cb (2) planes" ) \
2324 X(WL_SHM_FORMAT_YUV411 , 8 , "3 plane YCbCr format, 4x1 subsampled Cb (1) and Cr (2) planes" ) \
2325 X(WL_SHM_FORMAT_YVU411 , 8 , "3 plane YCbCr format, 4x1 subsampled Cr (1) and Cb (2) planes" ) \
2326 X(WL_SHM_FORMAT_YUV420 , 8 , "3 plane YCbCr format, 2x2 subsampled Cb (1) and Cr (2) planes" ) \
2327 X(WL_SHM_FORMAT_YVU420 , 8 , "3 plane YCbCr format, 2x2 subsampled Cr (1) and Cb (2) planes" ) \
2328 X(WL_SHM_FORMAT_YUV422 , 8 , "3 plane YCbCr format, 2x1 subsampled Cb (1) and Cr (2) planes" ) \
2329 X(WL_SHM_FORMAT_YVU422 , 8 , "3 plane YCbCr format, 2x1 subsampled Cr (1) and Cb (2) planes" ) \
2330 X(WL_SHM_FORMAT_YUV444 , 8 , "3 plane YCbCr format, non-subsampled Cb (1) and Cr (2) planes" ) \
2331 X(WL_SHM_FORMAT_YVU444 , 8 , "3 plane YCbCr format, non-subsampled Cr (1) and Cb (2) planes" ) \
2332 X(WL_SHM_FORMAT_R8 , 1 , "[7:0] R" ) \
2333 X(WL_SHM_FORMAT_R16 , 2 , "[15:0] R little endian" ) \
2334 X(WL_SHM_FORMAT_RG88 , 2 , "[15:0] R:G 8:8 little endian" ) \
2335 X(WL_SHM_FORMAT_GR88 , 2 , "[15:0] G:R 8:8 little endian" ) \
2336 X(WL_SHM_FORMAT_RG1616 , 4 , "[31:0] R:G 16:16 little endian" ) \
2337 X(WL_SHM_FORMAT_GR1616 , 4 , "[31:0] G:R 16:16 little endian" ) \
2338 X(WL_SHM_FORMAT_XRGB16161616F , 8 , "[63:0] x:R:G:B 16:16:16:16 little endian" ) \
2339 X(WL_SHM_FORMAT_XBGR16161616F , 8 , "[63:0] x:B:G:R 16:16:16:16 little endian" ) \
2340 X(WL_SHM_FORMAT_ARGB16161616F , 8 , "[63:0] A:R:G:B 16:16:16:16 little endian" ) \
2341 X(WL_SHM_FORMAT_ABGR16161616F , 8 , "[63:0] A:B:G:R 16:16:16:16 little endian" ) \
2342 X(WL_SHM_FORMAT_XYUV8888 , 4 , "[31:0] X:Y:Cb:Cr 8:8:8:8 little endian" ) \
2343 X(WL_SHM_FORMAT_VUY888 , 3 , "[23:0] Cr:Cb:Y 8:8:8 little endian" ) \
2344 X(WL_SHM_FORMAT_VUY101010 , 4 , "Y followed by U then V, 10:10:10. Non-linear modifier only" ) \
2345 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" ) \
2346 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" ) \
2347 X(WL_SHM_FORMAT_Y216 , 8 , "[63:0] Cr0:Y1:Cb0:Y0 16:16:16:16 little endian per 2 Y pixels" ) \
2348 X(WL_SHM_FORMAT_Y410 , 4 , "[31:0] A:Cr:Y:Cb 2:10:10:10 little endian" ) \
2349 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" ) \
2350 X(WL_SHM_FORMAT_Y416 , 8 , "[63:0] A:Cr:Y:Cb 16:16:16:16 little endian" ) \
2351 X(WL_SHM_FORMAT_XVYU2101010 , 4 , "[31:0] X:Cr:Y:Cb 2:10:10:10 little endian" ) \
2352 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" ) \
2353 X(WL_SHM_FORMAT_XVYU16161616 , 8 , "[63:0] X:Cr:Y:Cb 16:16:16:16 little endian" ) \
2354 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" ) \
2355 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" ) \
2356 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" ) \
2357 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" ) \
2358 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" ) \
2359 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" ) \
2360 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" ) \
2361 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" ) \
2362 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" ) \
2363 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" ) \
2364 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" ) \
2365 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" ) \
2366 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" ) \
2367 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" ) \
2368 X(WL_SHM_FORMAT_NV24 , 0 , "[UNKNOWN SIZE] non-subsampled Cr:Cb plane" ) \
2369 X(WL_SHM_FORMAT_NV42 , 0 , "[UNKNOWN SIZE] non-subsampled Cb:Cr plane" ) \
2370 X(WL_SHM_FORMAT_P210 , 0 , "[UNKNOWN SIZE] 2x1 subsampled Cr:Cb plane, 10 bits per channel" ) \
2371 X(WL_SHM_FORMAT_P010 , 0 , "[UNKNOWN SIZE] 2x2 subsampled Cr:Cb plane, 10 bits per channel" ) \
2372 X(WL_SHM_FORMAT_P012 , 0 , "[UNKNOWN SIZE] 2x2 subsampled Cr:Cb plane, 12 bits per channel" ) \
2373 X(WL_SHM_FORMAT_P016 , 0 , "[UNKNOWN SIZE] 2x2 subsampled Cr:Cb plane, 16 bits per channel" ) \
2381 #define ZAKERO_YETANI__OUTPUT_SUBPIXEL \
2382 X(WL_OUTPUT_SUBPIXEL_UNKNOWN , "Unkown Subpixel Format" ) \
2383 X(WL_OUTPUT_SUBPIXEL_NONE , "No Subpixels" ) \
2384 X(WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB , "Horizontal RGB" ) \
2385 X(WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR , "Horizontal BGR" ) \
2386 X(WL_OUTPUT_SUBPIXEL_VERTICAL_RGB , "Vertical RGB" ) \
2387 X(WL_OUTPUT_SUBPIXEL_VERTICAL_BGR , "Vertical BGR" ) \
2395 #define ZAKERO_YETANI__OUTPUT_TRANSFORM \
2396 X(WL_OUTPUT_TRANSFORM_NORMAL , "No Transform" ) \
2397 X(WL_OUTPUT_TRANSFORM_90 , "90 degrees Counter-Clockwise" ) \
2398 X(WL_OUTPUT_TRANSFORM_180 , "180 degrees Counter-Clockwise" ) \
2399 X(WL_OUTPUT_TRANSFORM_270 , "270 degrees Counter-Clockwise" ) \
2400 X(WL_OUTPUT_TRANSFORM_FLIPPED , "180 degree flip around a vertical axis" ) \
2401 X(WL_OUTPUT_TRANSFORM_FLIPPED_90 , "Flig and rotate 90 degrees counter-clockwise" ) \
2402 X(WL_OUTPUT_TRANSFORM_FLIPPED_180 , "Flig and rotate 180 degrees counter-clockwise" ) \
2428 #define ZAKERO_YETANI__ARRAY_FOR_EACH(type_, pos_, array_) \
2429 for(type_ pos_ = (type_)(array_)->data \
2430 ; (const char*)pos_ < ((const char*)(array_)->data + (array_)->size) \
2594 class YetaniErrorCategory_
2595 :
public std::error_category
2598 constexpr YetaniErrorCategory_() noexcept
2602 const char* name()
const noexcept
override
2604 return "zakero.Yetani";
2607 std::string message(
int condition
2608 )
const noexcept
override
2612 #define X(name_, val_, mesg_) \
2613 case val_: return mesg_;
2614 ZAKERO_YETANI__ERROR_DATA
2618 return "Unknown error condition";
2620 } YetaniErrorCategory;
2628 Yetani::LambdaKey LambdaKey_DoNothing = [](
const Yetani::Key&,
const Yetani::KeyModifier&) noexcept {};
2629 Yetani::LambdaAxis LambdaAxis_DoNothing = [](
const Yetani::PointerAxis&,
const Yetani::KeyModifier&) noexcept {};
2630 Yetani::LambdaButtonMm LambdaButtonMm_DoNothing = [](
const Yetani::PointerButton&,
const Yetani::PointMm&,
const Yetani::KeyModifier&) noexcept {};
2631 Yetani::LambdaButtonPercent LambdaButtonPercent_DoNothing = [](
const Yetani::PointerButton&,
const Yetani::PointPercent&,
const Yetani::KeyModifier&) noexcept {};
2632 Yetani::LambdaButtonPixel LambdaButtonPixel_DoNothing = [](
const Yetani::PointerButton&,
const Yetani::PointPixel&,
const Yetani::KeyModifier&) noexcept {};
2633 Yetani::LambdaPointMm LambdaPointMm_DoNothing = [](
const Yetani::PointMm&,
const Yetani::KeyModifier&) noexcept {};
2634 Yetani::LambdaPointPercent LambdaPointPercent_DoNothing = [](
const Yetani::PointPercent&,
const Yetani::KeyModifier&) noexcept {};
2635 Yetani::LambdaPointPixel LambdaPointPixel_DoNothing = [](
const Yetani::PointPixel&,
const Yetani::KeyModifier&) noexcept {};
2637 Yetani::LambdaOutputId LambdaOutputId_DoNothing = [](
const Yetani::OutputId) noexcept {};
2660 inline size_t sizeInBytes(
const Yetani::SizePixel& size
2661 ,
const wl_shm_format format
2686 std::error_code validateMinMax(
const Type& min
2696 return ZAKERO_YETANI__ERROR(Yetani::Error_Window_Size_Too_Small);
2701 && (min.width > max.width)
2704 return ZAKERO_YETANI__ERROR(Yetani::Error_Minimum_Size_Greater_Than_Maximum_Size);
2709 && (min.height > max.height)
2712 return ZAKERO_YETANI__ERROR(Yetani::Error_Minimum_Size_Greater_Than_Maximum_Size);
2715 return ZAKERO_YETANI__ERROR(Yetani::Error_None);
3129 struct wl_buffer_listener Yetani::buffer_listener =
3130 { .release = &Yetani::handlerBufferRelease
3133 struct wl_callback_listener Yetani::frame_callback_listener =
3134 { .done = &Yetani::handlerSwapBuffers
3137 struct wl_keyboard_listener Yetani::keyboard_listener =
3138 { .keymap = &Yetani::handlerKeyboardKeymap
3139 , .enter = &Yetani::handlerKeyboardEnter
3140 , .leave = &Yetani::handlerKeyboardLeave
3141 , .key = &Yetani::handlerKeyboardKey
3142 , .modifiers = &Yetani::handlerKeyboardModifiers
3143 , .repeat_info = &Yetani::handlerKeyboardRepeatInfo
3146 struct wl_output_listener Yetani::output_listener =
3147 { .geometry = &Yetani::handlerOutputGeometry
3148 , .mode = &Yetani::handlerOutputMode
3149 , .done = &Yetani::handlerOutputDone
3150 , .scale = &Yetani::handlerOutputScale
3153 struct wl_pointer_listener Yetani::pointer_listener =
3154 { .enter = &Yetani::handlerPointerEnter
3155 , .leave = &Yetani::handlerPointerLeave
3156 , .motion = &Yetani::handlerPointerMotion
3157 , .button = &Yetani::handlerPointerButton
3158 , .axis = &Yetani::handlerPointerAxis
3159 , .frame = &Yetani::handlerPointerFrame
3160 , .axis_source = &Yetani::handlerPointerAxisSource
3161 , .axis_stop = &Yetani::handlerPointerAxisStop
3162 , .axis_discrete = &Yetani::handlerPointerAxisDiscrete
3165 struct wl_registry_listener Yetani::registry_listener =
3166 { .global = &Yetani::handlerRegistryGlobal
3167 , .global_remove = &Yetani::handlerRegistryRemove
3170 struct wl_seat_listener Yetani::seat_listener =
3171 { .capabilities = &Yetani::handlerSeatCapabilities
3172 , .name = &Yetani::handlerSeatName
3175 struct wl_shm_listener Yetani::shm_listener =
3176 { .format = &Yetani::handlerShmFormat
3179 struct wl_surface_listener Yetani::surface_listener =
3180 { .enter = &Yetani::handlerSurfaceEnter
3181 , .leave = &Yetani::handlerSurfaceLeave
3189 struct xdg_wm_base_listener Yetani::xdg_wm_base_listener =
3190 { .ping = &Yetani::handlerXdgWmBasePing
3193 struct xdg_surface_listener Yetani::xdg_surface_listener =
3194 { .configure = &Yetani::handlerXdgSurfaceConfigure
3197 struct xdg_toplevel_listener Yetani::xdg_toplevel_listener =
3198 { .configure = &Yetani::handlerXdgToplevelConfigure
3199 , .close = &Yetani::handlerXdgToplevelClose
3205 struct zxdg_toplevel_decoration_v1_listener Yetani::xdg_toplevel_decoration_listener =
3206 { .configure = &Yetani::handlerXdgToplevelDecorationConfigure
3218 Yetani::Yetani() noexcept
3220 , cursor_surface_map()
3221 , cursor_memory_pool(
3222 std::string(
"Zakero.Yetani.")
3226 , cursor_shm_pool(
nullptr)
3227 , cursor_pointer(
nullptr)
3229 , event_loop_is_running(
false)
3230 , compositor(
nullptr)
3234 , shm_format_vector()
3241 , on_output_add(LambdaOutputId_DoNothing)
3242 , on_output_change(LambdaOutputId_DoNothing)
3243 , on_output_remove(LambdaOutputId_DoNothing)
3244 , output_changes_map()
3245 , output_state_map()
3246 , output_notify_surface_vector()
3248 , surface_event_map()
3249 , surface_extent_map()
3250 , surface_extent_mutex()
3251 , surface_frame_map()
3252 , surface_size_map()
3253 , surface_resize_mutex_map()
3255 , window_vector_mutex()
3256 , xdg_state_change_map()
3257 , xdg_state_change_mutex()
3258 , xdg_wm_base(
nullptr)
3260 , xdg_toplevel_map()
3261 , xdg_decoration_map()
3262 , decoration_manager(
nullptr)
3278 if(event_loop_is_running || event_loop.joinable())
3280 event_loop.request_stop();
3314 std::error_code error;
3347 std::error_code error;
3416 , std::error_code& error
3421 const char* display_name =
nullptr;
3423 if(display.empty() ==
false)
3425 display_name = display.c_str();
3429 yetani->display = wl_display_connect(display_name);
3430 if(yetani->display ==
nullptr)
3434 const char* session = getenv(
"XDG_SESSION_TYPE");
3436 if(session !=
nullptr
3437 && strcasecmp(session,
"wayland") != 0
3440 error = ZAKERO_YETANI__ERROR(Error_Wayland_Not_Available);
3442 else if(display.empty())
3444 error = ZAKERO_YETANI__ERROR(Error_Connection_Failed);
3448 error = ZAKERO_YETANI__ERROR(Error_Invalid_Display_Name);
3455 yetani->registry = wl_display_get_registry(yetani->display);
3456 if(yetani->registry ==
nullptr)
3460 error = ZAKERO_YETANI__ERROR(Error_Registry_Not_Available);
3465 wl_registry_add_listener(yetani->registry, ®istry_listener, yetani);
3468 wl_display_dispatch(yetani->display);
3469 wl_display_roundtrip(yetani->display);
3472 if(yetani->compositor ==
nullptr)
3476 error = ZAKERO_YETANI__ERROR(Error_Compositor_Was_Not_Found);
3481 if(yetani->shm ==
nullptr)
3485 error = ZAKERO_YETANI__ERROR(Error_Shm_Was_Not_Found);
3490 if(yetani->xdg_wm_base ==
nullptr)
3494 error = ZAKERO_YETANI__ERROR(Error_Xdg_WM_Base_Was_Not_Found);
3499 yetani->cursorSetup();
3501 yetani->eventLoopStart();
3503 error = ZAKERO_YETANI__ERROR(Error_None);
3518 void Yetani::disconnect() noexcept
3522 if(decoration_manager !=
nullptr)
3524 zxdg_decoration_manager_v1_destroy(decoration_manager);
3525 decoration_manager =
nullptr;
3528 if(xdg_wm_base !=
nullptr)
3530 xdg_wm_base_destroy(xdg_wm_base);
3531 xdg_wm_base =
nullptr;
3536 wl_shm_destroy(shm);
3543 while(seat_map.empty() ==
false)
3545 auto iter = std::begin(seat_map);
3547 struct wl_seat* wl_seat = iter->first;
3549 seatDestroy(wl_seat);
3554 std::lock_guard<std::mutex> lock(output_data.mutex);
3556 for(
auto& iter : output_data.output_map)
3558 struct wl_output* wayland_output = iter.first;
3560 wl_output_destroy(wayland_output);
3563 output_changes_map.clear();
3564 output_state_map.clear();
3565 output_data.output_map.clear();
3566 output_data.wloutput_to_outputid.clear();
3567 output_data.outputid_to_wloutput.clear();
3570 if(registry !=
nullptr)
3572 wl_registry_destroy(registry);
3576 if(compositor !=
nullptr)
3578 wl_compositor_destroy(compositor);
3579 compositor =
nullptr;
3582 if(display !=
nullptr)
3584 wl_display_disconnect(display);
3726 void Yetani::cursorAnimate() noexcept
3730 std::lock_guard<std::mutex> lock(cursor_mutex);
3732 for(
auto& iter : cursor_map)
3734 Yetani::Cursor& cursor = iter.second;
3736 if(cursor.next_frame_time <= time_now)
3738 const int64_t time_over = time_now - cursor.next_frame_time;
3739 cursor.next_frame_time = time_now + cursor.time_per_frame - time_over;
3741 cursor.buffer_index = (cursor.buffer_index + 1) % cursor.buffer_vector.size();
3743 wl_surface_attach(cursor.wl_surface, cursor.buffer_vector[cursor.buffer_index], 0, 0);
3744 wl_surface_damage(cursor.wl_surface
3746 , cursor.width, cursor.height
3749 wl_surface_commit(cursor.wl_surface);
3801 return ZAKERO_YETANI__ERROR(Error_Cursor_Name_Is_Invalid);
3804 if(cursor_map.contains(name) ==
true)
3806 return ZAKERO_YETANI__ERROR(Error_Cursor_Already_Exists);
3809 if(config.size.width <= 0 || config.size.height <= 0)
3811 return ZAKERO_YETANI__ERROR(Error_Cursor_Size_Too_Small);
3814 if(config.image_data.empty())
3816 return ZAKERO_YETANI__ERROR(Error_Cursor_Image_Data_Is_Empty);
3818 else if(config.image_data.size() > 1)
3820 if(config.time_per_frame.count() <= 0)
3822 return ZAKERO_YETANI__ERROR(Error_Cursor_Frame_Time_Too_Small);
3825 if(config.time_per_frame.count() > Size_Max)
3827 return ZAKERO_YETANI__ERROR(Error_Cursor_Frame_Time_Too_Large);
3831 std::error_code error = cursorCreateCursor(name, config);
3847 std::error_code Yetani::cursorCreateCursor(
const std::string& cursor_name
3851 const uint8_t bytes_per_pixel = shmFormatBytesPerPixel(cursor_config.format);
3852 const size_t frame_count = cursor_config.image_data.size();
3854 Yetani::Cursor cursor =
3855 { .wl_surface = wl_compositor_create_surface(compositor)
3856 , .buffer_vector = { frame_count,
nullptr }
3857 , .format = cursor_config.format
3860 , .time_per_frame = uint32_t(cursor_config.time_per_frame.count())
3861 , .width = cursor_config.size.width
3862 , .height = cursor_config.size.height
3863 , .hotspot_x = cursor_config.hotspot_x
3864 , .hotspot_y = cursor_config.hotspot_y
3867 if(cursor.time_per_frame == 0)
3869 cursor.time_per_frame = Size_Max;
3872 const int stride = cursor.width * bytes_per_pixel;
3873 const size_t image_size = stride * cursor.height;
3875 for(
size_t i = 0; i < frame_count; i++)
3877 std::error_code error;
3879 off_t offset = cursor_memory_pool.alloc(image_size, error);
3886 struct wl_buffer* buffer = cursor.buffer_vector[i];
3887 cursor.buffer_vector[i] =
nullptr;
3889 off_t offset = (off_t)wl_buffer_get_user_data(buffer);
3890 wl_buffer_destroy(buffer);
3892 cursor_memory_pool.free(offset);
3898 uint32_t* p = (uint32_t*)cursor_memory_pool.addressOf(offset);
3899 memcpy(p, (uint8_t*)cursor_config.image_data[i], image_size);
3901 cursor.buffer_vector[i] = wl_shm_pool_create_buffer(cursor_shm_pool
3909 wl_buffer_set_user_data(cursor.buffer_vector[i], (
void*)offset);
3912 wl_surface_attach(cursor.wl_surface, cursor.buffer_vector[0], 0, 0);
3913 wl_surface_commit(cursor.wl_surface);
3915 std::lock_guard<std::mutex> lock(cursor_mutex);
3917 cursor_map[cursor_name] = cursor;
3919 return ZAKERO_YETANI__ERROR(Error_None);
3936 Yetani::Cursor cursor;
3939 std::lock_guard<std::mutex> lock(cursor_mutex);
3941 if(cursor_map.contains(name) ==
false)
3943 return ZAKERO_YETANI__ERROR(Error_Cursor_Does_Not_Exist);
3946 cursor = cursor_map[name];
3948 cursor_map.erase(name);
3951 auto iter = std::begin(cursor_surface_map);
3952 auto iter_end = std::end(cursor_surface_map);
3953 while(iter != iter_end)
3955 if(cursor.wl_surface == iter->second.wl_surface)
3957 iter = cursor_surface_map.erase(iter);
3965 if(cursor.wl_surface)
3967 wl_surface_destroy(cursor.wl_surface);
3968 cursor.wl_surface =
nullptr;
3971 for(wl_buffer* buffer : cursor.buffer_vector)
3973 off_t offset = (off_t)wl_buffer_get_user_data(buffer);
3974 wl_buffer_destroy(buffer);
3976 cursor_memory_pool.free(offset);
3979 return ZAKERO_YETANI__ERROR(Error_None);
3991 void Yetani::cursorEnter(wl_pointer* wl_pointer
3993 ,
struct wl_surface* wl_surface
3996 std::lock_guard<std::mutex> lock(cursor_mutex);
3998 cursor_pointer = wl_pointer;
4000 if(cursor_surface_map.contains(wl_surface) ==
false)
4005 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4007 cursor_surface.wl_pointer = wl_pointer;
4008 cursor_surface.serial = serial;
4010 if(cursor_surface.is_visible)
4012 wl_pointer_set_cursor(cursor_surface.wl_pointer
4013 , cursor_surface.serial
4014 , cursor_surface.wl_surface
4015 , cursor_surface.hotspot_x
4016 , cursor_surface.hotspot_y
4021 wl_pointer_set_cursor(cursor_surface.wl_pointer
4022 , cursor_surface.serial
4040 void Yetani::cursorLeave(
struct wl_surface* wl_surface
4043 std::lock_guard<std::mutex> lock(cursor_mutex);
4045 cursor_pointer =
nullptr;
4047 if(cursor_surface_map.contains(wl_surface) ==
false)
4052 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4054 cursor_surface.wl_pointer =
nullptr;
4055 cursor_surface.serial = 0;
4066 void Yetani::cursorHide(
struct wl_surface* wl_surface
4069 std::lock_guard<std::mutex> lock(cursor_mutex);
4071 if(cursor_surface_map.contains(wl_surface) ==
false)
4076 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4078 cursor_surface.is_visible =
false;
4080 if(cursor_surface.wl_pointer !=
nullptr)
4082 wl_pointer_set_cursor(cursor_surface.wl_pointer
4083 , cursor_surface.serial
4099 void Yetani::cursorShow(
struct wl_surface* wl_surface
4102 std::lock_guard<std::mutex> lock(cursor_mutex);
4104 if(cursor_surface_map.contains(wl_surface) ==
false)
4109 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4111 cursor_surface.is_visible =
true;
4113 if(cursor_surface.wl_pointer !=
nullptr)
4115 wl_pointer_set_cursor(cursor_surface.wl_pointer
4116 , cursor_surface.serial
4117 , cursor_surface.wl_surface
4118 , cursor_surface.hotspot_x
4119 , cursor_surface.hotspot_y
4135 bool Yetani::cursorIsHidden(
struct wl_surface* wl_surface
4138 std::lock_guard<std::mutex> lock(cursor_mutex);
4140 if(cursor_surface_map.contains(wl_surface) ==
false)
4145 const Yetani::CursorSurface& cursor_surface = cursor_surface_map.at(wl_surface);
4147 return !(cursor_surface.is_visible);
4158 void Yetani::cursorSetup() noexcept
4162 uint64_t bytes =
zakero::convert((uint64_t)4, zakero::Storage::Kilobyte, zakero::Storage::Byte);
4163 cursor_memory_pool.
init(bytes,
true, zakero::MemoryPool::Alignment::Bits_32);
4167 wl_shm_pool_resize(cursor_shm_pool, new_size);
4170 cursor_shm_pool = wl_shm_create_pool(shm, cursor_memory_pool.
fd(), cursor_memory_pool.
size());
4181 void Yetani::cursorTeardown() noexcept
4183 while(cursor_map.empty() ==
false)
4185 const auto& iter = cursor_map.begin();
4187 const std::string& name = iter->first;
4192 if(cursor_shm_pool !=
nullptr)
4194 wl_shm_pool_destroy(cursor_shm_pool);
4210 std::error_code Yetani::cursorAttach(
const std::string& cursor_name
4211 ,
struct wl_surface* wl_surface
4214 std::lock_guard<std::mutex> lock(cursor_mutex);
4216 if(cursor_map.contains(cursor_name) ==
false)
4218 return ZAKERO_YETANI__ERROR(Error_Cursor_Does_Not_Exist);
4221 if(cursor_surface_map.contains(wl_surface) ==
false)
4223 cursor_surface_map[wl_surface] =
4224 { .wl_pointer = cursor_pointer
4225 , .wl_surface = nullptr
4229 , .is_visible =
true
4233 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4234 Yetani::Cursor& cursor = cursor_map[cursor_name];
4236 cursor_surface.wl_surface = cursor.wl_surface;
4237 cursor_surface.hotspot_x = cursor.hotspot_x;
4238 cursor_surface.hotspot_y = cursor.hotspot_y;
4240 if(cursor_surface.wl_pointer !=
nullptr)
4242 if(cursor_surface.is_visible)
4244 wl_pointer_set_cursor(cursor_surface.wl_pointer
4245 , cursor_surface.serial
4246 , cursor_surface.wl_surface
4247 , cursor_surface.hotspot_x
4248 , cursor_surface.hotspot_y
4253 wl_pointer_set_cursor(cursor_surface.wl_pointer
4254 , cursor_surface.serial
4262 return ZAKERO_YETANI__ERROR(Error_None);
4277 std::error_code Yetani::cursorDetach(
struct wl_surface* wl_surface
4280 std::lock_guard<std::mutex> lock(cursor_mutex);
4282 if(cursor_surface_map.contains(wl_surface) ==
false)
4284 return ZAKERO_YETANI__ERROR(Error_Cursor_Not_Attached);
4287 Yetani::CursorSurface& cursor_surface = cursor_surface_map[wl_surface];
4289 if(cursor_surface.wl_pointer !=
nullptr)
4291 wl_pointer_set_cursor(cursor_surface.wl_pointer
4292 , cursor_surface.serial
4299 cursor_surface_map.erase(wl_surface);
4301 return ZAKERO_YETANI__ERROR(Error_None);
4317 void Yetani::eventLoopStart() noexcept
4319 event_loop = std::jthread(&Yetani::eventLoop,
this);
4321 while(event_loop_is_running.load() ==
false)
4324 std::this_thread::sleep_for(std::chrono::nanoseconds(42));
4327 #ifdef ZAKERO_YETANI__ENABLE_THREAD_SCHEDULER
4328 int policy = SCHED_FIFO;
4329 int priority_min = sched_get_priority_min(policy);
4330 int priority_max = sched_get_priority_max(policy);
4333 { .sched_priority = (priority_min + priority_max) / 2
4336 pthread_setschedparam(event_loop.native_handle(), policy, &sched);
4368 void Yetani::eventLoop(std::stop_token thread_token
4372 struct pollfd fd_status =
4373 { .fd = wl_display_get_fd(yetani->display)
4374 , .events = POLLIN | POLLOUT
4378 yetani->event_loop_is_running.store(
true);
4381 while(thread_token.stop_requested() ==
false)
4383 poll(&fd_status, 1, 1);
4385 if(fd_status.revents & POLLIN)
4387 wl_display_dispatch(yetani->display);
4390 yetani->cursorAnimate();
4392 keyboardRepeat(yetani->keyboard);
4394 if(fd_status.revents & POLLOUT)
4396 wl_display_flush(yetani->display);
4399 #ifdef ZAKERO_YETANI__ENABLE_THREAD_SCHEDULER
4400 std::this_thread::yield();
4404 yetani->event_loop_is_running.store(
false);
4422 return shm_format_vector;
4442 #define X(value_, bytes_, desc_) \
4443 case value_: return bytes_;
4444 ZAKERO_YETANI__SHM_FORMAT
4467 #define X(value_, bytes_, desc_) \
4468 case value_: return desc_;
4469 ZAKERO_YETANI__SHM_FORMAT
4490 #define X(value_, bytes_, desc_) \
4491 case value_: return #value_;
4492 ZAKERO_YETANI__SHM_FORMAT
4545 struct wl_buffer* Yetani::bufferCreate(Yetani::SurfaceSize& surface_size
4547 , Yetani::Buffer* buffer
4550 off_t offset = window_memory->memory_pool.alloc(surface_size.in_bytes);
4552 struct wl_buffer* wl_buffer = wl_shm_pool_create_buffer(window_memory->wl_shm_pool
4554 , surface_size.width
4555 , surface_size.height
4556 , surface_size.stride
4557 , surface_size.pixel_format
4560 wl_buffer_set_user_data(wl_buffer, buffer);
4562 buffer->mutex.lock();
4564 buffer->map[wl_buffer] =
4565 { .memory_pool = &window_memory->memory_pool
4569 buffer->mutex.unlock();
4584 void Yetani::bufferDestroy(
struct wl_buffer*& wl_buffer
4587 Yetani::Buffer* buffer = (Yetani::Buffer*)wl_buffer_get_user_data(wl_buffer);
4589 wl_buffer_destroy(wl_buffer);
4591 buffer->mutex.lock();
4593 BufferData& buffer_data = buffer->map[wl_buffer];
4595 buffer_data.memory_pool->free(buffer_data.offset);
4597 buffer->map.erase(wl_buffer);
4599 buffer->mutex.unlock();
4601 wl_buffer =
nullptr;
4705 std::lock_guard<std::mutex> lock(output_data.mutex);
4707 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4709 ZAKERO_YETANI__DEBUG
4710 <<
"Invalid output_id: "
4711 << std::to_string(output_id)
4717 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4719 return output_data.output_map.at(wl_output);
4736 Yetani::VectorOutputId vector;
4738 std::lock_guard<std::mutex> lock(output_data.mutex);
4740 for(
const auto& iter : output_data.outputid_to_wloutput)
4742 vector.push_back(iter.first);
4763 switch(subpixel_format)
4765 #define X(value_, name_) \
4766 case value_: return name_;
4767 ZAKERO_YETANI__OUTPUT_SUBPIXEL
4790 #define X(value_, name_) \
4791 case value_: return name_;
4792 ZAKERO_YETANI__OUTPUT_TRANSFORM
4813 std::lock_guard<std::mutex> lock(output_data.mutex);
4815 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4817 return { point.time, 0, 0 };
4820 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4821 const Yetani::Output& output = output_data.output_map.at(wl_output);
4823 auto p = convertPixelToMm(output, point.
x, point.y);
4825 return { point.time, p.first, p.second };
4843 std::lock_guard<std::mutex> lock(output_data.mutex);
4845 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4847 return { point.time, 0, 0 };
4850 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4851 const Yetani::Output& output = output_data.output_map.at(wl_output);
4853 auto p = convertPixelToPercent(output, point.
x, point.y);
4855 return { point.time, p.first, p.second };
4873 std::lock_guard<std::mutex> lock(output_data.mutex);
4875 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4877 return { point.time, 0, 0 };
4880 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4881 const Yetani::Output& output = output_data.output_map.at(wl_output);
4883 auto p = convertMmToPixel(output, point.
x, point.y);
4885 return { point.time, p.first, p.second };
4903 std::lock_guard<std::mutex> lock(output_data.mutex);
4905 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4907 return { point.time, 0, 0 };
4910 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4911 const Yetani::Output& output = output_data.output_map.at(wl_output);
4913 auto p = convertPercentToPixel(output, point.
x, point.y);
4915 return { point.time, p.first, p.second };
4933 std::lock_guard<std::mutex> lock(output_data.mutex);
4935 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4940 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4941 const Yetani::Output& output = output_data.output_map.at(wl_output);
4943 auto p = convertPixelToMm(output, size.
width, size.height);
4945 return { p.first, p.second };
4963 std::lock_guard<std::mutex> lock(output_data.mutex);
4965 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4970 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
4971 const Yetani::Output& output = output_data.output_map.at(wl_output);
4973 auto p = convertPixelToPercent(output, size.
width, size.height);
4975 return { p.first, p.second };
4992 std::lock_guard<std::mutex> lock(output_data.mutex);
4994 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
4999 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
5000 const Yetani::Output& output = output_data.output_map.at(wl_output);
5002 auto p = convertMmToPixel(output, size.
width, size.height);
5004 return { p.first, p.second };
5021 std::lock_guard<std::mutex> lock(output_data.mutex);
5023 if(output_data.outputid_to_wloutput.contains(output_id) ==
false)
5028 struct wl_output* wl_output = output_data.outputid_to_wloutput.at(output_id);
5029 const Yetani::Output& output = output_data.output_map.at(wl_output);
5031 auto p = convertPercentToPixel(output, size.
width, size.height);
5033 return { p.first, p.second };
5049 if(lambda ==
nullptr)
5051 on_output_add = LambdaOutputId_DoNothing;
5055 on_output_add = lambda;
5072 if(lambda ==
nullptr)
5074 on_output_change = LambdaOutputId_DoNothing;
5078 on_output_change = lambda;
5095 if(lambda ==
nullptr)
5097 on_output_remove = LambdaOutputId_DoNothing;
5101 on_output_remove = lambda;
5114 void Yetani::convertPixel(
struct wl_surface* wl_surface
5115 ,
const int32_t pixel_xw
5116 ,
const int32_t pixel_yh
5123 std::lock_guard<std::mutex> lock(output_data.mutex);
5125 const Yetani::VectorWlOutput& vector = output_data.surface_output_map.at(wl_surface);
5126 struct wl_output* wl_output = vector.front();
5127 const Yetani::Output& output = output_data.output_map.at(wl_output);
5129 auto mm = convertPixelToMm(output, pixel_xw, pixel_yh);
5133 auto pc = convertPixelToPercent(output, pixel_xw, pixel_yh);
5150 std::pair<float, float> Yetani::convertPixelToMm(
const Yetani::Output& output
5176 std::pair<float, float> Yetani::convertPixelToPercent(
const Yetani::Output& output
5182 { float(xw) / output.
width
5183 , float(yh) / output.
height
5199 std::pair<int32_t, int32_t> Yetani::convertMmToPixel(
const Yetani::Output& output
5208 { int32_t(xw * ratio_h)
5209 , int32_t(yh * ratio_v)
5225 std::pair<int32_t, int32_t> Yetani::convertPercentToPixel(
const Yetani::Output& output
5231 { int32_t(xw * output.
width)
5232 , int32_t(yh * output.
height)
5248 void Yetani::outputNotifySurface(Yetani* yetani
5249 ,
struct wl_output* wl_output
5250 ,
struct wl_surface* wl_surface
5253 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
5254 if(surface_extent.preferred_unit == Yetani::SizeUnit::Pixel)
5259 Yetani::OutputData& output_data = yetani->output_data;
5261 std::lock_guard<std::mutex> lock(output_data.mutex);
5263 Yetani::VectorWlOutput& output_vector = output_data.surface_output_map[wl_surface];
5265 struct wl_output* output_current = output_vector.front();
5267 if(output_current != wl_output)
5272 Yetani::Output& output = output_data.output_map.at(wl_output);
5273 Yetani::SizePixel new_size = surface_extent.size_pixel;
5275 if(surface_extent.preferred_unit == Yetani::SizeUnit::Millimeter)
5277 auto p = yetani->convertMmToPixel(output, surface_extent.size_mm.width, surface_extent.size_mm.height);
5278 new_size = { p.first, p.second };
5280 else if(surface_extent.preferred_unit == Yetani::SizeUnit::Percent)
5282 auto p = yetani->convertPercentToPixel(output, surface_extent.size_percent.width, surface_extent.size_percent.height);
5283 new_size = { p.first, p.second };
5286 if(new_size.width <= 0)
5291 if(new_size.height <= 0)
5293 new_size.height = 1;
5296 yetani->surface_resize_mutex_map[wl_surface].lock();
5298 surface_extent.size_pixel = new_size;
5299 surfaceCalculateSize(yetani, wl_surface, new_size);
5301 yetani->surface_resize_mutex_map[wl_surface].unlock();
5339 void Yetani::seatDestroy(
struct wl_seat*& wl_seat
5342 Yetani::Seat& seat = seat_map[wl_seat];
5344 if(seat.wl_keyboard !=
nullptr)
5346 wl_keyboard_release(seat.wl_keyboard);
5347 seat.wl_keyboard =
nullptr;
5350 if(seat.wl_pointer !=
nullptr)
5352 wl_pointer_release(seat.wl_pointer);
5353 seat.wl_pointer =
nullptr;
5356 if(seat.wl_touch !=
nullptr)
5358 wl_touch_release(seat.wl_touch);
5359 seat.wl_touch =
nullptr;
5362 seat_map.erase(wl_seat);
5364 wl_seat_release(wl_seat);
5447 return keyboard.repeat_delay;
5461 return 1000 / keyboard.repeat_rate;
5468 void Yetani::keyboardDestroy(Yetani::Keyboard& keyboard
5471 if(keyboard.keymap !=
nullptr)
5473 munmap(keyboard.keymap, keyboard.keymap_size);
5476 keyboard.wl_surface =
nullptr;
5477 keyboard.event =
nullptr;
5478 keyboard.modifier = { 0 };
5479 keyboard.repeat_rate = 0;
5480 keyboard.repeat_delay = {};
5481 keyboard.keymap =
nullptr;
5482 keyboard.keymap_size = 0;
5492 void Yetani::keyboardRepeat(Yetani::Keyboard& keyboard
5495 auto now = std::chrono::steady_clock::now();
5497 for(
auto& iter : keyboard.repeat_map)
5499 Yetani::KeyRepeatData& key_repeat = iter.second;
5501 if(now >= key_repeat.trigger_time)
5503 uint32_t key_code = iter.first;
5506 { .time = key_repeat.base_time
5508 , .state = Yetani::KeyState::Repeat
5511 keyboard.event->on_key(key, keyboard.modifier);
5513 key_repeat.trigger_time = now
5514 + std::chrono::milliseconds(keyboard.repeat_rate)
5515 - (now - key_repeat.trigger_time)
5517 key_repeat.base_time += keyboard.repeat_rate;
5530 void Yetani::keyboardRepeatAdd(Yetani::Keyboard& keyboard
5535 auto trigger_time = std::chrono::steady_clock::now()
5536 + std::chrono::milliseconds(keyboard.repeat_delay)
5539 keyboard.repeat_map[key_code] =
5540 { .trigger_time = trigger_time
5541 , .base_time = time + keyboard.repeat_delay
5552 void Yetani::keyboardRepeatReleaseAll(Yetani::Keyboard& keyboard
5555 while(keyboard.repeat_map.empty() ==
false)
5557 auto iter = keyboard.repeat_map.begin();
5559 uint32_t key_code = iter->first;
5564 , .state = Yetani::KeyState::Released
5567 keyboard.event->on_key(key, keyboard.modifier);
5569 keyboard.repeat_map.erase(iter);
5580 void Yetani::keyboardRepeatRemove(Yetani::Keyboard& keyboard
5584 keyboard.repeat_map.erase(key_code);
5605 void Yetani::pointerClear(Yetani::Pointer& pointer
5608 pointer.enter_surface =
nullptr;
5609 pointer.enter_point = { 0, 0, 0 };
5610 pointer.leave_surface =
nullptr;
5611 pointer.motion_point = { 0, 0, 0 };
5612 pointer.button_event_code = 0;
5613 pointer.button_is_pressed =
false;
5614 pointer.button_time = 0;
5615 pointer.axis.time = 0;
5616 pointer.axis.type = Yetani::PointerAxisType::Unknown;
5617 pointer.axis.distance = 0;
5618 pointer.axis.source = Yetani::PointerAxisSource::Unknown;
5619 pointer.axis.steps = 0;
5662 void Yetani::surfaceCalculateSize(Yetani* yetani
5663 ,
struct wl_surface* wl_surface
5664 ,
const Yetani::SizePixel& size
5667 Yetani::SurfaceSize& surface_size = yetani->surface_size_map[wl_surface];
5668 surface_size.width = size.width;
5669 surface_size.height = size.height;
5670 surface_size.stride = size.width * surface_size.bytes_per_pixel;
5671 surface_size.in_bytes = surface_size.stride * surface_size.height;
5673 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
5674 surface_frame.width = size.width;
5675 surface_frame.height = size.height;
5696 struct wl_surface* Yetani::surfaceCreate(Yetani* yetani
5697 ,
const wl_shm_format pixel_format
5698 ,
const Yetani::SizePixel& size
5699 , Yetani::Window::Memory& window_memory
5702 struct wl_surface* wl_surface = wl_compositor_create_surface(yetani->compositor);
5704 Yetani::SurfaceSize& surface_size = yetani->surface_size_map[wl_surface];
5705 surface_size.pixel_format = pixel_format;
5706 surface_size.bytes_per_pixel = shmFormatBytesPerPixel(pixel_format);
5708 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
5709 surface_frame.wl_surface = wl_surface;
5710 surface_frame.time_ms = 0;
5712 surfaceCalculateSize(yetani, wl_surface, size);
5714 surface_frame.buffer_next = bufferCreate(surface_size, &window_memory, &yetani->buffer);
5717 bool event_keyboard =
true;
5720 yetani->keyboard.event_map[wl_surface] =
5721 { .on_enter = Lambda_DoNothing
5722 , .on_leave = Lambda_DoNothing
5723 , .on_key = LambdaKey_DoNothing
5728 bool event_pointer =
true;
5731 yetani->pointer.event_map[wl_surface] =
5732 { .on_axis = LambdaAxis_DoNothing
5733 , .on_axis_discrete = Lambda_DoNothing
5734 , .on_axis_source = Lambda_DoNothing
5735 , .on_axis_stop = Lambda_DoNothing
5736 , .on_button_mm = LambdaButtonMm_DoNothing
5737 , .on_button_percent = LambdaButtonPercent_DoNothing
5738 , .on_button_pixel = LambdaButtonPixel_DoNothing
5739 , .on_enter_mm = LambdaPointMm_DoNothing
5740 , .on_enter_percent = LambdaPointPercent_DoNothing
5741 , .on_enter_pixel = LambdaPointPixel_DoNothing
5742 , .on_leave = Lambda_DoNothing
5743 , .on_motion_mm = LambdaPointMm_DoNothing
5744 , .on_motion_percent = LambdaPointPercent_DoNothing
5745 , .on_motion_pixel = LambdaPointPixel_DoNothing
5749 yetani->surface_event_map[wl_surface] =
5750 { .on_size_mm_change = LambdaSizeMm_DoNothing
5751 , .on_size_percent_change = LambdaSizePercent_DoNothing
5752 , .on_size_pixel_change = LambdaSizePixel_DoNothing
5755 wl_surface_add_listener(wl_surface
5769 void Yetani::surfaceDestroy(Yetani* yetani
5770 ,
struct wl_surface*& wl_surface
5773 if(wl_surface ==
nullptr)
5778 if(yetani->surface_frame_map.contains(wl_surface))
5780 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
5782 struct wl_buffer* wl_buffer =
nullptr;
5783 wl_buffer = surface_frame.buffer_next.exchange(
nullptr);
5785 if(wl_buffer !=
nullptr)
5787 bufferDestroy(wl_buffer);
5791 if(yetani->keyboard.event_map.contains(wl_surface))
5793 yetani->keyboard.event_map.erase(wl_surface);
5796 if(yetani->pointer.event_map.contains(wl_surface))
5798 yetani->pointer.event_map.erase(wl_surface);
5801 yetani->surface_size_map.erase(wl_surface);
5802 yetani->surface_frame_map.erase(wl_surface);
5803 yetani->surface_event_map.erase(wl_surface);
5805 yetani->cursorDetach(wl_surface);
5807 wl_surface_destroy(wl_surface);
5808 wl_surface =
nullptr;
5826 void Yetani::handlerBufferRelease(
void*
5827 ,
struct wl_buffer* wl_buffer
5830 Yetani::bufferDestroy(wl_buffer);
5839 void Yetani::handlerKeyboardEnter(
void* data
5840 ,
struct wl_keyboard*
5842 ,
struct wl_surface* wl_surface
5843 ,
struct wl_array* key_array
5846 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
5848 if(keyboard.wl_surface !=
nullptr)
5850 keyboardRepeatReleaseAll(keyboard);
5852 keyboard.event->on_leave();
5855 keyboard.wl_surface = wl_surface;
5857 if(keyboard.event_map.contains(wl_surface))
5859 keyboard.event = &(keyboard.event_map[wl_surface]);
5863 keyboard.event = &(keyboard.event_map[
nullptr]);
5866 keyboard.event->on_enter();
5868 if(key_array->size > 0)
5873 , .state = Yetani::KeyState::Pressed
5876 ZAKERO_YETANI__ARRAY_FOR_EACH(uint32_t*, key_iter, key_array)
5878 key.code = *key_iter;
5880 keyboard.event->on_key(key, keyboard.modifier);
5882 keyboardRepeatAdd(keyboard, key.code, 0);
5891 void Yetani::handlerKeyboardKey(
void* data
5892 ,
struct wl_keyboard*
5899 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
5904 , .state = (state == WL_KEYBOARD_KEY_STATE_PRESSED)
5905 ? Yetani::KeyState::Pressed
5906 : Yetani::KeyState::Released
5909 keyboard.event->on_key(key, keyboard.modifier);
5911 if(key.state == Yetani::KeyState::Pressed
5912 && keyboard.repeat_rate > 0
5915 keyboardRepeatAdd(keyboard, key_code, time);
5917 else if(key.state == Yetani::KeyState::Released)
5919 keyboardRepeatRemove(keyboard, key_code);
5927 void Yetani::handlerKeyboardKeymap(
void* data
5928 ,
struct wl_keyboard*
5934 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
5936 if(format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
5938 if(keyboard.keymap !=
nullptr)
5940 munmap(keyboard.keymap
5941 , keyboard.keymap_size
5945 keyboard.keymap = (
char*)mmap(
nullptr
5948 , MAP_NORESERVE | MAP_PRIVATE
5952 keyboard.keymap_size = size;
5956 if(keyboard.keymap !=
nullptr)
5958 munmap(keyboard.keymap
5959 , keyboard.keymap_size
5962 keyboard.keymap =
nullptr;
5963 keyboard.keymap_size = 0;
5972 void Yetani::handlerKeyboardLeave(
void* data
5973 ,
struct wl_keyboard*
5975 ,
struct wl_surface* wl_surface
5978 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
5980 if(keyboard.wl_surface == wl_surface)
5982 keyboardRepeatReleaseAll(keyboard);
5984 keyboard.event->on_leave();
5986 keyboard.event = &(keyboard.event_map[
nullptr]);
5987 keyboard.wl_surface =
nullptr;
5995 void Yetani::handlerKeyboardModifiers(
void* data
5996 ,
struct wl_keyboard*
5998 , uint32_t mods_pressed
5999 , uint32_t mods_latched
6000 , uint32_t mods_locked
6004 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
6006 keyboard.modifier.pressed = mods_pressed;
6007 keyboard.modifier.latched = mods_latched;
6008 keyboard.modifier.locked = mods_locked;
6009 keyboard.modifier.group = group;
6016 void Yetani::handlerKeyboardRepeatInfo(
void* data
6017 ,
struct wl_keyboard*
6022 Yetani::Keyboard& keyboard = *((Yetani::Keyboard*)data);
6024 keyboard.repeat_delay = delay;
6025 keyboard.repeat_rate = 1000 / rate;
6034 void Yetani::handlerOutputDone(
void* data
6035 ,
struct wl_output* wl_output
6038 Yetani* yetani = (Yetani*)data;
6039 Yetani::Output& output = yetani->output_data.output_map[wl_output];
6040 Yetani::Output& changes = yetani->output_changes_map[wl_output];
6041 Yetani::OutputId output_id = yetani->output_data.wloutput_to_outputid[wl_output];
6071 output.pixels_per_mm_horizontal = output.width / float(output.physical_width_mm);
6072 output.pixels_per_mm_vertical = output.height / float(output.physical_height_mm);
6074 ZAKERO_YETANI__DEBUG <<
"\n" <<
to_string(output) <<
"\n";
6076 switch(yetani->output_state_map[wl_output])
6078 case Yetani::OutputState::Done:
6082 case Yetani::OutputState::Added:
6083 yetani->on_output_add(output_id);
6086 case Yetani::OutputState::Changed:
6087 yetani->on_output_change(output_id);
6089 for(
auto wl_surface : yetani->output_notify_surface_vector)
6091 outputNotifySurface(yetani, wl_output, wl_surface);
6097 yetani->output_state_map[wl_output] = Yetani::OutputState::Done;
6104 void Yetani::handlerOutputGeometry(
void* data
6105 ,
struct wl_output* wl_output
6108 , int32_t physical_width
6109 , int32_t physical_height
6116 Yetani* yetani = (Yetani*)data;
6117 Yetani::Output& output_changes = yetani->output_changes_map[wl_output];
6119 if(yetani->output_state_map[wl_output] != Yetani::OutputState::Added)
6121 yetani->output_state_map[wl_output] = Yetani::OutputState::Changed;
6124 output_changes.x = x;
6125 output_changes.y = y;
6126 output_changes.physical_width_mm = physical_width;
6127 output_changes.physical_height_mm = physical_height;
6128 output_changes.subpixel = subpixel;
6129 output_changes.make = std::string(make);
6130 output_changes.model = std::string(model);
6131 output_changes.transform = transform;
6138 void Yetani::handlerOutputMode(
void* data
6139 ,
struct wl_output* wl_output
6146 Yetani* yetani = (Yetani*)data;
6147 Yetani::Output& output_changes = yetani->output_changes_map[wl_output];
6149 if(yetani->output_state_map[wl_output] != Yetani::OutputState::Added)
6151 yetani->output_state_map[wl_output] = Yetani::OutputState::Changed;
6154 output_changes.flags = flags;
6155 output_changes.width = width;
6156 output_changes.height = height;
6157 output_changes.refresh_mHz = refresh;
6164 void Yetani::handlerOutputScale(
void* data
6165 ,
struct wl_output* wl_output
6169 Yetani* yetani = (Yetani*)data;
6170 Output& output_changes = yetani->output_changes_map[wl_output];
6172 if(yetani->output_state_map[wl_output] != Yetani::OutputState::Added)
6174 yetani->output_state_map[wl_output] = Yetani::OutputState::Changed;
6177 output_changes.scale_factor = factor;
6186 void Yetani::handlerPointerAxis(
void* data
6187 ,
struct wl_pointer*
6193 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6195 pointer.axis.time = time;
6196 pointer.axis.distance = (float)wl_fixed_to_double(value);
6198 if(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
6200 pointer.axis.type = Yetani::PointerAxisType::Horizontal;
6202 else if(axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
6204 pointer.axis.type = Yetani::PointerAxisType::Vertical;
6208 pointer.axis.type = Yetani::PointerAxisType::Unknown;
6216 void Yetani::handlerPointerAxisDiscrete(
void* data
6217 ,
struct wl_pointer*
6222 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6224 pointer.axis.steps = discrete;
6231 void Yetani::handlerPointerAxisSource(
void* data
6232 ,
struct wl_pointer*
6233 , uint32_t axis_source
6236 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6240 case WL_POINTER_AXIS_SOURCE_WHEEL:
6241 pointer.axis.source = Yetani::PointerAxisSource::Wheel;
6244 case WL_POINTER_AXIS_SOURCE_FINGER:
6245 pointer.axis.source = Yetani::PointerAxisSource::Finger;
6248 case WL_POINTER_AXIS_SOURCE_CONTINUOUS:
6249 pointer.axis.source = Yetani::PointerAxisSource::Continuous;
6252 case WL_POINTER_AXIS_SOURCE_WHEEL_TILT:
6253 pointer.axis.source = Yetani::PointerAxisSource::Wheel_Tilt;
6257 pointer.axis.source = Yetani::PointerAxisSource::Unknown;
6265 void Yetani::handlerPointerAxisStop(
void*
6266 ,
struct wl_pointer*
6287 void Yetani::handlerPointerButton(
void* data
6288 ,
struct wl_pointer*
6295 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6297 pointer.button.code = button;
6298 pointer.button_time = time;
6300 if(state == WL_POINTER_BUTTON_STATE_RELEASED)
6302 pointer.button.state = Yetani::PointerButtonState::Released;
6304 else if(state == WL_POINTER_BUTTON_STATE_PRESSED)
6306 pointer.button.state = Yetani::PointerButtonState::Pressed;
6314 void Yetani::handlerPointerEnter(
void* data
6315 ,
struct wl_pointer*
6317 ,
struct wl_surface* wl_surface
6318 , wl_fixed_t surface_x
6319 , wl_fixed_t surface_y
6322 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6324 pointer.enter_serial = serial;
6325 pointer.enter_surface = wl_surface;
6327 pointer.enter_point =
6329 , .x = wl_fixed_to_int(surface_x)
6330 , .y = wl_fixed_to_int(surface_y)
6338 void Yetani::handlerPointerFrame(
void* data
6339 ,
struct wl_pointer* wl_pointer
6342 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6343 Yetani* yetani = pointer.yetani;
6345 if(pointer.enter_surface !=
nullptr)
6347 if(pointer.wl_surface !=
nullptr)
6349 yetani->cursorLeave(pointer.wl_surface);
6350 pointer.event_map[pointer.wl_surface].on_leave();
6353 yetani->cursorEnter(wl_pointer
6354 , pointer.enter_serial
6355 , pointer.enter_surface
6358 pointer.wl_surface = pointer.enter_surface;
6359 pointer.point_pixel = pointer.enter_point;
6361 if(pointer.event_map.contains(pointer.wl_surface))
6363 pointer.event = &(pointer.event_map[pointer.wl_surface]);
6367 pointer.event = &(pointer.event_map[
nullptr]);
6370 yetani->convertPixel(pointer.enter_surface
6371 , pointer.point_pixel.x , pointer.point_pixel.y
6372 , pointer.point_mm.x , pointer.point_mm.y
6373 , pointer.point_percent.x, pointer.point_percent.y
6376 pointer.event->on_enter_pixel(pointer.point_pixel
6377 , yetani->keyboard.modifier
6379 pointer.event->on_enter_mm(pointer.point_mm
6380 , yetani->keyboard.modifier
6382 pointer.event->on_enter_percent(pointer.point_percent
6383 , yetani->keyboard.modifier
6387 if((pointer.motion_point.time != 0)
6388 && (pointer.wl_surface !=
nullptr)
6391 pointer.point_pixel = pointer.motion_point;
6393 yetani->convertPixel(pointer.wl_surface
6394 , pointer.point_pixel.x , pointer.point_pixel.y
6395 , pointer.point_mm.x , pointer.point_mm.y
6396 , pointer.point_percent.x, pointer.point_percent.y
6398 pointer.point_mm.time = pointer.point_pixel.time;
6399 pointer.point_percent.time = pointer.point_pixel.time;
6401 pointer.event->on_motion_pixel(pointer.point_pixel
6402 , yetani->keyboard.modifier
6404 pointer.event->on_motion_mm(pointer.point_mm
6405 , yetani->keyboard.modifier
6407 pointer.event->on_motion_percent(pointer.point_percent
6408 , yetani->keyboard.modifier
6412 if((pointer.button_time != 0)
6413 && (pointer.wl_surface !=
nullptr)
6416 pointer.point_mm.time = pointer.button_time;
6417 pointer.point_percent.time = pointer.button_time;
6418 pointer.point_pixel.time = pointer.button_time;
6420 pointer.event->on_button_pixel(pointer.button
6421 , pointer.point_pixel
6422 , yetani->keyboard.modifier
6424 pointer.event->on_button_mm(pointer.button
6426 , yetani->keyboard.modifier
6428 pointer.event->on_button_percent(pointer.button
6429 , pointer.point_percent
6430 , yetani->keyboard.modifier
6434 if((pointer.axis.time != 0)
6435 && (pointer.wl_surface !=
nullptr)
6438 pointer.event->on_axis(pointer.axis
6439 , yetani->keyboard.modifier
6443 if((pointer.leave_surface !=
nullptr)
6444 && (pointer.leave_surface == pointer.wl_surface)
6447 yetani->cursorLeave(pointer.leave_surface);
6449 pointer.event->on_leave();
6451 pointer.event = &(pointer.event_map[
nullptr]);
6452 pointer.wl_surface =
nullptr;
6455 pointerClear(pointer);
6462 void Yetani::handlerPointerLeave(
void* data
6463 ,
struct wl_pointer*
6465 ,
struct wl_surface* wl_surface
6468 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6470 pointer.leave_surface = wl_surface;
6477 void Yetani::handlerPointerMotion(
void* data
6478 ,
struct wl_pointer*
6480 , wl_fixed_t surface_x
6481 , wl_fixed_t surface_y
6484 Yetani::Pointer& pointer = *((Yetani::Pointer*)data);
6486 pointer.motion_point =
6488 , .x = wl_fixed_to_int(surface_x)
6489 , .y = wl_fixed_to_int(surface_y)
6499 void Yetani::handlerRegistryGlobal(
void* data
6500 ,
struct wl_registry* registry
6502 ,
const char* interface
6506 Yetani* yetani = (Yetani*)data;
6508 std::string_view interface_name(interface);
6509 ZAKERO_YETANI__DEBUG_VAR(interface_name);
6511 if(interface_name == wl_compositor_interface.name)
6513 yetani->compositor = (
struct wl_compositor*)
6514 wl_registry_bind(registry
6516 , &wl_compositor_interface
6523 if(interface_name == wl_output_interface.name)
6525 struct wl_output* wl_output = (
struct wl_output*)wl_registry_bind(registry
6527 , &wl_output_interface
6531 yetani->output_data.wloutput_to_outputid[wl_output] = id;
6532 yetani->output_data.outputid_to_wloutput[id] = wl_output;
6533 yetani->output_data.output_map[wl_output] = {};
6534 yetani->output_changes_map[wl_output] = {};
6535 yetani->output_state_map[wl_output] = Yetani::OutputState::Added;
6537 wl_output_add_listener(wl_output
6538 , &Yetani::output_listener
6545 if(interface_name == wl_seat_interface.name)
6547 yetani->seat = (
struct wl_seat*)
6548 wl_registry_bind(registry
6550 , &wl_seat_interface
6554 yetani->id_to_seat[id] = yetani->seat;
6556 wl_seat_add_listener(yetani->seat
6557 , &yetani->seat_listener
6564 if(interface_name == wl_shm_interface.name)
6566 yetani->shm = (
struct wl_shm*)
6567 wl_registry_bind(registry
6573 wl_shm_add_listener(yetani->shm
6574 , &yetani->shm_listener
6581 if(interface_name == xdg_wm_base_interface.name)
6583 yetani->xdg_wm_base = (
struct xdg_wm_base*)
6584 wl_registry_bind(registry
6586 , &xdg_wm_base_interface
6590 xdg_wm_base_add_listener(yetani->xdg_wm_base
6591 , &yetani->xdg_wm_base_listener
6596 if(interface_name == zxdg_decoration_manager_v1_interface.name)
6598 yetani->decoration_manager = (
struct zxdg_decoration_manager_v1*)
6599 wl_registry_bind(registry
6601 , &zxdg_decoration_manager_v1_interface
6604 ZAKERO_YETANI__DEBUG <<
"--- Using UNSTABLE Decoration Manager ---\n";
6612 void Yetani::handlerRegistryRemove(
void* data
6613 ,
struct wl_registry*
6617 Yetani* yetani = (Yetani*)data;
6619 printf(
"Got a registry remove event for id %d\n",
id);
6623 std::lock_guard<std::mutex> lock(yetani->output_data.mutex);
6625 if(yetani->output_data.outputid_to_wloutput.contains(
id))
6627 struct wl_output* wl_output = yetani->output_data.outputid_to_wloutput[id];
6629 yetani->output_data.outputid_to_wloutput.erase(
id);
6630 yetani->output_data.wloutput_to_outputid.erase(wl_output);
6632 yetani->output_changes_map.erase(wl_output);
6633 yetani->output_state_map.erase(wl_output);
6635 yetani->on_output_remove(
id);
6636 yetani->output_data.output_map.erase(wl_output);
6644 if(yetani->id_to_seat.contains(
id))
6646 struct wl_seat* wl_seat = yetani->id_to_seat[id];
6648 yetani->seatDestroy(wl_seat);
6650 yetani->id_to_seat.erase(
id);
6665 void Yetani::handlerSeatCapabilities(
void* data
6666 ,
struct wl_seat* wl_seat
6667 , uint32_t capabilities
6670 ZAKERO_YETANI__DEBUG_VAR((uint64_t)wl_seat);
6672 Yetani* yetani = (Yetani*)data;
6673 Yetani::Seat& seat = yetani->seat_map[wl_seat];
6675 seat.version = wl_seat_get_version(wl_seat);
6677 if(capabilities & WL_SEAT_CAPABILITY_KEYBOARD)
6679 ZAKERO_YETANI__DEBUG <<
"-- Got a keyboard device --\n";
6681 yetani->keyboard.event_map[
nullptr] =
6682 { .on_enter = Lambda_DoNothing
6683 , .on_leave = Lambda_DoNothing
6684 , .on_key = LambdaKey_DoNothing
6687 yetani->keyboard.event = &(yetani->keyboard.event_map[
nullptr]);
6689 seat.wl_keyboard = wl_seat_get_keyboard(wl_seat);
6691 wl_keyboard_add_listener(seat.wl_keyboard
6692 , &Yetani::keyboard_listener
6697 if(capabilities & WL_SEAT_CAPABILITY_POINTER)
6699 ZAKERO_YETANI__DEBUG <<
"-- Got a pointer device --\n";
6701 yetani->pointer.yetani = yetani;
6703 yetani->pointer.event_map[
nullptr] =
6704 { .on_axis = LambdaAxis_DoNothing
6705 , .on_axis_discrete = Lambda_DoNothing
6706 , .on_axis_source = Lambda_DoNothing
6707 , .on_axis_stop = Lambda_DoNothing
6708 , .on_button_mm = LambdaButtonMm_DoNothing
6709 , .on_button_percent = LambdaButtonPercent_DoNothing
6710 , .on_button_pixel = LambdaButtonPixel_DoNothing
6711 , .on_enter_mm = LambdaPointMm_DoNothing
6712 , .on_enter_percent = LambdaPointPercent_DoNothing
6713 , .on_enter_pixel = LambdaPointPixel_DoNothing
6714 , .on_leave = Lambda_DoNothing
6715 , .on_motion_mm = LambdaPointMm_DoNothing
6716 , .on_motion_percent = LambdaPointPercent_DoNothing
6717 , .on_motion_pixel = LambdaPointPixel_DoNothing
6720 yetani->pointer.event = &(yetani->pointer.event_map[
nullptr]);
6722 seat.wl_pointer = wl_seat_get_pointer(wl_seat);
6724 wl_pointer_add_listener(seat.wl_pointer
6725 , &Yetani::pointer_listener
6730 if(capabilities & WL_SEAT_CAPABILITY_TOUCH)
6732 ZAKERO_YETANI__DEBUG <<
"-- Got a touch device --\n";
6733 seat.wl_touch = wl_seat_get_touch(wl_seat);
6746 void Yetani::handlerSeatName(
void* data
6747 ,
struct wl_seat* wl_seat
6751 ZAKERO_YETANI__DEBUG_VAR((uint64_t)wl_seat);
6752 ZAKERO_YETANI__DEBUG_VAR(name);
6754 Yetani* yetani = (Yetani*)data;
6756 yetani->seat_map[wl_seat].name = name;
6765 void Yetani::handlerShmFormat(
void* data
6770 Yetani* yetani = (Yetani*)data;
6772 wl_shm_format format = (wl_shm_format)value;
6779 yetani->shm_format_vector.push_back(format);
6788 void Yetani::handlerSurfaceEnter(
void* data
6789 ,
struct wl_surface* wl_surface
6790 ,
struct wl_output* wl_output
6798 Yetani* yetani = (Yetani*)data;
6799 Yetani::OutputData& output_data = yetani->output_data;
6801 output_data.mutex.lock();
6802 output_data.surface_output_map[wl_surface].push_back(wl_output);
6803 output_data.mutex.unlock();
6810 void Yetani::handlerSurfaceLeave(
void* data
6811 ,
struct wl_surface* wl_surface
6812 ,
struct wl_output* wl_output
6820 Yetani* yetani = (Yetani*)data;
6822 Yetani::OutputData& output_data = yetani->output_data;
6823 std::lock_guard<std::mutex> lock(output_data.mutex);
6825 Yetani::VectorWlOutput& output_vector = output_data.surface_output_map[wl_surface];
6828 struct wl_output* current_output = output_vector.front();
6834 if(current_output == output_vector.front())
6842 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
6844 if(surface_extent.preferred_unit == Yetani::SizeUnit::Pixel)
6852 current_output = output_vector.front();
6854 Yetani::Output& output = output_data.output_map.at(current_output);
6855 Yetani::SizePixel new_size;
6857 if(surface_extent.preferred_unit == Yetani::SizeUnit::Millimeter)
6859 auto p = yetani->convertMmToPixel(output
6860 , surface_extent.size_mm.width
6861 , surface_extent.size_mm.height
6864 new_size = { p.first, p.second };
6868 auto p = yetani->convertPercentToPixel(output
6869 , surface_extent.size_percent.width
6870 , surface_extent.size_percent.height
6873 new_size = { p.first, p.second };
6876 if(new_size.width <= 0)
6881 if(new_size.height <= 0)
6883 new_size.height = 1;
6886 if((new_size.width != surface_extent.size_pixel.width)
6887 && (new_size.height != surface_extent.size_pixel.height)
6890 yetani->surface_resize_mutex_map[wl_surface].lock();
6892 XdgSurface& surface = yetani->xdg_surface_map[wl_surface];
6894 surface_extent.size_pixel = new_size;
6895 surfaceCalculateSize(surface.yetani, surface.wl_surface, new_size);
6897 yetani->surface_resize_mutex_map[wl_surface].unlock();
6899 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
6900 event.on_size_pixel_change(surface_extent.size_pixel);
6910 void Yetani::handlerSwapBuffers(
void* data
6911 ,
struct wl_callback* callback
6915 Yetani::SurfaceFrame* surface_frame = (Yetani::SurfaceFrame*)data;
6917 wl_callback_destroy(callback);
6919 callback = wl_surface_frame(surface_frame->wl_surface);
6921 wl_callback_add_listener(callback
6922 , &frame_callback_listener
6926 struct wl_buffer* wl_buffer = surface_frame->buffer_next.exchange(
nullptr);
6927 if(wl_buffer !=
nullptr)
6929 wl_buffer_add_listener(wl_buffer
6930 , &Yetani::buffer_listener
6931 , wl_buffer_get_user_data(wl_buffer)
6934 surface_frame->time_ms = time_ms;
6936 wl_surface_attach(surface_frame->wl_surface, wl_buffer, 0, 0);
6938 wl_surface_damage(surface_frame->wl_surface
6940 , surface_frame->width, surface_frame->height
6944 wl_surface_commit(surface_frame->wl_surface);
6971 case Yetani::XdgState::Toplevel_Window_Fullscreen:
6972 return Yetani::WindowMode::Fullscreen;
6974 case Yetani::XdgState::Toplevel_Window_Maximized:
6975 return Yetani::WindowMode::Maximized;
6978 case Yetani::XdgState::Toplevel_Window_Normal:
6979 return Yetani::WindowMode::Normal;
6994 case Yetani::WindowMode::Fullscreen:
6995 return Yetani::XdgState::Toplevel_Window_Fullscreen;
6997 case Yetani::WindowMode::Maximized:
6998 return Yetani::XdgState::Toplevel_Window_Maximized;
7001 case Yetani::WindowMode::Normal:
7002 return Yetani::XdgState::Toplevel_Window_Normal;
7029 struct xdg_surface* Yetani::xdgSurfaceCreate(
struct wl_surface* wl_surface
7032 XdgSurface& surface = xdg_surface_map[wl_surface];
7034 surface.yetani =
this;
7035 surface.wl_surface = wl_surface;
7037 surface_extent_mutex.lock();
7039 Yetani::SurfaceExtent& surface_extent = surface_extent_map[wl_surface];
7041 surface_extent.preferred_unit = Yetani::SizeUnit::Pixel;
7042 surface_extent.preferred_mm = { 160, 90 };
7043 surface_extent.preferred_percent = { 0.32, 0.18 };
7044 surface_extent.size_mm = { 160, 90 };
7045 surface_extent.size_percent = { 0.32, 0.18 };
7046 surface_extent.size_pixel = { 800, 450 };
7047 surface_extent.size_pixel_max = { 0, 0 };
7048 surface_extent.size_pixel_min = { 0, 0 };
7050 surface_extent_mutex.unlock();
7052 output_notify_surface_vector.push_back(wl_surface);
7054 struct xdg_surface* xdg_surface = xdg_wm_base_get_xdg_surface(xdg_wm_base
7058 xdg_state_change_mutex.lock();
7060 xdg_state_change_map[xdg_surface] = {};
7062 xdg_state_change_mutex.unlock();
7064 xdg_surface_add_listener(xdg_surface
7065 , &xdg_surface_listener
7081 void Yetani::xdgSurfaceDestroy(
struct wl_surface* wl_surface
7082 ,
struct xdg_surface*& xdg_surface
7087 xdg_surface_destroy(xdg_surface);
7092 if(xdg_surface_map.contains(wl_surface))
7094 xdg_surface_map.erase(wl_surface);
7097 xdg_state_change_mutex.lock();
7099 if(xdg_state_change_map.contains(xdg_surface))
7101 xdg_state_change_map.erase(xdg_surface);
7104 xdg_state_change_mutex.unlock();
7106 surface_extent_mutex.lock();
7108 if(surface_extent_map.contains(wl_surface))
7110 surface_extent_map.erase(wl_surface);
7113 surface_extent_mutex.unlock();
7115 xdg_surface =
nullptr;
7122 void Yetani::xdgSurfaceSetExtent(
struct wl_surface* wl_surface
7123 ,
const Yetani::SizeUnit& size_unit
7124 ,
const Yetani::SizeMm& size_mm
7125 ,
const Yetani::SizePercent& size_percent
7126 ,
const Yetani::SizePixel& size_pixel
7129 Yetani::SurfaceExtent& surface_extent = surface_extent_map[wl_surface];
7131 surface_extent.preferred_unit = size_unit;
7132 surface_extent.preferred_mm = size_mm;
7133 surface_extent.preferred_percent = size_percent;
7134 surface_extent.size_mm = size_mm;
7135 surface_extent.size_percent = size_percent;
7136 surface_extent.size_pixel = size_pixel;
7137 surface_extent.size_pixel_max = { 0, 0 };
7138 surface_extent.size_pixel_min = { 0, 0 };
7182 struct xdg_toplevel* Yetani::xdgToplevelCreate(
struct xdg_surface* xdg_surface
7185 Yetani::XdgToplevel& toplevel = xdg_toplevel_map[xdg_surface];
7187 toplevel.close_request_lambda = Lambda_DoNothing;
7188 toplevel.state_change = &(xdg_state_change_map[xdg_surface]);
7189 toplevel.is_active =
false;
7190 toplevel.window_state = Yetani::XdgState::Toplevel_Window_Normal;
7191 toplevel.is_active_lambda = LambdaBool_DoNothing;
7192 toplevel.window_state_lambda = LambdaWindowMode_DoNothing;
7193 toplevel.previous_size = { 0, 0 };
7194 toplevel.xdg_toplevel =
nullptr;
7201 toplevel.state_change->push_back(Yetani::XdgState::Toplevel_Attach_Buffer);
7203 struct xdg_toplevel* xdg_toplevel =
nullptr;
7205 xdg_toplevel = xdg_surface_get_toplevel(xdg_surface);
7206 toplevel.xdg_toplevel = xdg_toplevel;
7208 xdg_toplevel_add_listener(xdg_toplevel
7209 , &xdg_toplevel_listener
7213 return xdg_toplevel;
7223 void Yetani::xdgToplevelDestroy(
struct xdg_surface* xdg_surface
7224 ,
struct xdg_toplevel*& xdg_toplevel
7227 if(xdg_toplevel !=
nullptr)
7229 xdg_toplevel_destroy(xdg_toplevel);
7232 if(xdg_toplevel_map.contains(xdg_surface))
7234 XdgToplevel& toplevel = xdg_toplevel_map[xdg_surface];
7236 toplevel.close_request_lambda =
nullptr;
7237 toplevel.state_change =
nullptr;
7238 toplevel.window_state = Yetani::XdgState::Unknown;
7239 toplevel.is_active =
false;
7240 toplevel.is_active_lambda =
nullptr;
7241 toplevel.window_state_lambda =
nullptr;
7243 xdg_toplevel_map.erase(xdg_surface);
7246 xdg_toplevel =
nullptr;
7259 void Yetani::xdgToplevelSizeChange(Yetani* yetani
7260 ,
struct wl_surface* wl_surface
7261 ,
const Yetani::SizePixel& size_pixel
7264 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
7265 Yetani::SizePixel new_size = surface_extent.size_pixel;
7267 if(((surface_extent.size_pixel_min.width == 0) || (size_pixel.width >= surface_extent.size_pixel_min.width))
7268 && ((surface_extent.size_pixel_max.width == 0) || (size_pixel.width <= surface_extent.size_pixel_max.width))
7271 new_size.width = size_pixel.width;
7274 if(((surface_extent.size_pixel_min.height == 0) || (size_pixel.height >= surface_extent.size_pixel_min.height))
7275 && ((surface_extent.size_pixel_max.height == 0) || (size_pixel.height <= surface_extent.size_pixel_max.height))
7278 new_size.height = size_pixel.height;
7281 if((new_size.width == surface_extent.size_pixel.width)
7282 && (new_size.height == surface_extent.size_pixel.height)
7289 Yetani::SizeMm size_mm;
7290 Yetani::SizePercent size_percent;
7291 yetani->convertPixel(wl_surface
7292 , size_pixel.width , size_pixel.height
7293 , size_mm.width , size_mm.height
7294 , size_percent.width, size_percent.height
7297 yetani->surface_resize_mutex_map[wl_surface].lock();
7299 surface_extent.size_pixel = new_size;
7300 surfaceCalculateSize(yetani, wl_surface, new_size);
7302 yetani->surface_resize_mutex_map[wl_surface].unlock();
7304 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
7305 event.on_size_pixel_change(surface_extent.size_pixel);
7306 event.on_size_mm_change(surface_extent.size_mm);
7307 event.on_size_percent_change(surface_extent.size_percent);
7314 void Yetani::xdgToplevelSizeMinMaxChange(Yetani* yetani
7315 ,
struct xdg_toplevel* xdg_toplevel
7316 ,
struct wl_surface* wl_surface
7317 ,
const Yetani::SizePixel& size_pixel_min
7318 ,
const Yetani::SizePixel& size_pixel_max
7321 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
7323 Yetani::SizePixel size_pixel = surface_extent.size_pixel;
7324 bool need_to_resize =
false;
7326 if(size_pixel_max.width > 0
7327 && size_pixel_max.width < surface_extent.size_pixel.width
7330 need_to_resize =
true;
7331 size_pixel.width = size_pixel_max.width;
7334 if(size_pixel_max.height > 0
7335 && size_pixel_max.height < surface_extent.size_pixel.height
7338 need_to_resize =
true;
7339 size_pixel.height = size_pixel_max.height;
7342 if(size_pixel_min.width > 0
7343 && size_pixel_min.width > surface_extent.size_pixel.width
7346 need_to_resize =
true;
7347 size_pixel.width = size_pixel_min.width;
7350 if(size_pixel_min.height > 0
7351 && size_pixel_min.height > surface_extent.size_pixel.height
7354 need_to_resize =
true;
7355 size_pixel.height = size_pixel_min.height;
7360 xdg_toplevel_set_max_size(xdg_toplevel, 0, 0);
7361 xdg_toplevel_set_min_size(xdg_toplevel, 0, 0);
7363 yetani->surface_resize_mutex_map[wl_surface].lock();
7365 surface_extent.size_pixel = size_pixel;
7366 surfaceCalculateSize(yetani, wl_surface, size_pixel);
7368 yetani->surface_resize_mutex_map[wl_surface].unlock();
7371 xdg_toplevel_set_min_size(xdg_toplevel
7372 , size_pixel_min.width
7373 , size_pixel_min.height
7376 xdg_toplevel_set_max_size(xdg_toplevel
7377 , size_pixel_max.width
7378 , size_pixel_max.height
7381 surface_extent.size_pixel_min = size_pixel_min;
7382 surface_extent.size_pixel_max = size_pixel_max;
7389 void Yetani::xdgToplevelWindowChange(Yetani* yetani
7390 ,
struct wl_surface* wl_surface
7391 , Yetani::XdgToplevel& toplevel
7392 ,
const Yetani::XdgState window_state
7393 ,
const Yetani::SizePixel& size_pixel
7396 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
7397 Yetani::SizePixel new_size{1, 1};
7399 toplevel.window_state = window_state;
7401 if((toplevel.window_state == Yetani::XdgState::Toplevel_Window_Fullscreen)
7402 || (toplevel.window_state == Yetani::XdgState::Toplevel_Window_Maximized)
7405 if(toplevel.previous_size.width == 0)
7407 xdg_toplevel_set_max_size(toplevel.xdg_toplevel, 0, 0);
7408 xdg_toplevel_set_min_size(toplevel.xdg_toplevel, 0, 0);
7410 toplevel.previous_size = surface_extent.size_pixel;
7413 if((size_pixel.width != 0)
7414 && (size_pixel.height != 0)
7417 new_size = size_pixel;
7420 else if(toplevel.window_state == Yetani::XdgState::Toplevel_Window_Normal)
7422 xdg_toplevel_set_max_size(toplevel.xdg_toplevel
7423 , surface_extent.size_pixel_max.width
7424 , surface_extent.size_pixel_max.height
7427 xdg_toplevel_set_min_size(toplevel.xdg_toplevel
7428 , surface_extent.size_pixel_min.width
7429 , surface_extent.size_pixel_min.height
7432 new_size = toplevel.previous_size;
7433 toplevel.previous_size.width = 0;
7436 if(new_size == surface_extent.size_pixel)
7442 Yetani::SizeMm size_mm;
7443 Yetani::SizePercent size_percent;
7444 yetani->convertPixel(wl_surface
7445 , size_pixel.width , size_pixel.height
7446 , size_mm.width , size_mm.height
7447 , size_percent.width, size_percent.height
7450 yetani->surface_resize_mutex_map[wl_surface].lock();
7452 surface_extent.size_mm = size_mm;
7453 surface_extent.size_percent = size_percent;
7454 surface_extent.size_pixel = new_size;
7455 surfaceCalculateSize(yetani, wl_surface, new_size);
7457 yetani->surface_resize_mutex_map[wl_surface].unlock();
7459 toplevel.window_state_lambda(Yetani::toWindowMode(toplevel.window_state));
7461 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
7462 event.on_size_pixel_change(surface_extent.size_pixel);
7463 event.on_size_mm_change(surface_extent.size_mm);
7464 event.on_size_percent_change(surface_extent.size_percent);
7493 struct zxdg_toplevel_decoration_v1* Yetani::xdgDecorationCreate(
struct xdg_surface* xdg_surface
7494 ,
struct xdg_toplevel* xdg_toplevel
7497 if(decoration_manager ==
nullptr)
7508 zxdg_toplevel_decoration_v1* xdg_decoration =
7509 zxdg_decoration_manager_v1_get_toplevel_decoration(decoration_manager
7513 Yetani::XdgDecoration& decoration = xdg_decoration_map[xdg_surface];
7514 decoration.state_change = &(xdg_state_change_map[xdg_surface]);
7515 decoration.lambda = LambdaWindowDecorations_DoNothing;
7516 decoration.state = 0;
7517 decoration.is_present =
false;
7519 zxdg_toplevel_decoration_v1_add_listener(xdg_decoration
7520 , &xdg_toplevel_decoration_listener
7524 return xdg_decoration;
7533 void Yetani::xdgDecorationDestroy(
struct xdg_surface* xdg_surface
7534 ,
struct xdg_toplevel*
7535 ,
struct zxdg_toplevel_decoration_v1*& xdg_decoration
7538 zxdg_toplevel_decoration_v1_destroy(xdg_decoration);
7540 if(xdg_decoration_map.contains(xdg_surface))
7542 Yetani::XdgDecoration& decoration = xdg_decoration_map[xdg_surface];
7543 decoration.state_change =
nullptr;
7544 decoration.lambda =
nullptr;
7545 decoration.state = 0;
7546 decoration.is_present =
false;
7548 xdg_decoration_map.erase(xdg_surface);
7551 xdg_decoration =
nullptr;
7560 void Yetani::xdgDecorationChange(Yetani::XdgDecoration& decoration
7561 ,
const uint32_t decoration_state
7564 if(decoration_state == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE)
7566 if(decoration.state != decoration_state)
7568 decoration.state = decoration_state;
7569 decoration.is_present =
false;
7572 Yetani::WindowDecorations::Client_Side
7576 else if(decoration_state == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE)
7578 if(decoration.state != decoration_state)
7580 decoration.state = decoration_state;
7581 decoration.is_present =
true;
7585 decoration.is_present = !decoration.is_present;
7588 if(decoration.is_present ==
true)
7591 Yetani::WindowDecorations::Server_Side
7597 Yetani::WindowDecorations::Client_Side
7619 void Yetani::handlerXdgSurfaceConfigure(
void* data
7620 , xdg_surface* xdg_surface
7624 Yetani::XdgSurface& surface = *((Yetani::XdgSurface*)data);
7625 Yetani* yetani = surface.yetani;
7627 xdg_surface_ack_configure(xdg_surface, serial);
7629 VectorXdgStateChange& state_change = yetani->xdg_state_change_map[xdg_surface];
7631 if(state_change.empty())
7636 auto iter = std::begin(state_change);
7637 auto iter_end = std::end(state_change);
7639 while(iter != iter_end)
7643 case Yetani::XdgState::Toplevel_Active:
7645 Yetani::XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
7648 bool is_active = bool(*iter);
7649 if(toplevel.is_active != is_active)
7651 toplevel.is_active = is_active;
7653 toplevel.is_active_lambda(is_active);
7657 case Yetani::XdgState::Toplevel_Attach_Buffer:
7659 struct wl_surface* wl_surface = surface.wl_surface;
7661 SurfaceFrame& surface_frame =
7662 yetani->surface_frame_map[wl_surface];
7664 wl_surface_attach(surface_frame.wl_surface
7665 , surface_frame.buffer_next
7669 struct wl_callback* callback = wl_surface_frame(surface_frame.wl_surface);
7671 wl_callback_add_listener(callback
7672 , &frame_callback_listener
7676 wl_surface_commit(surface_frame.wl_surface);
7679 case Yetani::XdgState::Toplevel_Window_Normal:
7680 case Yetani::XdgState::Toplevel_Window_Maximized:
7681 case Yetani::XdgState::Toplevel_Window_Fullscreen:
7683 struct wl_surface* wl_surface = surface.wl_surface;
7685 Yetani::XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
7687 Yetani::XdgState window_state = XdgState(*iter);
7689 Yetani::SizePixel size_pixel;
7692 size_pixel.width = *iter;
7695 size_pixel.height = *iter;
7697 if(toplevel.window_state != window_state)
7699 xdgToplevelWindowChange(yetani
7708 case Yetani::XdgState::Toplevel_Resizing:
7710 struct wl_surface* wl_surface = surface.wl_surface;
7712 Yetani::SizePixel size_pixel;
7715 size_pixel.width = *iter;
7718 size_pixel.height = *iter;
7720 if(size_pixel.width > 0
7721 && size_pixel.height > 0
7724 xdgToplevelSizeChange(yetani
7731 case Yetani::XdgState::Toplevel_Decoration:
7734 uint32_t decoration_state = *iter;
7736 Yetani::XdgDecoration& decoration = yetani->xdg_decoration_map[xdg_surface];
7738 xdgDecorationChange(decoration, decoration_state);
7745 state_change.clear();
7754 void Yetani::handlerXdgToplevelClose(
void* data
7755 ,
struct xdg_toplevel*
7758 Yetani::XdgToplevel* toplevel = (Yetani::XdgToplevel*)data;
7760 toplevel->close_request_lambda();
7767 void Yetani::handlerXdgToplevelConfigure(
void* data
7768 ,
struct xdg_toplevel*
7771 ,
struct wl_array* state_array
7774 Yetani::XdgToplevel* toplevel = (Yetani::XdgToplevel*)data;
7776 Yetani::XdgState window_state = Yetani::XdgState::Toplevel_Window_Normal;
7777 int32_t is_active = 0;
7779 ZAKERO_YETANI__ARRAY_FOR_EACH(xdg_toplevel_state*, state_iter, state_array)
7781 xdg_toplevel_state state = *state_iter;
7785 case XDG_TOPLEVEL_STATE_MAXIMIZED:
7786 window_state = Yetani::XdgState::Toplevel_Window_Maximized;
7788 case XDG_TOPLEVEL_STATE_FULLSCREEN:
7789 window_state = Yetani::XdgState::Toplevel_Window_Fullscreen;
7791 case XDG_TOPLEVEL_STATE_RESIZING:
7792 toplevel->state_change->push_back(Yetani::XdgState::Toplevel_Resizing);
7793 toplevel->state_change->push_back(width);
7794 toplevel->state_change->push_back(height);
7796 case XDG_TOPLEVEL_STATE_ACTIVATED:
7799 case XDG_TOPLEVEL_STATE_TILED_LEFT:
7801 case XDG_TOPLEVEL_STATE_TILED_RIGHT:
7803 case XDG_TOPLEVEL_STATE_TILED_TOP:
7805 case XDG_TOPLEVEL_STATE_TILED_BOTTOM:
7812 toplevel->state_change->push_back(window_state);
7813 toplevel->state_change->push_back(width);
7814 toplevel->state_change->push_back(height);
7816 toplevel->state_change->push_back(Yetani::XdgState::Toplevel_Active);
7817 toplevel->state_change->push_back(is_active);
7826 void Yetani::handlerXdgWmBasePing(
void*
7827 ,
struct xdg_wm_base* xdg_wm_base
7831 xdg_wm_base_pong(xdg_wm_base, serial);
7840 void Yetani::handlerXdgToplevelDecorationConfigure(
void* data
7841 ,
struct zxdg_toplevel_decoration_v1*
7845 Yetani::XdgDecoration* deco = (Yetani::XdgDecoration*)data;
7847 deco->state_change->push_back(Yetani::XdgState::Toplevel_Decoration);
7848 deco->state_change->push_back(mode);
8019 , std::error_code& error
8022 return windowCreate(Yetani::SizeUnit::Millimeter
8026 , SHM_FORMAT_DEFAULT
8045 ,
const wl_shm_format format
8048 std::error_code error;
8050 return windowCreate(Yetani::SizeUnit::Millimeter
8076 ,
const wl_shm_format format
8077 , std::error_code& error
8080 return windowCreate(Yetani::SizeUnit::Millimeter
8104 , std::error_code& error
8107 return windowCreate(Yetani::SizeUnit::Percent
8111 , SHM_FORMAT_DEFAULT
8130 ,
const wl_shm_format format
8133 std::error_code error;
8135 return windowCreate(Yetani::SizeUnit::Percent
8161 ,
const wl_shm_format format
8162 , std::error_code& error
8165 return windowCreate(Yetani::SizeUnit::Percent
8189 , std::error_code& error
8192 return windowCreate(Yetani::SizeUnit::Pixel
8196 , SHM_FORMAT_DEFAULT
8215 ,
const wl_shm_format format
8218 std::error_code error;
8220 return windowCreate(Yetani::SizeUnit::Pixel
8246 ,
const wl_shm_format format
8247 , std::error_code& error
8250 return windowCreate(Yetani::SizeUnit::Pixel
8271 ,
const wl_shm_format pixel_format
8272 , std::error_code& error
8275 if((size_unit == Yetani::SizeUnit::Millimeter)
8276 && (size_mm.width <= 0 || size_mm.height <= 0)
8279 error = ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
8284 if((size_unit == Yetani::SizeUnit::Percent)
8285 && (size_percent.width <= 0 || size_percent.height <= 0)
8288 error = ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
8293 if((size_unit == Yetani::SizeUnit::Pixel)
8294 && (size_pixel.width <= 0 || size_pixel.height <= 0)
8297 error = ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
8302 const std::string file_name =
"Zakero.Yetani."
8306 struct WindowData window_data =
8309 , .wl_output = nullptr
8310 , .file_name = file_name
8311 , .size_mm = size_mm
8312 , .size_percent = size_percent
8313 , .size_pixel = size_pixel
8314 , .size_unit = size_unit
8315 , .pixel_format = pixel_format
8316 , .error = ZAKERO_YETANI__ERROR(Error_None)
8319 windowDataInit(window_data);
8321 if(window_data.error)
8323 error = window_data.error;
8328 Yetani::Window* window =
new Window(&window_data);
8330 if(window_data.error)
8335 ZAKERO_YETANI__DEBUG <<
to_string(window_data.error) <<
"\n";
8337 error = ZAKERO_YETANI__ERROR(Error_Window_Initialization_Failed);
8342 error = ZAKERO_YETANI__ERROR(Error_None);
8351 void Yetani::windowDataInit(Yetani::WindowData& window_data
8354 windowDataInitOutput(window_data);
8356 if(window_data.error)
8361 window_data.size_pixel.width = std::max(1, window_data.size_pixel.width);
8362 window_data.size_pixel.height = std::max(1, window_data.size_pixel.height);
8364 window_data.error = ZAKERO_YETANI__ERROR(Error_None);
8371 void Yetani::windowDataInitOutput(Yetani::WindowData& window_data
8374 std::lock_guard<std::mutex> lock(output_data.mutex);
8376 if(output_data.output_map.empty())
8378 window_data.error = ZAKERO_YETANI__ERROR(Error_No_Output_Available);
8383 const auto& iter = output_data.output_map.begin();
8385 window_data.wl_output = iter->first;
8386 Yetani::Output& output = iter->second;
8388 if(window_data.size_unit == Yetani::SizeUnit::Millimeter)
8390 auto px = convertMmToPixel(output
8391 , window_data.size_mm.width
8392 , window_data.size_mm.height
8395 auto pc = convertPixelToPercent(output
8400 window_data.size_mm = window_data.size_mm;
8401 window_data.size_percent = { pc.first, pc.second };
8402 window_data.size_pixel = { px.first, px.second };
8404 else if(window_data.size_unit == Yetani::SizeUnit::Percent)
8406 auto px = convertPercentToPixel(output
8407 , window_data.size_percent.width
8408 , window_data.size_percent.height
8411 auto mm = convertPixelToMm(output
8416 window_data.size_mm = { mm.first, mm.second };
8417 window_data.size_percent = window_data.size_percent;
8418 window_data.size_pixel = { px.first, px.second };
8420 else if(window_data.size_unit == Yetani::SizeUnit::Pixel)
8422 auto mm = convertPixelToMm(output
8423 , window_data.size_pixel.width
8424 , window_data.size_pixel.height
8427 auto pc = convertPixelToPercent(output
8428 , window_data.size_pixel.width
8429 , window_data.size_pixel.height
8432 window_data.size_mm = { mm.first, mm.second };
8433 window_data.size_percent = { pc.first, pc.second };
8434 window_data.size_pixel = window_data.size_pixel;
8437 window_data.error = ZAKERO_YETANI__ERROR(Error_None);
8444 void Yetani::windowInitMemory(Yetani::WindowData& window_data
8445 , Yetani::Window::Memory& window_memory
8448 size_t size_in_bytes = sizeInBytes(window_data.size_pixel
8449 , window_data.pixel_format
8452 window_data.error = window_memory.memory_pool.init(size_in_bytes
8454 , zakero::MemoryPool::Alignment::Bits_32
8457 if(window_data.error)
8462 window_memory.wl_shm_pool = wl_shm_create_pool(window_data.wl_shm
8463 , window_memory.memory_pool.fd()
8464 , window_memory.memory_pool.size()
8467 window_memory.memory_pool.sizeOnChange([&](
size_t new_size)
8469 wl_shm_pool_resize(window_memory.wl_shm_pool, new_size);
8472 window_data.error = ZAKERO_YETANI__ERROR(Error_None);
8479 void Yetani::windowInitOutput(Yetani::WindowData& window_data
8480 ,
struct wl_surface* wl_surface
8483 std::lock_guard<std::mutex> lock(output_data.mutex);
8485 output_data.surface_output_map[wl_surface].push_back(window_data.wl_output);
8492 void Yetani::windowEraseMemory(Yetani::Window::Memory& window_memory
8495 if(window_memory.wl_shm_pool)
8497 wl_shm_pool_destroy(window_memory.wl_shm_pool);
8498 window_memory.wl_shm_pool =
nullptr;
8506 void Yetani::windowEraseOutput(
struct wl_surface* wl_surface
8509 std::lock_guard<std::mutex> lock(output_data.mutex);
8511 if(output_data.surface_output_map.contains(wl_surface))
8513 output_data.surface_output_map.erase(wl_surface);
8521 void Yetani::windowEraseSurfaceExtent(
struct wl_surface* wl_surface
8524 std::lock_guard<std::mutex> lock(surface_extent_mutex);
8526 if(surface_extent_map.contains(wl_surface))
8528 surface_extent_map.erase(wl_surface);
8536 void Yetani::windowAdd(Yetani::Window* window
8539 std::lock_guard<std::mutex> lock(window_vector_mutex);
8541 window_vector.push_back(window);
8548 void Yetani::windowRemove(Yetani::Window* window
8551 std::lock_guard<std::mutex> lock(window_vector_mutex);
8756 : yetani {((
Yetani::WindowData*)ptr)->yetani}
8757 , wl_buffer {nullptr}
8758 , wl_surface {nullptr}
8759 , xdg_surface {nullptr}
8760 , xdg_toplevel {nullptr}
8761 , xdg_decoration {nullptr}
8762 , window_memory {nullptr, ((
Yetani::WindowData*)ptr)->file_name}
8763 , pixel_format {((
Yetani::WindowData*)ptr)->pixel_format}
8765 Yetani::WindowData& window_data = *((Yetani::WindowData*)ptr);
8767 yetani->windowInitMemory(window_data, window_memory);
8768 if(window_data.error)
8773 wl_surface = yetani->surfaceCreate(yetani
8775 , window_data.size_pixel
8779 xdg_surface = yetani->xdgSurfaceCreate(wl_surface);
8781 yetani->xdgSurfaceSetExtent(wl_surface
8782 , window_data.size_unit
8783 , window_data.size_mm
8784 , window_data.size_percent
8785 , window_data.size_pixel
8788 xdg_toplevel = yetani->xdgToplevelCreate(xdg_surface);
8790 xdg_decoration = yetani->xdgDecorationCreate(xdg_surface, xdg_toplevel);
8792 wl_surface_commit(wl_surface);
8794 yetani->windowInitOutput(window_data, wl_surface);
8795 if(window_data.error)
8800 yetani->windowAdd(
this);
8809 yetani->windowRemove(
this);
8811 if(xdg_decoration !=
nullptr)
8813 yetani->xdgDecorationDestroy(xdg_surface, xdg_toplevel, xdg_decoration);
8816 if(xdg_toplevel !=
nullptr)
8818 yetani->xdgToplevelDestroy(xdg_surface, xdg_toplevel);
8821 if(xdg_surface !=
nullptr)
8823 yetani->xdgSurfaceDestroy(wl_surface, xdg_surface);
8826 if(wl_surface !=
nullptr)
8828 yetani->windowEraseOutput(wl_surface);
8829 yetani->surfaceDestroy(yetani, wl_surface);
8830 yetani->windowEraseSurfaceExtent(wl_surface);
8833 yetani->windowEraseMemory(window_memory);
8857 return yetani->cursorDetach(wl_surface);
8860 return yetani->cursorAttach(name, wl_surface);
8871 yetani->cursorHide(wl_surface);
8882 yetani->cursorShow(wl_surface);
8907 xdg_toplevel_set_app_id(xdg_toplevel, class_name.c_str());
8920 xdg_toplevel_set_title(xdg_toplevel, title.c_str());
8946 if(yetani->decoration_manager ==
nullptr)
8948 return ZAKERO_YETANI__ERROR(Error_Server_Side_Decorations_Not_Available);
8951 uint32_t decoration_state = decorations == Yetani::WindowDecorations::Server_Side
8952 ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE
8953 : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE
8956 zxdg_toplevel_decoration_v1_set_mode(xdg_decoration
8960 return ZAKERO_YETANI__ERROR(Error_None);
8973 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
8992 XdgState window_state = Yetani::toXdgState(window_mode);
8994 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
8996 if(toplevel.window_state == window_state)
9016 XdgState window_state = Yetani::toXdgState(window_mode);
9018 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
9020 if(toplevel.window_state == window_state)
9027 case WindowMode::Fullscreen:
9028 xdg_toplevel_set_fullscreen(xdg_toplevel,
nullptr);
9031 case WindowMode::Maximized:
9032 xdg_toplevel_set_maximized(xdg_toplevel);
9035 case WindowMode::Normal:
9036 xdg_toplevel_unset_fullscreen(xdg_toplevel);
9037 xdg_toplevel_unset_maximized(xdg_toplevel);
9062 if(size.width <= 0 || size.height <= 0)
9064 return ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
9069 if(size_pixel.
width <= 0)
9071 size_pixel.
width = 1;
9074 if(size_pixel.
height <= 0)
9079 yetani->surface_resize_mutex_map[wl_surface].lock();
9081 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
9083 surface_extent.preferred_unit = Yetani::SizeUnit::Millimeter;
9084 surface_extent.preferred_mm = size;
9085 surface_extent.size_pixel = size_pixel;
9087 surfaceCalculateSize(yetani, wl_surface, size_pixel);
9089 yetani->surface_resize_mutex_map[wl_surface].unlock();
9091 return ZAKERO_YETANI__ERROR(Error_None);
9114 if(size.width <= 0 || size.height <= 0)
9116 return ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
9121 if(size_pixel.
width <= 0)
9123 size_pixel.
width = 1;
9126 if(size_pixel.
height <= 0)
9131 yetani->surface_resize_mutex_map[wl_surface].lock();
9133 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
9135 surface_extent.preferred_unit = Yetani::SizeUnit::Percent;
9136 surface_extent.preferred_percent = size;
9137 surface_extent.size_pixel = size_pixel;
9139 surfaceCalculateSize(yetani, wl_surface, size_pixel);
9141 yetani->surface_resize_mutex_map[wl_surface].unlock();
9143 return ZAKERO_YETANI__ERROR(Error_None);
9166 if(size.width <= 0 || size.height <= 0)
9168 return ZAKERO_YETANI__ERROR(Error_Window_Size_Too_Small);
9171 yetani->surface_resize_mutex_map[wl_surface].lock();
9173 Yetani::SurfaceExtent& surface_extent = yetani->surface_extent_map[wl_surface];
9175 surface_extent.preferred_unit = Yetani::SizeUnit::Pixel;
9176 surface_extent.size_pixel = size;
9178 surfaceCalculateSize(yetani, wl_surface, size);
9180 yetani->surface_resize_mutex_map[wl_surface].unlock();
9182 return ZAKERO_YETANI__ERROR(Error_None);
9201 std::error_code error = validateMinMax<Yetani::SizeMm>(size_min, size_max);
9211 Yetani::OutputData& output_data = yetani->output_data;
9213 std::lock_guard<std::mutex> lock(output_data.mutex);
9215 Yetani::VectorWlOutput& vector = output_data.surface_output_map[wl_surface];
9216 struct wl_output* wl_output = vector.front();
9219 auto min = yetani->convertMmToPixel(
output, size_min.
width, size_min.height);
9220 size_pixel_min = { min.first, min.second };
9222 auto max = yetani->convertMmToPixel(
output, size_max.
width, size_max.height);
9223 size_pixel_max = { max.first, max.second };
9226 yetani->xdgToplevelSizeMinMaxChange(yetani
9233 return ZAKERO_YETANI__ERROR(Error_None);
9252 std::error_code error = validateMinMax<Yetani::SizePercent>(size_min, size_max);
9262 Yetani::OutputData& output_data = yetani->output_data;
9264 std::lock_guard<std::mutex> lock(output_data.mutex);
9266 Yetani::VectorWlOutput& vector = output_data.surface_output_map[wl_surface];
9267 struct wl_output* wl_output = vector.front();
9270 auto min = yetani->convertPercentToPixel(
output, size_min.
width, size_min.height);
9271 size_pixel_min = { min.first, min.second };
9273 auto max = yetani->convertPercentToPixel(
output, size_max.
width, size_max.height);
9274 size_pixel_max = { max.first, max.second };
9277 yetani->xdgToplevelSizeMinMaxChange(yetani
9284 return ZAKERO_YETANI__ERROR(Error_None);
9303 std::error_code error = validateMinMax<Yetani::SizePixel>(size_min, size_max);
9309 yetani->xdgToplevelSizeMinMaxChange(yetani
9316 return ZAKERO_YETANI__ERROR(Error_None);
9362 if(wl_buffer !=
nullptr)
9364 bufferDestroy(wl_buffer);
9367 Yetani::SurfaceSize& surface_size = yetani->surface_size_map[wl_surface];
9369 yetani->surface_resize_mutex_map[wl_surface].lock();
9371 wl_buffer = bufferCreate(surface_size
9376 yetani->surface_resize_mutex_map[wl_surface].unlock();
9378 image = window_memory.memory_pool.addressOf(
9379 yetani->buffer.map[wl_buffer].offset
9382 size = { surface_size.width, surface_size.height };
9384 return ZAKERO_YETANI__ERROR(Error_None);
9396 if(wl_buffer ==
nullptr)
9408 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
9410 wl_buffer = surface_frame.buffer_next.exchange(wl_buffer);
9428 Yetani::SurfaceFrame& surface_frame = yetani->surface_frame_map[wl_surface];
9430 return surface_frame.time_ms;
9446 return yetani->shmFormatBytesPerPixel(pixel_format);
9459 xdg_toplevel_set_minimized(xdg_toplevel);
9475 const Yetani::OutputData& output_data = yetani->output_data;
9477 std::lock_guard<std::mutex> lock(output_data.mutex);
9479 struct wl_output* wl_output = output_data.surface_output_map.at(wl_surface).front();
9482 auto p = yetani->convertPixelToMm(
output, point.
x, point.y);
9484 return { point.time, p.first, p.second };
9498 const Yetani::OutputData& output_data = yetani->output_data;
9500 std::lock_guard<std::mutex> lock(output_data.mutex);
9502 struct wl_output* wl_output = output_data.surface_output_map.at(wl_surface).front();
9505 auto p = yetani->convertPixelToPercent(
output, point.
x, point.y);
9507 return { point.time, p.first, p.second };
9521 Yetani::OutputData& output_data = yetani->output_data;
9523 std::lock_guard<std::mutex> lock(output_data.mutex);
9525 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9528 auto p = yetani->convertMmToPixel(
output, point.
x, point.y);
9530 return { point.time, p.first, p.second };
9544 Yetani::OutputData& output_data = yetani->output_data;
9546 std::lock_guard<std::mutex> lock(output_data.mutex);
9548 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9551 auto p = yetani->convertPercentToPixel(
output, point.
x, point.y);
9553 return { point.time, p.first, p.second };
9567 Yetani::OutputData& output_data = yetani->output_data;
9569 std::lock_guard<std::mutex> lock(output_data.mutex);
9571 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9574 auto p = yetani->convertPixelToMm(
output, size.
width, size.height);
9576 return { p.first, p.second };
9590 Yetani::OutputData& output_data = yetani->output_data;
9592 std::lock_guard<std::mutex> lock(output_data.mutex);
9594 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9597 auto p = yetani->convertPixelToPercent(
output, size.
width, size.height);
9599 return { p.first, p.second };
9613 Yetani::OutputData& output_data = yetani->output_data;
9615 std::lock_guard<std::mutex> lock(output_data.mutex);
9617 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9620 auto p = yetani->convertMmToPixel(
output, size.
width, size.height);
9622 return { p.first, p.second };
9636 Yetani::OutputData& output_data = yetani->output_data;
9638 std::lock_guard<std::mutex> lock(output_data.mutex);
9640 struct wl_output* wl_output = output_data.surface_output_map[wl_surface].front();
9643 auto p = yetani->convertPercentToPixel(
output, size.
width, size.height);
9645 return { p.first, p.second };
9665 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
9667 if(lambda ==
nullptr)
9669 toplevel.close_request_lambda = Lambda_DoNothing;
9673 toplevel.close_request_lambda = lambda;
9690 XdgDecoration& decoration = yetani->xdg_decoration_map[xdg_surface];
9692 if(lambda ==
nullptr)
9694 decoration.lambda = LambdaWindowDecorations_DoNothing;
9698 decoration.lambda = lambda;
9719 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
9721 if(lambda ==
nullptr)
9723 toplevel.is_active_lambda = LambdaBool_DoNothing;
9727 toplevel.is_active_lambda = lambda;
9740 if(yetani->keyboard.event_map.contains(wl_surface) ==
false)
9745 Yetani::KeyboardEvent&
event = yetani->keyboard.event_map[wl_surface];
9747 if(lambda ==
nullptr)
9749 event.on_enter = Lambda_DoNothing;
9753 event.on_enter = lambda;
9766 if(yetani->keyboard.event_map.contains(wl_surface) ==
false)
9771 Yetani::KeyboardEvent&
event = yetani->keyboard.event_map[wl_surface];
9773 if(lambda ==
nullptr)
9775 event.on_leave = Lambda_DoNothing;
9779 event.on_leave = lambda;
9794 if(yetani->keyboard.event_map.contains(wl_surface) ==
false)
9799 Yetani::KeyboardEvent&
event = yetani->keyboard.event_map[wl_surface];
9801 if(lambda ==
nullptr)
9803 event.on_key = LambdaKey_DoNothing;
9807 event.on_key = lambda;
9821 XdgToplevel& toplevel = yetani->xdg_toplevel_map[xdg_surface];
9823 if(lambda ==
nullptr)
9825 toplevel.window_state_lambda = LambdaWindowMode_DoNothing;
9829 toplevel.window_state_lambda = lambda;
9850 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
9852 if(lambda ==
nullptr)
9854 event.on_size_mm_change = LambdaSizeMm_DoNothing;
9858 event.on_size_mm_change = lambda;
9879 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
9881 if(lambda ==
nullptr)
9883 event.on_size_percent_change = LambdaSizePercent_DoNothing;
9887 event.on_size_percent_change = lambda;
9908 Yetani::SurfaceEvent&
event = yetani->surface_event_map[wl_surface];
9910 if(lambda ==
nullptr)
9912 event.on_size_pixel_change = LambdaSizePixel_DoNothing;
9916 event.on_size_pixel_change = lambda;
9931 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
9936 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
9938 if(lambda ==
nullptr)
9940 event.on_button_mm = LambdaButtonMm_DoNothing;
9944 event.on_button_mm = lambda;
9959 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
9964 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
9966 if(lambda ==
nullptr)
9968 event.on_button_percent = LambdaButtonPercent_DoNothing;
9972 event.on_button_percent = lambda;
9987 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
9992 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
9994 if(lambda ==
nullptr)
9996 event.on_button_pixel = LambdaButtonPixel_DoNothing;
10000 event.on_button_pixel = lambda;
10018 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10023 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10025 if(lambda ==
nullptr)
10027 event.on_enter_mm = LambdaPointMm_DoNothing;
10031 event.on_enter_mm = lambda;
10049 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10054 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10056 if(lambda ==
nullptr)
10058 event.on_enter_percent = LambdaPointPercent_DoNothing;
10062 event.on_enter_percent = lambda;
10080 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10085 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10087 if(lambda ==
nullptr)
10089 event.on_enter_pixel = LambdaPointPixel_DoNothing;
10093 event.on_enter_pixel = lambda;
10108 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10113 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10115 if(lambda ==
nullptr)
10117 event.on_leave = Lambda_DoNothing;
10121 event.on_leave = lambda;
10136 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10141 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10143 if(lambda ==
nullptr)
10145 event.on_motion_mm = LambdaPointMm_DoNothing;
10149 event.on_motion_mm = lambda;
10164 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10169 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10171 if(lambda ==
nullptr)
10173 event.on_motion_percent = LambdaPointPercent_DoNothing;
10177 event.on_motion_percent = lambda;
10192 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10197 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10199 if(lambda ==
nullptr)
10201 event.on_motion_pixel = LambdaPointPixel_DoNothing;
10205 event.on_motion_pixel = lambda;
10219 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10224 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10226 if(lambda ==
nullptr)
10228 event.on_axis = LambdaAxis_DoNothing;
10232 event.on_axis = lambda;
10246 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10251 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10253 if(lambda ==
nullptr)
10255 event.on_axis_source = Lambda_DoNothing;
10259 event.on_axis_source = lambda;
10273 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10278 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10280 if(lambda ==
nullptr)
10282 event.on_axis_stop = Lambda_DoNothing;
10286 event.on_axis_stop = lambda;
10300 if(yetani->pointer.event_map.contains(wl_surface) ==
false)
10305 Yetani::PointerEvent&
event = yetani->pointer.event_map[wl_surface];
10307 if(lambda ==
nullptr)
10309 event.on_axis_discrete = Lambda_DoNothing;
10313 event.on_axis_discrete = lambda;
10348 return std::string()
10349 +
"{ \"time\": " + std::to_string(key.time)
10350 +
", \"code\": " + std::to_string(key.code)
10367 auto mod_to_str = [](std::string& s, uint32_t m)
10370 std::string delim =
"";
10374 s += delim +
"\"Shift\"";
10380 s += delim +
"\"CapsLock\"";
10386 s += delim +
"\"Control\"";
10392 s += delim +
"\"Alt\"";
10396 if(m & Yetani::KeyModifier_NumLock)
10398 s += delim +
"\"NumLock\"";
10403 s += delim +
"\"Meta\"";
10409 std::string str =
"{ \"pressed\": ";
10410 mod_to_str(str, key_modifier.pressed);
10412 str +=
", \"latched\": ";
10413 mod_to_str(str, key_modifier.latched);
10415 str +=
", \"locked\": ";
10416 mod_to_str(str, key_modifier.locked);
10436 case Yetani::KeyState::Pressed:
return "Pressed";
10437 case Yetani::KeyState::Released:
return "Released";
10438 case Yetani::KeyState::Repeat:
return "Repeat";
10439 default:
return "";
10454 return std::string()
10455 +
"{ \"x\": " + std::to_string(
output.
x)
10456 +
", \"y\": " + std::to_string(
output.
y)
10486 return std::string()
10487 +
"{ \"time\": " + std::to_string(point.time)
10488 +
", \"x\": " + std::to_string(point.x)
10489 +
", \"y\": " + std::to_string(point.y)
10504 return std::string()
10505 +
"{ \"time\": " + std::to_string(point.time)
10506 +
", \"x\": " + std::to_string(point.x)
10507 +
", \"y\": " + std::to_string(point.y)
10522 return std::string()
10523 +
"{ \"time\": " + std::to_string(point.time)
10524 +
", \"x\": " + std::to_string(point.x)
10525 +
", \"y\": " + std::to_string(point.y)
10540 return std::string()
10541 +
"{ \"time\": " + std::to_string(axis.time)
10542 +
", \"steps\": " + std::to_string(axis.steps)
10543 +
", \"distance\": " + std::to_string(axis.distance)
10562 case Yetani::PointerAxisSource::Continuous:
return "Continuous";
10563 case Yetani::PointerAxisSource::Finger:
return "Finger";
10564 case Yetani::PointerAxisSource::Wheel:
return "Wheel";
10565 case Yetani::PointerAxisSource::Wheel_Tilt:
return "Wheel Tilt";
10566 case Yetani::PointerAxisSource::Unknown: [[fallthrough]];
10567 default:
return "";
10584 case Yetani::PointerAxisType::Horizontal:
return "Horizontal";
10585 case Yetani::PointerAxisType::Vertical:
return "Vertical";
10586 case Yetani::PointerAxisType::Unknown: [[fallthrough]];
10587 default:
return "";
10602 return std::string()
10603 +
"{ \"code\": " + std::to_string(button.code)
10619 switch(button_state)
10621 case Yetani::PointerButtonState::Pressed:
return "Pressed";
10622 case Yetani::PointerButtonState::Released:
return "Released";
10623 default:
return "";
10638 return std::string()
10639 +
"{ \"width\": " + std::to_string(size.width)
10640 +
", \"height\": " + std::to_string(size.height)
10655 return std::string()
10656 +
"{ \"width\": " + std::to_string(size.width)
10657 +
", \"height\": " + std::to_string(size.height)
10672 return std::string()
10673 +
"{ \"width\": " + std::to_string(size.width)
10674 +
", \"height\": " + std::to_string(size.height)
10689 switch(window_mode)
10691 case Yetani::WindowMode::Fullscreen:
return "Fullscreen";
10692 case Yetani::WindowMode::Maximized:
return "Maximized";
10693 case Yetani::WindowMode::Normal:
return "Normal";
10694 default:
return "";
10759 return (lhs.x == rhs.x) && (lhs.y == rhs.y);
10817 return (lhs.width == rhs.width) && (lhs.height == rhs.height);
std::string to_string(const bool value) noexcept
Convert a bool into a string.
Definition: Zakero_Base.h:534
#define ZAKERO_STEADY_TIME_NOW(unit_)
Get the current time.
Definition: Zakero_Base.h:205
auto vectorErase(std::vector< Type > &vector, const Type &value) noexcept
Erase the contents of a std::vector.
Definition: Zakero_Base.h:476
bool vectorContains(const std::vector< Type > &vector, const Type &value) noexcept
Check the contents of a std::vector.
Definition: Zakero_Base.h:404
uint64_t convert(const uint64_t size, const zakero::Storage from, const zakero::Storage to) noexcept
Convert storage sizes.
Definition: Zakero_Base.h:292
bool equalish(const float a, const float b, const float delta) noexcept
Compare two floats.
Definition: Zakero_Base.h:348
bool operator==(Xenium::PointMm &lhs, Xenium::PointMm &rhs) noexcept
Compare two Point objects.
Definition: Zakero_Xenium.h:8993
A pool of memory.
Definition: Zakero_MemoryPool.h:264
std::error_code init(const size_t, const bool=false, const MemoryPool::Alignment=MemoryPool::Alignment::Bits_64) noexcept
Initialize the MemoryPool.
Definition: Zakero_MemoryPool.h:639
size_t size() const noexcept
The size of the memory pool.
Definition: Zakero_MemoryPool.h:746
int fd() const noexcept
The backing file descriptor.
Definition: Zakero_MemoryPool.h:733
void sizeOnChange(MemoryPool::LambdaSize) noexcept
Set the Size Event callback.
Definition: Zakero_MemoryPool.h:781
A Window.
Definition: Zakero_Yetani.h:1314
std::error_code sizeSet(const Yetani::SizeMm &) noexcept
Set the window size.
Definition: Zakero_Yetani.h:9059
void imagePresent() noexcept
Render the image.
Definition: Zakero_Yetani.h:9394
struct wl_shm_pool * wl_shm_pool
A pointer to the Wayland Shared Memory Pool.
Definition: Zakero_Yetani.h:1418
zakero::MemoryPool memory_pool
The Window's Memory Pool.
Definition: Zakero_Yetani.h:1419
void onCloseRequest(Yetani::Lambda) noexcept
Respond to "Close Request" events.
Definition: Zakero_Yetani.h:9662
void pointerOnEnter(Yetani::LambdaPointMm) noexcept
Respond to "Pointer Enter" events.
Definition: Zakero_Yetani.h:10015
void onFocusChange(Yetani::LambdaBool) noexcept
Respond to "Active" change events.
Definition: Zakero_Yetani.h:9716
uint32_t time() const noexcept
When the last frame was rendered.
Definition: Zakero_Yetani.h:9426
Yetani::PointPixel convertToPixel(const Yetani::PointMm &) const noexcept
Unit conversion.
Definition: Zakero_Yetani.h:9518
std::error_code decorationsSet(const Yetani::WindowDecorations) noexcept
Use the Desktop Environment borders.
Definition: Zakero_Yetani.h:8943
void windowModeOnChange(Yetani::LambdaWindowMode) noexcept
Respond to "Window Mode" events.
Definition: Zakero_Yetani.h:9818
virtual ~Window()
Destroy a Window.
Definition: Zakero_Yetani.h:8807
void pointerOnLeave(Yetani::Lambda) noexcept
Respond to "Pointer Leave" events.
Definition: Zakero_Yetani.h:10105
void cursorShow() noexcept
Show the cursor.
Definition: Zakero_Yetani.h:8880
void pointerOnButton(Yetani::LambdaButtonMm) noexcept
Respond to "Pointer Button" events.
Definition: Zakero_Yetani.h:9928
void pointerOnAxisSource(Yetani::Lambda) noexcept
Respond to "Pointer Axis Source" events.
Definition: Zakero_Yetani.h:10243
uint8_t bytesPerPixel() const noexcept
Get the number of bytes per pixel.
Definition: Zakero_Yetani.h:9444
void sizeOnChange(Yetani::LambdaSizeMm) noexcept
Respond to "Resize" events.
Definition: Zakero_Yetani.h:9847
std::error_code cursorUse(const std::string &) noexcept
Use a cursor.
Definition: Zakero_Yetani.h:8852
void keyboardOnEnter(Yetani::Lambda) noexcept
Respond to "Keyboard Enter" events.
Definition: Zakero_Yetani.h:9737
bool windowModeIs(const Yetani::WindowMode) noexcept
Check the WindowMode.
Definition: Zakero_Yetani.h:8989
std::error_code sizeSetMinMax(const Yetani::SizeMm &, const Yetani::SizeMm &) noexcept
Set the minimum window size.
Definition: Zakero_Yetani.h:9197
void titleSet(const std::string &) noexcept
Change the window title.
Definition: Zakero_Yetani.h:8917
void pointerOnMotion(Yetani::LambdaPointMm) noexcept
Respond to "Pointer Motion" events.
Definition: Zakero_Yetani.h:10133
Yetani::PointPercent convertToPercent(const Yetani::PointPixel &) const noexcept
Unit conversion.
Definition: Zakero_Yetani.h:9495
void classSet(const std::string &) noexcept
Change the window class.
Definition: Zakero_Yetani.h:8904
void pointerOnAxisDiscrete(Yetani::Lambda) noexcept
Respond to "Pointer Axis Discrete" events.
Definition: Zakero_Yetani.h:10297
void windowModeSet(const Yetani::WindowMode) noexcept
Change the window mode.
Definition: Zakero_Yetani.h:9013
Yetani::WindowMode windowMode() noexcept
Get the current WindowMode.
Definition: Zakero_Yetani.h:8971
std::error_code imageNext(uint8_t *&, Yetani::SizePixel &) noexcept
Get an image buffer.
Definition: Zakero_Yetani.h:9358
void pointerOnAxisStop(Yetani::Lambda) noexcept
Respond to "Pointer Axis Stop" events.
Definition: Zakero_Yetani.h:10270
void decorationsOnChange(Yetani::LambdaWindowDecorations) noexcept
Respond to "Decoration Change" events.
Definition: Zakero_Yetani.h:9687
Window(void *)
Construct a Window.
Definition: Zakero_Yetani.h:8754
void keyboardOnKey(Yetani::LambdaKey) noexcept
Respond to "Keyboard Key" events.
Definition: Zakero_Yetani.h:9791
void cursorHide() noexcept
Hide the cursor.
Definition: Zakero_Yetani.h:8869
void minimize() noexcept
Minimize the window.
Definition: Zakero_Yetani.h:9457
Yetani::PointMm convertToMm(const Yetani::PointPixel &) const noexcept
Unit conversion.
Definition: Zakero_Yetani.h:9472
void pointerOnAxis(Yetani::LambdaAxis) noexcept
Respond to "Pointer Axis" events.
Definition: Zakero_Yetani.h:10216
void keyboardOnLeave(Yetani::Lambda) noexcept
Respond to "Keyboard Leave" events.
Definition: Zakero_Yetani.h:9763
The shared memory.
Definition: Zakero_Yetani.h:1417
A wrapper class for Wayland.
Definition: Zakero_Yetani.h:1027
uint32_t code
The key code of the event.
Definition: Zakero_Yetani.h:1047
std::string make
Description of the manufacturer.
Definition: Zakero_Yetani.h:1200
static std::string outputTransformName(int32_t) noexcept
Get a human readable string.
Definition: Zakero_Yetani.h:4785
float pixels_per_mm_vertical
A pre-calculated value.
Definition: Zakero_Yetani.h:1214
std::function< void(const Yetani::Key &, const Yetani::KeyModifier &)> LambdaKey
A Lambda that has parameters: Key and KeyModifier.
Definition: Zakero_Yetani.h:1296
static std::string outputSubpixelName(int32_t) noexcept
Get a human readable string.
Definition: Zakero_Yetani.h:4760
float pixels_per_mm_horizontal
A pre-calculated value.
Definition: Zakero_Yetani.h:1213
float distance
The distance traveled.
Definition: Zakero_Yetani.h:1117
const std::vector< void * > & image_data
A collection of image data.
Definition: Zakero_Yetani.h:1181
std::function< void(const Yetani::PointerButton &, const Yetani::PointPercent &, const Yetani::KeyModifier &)> LambdaButtonPercent
A Lambda that has parameters: PointerButton, PointPercent and KeyModifier.
Definition: Zakero_Yetani.h:1299
static std::string shmFormatName(const wl_shm_format) noexcept
Get the name of the format.
Definition: Zakero_Yetani.h:4485
Yetani::VectorOutputId outputVector() const noexcept
Get a list of the Output Id's.
Definition: Zakero_Yetani.h:4734
int32_t height
The height of the device in hardware units.
Definition: Zakero_Yetani.h:1205
int32_t keyRepeatDelay() const noexcept
The key repeat delay.
Definition: Zakero_Yetani.h:5445
static constexpr uint32_t KeyModifier_Alt
Key Modifier flag.
Definition: Zakero_Yetani.h:1054
uint32_t pressed
A collection of pressed modifiers.
Definition: Zakero_Yetani.h:1060
void outputOnAdd(Yetani::LambdaOutputId) noexcept
Notification of adding an Output device.
Definition: Zakero_Yetani.h:5046
Yetani::PointPixel outputConvertToPixel(const Yetani::OutputId, const Yetani::PointMm &) const noexcept
Convert Millimeter to Pixel.
Definition: Zakero_Yetani.h:4869
Yetani::PointerAxisType type
The type of Axis.
Definition: Zakero_Yetani.h:1119
static constexpr uint32_t KeyModifier_Meta
Key Modifier flag.
Definition: Zakero_Yetani.h:1056
Yetani::PointPercent outputConvertToPercent(const Yetani::OutputId, const Yetani::PointPixel &) const noexcept
Convert Pixel to a Percentage.
Definition: Zakero_Yetani.h:4839
Yetani::Output output(const Yetani::OutputId) const noexcept
Get a copy of the Output information.
Definition: Zakero_Yetani.h:4702
int32_t y
The Y position within the global compositor.
Definition: Zakero_Yetani.h:1203
Yetani::Window * windowCreate(const Yetani::SizeMm &, std::error_code &) noexcept
Create a window.
Definition: Zakero_Yetani.h:8018
PointerAxisType
The direction of the axis movement.
Definition: Zakero_Yetani.h:1108
void outputOnChange(Yetani::LambdaOutputId) noexcept
Notification that an Output device has changed.
Definition: Zakero_Yetani.h:5069
Yetani::PointerButtonState state
The button state.
Definition: Zakero_Yetani.h:1133
PointerButtonState
Mouse button state.
Definition: Zakero_Yetani.h:1126
uint32_t time
When the key event happened.
Definition: Zakero_Yetani.h:1046
std::function< void(Yetani::WindowMode)> LambdaWindowMode
A Lambda that has a parameter: WindowMode.
Definition: Zakero_Yetani.h:1306
std::function< void(const Yetani::PointerButton &, const Yetani::PointPixel &, const Yetani::KeyModifier &)> LambdaButtonPixel
A Lambda that has parameters: PointerButton, PointPixel and KeyModifier.
Definition: Zakero_Yetani.h:1300
uint32_t flags
wl_output_mode bitfield properties.
Definition: Zakero_Yetani.h:1212
static constexpr wl_shm_format SHM_FORMAT_DEFAULT
The default pixel format.
Definition: Zakero_Yetani.h:1438
static constexpr uint32_t KeyModifier_CapsLock
Key Modifier flag.
Definition: Zakero_Yetani.h:1052
void outputOnRemove(Yetani::LambdaOutputId) noexcept
Notification of removing an Output device.
Definition: Zakero_Yetani.h:5092
PointerAxisSource
Where the axis information came from.
Definition: Zakero_Yetani.h:1100
std::function< void(const Yetani::PointerAxis &, const Yetani::KeyModifier &)> LambdaAxis
A Lambda that has parameters: PointerAxis and KeyModifier.
Definition: Zakero_Yetani.h:1297
std::function< void(const Yetani::PointMm &, const Yetani::KeyModifier &)> LambdaPointMm
A Lambda that has parameters: PointMm and KeyModifier.
Definition: Zakero_Yetani.h:1301
uint32_t latched
A collection of latched modifiers.
Definition: Zakero_Yetani.h:1061
static Yetani * connect() noexcept
Establish a connection with the Wayland Compositor.
Definition: Zakero_Yetani.h:3312
std::error_code cursorCreate(const std::string &, const Yetani::CursorConfig &) noexcept
Create a cursor.
Definition: Zakero_Yetani.h:3795
std::function< void(const Yetani::PointPercent &, const Yetani::KeyModifier &)> LambdaPointPercent
A Lambda that has parameters: PointPercent and KeyModifier.
Definition: Zakero_Yetani.h:1302
std::function< void()> Lambda
A Lambda that has no parameters.
Definition: Zakero_Yetani.h:1295
uint32_t physical_height_mm
The height of the device in millimeters.
Definition: Zakero_Yetani.h:1207
uint32_t physical_width_mm
The width of the device in millimeters.
Definition: Zakero_Yetani.h:1206
int32_t keyRepeatRate() const noexcept
The key repeat rate.
Definition: Zakero_Yetani.h:5459
std::function< void(const Yetani::SizeMm &)> LambdaSizeMm
A Lambda that has a parameter: SizeMm.
Definition: Zakero_Yetani.h:1307
std::string model
Description of the model.
Definition: Zakero_Yetani.h:1201
const Yetani::VectorShmFormat & shmFormatAvailable() const noexcept
Get all the support color formats.
Definition: Zakero_Yetani.h:4420
std::error_code cursorDestroy(const std::string &) noexcept
Destroy a cursor.
Definition: Zakero_Yetani.h:3933
std::function< void(const Yetani::SizePercent &)> LambdaSizePercent
A Lambda that has a parameter: SizePercent.
Definition: Zakero_Yetani.h:1308
WindowDecorations
Who is responsible for rendering the decorations.
Definition: Zakero_Yetani.h:1283
KeyState
Keyboard key state
Definition: Zakero_Yetani.h:1039
int32_t refresh_mHz
The current refresh rate of the device.
Definition: Zakero_Yetani.h:1209
uint32_t time
When the event occurred.
Definition: Zakero_Yetani.h:1115
int32_t x
The X position within the global compositor.
Definition: Zakero_Yetani.h:1202
int32_t width
The width of the device in hardware units.
Definition: Zakero_Yetani.h:1204
uint32_t group
The keyboard layout.
Definition: Zakero_Yetani.h:1063
std::function< void(const Yetani::PointPixel &, const Yetani::KeyModifier &)> LambdaPointPixel
A Lambda that has parameters: PointPixel and KeyModifier.
Definition: Zakero_Yetani.h:1303
int32_t scale_factor
The scaling factor between the device and compositor.
Definition: Zakero_Yetani.h:1210
std::function< void(bool)> LambdaBool
A Lambda that has a parameter: bool.
Definition: Zakero_Yetani.h:1304
virtual ZAKERO_YETANI__ERROR_DATA ~Yetani() noexcept
Destructor.
Definition: Zakero_Yetani.h:3276
std::function< void(const Yetani::PointerButton &, const Yetani::PointMm &, const Yetani::KeyModifier &)> LambdaButtonMm
A Lambda that has parameters: PointerButton, PointMm and KeyModifier.
Definition: Zakero_Yetani.h:1298
WindowMode
Definition: Zakero_Yetani.h:1288
int32_t steps
The number of rotation steps.
Definition: Zakero_Yetani.h:1116
KeyState state
The state of the key.
Definition: Zakero_Yetani.h:1048
std::function< void(const Yetani::SizePixel &)> LambdaSizePixel
A Lambda that has a parameter: SizePixel.
Definition: Zakero_Yetani.h:1309
int32_t subpixel
The device's subpixel orientation.
Definition: Zakero_Yetani.h:1208
std::function< void(Yetani::WindowDecorations)> LambdaWindowDecorations
A Lambda that has a parameter: WindowDecorations.
Definition: Zakero_Yetani.h:1305
static constexpr uint32_t KeyModifier_Control
Key Modifier flag.
Definition: Zakero_Yetani.h:1053
static uint8_t shmFormatBytesPerPixel(const wl_shm_format) noexcept
Determine bytes-per-pixel.
Definition: Zakero_Yetani.h:4437
static constexpr uint32_t KeyModifier_Shift
Key Modifier flag.
Definition: Zakero_Yetani.h:1051
uint32_t code
The event code.
Definition: Zakero_Yetani.h:1132
Yetani::PointMm outputConvertToMm(const Yetani::OutputId, const Yetani::PointPixel &) const noexcept
Convert Pixel to Millimeter.
Definition: Zakero_Yetani.h:4809
Yetani::PointerAxisSource source
The source of the event.
Definition: Zakero_Yetani.h:1118
int32_t transform
Transform that maps framebuffer to output.
Definition: Zakero_Yetani.h:1211
static std::string shmFormatDescription(const wl_shm_format) noexcept
Get a description of the format.
Definition: Zakero_Yetani.h:4462
uint32_t locked
A collection of locked modifiers.
Definition: Zakero_Yetani.h:1062
Cursor configuration.
Definition: Zakero_Yetani.h:1175
Key event information.
Definition: Zakero_Yetani.h:1045
A collection modifier flags.
Definition: Zakero_Yetani.h:1059
Information about a output device.
Definition: Zakero_Yetani.h:1199
Information about an Axis event.
Definition: Zakero_Yetani.h:1114
A location that uses millimeters.
Definition: Zakero_Yetani.h:1070
float x
Where in the X-Axis the point is.
Definition: Zakero_Yetani.h:1072
uint32_t time
Where in time the point is (if > 0).
Definition: Zakero_Yetani.h:1071
float y
Where in the Y-Axis the point is.
Definition: Zakero_Yetani.h:1073
friend bool operator==(Yetani::PointMm &, Yetani::PointMm &) noexcept
Compare two Point objects.
Definition: Zakero_Yetani.h:10712
A location that uses percentages.
Definition: Zakero_Yetani.h:1079
uint32_t time
Where in time the point is (if > 0).
Definition: Zakero_Yetani.h:1080
float x
Where in the X-Axis the point is.
Definition: Zakero_Yetani.h:1081
friend bool operator==(Yetani::PointPercent &, Yetani::PointPercent &) noexcept
Compare two Point objects.
Definition: Zakero_Yetani.h:10735
float y
Where in the Y-Axis the point is.
Definition: Zakero_Yetani.h:1082
A location that uses pixels.
Definition: Zakero_Yetani.h:1088
friend bool operator==(Yetani::PointPixel &, Yetani::PointPixel &) noexcept
Compare two Point objects.
Definition: Zakero_Yetani.h:10755
uint32_t time
Where in time the point is (if > 0).
Definition: Zakero_Yetani.h:1089
int32_t x
Where in the X-Axis the point is.
Definition: Zakero_Yetani.h:1090
int32_t y
Where in the Y-Axis the point is.
Definition: Zakero_Yetani.h:1091
Size measured in millimeters.
Definition: Zakero_Yetani.h:1140
friend bool operator==(Yetani::SizeMm &, Yetani::SizeMm &) noexcept
Compare two Point objects.
Definition: Zakero_Yetani.h:10774
float width
The width.
Definition: Zakero_Yetani.h:1141
float height
The height.
Definition: Zakero_Yetani.h:1142
Size measured as a percentage of the Output (Monitor) resolution.
Definition: Zakero_Yetani.h:1148
float width
The width.
Definition: Zakero_Yetani.h:1149
float height
The height.
Definition: Zakero_Yetani.h:1150
friend bool operator==(Yetani::SizePercent &, Yetani::SizePercent &) noexcept
Compare two Point objects.
Definition: Zakero_Yetani.h:10795
Size measured in pixels.
Definition: Zakero_Yetani.h:1156
friend bool operator==(Yetani::SizePixel &, Yetani::SizePixel &) noexcept
Compare two Size objects.
Definition: Zakero_Yetani.h:10813
int32_t width
The width.
Definition: Zakero_Yetani.h:1157
int32_t height
The height.
Definition: Zakero_Yetani.h:1158