Compare commits
68 Commits
master
..
f3c13b915a
| Author | SHA1 | Date | |
|---|---|---|---|
| f3c13b915a | |||
| df00037296 | |||
| 670848e924 | |||
| d28bb6f8ee | |||
| c6365c0cc1 | |||
| f9dff4265a | |||
| 6cd7099c39 | |||
| 3fcf769aff | |||
| 389c1f9934 | |||
| 4ddd9a0ca7 | |||
| 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
|
||||
|
||||
Generated
+3
-3
@@ -97,11 +97,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1759496058,
|
||||
"narHash": "sha256-eVgGEO+KhJX307XQ0gbbCWguJfoSJlZRFQrpvalK7kM=",
|
||||
"lastModified": 1759266345,
|
||||
"narHash": "sha256-BJ+CTRXaFArVFgJfL19QpoR7Ebk8HU63Lz0+jQvhV3Y=",
|
||||
"owner": "slendidev",
|
||||
"repo": "wlroots-lunar",
|
||||
"rev": "00d01dcc297e1991809ad2c0f6b50fb66478d748",
|
||||
"rev": "1179ca07821decbff320eafd7ffb3caaadcefbf4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
ninja
|
||||
(pkgs.llvmPackages_20.clang-tools.override { enableLibcxx = true; })
|
||||
lldb
|
||||
valgrind
|
||||
|
||||
lua
|
||||
|
||||
|
||||
+1
-10
@@ -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);
|
||||
}
|
||||
LunarWM_set_recenter_from_camera(&g_wm);
|
||||
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
@@ -268,13 +266,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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -130,8 +130,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 {
|
||||
|
||||
+132
-55
@@ -10,7 +10,6 @@
|
||||
#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>
|
||||
@@ -428,6 +427,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 +524,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 +601,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 +647,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 +667,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 +680,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 +698,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 +770,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 +931,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;
|
||||
}
|
||||
@@ -1564,19 +1635,42 @@ 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_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,
|
||||
@@ -1594,18 +1688,6 @@ static void handle_output_frame(struct wl_listener *listener, void *data)
|
||||
|
||||
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 };
|
||||
}
|
||||
|
||||
Vector3 right = Vector3Normalize(Vector3CrossProduct(forward, worldUp));
|
||||
wm->renderer.camera.up
|
||||
= Vector3Normalize(Vector3CrossProduct(right, forward));
|
||||
}
|
||||
|
||||
int const hud_size = wm->cman->cfg.displays.hud.size;
|
||||
@@ -1614,7 +1696,7 @@ static void handle_output_frame(struct wl_listener *listener, void *data)
|
||||
}
|
||||
BeginTextureMode(wm->renderer.hud_rt);
|
||||
{
|
||||
LunarWM_render_hud(wm, GetFrameTime(), hud_size);
|
||||
LunarWM_render_hud(wm, GetFrameTime(), 1);
|
||||
}
|
||||
EndTextureMode();
|
||||
|
||||
@@ -1630,7 +1712,6 @@ static void handle_output_frame(struct wl_listener *listener, void *data)
|
||||
}
|
||||
EndMode3D();
|
||||
|
||||
DrawFPS(0, 0);
|
||||
rlDrawRenderBatchActive();
|
||||
}
|
||||
EndTextureMode();
|
||||
@@ -1661,11 +1742,7 @@ static void handle_output_frame(struct wl_listener *listener, void *data)
|
||||
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)
|
||||
|
||||
+1
-1
Submodule wlroots-lunar updated: 00d01dcc29...a9abd5a6e4
Reference in New Issue
Block a user