#ifndef LUNAR_WM_H #define LUNAR_WM_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "Config.h" #include "common.h" struct LunarWM; typedef struct { struct LunarWM *server; struct wl_list link; struct wlr_keyboard *wlr_keyboard; struct wl_listener modifiers; struct wl_listener key; struct wl_listener destroy; } LunarWM_Keyboard; typedef struct { struct LunarWM *server; struct wl_listener commit; struct wl_listener destroy; struct wlr_xdg_toplevel *xdg_toplevel; struct wlr_surface *surface; struct wlr_texture *texture; struct wlr_buffer *locked_buffer; struct wlr_gles2_texture_attribs attribs; struct wlr_gles2_texture *gles_texture; Texture2D rl_texture; } LunarWM_Toplevel; bool LunarWM_Toplevel_init( LunarWM_Toplevel *tl, struct LunarWM *wm, struct wlr_xdg_toplevel *xdg); bool LunarWM_Toplevel_destroy(LunarWM_Toplevel *this); bool LunarWM_Toplevel_update(LunarWM_Toplevel *this); typedef struct { XrSwapchain swapchain; int64_t swapchain_format; GLuint *v_image_views; } LunarWM_SwapchainInfo; typedef struct { XrSwapchain handle; XrSwapchainImageOpenGLESKHR *a_imgs; uint32_t a_imgs_count; } LunarWM_SwapchainImagesEntry; typedef struct { XrHandJointLocationEXT joint_locations[XR_HAND_JOINT_COUNT_EXT]; XrHandTrackerEXT hand_tracker; } LunarWM_Hand; typedef struct { XrTime predicted_display_time; XrCompositionLayerProjection layer_projection; XrCompositionLayerBaseHeader *layers[10]; uint32_t layers_count; XrCompositionLayerProjectionView layer_projection_views[10]; // Hopefully we dont have more than 10. uint32_t layer_projection_views_count; } LunarWM_RenderLayerInfo; typedef struct LunarWM { struct { struct wl_display *display; struct wl_event_loop *event_loop; struct wlr_backend *backend; struct wlr_renderer *renderer; struct wlr_session *session; struct wlr_egl *egl; EGLDisplay egl_display; EGLContext egl_context; EGLConfig egl_config; struct wlr_allocator *allocator; struct wlr_compositor *compositor; struct wlr_subcompositor *subcompositor; struct wlr_data_device_manager *data_device_manager; struct wlr_seat *seat; struct wl_list keyboards; struct wl_listener new_input_listener; struct wlr_xdg_shell *xdg_shell; struct wl_listener new_xdg_toplevel_listener; struct wl_listener new_xdg_popup_listener; struct wlr_cursor *cursor; LunarWM_Toplevel **v_toplevels; } wayland; struct { XrInstance instance; XrSystemId system_id; XrSession session; XrSessionState session_state; struct { LunarWM_SwapchainInfo *v_color; LunarWM_SwapchainInfo *v_depth; } swapchains; LunarWM_SwapchainImagesEntry swapchain_images[2]; // 0 is color, 1 is depth XrViewConfigurationView *a_view_configuration_views; uint32_t view_configuration_views_count; XrEnvironmentBlendMode environment_blend_mode; XrSpace local_space, view_space; LunarWM_Hand hands[2]; XrSystemHandTrackingPropertiesEXT hand_tracking_system_properties; PFN_xrCreateHandTrackerEXT CreateHandTrackerEXT; PFN_xrDestroyHandTrackerEXT DestroyHandTrackerEXT; PFN_xrLocateHandJointsEXT LocateHandJointsEXT; bool session_running; } xr; struct { GLuint fbo; RenderTexture2D tmp_rt; Camera3D camera; } renderer; ConfigManager *cman; bool initialized; bool running; } LunarWM; bool LunarWM_init(LunarWM *wm); void LunarWM_destroy(LunarWM *this); void LunarWM_terminate(LunarWM *this); void LunarWM_run(LunarWM *this); extern LunarWM g_wm; #endif // LUNAR_WM_H