|
XenevaOS
|
#include "compose3d.h"#include "compose.h"#include "cursor.h"#include "xr_present.h"#include "nanojpg.h"#include <keycode.h>#include <color.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <sys/mman.h>#include <sys/_kefile.h>#include <_xeneva.h>
Classes | |
| struct | _vec3_ |
| struct | _lin3_ |
| struct | _win3d_ |
Macros | |
| #define | DEODHAI3D_PI 3.14159265f |
| #define | DEODHAI3D_TWO_PI 6.28318531f |
| #define | DEODHAI3D_FOV_X 1.57079633f /* 90 degrees horizontal */ |
| #define | DEODHAI3D_PITCH_LIMIT 0.52359878f /* 30 degrees */ |
| #define | DEODHAI3D_NEAR 0.05f /* near plane, fraction of focal */ |
| #define | DEODHAI3D_MIN_DIST 0.25f /* closest a window may come, x focal */ |
| #define | DEODHAI3D_MAX_DIST 8.0f /* farthest, x focal */ |
| #define | DEODHAI3D_DEPTH_SPEED 0.004f /* Ctrl+drag: distance change per pixel */ |
| #define | DEODHAI3D_DEPTH_STEP 1.25f /* Ctrl+'-' / Ctrl+'=' distance factor */ |
| #define | DEODHAI3D_DEPTH_GAP 1.12f /* send-to-back / bring-to-front spacing */ |
| #define | DEODHAI3D_DEPTH_EASE 0.25f /* fraction of the remaining depth per frame */ |
| #define | DEODHAI3D_DEN_EPS 1e-3f |
| #define | DEODHAI3D_TITLEBAR 26 /* same hit zone as DeodhaiWindowCheckDraggable */ |
| #define | DEODHAI3D_CURSOR_SIZE 24 |
| #define | DEODHAI3D_SUBSPAN 16 /* perspective-correct samples every N pixels */ |
| #define | DEODHAI3D_DRAG_LOD 1 /* half-resolution panorama while turning */ |
| #define | DEODHAI3D_HASH_SIZE 256 /* power of two, > 2 x DEODHAI3D_MAX_WINDOWS */ |
| #define | DEODHAI3D_DRAG_NONE 0 |
| #define | DEODHAI3D_DRAG_CAMERA 1 |
| #define | DEODHAI3D_DRAG_WINDOW 2 |
Typedefs | |
| typedef struct _vec3_ | Vec3 |
| typedef struct _lin3_ | Lin3 |
| typedef struct _win3d_ | Win3D |
Functions | |
| Window * | _get_root_window () |
| Window * | _get_always_on_top () |
| Window * | _get_focused_window () |
| Cursor * | _get_current_cursor () |
| void | _take_update_bits (bool *window_update_all, bool *always_on_top_update) |
| void | _set_always_on_top_update (bool update) |
| void | XRComposeFrame (ChCanvas *canvas) |
| void | CursorStoreBack (ChCanvas *canv, Cursor *cur, unsigned x, unsigned y) |
| void | CursorDrawBack (ChCanvas *canv, Cursor *cur, unsigned x, unsigned y) |
| void | DeodhaiWindowSetFocused (Window *win, bool notify) |
| DeodhaiWindowSetFocused – cast focus to a new window. | |
| void | DeodhaiSendMouseEvent (int handle, int ownerId, uint8_t handleType, uint8_t eventType, int x, int y, int button) |
| DeodhaiSendMouseEvent – send mouse event to desired window. | |
| bool | Deodhai3DLoadPanorama (const char *path) |
| Deodhai3DLoadPanorama – load a 360 degree cylindrical panorama. | |
| void | Deodhai3DSetCamera (float yaw, float pitch) |
| Deodhai3DSetCamera – set camera orientation (radians) | |
| void | Deodhai3DGetCamera (float *yaw, float *pitch) |
| Deodhai3DGetCamera – get camera orientation (radians) | |
| void | Deodhai3DInitialise (ChCanvas *canvas) |
| Deodhai3DInitialise – set up the 3D compositor. | |
| bool | Deodhai3DEnabled () |
| Deodhai3DEnabled – returns true while 3D mode is active. | |
| void | Deodhai3DSetEnabled (bool enable) |
| Deodhai3DSetEnabled – switch between 3D and 2D compositing. | |
| void | Deodhai3DToggle () |
| Deodhai3DToggle – flips 3D mode. | |
| bool | Deodhai3DWindowSetPosition (Window *win, float x, float y, float z) |
| Deodhai3DWindowSetPosition – translate a window in 3D space. | |
| bool | Deodhai3DWindowGetPosition (Window *win, float *x, float *y, float *z) |
| Deodhai3DWindowGetPosition – get the world position of a window. | |
| bool | Deodhai3DWindowPushDepth (Window *win, float factor) |
| Deodhai3DWindowPushDepth – move a window along its view ray. | |
| bool | Deodhai3DWindowSendToBack (Window *win) |
| Deodhai3DWindowSendToBack – behind every other window. | |
| bool | Deodhai3DWindowBringToFront (Window *win) |
| Deodhai3DWindowBringToFront – in front of every other window. | |
| bool | Deodhai3DHandleKey (int key, bool ctrl) |
| Deodhai3DHandleKey – 3D shortcuts (with Ctrl held) | |
| bool | Deodhai3DScreenToWindow (Window *win, int sx, int sy, int *lx, int *ly) |
| Deodhai3DScreenToWindow – maps a screen pixel onto a window. | |
| void | XRComposeFrame3D (ChCanvas *canvas) |
| XRComposeFrame3D – the 3D compose pipeline. | |
| bool | Deodhai3DHandleMouse (ChCanvas *canvas, int x, int y, int button) |
| Deodhai3DHandleMouse – 3D input routing. | |
| #define DEODHAI3D_CURSOR_SIZE 24 |
| #define DEODHAI3D_DEN_EPS 1e-3f |
| #define DEODHAI3D_DEPTH_EASE 0.25f /* fraction of the remaining depth per frame */ |
| #define DEODHAI3D_DEPTH_SPEED 0.004f /* Ctrl+drag: distance change per pixel */ |
| #define DEODHAI3D_DEPTH_STEP 1.25f /* Ctrl+'-' / Ctrl+'=' distance factor */ |
| #define DEODHAI3D_DRAG_CAMERA 1 |
| #define DEODHAI3D_DRAG_LOD 1 /* half-resolution panorama while turning */ |
| #define DEODHAI3D_DRAG_NONE 0 |
| #define DEODHAI3D_DRAG_WINDOW 2 |
| #define DEODHAI3D_FOV_X 1.57079633f /* 90 degrees horizontal */ |
| #define DEODHAI3D_HASH_SIZE 256 /* power of two, > 2 x DEODHAI3D_MAX_WINDOWS */ |
| #define DEODHAI3D_MAX_DIST 8.0f /* farthest, x focal */ |
| #define DEODHAI3D_PI 3.14159265f |
| #define DEODHAI3D_PITCH_LIMIT 0.52359878f /* 30 degrees */ |
| #define DEODHAI3D_SUBSPAN 16 /* perspective-correct samples every N pixels */ |
| #define DEODHAI3D_TITLEBAR 26 /* same hit zone as DeodhaiWindowCheckDraggable */ |
| #define DEODHAI3D_TWO_PI 6.28318531f |
|
extern |
|
extern |
|
extern |
|
extern |
BSD 2-Clause License
Copyright (c) 2022-2026, Manas Kamal Choudhury All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
extern |
| bool Deodhai3DEnabled | ( | ) |
Deodhai3DEnabled – returns true while 3D mode is active.
| void Deodhai3DGetCamera | ( | float * | yaw, |
| float * | pitch | ||
| ) |
Deodhai3DGetCamera – get camera orientation (radians)
Deodhai3DHandleKey – 3D shortcuts (with Ctrl held)
Deodhai3DHandleKey – 3D keyboard shortcuts, all with Ctrl held: Ctrl+3 toggle 3D compositing Ctrl+- push the focused window back Ctrl+= pull it closer Ctrl+[ send it behind every window Ctrl+] bring it to the front.
Deodhai3DHandleMouse – 3D input routing.
Deodhai3DHandleMouse – 3D input: drag on empty space turns the camera, drag a titlebar to move a window around you, Ctrl + titlebar drag pushes it away / pulls it closer. Everything else is forwarded to the window under the cursor in the coordinates the client expects.
| void Deodhai3DInitialise | ( | ChCanvas * | canvas | ) |
Deodhai3DInitialise – set up the 3D compositor.
Deodhai3DInitialise – set up the 3D compositor. Call once after the wallpaper is in the back surface and the screen blur is baked. Snapshots the flat wallpaper (used as the fallback panorama and to restore 2D mode). 3D mode starts disabled.
| bool Deodhai3DLoadPanorama | ( | const char * | path | ) |
Deodhai3DLoadPanorama – load a 360 degree cylindrical panorama.
Deodhai3DLoadPanorama – load a 360 degree cylindrical panorama (JPEG). Without one, the flat wallpaper is wrapped with mirror repeat.
Deodhai3DScreenToWindow – maps a screen pixel onto a window.
Deodhai3DScreenToWindow – maps a screen pixel onto a window's own pixel grid using the last composed frame.
| void Deodhai3DSetCamera | ( | float | yaw, |
| float | pitch | ||
| ) |
Deodhai3DSetCamera – set camera orientation (radians)
| yaw | – rotation about the vertical axis, + turns right |
| pitch | – + looks up; clamped to +-DEODHAI3D_PITCH_LIMIT |
| void Deodhai3DSetEnabled | ( | bool | enable | ) |
Deodhai3DSetEnabled – switch between 3D and 2D compositing.
Deodhai3DSetEnabled – switch between 3D and the classic 2D compositor. Enabling places every window where it is on screen now; disabling restores the flat wallpaper and the 2D layout.
| void Deodhai3DToggle | ( | ) |
Deodhai3DToggle – flips 3D mode.
Deodhai3DWindowBringToFront – in front of every other window.
Deodhai3DWindowBringToFront – eases a window in front of every other window.
Deodhai3DWindowGetPosition – get the world position of a window.
Deodhai3DWindowPushDepth – move a window along its view ray.
Deodhai3DWindowPushDepth – move a window along its view ray (it stays under the same screen spot, only grows / shrinks). Eased over a few frames.
Deodhai3DWindowSendToBack – behind every other window.
Deodhai3DWindowSendToBack – eases a window behind every other window (painter order is by distance, so it draws first)
Deodhai3DWindowSetPosition – translate a window in 3D space.
Deodhai3DWindowSetPosition – translate a window in 3D space. The window turns to face the camera.
|
extern |
DeodhaiSendMouseEvent – send mouse event to desired window.
| win | – Pointer to window |
| eventType | – either MOUSE_EVENT or MOUSE_LEAVE |
| x | – Mouse x location |
| y | – Mouse y location |
| button | – Mouse button state |
DeodhaiWindowSetFocused – cast focus to a new window.
|
extern |
Normal application windows
do either one – dirty area tracking or else update all
Zoomed (maximised) windows: stretched-fill upscale into the compose canvas (the back surface the GPU flush presents from), above normal windows; always-on-top and cursor still compose over them afterwards. Fullscreen dirty is published so transfer moves it.
Always on Top window , stacking order
| void XRComposeFrame3D | ( | ChCanvas * | canvas | ) |
XRComposeFrame3D – the 3D compose pipeline.
XRComposeFrame3D – the 3D compose pipeline; drop-in for XRComposeFrame (falls back to it while 3D mode is off or a window is zoomed).
| bool blurStale |
| bool cameraDirty |
| ChCanvas* canvas |
| float* colK |
| int32_t* colTex |
| int32_t* colU |
| float cosYaw |
| float cx |
| float cy |
| Win3D* dragEntry |
| uint32_t dragHandle |
| int dragMode |
| bool enabled |
| float f |
| uint32_t* flat |
| float grabR |
| float grabU |
| float grabV |
| int H |
| Window* hovered |
| uint32_t hoveredHandle |
| bool hudRefresh |
| int lastButton |
| int lastX |
| int lastY |
| bool needSync |
| uint32_t* pano |
| int panoH |
| bool panoMirror |
| bool panoOwned |
| float panoSpan |
| int panoW |
| float pitch |
| bool ready |
| float shear |
| float sinYaw |
| int W |
| bool wasZoomed |
| float yaw |