Compare commits
58 Commits
master
..
2ed9a495bf
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ed9a495bf | |||
| ed429d6a30 | |||
| d193ef0295 | |||
| a253869c24 | |||
| e072b1f6e0 | |||
| 9b00e30b97 | |||
| e8ee25cd88 | |||
| 66a46a9912 | |||
| 72a6ac3d00 | |||
| 22c005999c | |||
| 159bd314e5 | |||
| b0a1c2cb27 | |||
| 28a9f54227 | |||
| a6949eeda0 | |||
| 1af7357301 | |||
| 70ff013dbc | |||
| 971040e038 | |||
| bf3ed0dd0c | |||
| 794178668e | |||
| e3b2f44621 | |||
| ef96c51566 | |||
| c9590037aa | |||
| aa80a4c9d0 | |||
| 39a27eaae6 | |||
| e9a31ac4a6 | |||
| ec61c13aa6 | |||
| 025ee9da91 | |||
| ad0d09ebd2 | |||
| ab7ca71ba2 | |||
| 3e4d4514ad | |||
| 3a50e5e403 | |||
| 146c4e27cf | |||
| 4e23877697 | |||
| d154db1422 | |||
| 14f2e52722 | |||
| 78c86aaabd | |||
| 7dc90058b2 | |||
| c21397cef5 | |||
| c1e331ca7e | |||
| 1cc97753a5 | |||
| dd6cadb50d | |||
| 9fa2a1e8c7 | |||
| cecea144e4 | |||
| ccffc7908a | |||
| 2ebc752cc7 | |||
| 21c8c60369 | |||
| 2e38196ea5 | |||
| 9d39cd9a38 | |||
| 470c248bcf | |||
| bdb9d472de | |||
| fdafccbdad | |||
| 1fb48e2426 | |||
| d83e7f4337 | |||
| 1d99b16685 | |||
| 1a654ec009 | |||
| cc1137c011 | |||
| 9fdb148c89 | |||
| c93ab29a90 |
+1
-1
@@ -1,3 +1,3 @@
|
||||
[submodule "wlroots-lunar"]
|
||||
path = wlroots-lunar
|
||||
url = https://github.com/slendidev/wlroots-lunar
|
||||
url = git@github.com:slendidev/wlroots-lunar
|
||||
|
||||
@@ -25,7 +25,6 @@ pkg_check_modules(WLROOTS REQUIRED IMPORTED_TARGET wlroots-0.20)
|
||||
pkg_check_modules(XKBCOMMON REQUIRED IMPORTED_TARGET xkbcommon)
|
||||
pkg_check_modules(OPENXR REQUIRED IMPORTED_TARGET openxr)
|
||||
pkg_check_modules(LUA REQUIRED IMPORTED_TARGET lua)
|
||||
pkg_check_modules(PIXMAN REQUIRED IMPORTED_TARGET pixman-1)
|
||||
|
||||
find_program(WAYLAND_SCANNER_EXECUTABLE wayland-scanner REQUIRED)
|
||||
message(STATUS "Found wayland-scanner at ${WAYLAND_SCANNER_EXECUTABLE}")
|
||||
@@ -68,7 +67,6 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
|
||||
PkgConfig::WLROOTS
|
||||
PkgConfig::OPENXR
|
||||
PkgConfig::LUA
|
||||
PkgConfig::PIXMAN
|
||||
|
||||
raylib
|
||||
)
|
||||
|
||||
Generated
+3
-3
@@ -97,11 +97,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1759496058,
|
||||
"narHash": "sha256-eVgGEO+KhJX307XQ0gbbCWguJfoSJlZRFQrpvalK7kM=",
|
||||
"lastModified": 1759215258,
|
||||
"narHash": "sha256-Y7aXk0Zxu+X2BbO5MLkCvClrPsKfZ2sm34N2n7tXx4I=",
|
||||
"owner": "slendidev",
|
||||
"repo": "wlroots-lunar",
|
||||
"rev": "00d01dcc297e1991809ad2c0f6b50fb66478d748",
|
||||
"rev": "a9abd5a6e4fb4e5ac6c410e1fb1ad438d3b12001",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
ninja
|
||||
(pkgs.llvmPackages_20.clang-tools.override { enableLibcxx = true; })
|
||||
lldb
|
||||
valgrind
|
||||
|
||||
lua
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
{
|
||||
"rdocCaptureSettings": 1,
|
||||
"settings": {
|
||||
"autoStart": false,
|
||||
"commandLine": "",
|
||||
"environment": [
|
||||
{
|
||||
"separator": "Platform style",
|
||||
"type": "Set",
|
||||
"value": "1",
|
||||
"variable": "LWM_NO_XR"
|
||||
}
|
||||
],
|
||||
"executable": "/home/lain/Documents/projs/lunarwm/build/LunarWM",
|
||||
"inject": false,
|
||||
"numQueuedFrames": 0,
|
||||
"options": {
|
||||
"allowFullscreen": true,
|
||||
"allowVSync": true,
|
||||
"apiValidation": false,
|
||||
"captureAllCmdLists": false,
|
||||
"captureCallstacks": false,
|
||||
"captureCallstacksOnlyDraws": false,
|
||||
"debugOutputMute": true,
|
||||
"delayForDebugger": 0,
|
||||
"hookIntoChildren": false,
|
||||
"refAllResources": false,
|
||||
"softMemoryLimit": 0,
|
||||
"verifyBufferAccess": false
|
||||
},
|
||||
"queuedFrameCap": 0,
|
||||
"workingDir": "/home/lain/Documents/projs/lunarwm"
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef LUNAR_WM_H
|
||||
#define LUNAR_WM_H
|
||||
|
||||
#include "LunarWM_core.h"
|
||||
#include "LunarWM_types.h"
|
||||
#include "LunarWM_core.h"
|
||||
|
||||
#endif
|
||||
|
||||
+3
-23
@@ -120,9 +120,7 @@ static int l_recenter(lua_State *L)
|
||||
{
|
||||
(void)L;
|
||||
|
||||
if (g_wm.xr.available) {
|
||||
LunarWM_set_recenter_from_camera(&g_wm);
|
||||
}
|
||||
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
@@ -219,24 +217,13 @@ bool LunarWM_init(LunarWM *wm)
|
||||
return false;
|
||||
}
|
||||
|
||||
wm->xr.available = false;
|
||||
{
|
||||
char *no_xr = getenv("LWM_NO_XR");
|
||||
bool xr = true;
|
||||
|
||||
if (no_xr != NULL && no_xr[0] != '\0')
|
||||
xr = false;
|
||||
|
||||
if (xr) {
|
||||
if (!LunarWM_xr_init(wm)) {
|
||||
wlr_log(
|
||||
WLR_ERROR, "Failed to initialize OpenXR! Disabling XR...");
|
||||
wlr_log(WLR_ERROR, "Failed to initialize OpenXR! Disabling XR...");
|
||||
wm->xr.available = false;
|
||||
LunarWM_xr_cleanup(wm);
|
||||
} else {
|
||||
wm->xr.available = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wlr_log(WLR_INFO, "OpenGL ES version: %s", glGetString(GL_VERSION));
|
||||
InitWindow(0, 0, "");
|
||||
@@ -268,13 +255,6 @@ void LunarWM_destroy(LunarWM *wm)
|
||||
LunarWM_wayland_cleanup(wm);
|
||||
cleanup_lua_cfg(wm);
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SZ(wm->wm.workspaces); ++i) {
|
||||
if (wm->wm.workspaces[i].v_windows) {
|
||||
vector_free(wm->wm.workspaces[i].v_windows);
|
||||
wm->wm.workspaces[i].v_windows = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
memset(wm, 0, sizeof(*wm));
|
||||
}
|
||||
|
||||
@@ -437,7 +417,7 @@ void LunarWM_run(LunarWM *wm)
|
||||
|
||||
EndDrawing();
|
||||
} else {
|
||||
wm->renderer.camera.fovy = 75;
|
||||
wm->renderer.camera.fovy = 90;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,13 +328,16 @@ void LunarWM_render_windows(LunarWM *this, bool alpha_check)
|
||||
if (!tl || !tl->surface) {
|
||||
continue;
|
||||
}
|
||||
if (IsTextureValid(tl->surface_rt.texture)) {
|
||||
Texture2D tex = tl->surface_rt.texture;
|
||||
if (tl->gles_texture) {
|
||||
if (alpha_check && tl->composed_has_alpha) {
|
||||
continue;
|
||||
}
|
||||
Texture2D tex = tl->rl_texture;
|
||||
bool y_flip = false;
|
||||
if (IsRenderTextureValid(tl->surface_rt)) {
|
||||
tex = tl->surface_rt.texture;
|
||||
tex.width = tl->surface_rt.texture.width;
|
||||
tex.height = tl->surface_rt.texture.height;
|
||||
tex.width = tl->rl_texture.width;
|
||||
tex.height = tl->rl_texture.height;
|
||||
y_flip = true;
|
||||
}
|
||||
if (!tex.id)
|
||||
@@ -348,6 +351,8 @@ void LunarWM_render_windows(LunarWM *this, bool alpha_check)
|
||||
|
||||
void LunarWM_render_3d(LunarWM *this, float /*dt*/)
|
||||
{
|
||||
LunarWM_render_windows(this, true);
|
||||
|
||||
for (int h = 0; this->xr.hand_tracking_enabled && h < 2; ++h) {
|
||||
auto *hand_info = &this->xr.hands[h];
|
||||
if (hand_info->hand_tracker == XR_NULL_HANDLE)
|
||||
|
||||
+9
-2
@@ -22,8 +22,8 @@
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_cursor.h>
|
||||
#include <wlr/types/wlr_data_device.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_pointer.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_subcompositor.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/util/box.h>
|
||||
@@ -112,6 +112,7 @@ typedef struct {
|
||||
struct wl_listener destroy;
|
||||
} LunarWM_Output;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t id;
|
||||
|
||||
@@ -130,8 +131,15 @@ typedef struct {
|
||||
} u;
|
||||
|
||||
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;
|
||||
RenderTexture2D surface_rt;
|
||||
struct wlr_box surface_extents;
|
||||
bool composed_has_alpha;
|
||||
} LunarWM_Toplevel;
|
||||
|
||||
typedef struct {
|
||||
@@ -190,7 +198,6 @@ typedef struct LunarWM {
|
||||
|
||||
struct wlr_allocator *allocator;
|
||||
struct wlr_compositor *compositor;
|
||||
struct wl_listener new_surface_listener;
|
||||
struct wlr_subcompositor *subcompositor;
|
||||
struct wlr_data_device_manager *data_device_manager;
|
||||
|
||||
|
||||
+137
-168
@@ -1,16 +1,12 @@
|
||||
#include "LunarWM_wayland.h"
|
||||
|
||||
#include "LunarWM_core.h"
|
||||
#include "LunarWM_render.h"
|
||||
#include "common.h"
|
||||
#include "raylib.h"
|
||||
#include "vec.h"
|
||||
|
||||
#include <pixman.h>
|
||||
#include <wlr/backend/wayland.h>
|
||||
#include <wlr/backend/x11.h>
|
||||
#include <wlr/render/color.h>
|
||||
#include <wlr/render/pass.h>
|
||||
#include <wlr/xwayland/xwayland.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
@@ -24,7 +20,6 @@
|
||||
#include <xkbcommon/xkbcommon-keysyms.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
|
||||
#include <raylib.h>
|
||||
#include <rlgl.h>
|
||||
|
||||
static void handle_new_output(struct wl_listener *listener, void *data);
|
||||
@@ -41,90 +36,6 @@ static inline SphericalCoord get_forward_spherical_with_nearest(
|
||||
return Vector3ToSpherical(vec);
|
||||
}
|
||||
|
||||
struct SurfaceDamageListener {
|
||||
struct wl_listener client_commit;
|
||||
struct wl_listener destroy;
|
||||
};
|
||||
|
||||
static void surface_damage_client_commit(
|
||||
struct wl_listener *listener, void *data)
|
||||
{
|
||||
(void)listener;
|
||||
struct wlr_surface *surface = data;
|
||||
if (!surface) {
|
||||
return;
|
||||
}
|
||||
if (!wlr_surface_state_has_buffer(&surface->pending)) {
|
||||
return;
|
||||
}
|
||||
if (pixman_region32_not_empty(&surface->pending.surface_damage)
|
||||
|| pixman_region32_not_empty(&surface->pending.buffer_damage)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int surface_width = surface->pending.width > 0 ? surface->pending.width
|
||||
: surface->current.width;
|
||||
int surface_height = surface->pending.height > 0 ? surface->pending.height
|
||||
: surface->current.height;
|
||||
int buffer_width = surface->pending.buffer_width > 0
|
||||
? surface->pending.buffer_width
|
||||
: surface->current.buffer_width;
|
||||
int buffer_height = surface->pending.buffer_height > 0
|
||||
? surface->pending.buffer_height
|
||||
: surface->current.buffer_height;
|
||||
|
||||
if (surface_width <= 0 || surface_height <= 0 || buffer_width <= 0
|
||||
|| buffer_height <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
pixman_region32_union_rect(&surface->pending.surface_damage,
|
||||
&surface->pending.surface_damage, 0, 0, surface_width, surface_height);
|
||||
pixman_region32_union_rect(&surface->pending.buffer_damage,
|
||||
&surface->pending.buffer_damage, 0, 0, buffer_width, buffer_height);
|
||||
}
|
||||
|
||||
static void surface_damage_destroy(struct wl_listener *listener, void *data)
|
||||
{
|
||||
(void)data;
|
||||
struct SurfaceDamageListener *hook
|
||||
= wl_container_of(listener, hook, destroy);
|
||||
wl_list_remove(&hook->client_commit.link);
|
||||
wl_list_remove(&hook->destroy.link);
|
||||
free(hook);
|
||||
}
|
||||
|
||||
static void surface_damage_track(struct wlr_surface *surface)
|
||||
{
|
||||
if (!surface) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct SurfaceDamageListener *hook = calloc(1, sizeof(*hook));
|
||||
if (!hook) {
|
||||
wlr_log(WLR_ERROR, "Failed to allocate surface damage listener");
|
||||
return;
|
||||
}
|
||||
|
||||
hook->client_commit.notify = surface_damage_client_commit;
|
||||
wl_signal_add(&surface->events.client_commit, &hook->client_commit);
|
||||
|
||||
hook->destroy.notify = surface_damage_destroy;
|
||||
wl_signal_add(&surface->events.destroy, &hook->destroy);
|
||||
}
|
||||
|
||||
static void compositor_new_surface_notify(
|
||||
struct wl_listener *listener, void *data)
|
||||
{
|
||||
(void)listener;
|
||||
struct wlr_surface *surface = data;
|
||||
if (!surface) {
|
||||
return;
|
||||
}
|
||||
|
||||
surface_damage_track(surface);
|
||||
}
|
||||
|
||||
struct ExternalTexturePipeline {
|
||||
bool attempted_init;
|
||||
bool ready;
|
||||
@@ -428,6 +339,8 @@ static void LunarWM_Toplevel_release_surface_rt(LunarWM_Toplevel *tl)
|
||||
UnloadRenderTexture(tl->surface_rt);
|
||||
}
|
||||
tl->surface_rt = (RenderTexture2D) { 0 };
|
||||
tl->surface_extents = (struct wlr_box) { 0 };
|
||||
tl->composed_has_alpha = false;
|
||||
}
|
||||
|
||||
static void remove_windows_for_tl(LunarWM *wm, LunarWM_Toplevel *tl)
|
||||
@@ -523,8 +436,16 @@ static void toplevel_unmap_notify(struct wl_listener *l, void *data)
|
||||
if (tl->commit.link.prev || tl->commit.link.next)
|
||||
wl_list_remove(&tl->commit.link);
|
||||
|
||||
if (tl->locked_buffer) {
|
||||
wlr_buffer_unlock(tl->locked_buffer);
|
||||
tl->locked_buffer = NULL;
|
||||
}
|
||||
tl->texture = NULL;
|
||||
tl->gles_texture = NULL;
|
||||
tl->rl_texture = (Texture) { 0 };
|
||||
LunarWM_Toplevel_release_surface_rt(tl);
|
||||
tl->surface = NULL;
|
||||
tl->composed_has_alpha = false;
|
||||
|
||||
focus_fallback(tl->server);
|
||||
}
|
||||
@@ -592,13 +513,16 @@ bool LunarWM_Toplevel_destroy(LunarWM_Toplevel *this)
|
||||
wl_list_remove(&this->commit.link);
|
||||
if (this->destroy.link.prev || this->destroy.link.next)
|
||||
wl_list_remove(&this->destroy.link);
|
||||
if (this->locked_buffer)
|
||||
wlr_buffer_unlock(this->locked_buffer);
|
||||
LunarWM_Toplevel_release_surface_rt(this);
|
||||
this->composed_has_alpha = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
struct SurfaceComposeCtx {
|
||||
Vector2 size;
|
||||
LunarWM *wm;
|
||||
struct wlr_box extents;
|
||||
bool *has_alpha;
|
||||
};
|
||||
|
||||
char const *GLInternalFormatName(GLenum format)
|
||||
@@ -635,14 +559,18 @@ static void surface_compose_draw(
|
||||
struct wlr_surface *surface, int sx, int sy, void *user_data)
|
||||
{
|
||||
struct SurfaceComposeCtx *ctx = user_data;
|
||||
if (!ctx) {
|
||||
if (!ctx)
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_texture *wlr_tex = wlr_surface_get_texture(surface);
|
||||
if (!wlr_tex || wlr_tex->width == 0 || wlr_tex->height == 0) {
|
||||
if (!wlr_tex || wlr_tex->width == 0 || wlr_tex->height == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_gles2_texture *gles_tex = gles2_get_texture(wlr_tex);
|
||||
if (!gles_tex)
|
||||
return;
|
||||
if (ctx->has_alpha && gles_tex->has_alpha)
|
||||
*ctx->has_alpha = true;
|
||||
|
||||
struct wlr_gles2_texture_attribs attribs;
|
||||
wlr_gles2_texture_get_attribs(wlr_tex, &attribs);
|
||||
@@ -651,7 +579,8 @@ static void surface_compose_draw(
|
||||
.width = (int)wlr_tex->width,
|
||||
.height = (int)wlr_tex->height,
|
||||
.mipmaps = 1,
|
||||
.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
|
||||
.format = gles_tex->has_alpha ? PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
|
||||
: PIXELFORMAT_UNCOMPRESSED_R8G8B8,
|
||||
};
|
||||
|
||||
float dest_w = (float)surface->current.width;
|
||||
@@ -663,16 +592,16 @@ static void surface_compose_draw(
|
||||
|
||||
Rectangle src = { 0.0f, 0.0f, (float)tex.width, (float)tex.height };
|
||||
Rectangle dst = {
|
||||
sx,
|
||||
sy,
|
||||
(float)(sx - ctx->extents.x),
|
||||
(float)(sy - ctx->extents.y),
|
||||
dest_w,
|
||||
dest_h,
|
||||
};
|
||||
|
||||
if (attribs.target == GL_TEXTURE_EXTERNAL_OES) {
|
||||
static bool external_draw_warned = false;
|
||||
if (!draw_external_texture(
|
||||
&attribs, tex.width, tex.height, src, dst, dest_w, dest_h)) {
|
||||
if (!draw_external_texture(&attribs, tex.width, tex.height, src, dst,
|
||||
ctx->extents.width, ctx->extents.height)) {
|
||||
if (!external_draw_warned) {
|
||||
TraceLog(LOG_WARNING,
|
||||
"Failed to draw external texture, skipping frame");
|
||||
@@ -681,29 +610,70 @@ static void surface_compose_draw(
|
||||
}
|
||||
} else {
|
||||
assert(attribs.target == GL_TEXTURE_2D);
|
||||
|
||||
glClearStencil(0);
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
DrawTexture(tex, sx, sy, WHITE);
|
||||
rlDrawRenderBatchActive();
|
||||
DrawTexturePro(tex, src, dst, (Vector2) { 0.0f, 0.0f }, 0.0f, WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
bool LunarWM_Toplevel_update(LunarWM_Toplevel *this)
|
||||
{
|
||||
if (!this->surface->mapped) {
|
||||
if (!this || !this->surface)
|
||||
return false;
|
||||
|
||||
this->texture = wlr_surface_get_texture(this->surface);
|
||||
struct wlr_client_buffer *cl_buf = this->surface->buffer;
|
||||
if ((this->texture == nullptr) || (cl_buf == nullptr)) {
|
||||
return false;
|
||||
}
|
||||
int width = this->surface->current.width;
|
||||
int height = this->surface->current.height;
|
||||
|
||||
if ((this->locked_buffer != nullptr)
|
||||
&& this->locked_buffer != &cl_buf->base) {
|
||||
wlr_buffer_unlock(this->locked_buffer);
|
||||
this->locked_buffer = nullptr;
|
||||
}
|
||||
if (this->locked_buffer == nullptr) {
|
||||
this->locked_buffer = wlr_buffer_lock(&cl_buf->base);
|
||||
}
|
||||
|
||||
wlr_gles2_texture_get_attribs(this->texture, &this->attribs);
|
||||
this->gles_texture = gles2_get_texture(this->texture);
|
||||
if (this->gles_texture == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->rl_texture.id = (unsigned int)this->attribs.tex;
|
||||
this->rl_texture.width = (int)this->texture->width;
|
||||
this->rl_texture.height = (int)this->texture->height;
|
||||
this->rl_texture.mipmaps = 1;
|
||||
this->rl_texture.format = this->gles_texture->has_alpha
|
||||
? PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
|
||||
: PIXELFORMAT_UNCOMPRESSED_R8G8B8;
|
||||
|
||||
SetTextureFilter(this->rl_texture, TEXTURE_FILTER_BILINEAR);
|
||||
SetTextureWrap(this->rl_texture, TEXTURE_WRAP_CLAMP);
|
||||
|
||||
struct wlr_box extents = { 0 };
|
||||
wlr_surface_get_extents(this->surface, &extents);
|
||||
if (extents.width <= 0 || extents.height <= 0) {
|
||||
LunarWM_Toplevel_release_surface_rt(this);
|
||||
this->composed_has_alpha = this->gles_texture->has_alpha;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool needs_alpha = this->gles_texture->has_alpha;
|
||||
if (extents.x != 0 || extents.y != 0
|
||||
|| extents.width != (int)this->texture->width
|
||||
|| extents.height != (int)this->texture->height) {
|
||||
needs_alpha = true;
|
||||
}
|
||||
|
||||
bool const size_changed = !IsRenderTextureValid(this->surface_rt)
|
||||
|| this->surface_rt.texture.width != width
|
||||
|| this->surface_rt.texture.height != height;
|
||||
|| this->surface_rt.texture.width != extents.width
|
||||
|| this->surface_rt.texture.height != extents.height;
|
||||
if (size_changed) {
|
||||
LunarWM_Toplevel_release_surface_rt(this);
|
||||
this->surface_rt = LoadRenderTexture(width, height);
|
||||
this->surface_rt = LoadRenderTexture(extents.width, extents.height);
|
||||
if (!IsRenderTextureValid(this->surface_rt)) {
|
||||
this->composed_has_alpha = needs_alpha;
|
||||
return true;
|
||||
}
|
||||
SetTextureFilter(this->surface_rt.texture, TEXTURE_FILTER_BILINEAR);
|
||||
@@ -712,17 +682,22 @@ bool LunarWM_Toplevel_update(LunarWM_Toplevel *this)
|
||||
|
||||
BeginTextureMode(this->surface_rt);
|
||||
ClearBackground(BLANK);
|
||||
BeginBlendMode(BLEND_ALPHA);
|
||||
struct SurfaceComposeCtx ctx = {
|
||||
.size = (Vector2) { width, height },
|
||||
.wm = this->server,
|
||||
.extents = extents,
|
||||
.has_alpha = &needs_alpha,
|
||||
};
|
||||
// DrawRectangle(0, 0, this->surface_rt.texture.width,
|
||||
// this->surface_rt.texture.height, BLACK);
|
||||
rlSetShader(rlGetShaderIdDefault(), rlGetShaderLocsDefault());
|
||||
wlr_surface_for_each_surface(this->surface, surface_compose_draw, &ctx);
|
||||
DrawFPS(0, 0);
|
||||
EndBlendMode();
|
||||
EndTextureMode();
|
||||
|
||||
this->surface_extents = extents;
|
||||
Texture2D composed = this->surface_rt.texture;
|
||||
composed.width = extents.width;
|
||||
composed.height = extents.height;
|
||||
this->rl_texture = composed;
|
||||
this->composed_has_alpha = needs_alpha;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -868,6 +843,14 @@ static void xwl_unmap_toplevel(LunarWM_Toplevel *tl)
|
||||
if (tl->destroy.link.prev || tl->destroy.link.next)
|
||||
wl_list_remove(&tl->destroy.link);
|
||||
|
||||
if (tl->locked_buffer) {
|
||||
wlr_buffer_unlock(tl->locked_buffer);
|
||||
tl->locked_buffer = NULL;
|
||||
}
|
||||
|
||||
tl->texture = NULL;
|
||||
tl->gles_texture = NULL;
|
||||
tl->rl_texture = (Texture) { 0 };
|
||||
LunarWM_Toplevel_release_surface_rt(tl);
|
||||
tl->surface = NULL;
|
||||
}
|
||||
@@ -1232,7 +1215,6 @@ static void Pointer_motion_notify(struct wl_listener *listener, void *data)
|
||||
if (p->server->cman->cfg.input.mouse.invert_y) {
|
||||
dy *= -1;
|
||||
}
|
||||
|
||||
float const R = p->server->cman->cfg.space.radius;
|
||||
float const g = 0.0005f;
|
||||
|
||||
@@ -1564,19 +1546,44 @@ static void handle_output_frame(struct wl_listener *listener, void *data)
|
||||
|
||||
struct wlr_render_pass *pass
|
||||
= wlr_output_begin_render_pass(wlr_output, &state, NULL);
|
||||
if (pass == NULL) {
|
||||
wlr_output_state_finish(&state);
|
||||
wlr_output_schedule_frame(wlr_output);
|
||||
wlr_log(WLR_ERROR, "Failed to begin render pass for output %s",
|
||||
wlr_output->name);
|
||||
return;
|
||||
}
|
||||
|
||||
GLint draw_fbo = 0;
|
||||
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &draw_fbo);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
GLint drawFboId = 0, readFboId = 0;
|
||||
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFboId);
|
||||
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &readFboId);
|
||||
|
||||
rlMatrixMode(RL_MODELVIEW);
|
||||
rlLoadIdentity();
|
||||
|
||||
wm->renderer.tmp_rt.id = draw_fbo;
|
||||
// if (!IsTextureValid(wm->renderer.main_rt.texture)) {
|
||||
// wm->renderer.main_rt = LoadRenderTexture(width, height);
|
||||
// }
|
||||
|
||||
if (!wlr_render_pass_submit(pass)) {
|
||||
wlr_output_state_finish(&state);
|
||||
wlr_output_schedule_frame(wlr_output);
|
||||
wlr_log(WLR_ERROR, "Failed to submit render pass for output %s",
|
||||
wlr_output->name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wlr_output_commit_state(wlr_output, &state)) {
|
||||
wlr_log(WLR_ERROR, "Failed to commit state for output %s",
|
||||
wlr_output->name);
|
||||
wlr_output_state_finish(&state);
|
||||
wlr_output_schedule_frame(wlr_output);
|
||||
return;
|
||||
}
|
||||
|
||||
wm->renderer.tmp_rt.id = drawFboId;
|
||||
wm->renderer.tmp_rt.texture = (Texture) {
|
||||
.id = draw_fbo,
|
||||
.id = drawFboId,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.mipmaps = 1,
|
||||
@@ -1592,35 +1599,18 @@ static void handle_output_frame(struct wl_listener *listener, void *data)
|
||||
rlFramebufferAttach(wm->renderer.tmp_rt.id, wm->renderer.tmp_rt.depth.id,
|
||||
RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
||||
|
||||
if (!wm->xr.available && !wm->renderer.first_frame) {
|
||||
wm->renderer.camera.target = SphericalToVector3(wm->wm.pointer);
|
||||
|
||||
Vector3 forward = Vector3Normalize(Vector3Subtract(
|
||||
wm->renderer.camera.target, wm->renderer.camera.position));
|
||||
Vector3 worldUp = (Vector3) { 0, 1, 0 };
|
||||
|
||||
if (fabsf(Vector3DotProduct(forward, worldUp)) > 0.999f) {
|
||||
worldUp = (Vector3) { 0, 0, 1 };
|
||||
if (!IsTextureValid(wm->renderer.main_rt.texture)) {
|
||||
wm->renderer.main_rt = LoadRenderTexture(width, height);
|
||||
}
|
||||
|
||||
Vector3 right = Vector3Normalize(Vector3CrossProduct(forward, worldUp));
|
||||
wm->renderer.camera.up
|
||||
= Vector3Normalize(Vector3CrossProduct(right, forward));
|
||||
}
|
||||
|
||||
int const hud_size = wm->cman->cfg.displays.hud.size;
|
||||
if (!IsTextureValid(wm->renderer.hud_rt.texture)) {
|
||||
wm->renderer.hud_rt = LoadRenderTexture(hud_size, hud_size);
|
||||
}
|
||||
BeginTextureMode(wm->renderer.hud_rt);
|
||||
{
|
||||
LunarWM_render_hud(wm, GetFrameTime(), hud_size);
|
||||
LunarWM_render_hud(wm, GetFrameTime(), 1);
|
||||
}
|
||||
EndTextureMode();
|
||||
|
||||
if (!IsTextureValid(wm->renderer.main_rt.texture)) {
|
||||
wm->renderer.main_rt = LoadRenderTexture(width, height);
|
||||
}
|
||||
BeginTextureMode(wm->renderer.main_rt);
|
||||
{
|
||||
BeginMode3D(wm->renderer.camera);
|
||||
@@ -1630,7 +1620,6 @@ static void handle_output_frame(struct wl_listener *listener, void *data)
|
||||
}
|
||||
EndMode3D();
|
||||
|
||||
DrawFPS(0, 0);
|
||||
rlDrawRenderBatchActive();
|
||||
}
|
||||
EndTextureMode();
|
||||
@@ -1654,18 +1643,7 @@ static void handle_output_frame(struct wl_listener *listener, void *data)
|
||||
}
|
||||
EndTextureMode();
|
||||
|
||||
if (wm->renderer.first_frame) {
|
||||
LunarWM_set_recenter_from_camera(wm);
|
||||
wm->renderer.first_frame = false;
|
||||
wm->wm.pointer = get_forward_spherical_with_nearest(
|
||||
wm->renderer.camera.target, wm->cman->cfg.space.radius);
|
||||
}
|
||||
|
||||
wlr_render_pass_submit(pass);
|
||||
wlr_output_commit_state(wlr_output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
static void handle_new_output(struct wl_listener *listener, void *data)
|
||||
@@ -1786,9 +1764,6 @@ bool LunarWM_wayland_init(LunarWM *this)
|
||||
wlr_log(WLR_ERROR, "Failed to create compositor");
|
||||
return false;
|
||||
}
|
||||
this->wayland.new_surface_listener.notify = compositor_new_surface_notify;
|
||||
wl_signal_add(&this->wayland.compositor->events.new_surface,
|
||||
&this->wayland.new_surface_listener);
|
||||
|
||||
this->wayland.subcompositor
|
||||
= wlr_subcompositor_create(this->wayland.display);
|
||||
@@ -1866,12 +1841,6 @@ void LunarWM_wayland_cleanup(LunarWM *this)
|
||||
this->wayland.new_output_listener.notify = NULL;
|
||||
}
|
||||
|
||||
if (this->wayland.new_surface_listener.link.prev
|
||||
|| this->wayland.new_surface_listener.link.next) {
|
||||
wl_list_remove(&this->wayland.new_surface_listener.link);
|
||||
this->wayland.new_surface_listener.notify = NULL;
|
||||
}
|
||||
|
||||
if (this->wayland.v_outputs) {
|
||||
for (size_t i = 0; i < vector_size(this->wayland.v_outputs); ++i) {
|
||||
destroy_output(this->wayland.v_outputs[i]);
|
||||
|
||||
@@ -35,9 +35,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifdef __cpp_decltype
|
||||
#include <type_traits>
|
||||
# define typeof(T) \
|
||||
std::remove_reference< \
|
||||
std::add_lvalue_reference<decltype(T)>::type>::type
|
||||
#define typeof(T) std::remove_reference<std::add_lvalue_reference<decltype(T)>::type>::type
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -61,13 +59,15 @@ typedef size_t vec_type_t;
|
||||
|
||||
// vec_addr is a vector* (aka type**)
|
||||
#define vector_add_dst(vec_addr)\
|
||||
((typeof(*vec_addr))(_vector_add_dst( \
|
||||
(vector *)vec_addr, sizeof(**vec_addr))))
|
||||
((typeof(*vec_addr))(\
|
||||
_vector_add_dst((vector*)vec_addr, sizeof(**vec_addr))\
|
||||
))
|
||||
#define vector_insert_dst(vec_addr, pos)\
|
||||
((typeof(*vec_addr))(_vector_insert_dst( \
|
||||
(vector *)vec_addr, sizeof(**vec_addr), pos)))
|
||||
((typeof(*vec_addr))(\
|
||||
_vector_insert_dst((vector*)vec_addr, sizeof(**vec_addr), pos)))
|
||||
|
||||
# define vector_add(vec_addr, value) (*vector_add_dst(vec_addr) = value)
|
||||
#define vector_add(vec_addr, value)\
|
||||
(*vector_add_dst(vec_addr) = value)
|
||||
#define vector_insert(vec_addr, pos, value)\
|
||||
(*vector_insert_dst(vec_addr, pos) = value)
|
||||
|
||||
@@ -88,12 +88,14 @@ typedef size_t vec_type_t;
|
||||
// vec is a vector (aka type*)
|
||||
#define vector_erase(vec, pos, len)\
|
||||
(_vector_erase((vector)vec, sizeof(*vec), pos, len))
|
||||
#define vector_remove(vec, pos) (_vector_remove((vector)vec, sizeof(*vec), pos))
|
||||
#define vector_remove(vec, pos)\
|
||||
(_vector_remove((vector)vec, sizeof(*vec), pos))
|
||||
|
||||
#define vector_reserve(vec_addr, capacity)\
|
||||
(_vector_reserve((vector*)vec_addr, sizeof(**vec_addr), capacity))
|
||||
|
||||
#define vector_copy(vec) (_vector_copy((vector)vec, sizeof(*vec)))
|
||||
#define vector_copy(vec)\
|
||||
(_vector_copy((vector)vec, sizeof(*vec)))
|
||||
|
||||
vector vector_create(void);
|
||||
|
||||
@@ -101,18 +103,15 @@ void vector_free(vector vec);
|
||||
|
||||
void* _vector_add_dst(vector* vec_addr, vec_type_t type_size);
|
||||
|
||||
void *_vector_insert_dst(
|
||||
vector *vec_addr, vec_type_t type_size, vec_size_t pos);
|
||||
void* _vector_insert_dst(vector* vec_addr, vec_type_t type_size, vec_size_t pos);
|
||||
|
||||
void _vector_erase(
|
||||
vector vec_addr, vec_type_t type_size, vec_size_t pos, vec_size_t len);
|
||||
void _vector_erase(vector vec_addr, vec_type_t type_size, vec_size_t pos, vec_size_t len);
|
||||
|
||||
void _vector_remove(vector vec_addr, vec_type_t type_size, vec_size_t pos);
|
||||
|
||||
void vector_pop(vector vec);
|
||||
|
||||
void _vector_reserve(
|
||||
vector *vec_addr, vec_type_t type_size, vec_size_t capacity);
|
||||
void _vector_reserve(vector* vec_addr, vec_type_t type_size, vec_size_t capacity);
|
||||
|
||||
vector _vector_copy(vector vec, vec_type_t type_size);
|
||||
|
||||
|
||||
+1
-1
@@ -3,6 +3,6 @@ set -euo pipefail
|
||||
|
||||
ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
find "$ROOT/src" -type f -name '*.c' -o -name '*.h' -print0 | while IFS= read -r -d '' f; do
|
||||
find "$ROOT/src" -type f -name '*.cppm' -print0 | while IFS= read -r -d '' f; do
|
||||
clang-format -i --style=file "$f"
|
||||
done
|
||||
|
||||
+1
-1
Submodule wlroots-lunar updated: 00d01dcc29...a9abd5a6e4
Reference in New Issue
Block a user