Mouse cursor

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-09-04 15:11:29 +03:00
parent 1af7357301
commit a6949eeda0
4 changed files with 340 additions and 47 deletions

View File

@@ -37,6 +37,34 @@
struct LunarWM;
typedef struct {
float r, theta, phi;
} SphericalCoord;
static inline SphericalCoord Vector3ToSpherical(Vector3 v)
{
SphericalCoord s;
s.r = sqrtf(v.x * v.x + v.y * v.y + v.z * v.z);
if (s.r > 0.0f) {
s.theta = atan2f(v.z, v.x); // azimuth around Y axis
s.phi = acosf(v.y / s.r); // polar angle from Y+
} else {
s.theta = 0.0f;
s.phi = 0.0f;
}
return s;
}
static inline Vector3 SphericalToVector3(SphericalCoord s)
{
Vector3 v;
float sin_phi = sinf(s.phi);
v.x = s.r * cosf(s.theta) * sin_phi;
v.y = s.r * cosf(s.phi);
v.z = s.r * sinf(s.theta) * sin_phi;
return v;
}
typedef struct virtual_output {
struct wl_global *global;
struct wl_display *display;
@@ -65,6 +93,16 @@ typedef struct {
struct wl_listener destroy;
} LunarWM_Keyboard;
typedef struct {
struct LunarWM *server;
struct wl_list link;
struct wlr_pointer *wlr_pointer;
struct wl_listener motion;
struct wl_listener destroy;
} LunarWM_Pointer;
typedef struct {
uint32_t id;
@@ -91,6 +129,11 @@ typedef struct {
Texture2D rl_texture;
} LunarWM_Toplevel;
typedef struct {
LunarWM_Toplevel *tl;
SphericalCoord coord;
} LunarWM_Window;
bool LunarWM_Toplevel_init_xdg(
LunarWM_Toplevel *tl, struct LunarWM *wm, struct wlr_xdg_toplevel *xdg);
bool LunarWM_Toplevel_init_xwayland(
@@ -148,14 +191,13 @@ typedef struct LunarWM {
struct wlr_seat *seat;
struct wl_list keyboards;
struct wl_list pointers;
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;
struct wlr_xwayland *xwayland;
struct wl_listener xwayland_ready;
@@ -212,8 +254,18 @@ typedef struct LunarWM {
bool first_frame;
} renderer;
struct {
SphericalCoord pointer;
int active_workspace;
struct {
LunarWM_Window *v_windows;
} workspaces[10];
} wm;
ConfigManager *cman;
_Atomic(int) counter;
bool initialized;
bool running;
} LunarWM;
@@ -224,6 +276,8 @@ void LunarWM_destroy(LunarWM *this);
void LunarWM_terminate(LunarWM *this);
void LunarWM_run(LunarWM *this);
static inline bool LunarWM_get_new_id(LunarWM *this) { return ++this->counter; }
extern LunarWM g_wm;
#endif // LUNAR_WM_H