2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
|||||||
[submodule "wlroots-lunar"]
|
[submodule "wlroots-lunar"]
|
||||||
path = wlroots-lunar
|
path = wlroots-lunar
|
||||||
url = git@github.com:slendidev/wlroots-lunar
|
url = https://github.com/slendidev/wlroots-lunar
|
||||||
|
|||||||
6
flake.lock
generated
6
flake.lock
generated
@@ -97,11 +97,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1759266345,
|
"lastModified": 1759496058,
|
||||||
"narHash": "sha256-BJ+CTRXaFArVFgJfL19QpoR7Ebk8HU63Lz0+jQvhV3Y=",
|
"narHash": "sha256-eVgGEO+KhJX307XQ0gbbCWguJfoSJlZRFQrpvalK7kM=",
|
||||||
"owner": "slendidev",
|
"owner": "slendidev",
|
||||||
"repo": "wlroots-lunar",
|
"repo": "wlroots-lunar",
|
||||||
"rev": "1179ca07821decbff320eafd7ffb3caaadcefbf4",
|
"rev": "00d01dcc297e1991809ad2c0f6b50fb66478d748",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -328,16 +328,13 @@ void LunarWM_render_windows(LunarWM *this, bool alpha_check)
|
|||||||
if (!tl || !tl->surface) {
|
if (!tl || !tl->surface) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (tl->gles_texture) {
|
if (IsTextureValid(tl->surface_rt.texture)) {
|
||||||
if (alpha_check && tl->composed_has_alpha) {
|
Texture2D tex = tl->surface_rt.texture;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Texture2D tex = tl->rl_texture;
|
|
||||||
bool y_flip = false;
|
bool y_flip = false;
|
||||||
if (IsRenderTextureValid(tl->surface_rt)) {
|
if (IsRenderTextureValid(tl->surface_rt)) {
|
||||||
tex = tl->surface_rt.texture;
|
tex = tl->surface_rt.texture;
|
||||||
tex.width = tl->rl_texture.width;
|
tex.width = tl->surface_rt.texture.width;
|
||||||
tex.height = tl->rl_texture.height;
|
tex.height = tl->surface_rt.texture.height;
|
||||||
y_flip = true;
|
y_flip = true;
|
||||||
}
|
}
|
||||||
if (!tex.id)
|
if (!tex.id)
|
||||||
|
|||||||
@@ -130,15 +130,8 @@ typedef struct {
|
|||||||
} u;
|
} u;
|
||||||
|
|
||||||
struct wlr_surface *surface;
|
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;
|
RenderTexture2D surface_rt;
|
||||||
struct wlr_box surface_extents;
|
|
||||||
bool composed_has_alpha;
|
|
||||||
} LunarWM_Toplevel;
|
} LunarWM_Toplevel;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <wlr/backend/x11.h>
|
#include <wlr/backend/x11.h>
|
||||||
#include <wlr/render/color.h>
|
#include <wlr/render/color.h>
|
||||||
#include <wlr/render/pass.h>
|
#include <wlr/render/pass.h>
|
||||||
|
#include <wlr/xwayland/xwayland.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@@ -427,8 +428,6 @@ static void LunarWM_Toplevel_release_surface_rt(LunarWM_Toplevel *tl)
|
|||||||
UnloadRenderTexture(tl->surface_rt);
|
UnloadRenderTexture(tl->surface_rt);
|
||||||
}
|
}
|
||||||
tl->surface_rt = (RenderTexture2D) { 0 };
|
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)
|
static void remove_windows_for_tl(LunarWM *wm, LunarWM_Toplevel *tl)
|
||||||
@@ -524,16 +523,8 @@ static void toplevel_unmap_notify(struct wl_listener *l, void *data)
|
|||||||
if (tl->commit.link.prev || tl->commit.link.next)
|
if (tl->commit.link.prev || tl->commit.link.next)
|
||||||
wl_list_remove(&tl->commit.link);
|
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);
|
LunarWM_Toplevel_release_surface_rt(tl);
|
||||||
tl->surface = NULL;
|
tl->surface = NULL;
|
||||||
tl->composed_has_alpha = false;
|
|
||||||
|
|
||||||
focus_fallback(tl->server);
|
focus_fallback(tl->server);
|
||||||
}
|
}
|
||||||
@@ -601,16 +592,13 @@ bool LunarWM_Toplevel_destroy(LunarWM_Toplevel *this)
|
|||||||
wl_list_remove(&this->commit.link);
|
wl_list_remove(&this->commit.link);
|
||||||
if (this->destroy.link.prev || this->destroy.link.next)
|
if (this->destroy.link.prev || this->destroy.link.next)
|
||||||
wl_list_remove(&this->destroy.link);
|
wl_list_remove(&this->destroy.link);
|
||||||
if (this->locked_buffer)
|
|
||||||
wlr_buffer_unlock(this->locked_buffer);
|
|
||||||
LunarWM_Toplevel_release_surface_rt(this);
|
LunarWM_Toplevel_release_surface_rt(this);
|
||||||
this->composed_has_alpha = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SurfaceComposeCtx {
|
struct SurfaceComposeCtx {
|
||||||
struct wlr_box extents;
|
Vector2 size;
|
||||||
bool *has_alpha;
|
LunarWM *wm;
|
||||||
};
|
};
|
||||||
|
|
||||||
char const *GLInternalFormatName(GLenum format)
|
char const *GLInternalFormatName(GLenum format)
|
||||||
@@ -647,18 +635,14 @@ static void surface_compose_draw(
|
|||||||
struct wlr_surface *surface, int sx, int sy, void *user_data)
|
struct wlr_surface *surface, int sx, int sy, void *user_data)
|
||||||
{
|
{
|
||||||
struct SurfaceComposeCtx *ctx = user_data;
|
struct SurfaceComposeCtx *ctx = user_data;
|
||||||
if (!ctx)
|
if (!ctx) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_texture *wlr_tex = wlr_surface_get_texture(surface);
|
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;
|
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;
|
struct wlr_gles2_texture_attribs attribs;
|
||||||
wlr_gles2_texture_get_attribs(wlr_tex, &attribs);
|
wlr_gles2_texture_get_attribs(wlr_tex, &attribs);
|
||||||
@@ -666,9 +650,8 @@ static void surface_compose_draw(
|
|||||||
.id = (unsigned int)attribs.tex,
|
.id = (unsigned int)attribs.tex,
|
||||||
.width = (int)wlr_tex->width,
|
.width = (int)wlr_tex->width,
|
||||||
.height = (int)wlr_tex->height,
|
.height = (int)wlr_tex->height,
|
||||||
.mipmaps = 1,
|
.mipmaps = 0,
|
||||||
.format = gles_tex->has_alpha ? PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
|
.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
|
||||||
: PIXELFORMAT_UNCOMPRESSED_R8G8B8,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float dest_w = (float)surface->current.width;
|
float dest_w = (float)surface->current.width;
|
||||||
@@ -680,16 +663,16 @@ static void surface_compose_draw(
|
|||||||
|
|
||||||
Rectangle src = { 0.0f, 0.0f, (float)tex.width, (float)tex.height };
|
Rectangle src = { 0.0f, 0.0f, (float)tex.width, (float)tex.height };
|
||||||
Rectangle dst = {
|
Rectangle dst = {
|
||||||
(float)(sx - ctx->extents.x),
|
sx,
|
||||||
(float)(sy - ctx->extents.y),
|
sy,
|
||||||
dest_w,
|
dest_w,
|
||||||
dest_h,
|
dest_h,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (attribs.target == GL_TEXTURE_EXTERNAL_OES) {
|
if (attribs.target == GL_TEXTURE_EXTERNAL_OES) {
|
||||||
static bool external_draw_warned = false;
|
static bool external_draw_warned = false;
|
||||||
if (!draw_external_texture(&attribs, tex.width, tex.height, src, dst,
|
if (!draw_external_texture(
|
||||||
ctx->extents.width, ctx->extents.height)) {
|
&attribs, tex.width, tex.height, src, dst, dest_w, dest_h)) {
|
||||||
if (!external_draw_warned) {
|
if (!external_draw_warned) {
|
||||||
TraceLog(LOG_WARNING,
|
TraceLog(LOG_WARNING,
|
||||||
"Failed to draw external texture, skipping frame");
|
"Failed to draw external texture, skipping frame");
|
||||||
@@ -704,88 +687,36 @@ static void surface_compose_draw(
|
|||||||
|
|
||||||
bool LunarWM_Toplevel_update(LunarWM_Toplevel *this)
|
bool LunarWM_Toplevel_update(LunarWM_Toplevel *this)
|
||||||
{
|
{
|
||||||
if (!this || !this->surface)
|
auto texture = wlr_surface_get_texture(this->surface);
|
||||||
|
if (!texture)
|
||||||
return false;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
bool const size_changed = !IsRenderTextureValid(this->surface_rt)
|
||||||
|| this->surface_rt.texture.width != extents.width
|
|| this->surface_rt.texture.width != texture->width
|
||||||
|| this->surface_rt.texture.height != extents.height;
|
|| this->surface_rt.texture.height != texture->height;
|
||||||
if (size_changed) {
|
if (size_changed) {
|
||||||
LunarWM_Toplevel_release_surface_rt(this);
|
LunarWM_Toplevel_release_surface_rt(this);
|
||||||
this->surface_rt = LoadRenderTexture(extents.width, extents.height);
|
this->surface_rt = LoadRenderTexture(texture->width, texture->height);
|
||||||
if (!IsRenderTextureValid(this->surface_rt)) {
|
if (!IsRenderTextureValid(this->surface_rt)) {
|
||||||
this->composed_has_alpha = needs_alpha;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SetTextureFilter(this->surface_rt.texture, TEXTURE_FILTER_BILINEAR);
|
SetTextureFilter(this->surface_rt.texture, TEXTURE_FILTER_BILINEAR);
|
||||||
SetTextureWrap(this->surface_rt.texture, TEXTURE_WRAP_CLAMP);
|
SetTextureWrap(this->surface_rt.texture, TEXTURE_WRAP_CLAMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rlSetShader(rlGetShaderIdDefault(), rlGetShaderLocsDefault());
|
||||||
BeginTextureMode(this->surface_rt);
|
BeginTextureMode(this->surface_rt);
|
||||||
ClearBackground(BLANK);
|
ClearBackground(BLANK);
|
||||||
BeginBlendMode(BLEND_ALPHA);
|
|
||||||
struct SurfaceComposeCtx ctx = {
|
struct SurfaceComposeCtx ctx = {
|
||||||
.extents = extents,
|
.size = (Vector2) { texture->width, texture->height },
|
||||||
.has_alpha = &needs_alpha,
|
.wm = this->server,
|
||||||
};
|
};
|
||||||
|
// DrawRectangle(0, 0, this->surface_rt.texture.width,
|
||||||
|
// this->surface_rt.texture.height, BLACK);
|
||||||
wlr_surface_for_each_surface(this->surface, surface_compose_draw, &ctx);
|
wlr_surface_for_each_surface(this->surface, surface_compose_draw, &ctx);
|
||||||
EndBlendMode();
|
DrawFPS(0, 0);
|
||||||
EndTextureMode();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -931,14 +862,6 @@ static void xwl_unmap_toplevel(LunarWM_Toplevel *tl)
|
|||||||
if (tl->destroy.link.prev || tl->destroy.link.next)
|
if (tl->destroy.link.prev || tl->destroy.link.next)
|
||||||
wl_list_remove(&tl->destroy.link);
|
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);
|
LunarWM_Toplevel_release_surface_rt(tl);
|
||||||
tl->surface = NULL;
|
tl->surface = NULL;
|
||||||
}
|
}
|
||||||
@@ -1635,18 +1558,14 @@ static void handle_output_frame(struct wl_listener *listener, void *data)
|
|||||||
|
|
||||||
struct wlr_render_pass *pass
|
struct wlr_render_pass *pass
|
||||||
= wlr_output_begin_render_pass(wlr_output, &state, NULL);
|
= 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 drawFboId = 0, readFboId = 0;
|
GLint drawFboId = 0, readFboId = 0;
|
||||||
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFboId);
|
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFboId);
|
||||||
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &readFboId);
|
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &readFboId);
|
||||||
|
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
rlMatrixMode(RL_MODELVIEW);
|
rlMatrixMode(RL_MODELVIEW);
|
||||||
rlLoadIdentity();
|
rlLoadIdentity();
|
||||||
|
|
||||||
@@ -1682,7 +1601,7 @@ static void handle_output_frame(struct wl_listener *listener, void *data)
|
|||||||
}
|
}
|
||||||
BeginTextureMode(wm->renderer.hud_rt);
|
BeginTextureMode(wm->renderer.hud_rt);
|
||||||
{
|
{
|
||||||
LunarWM_render_hud(wm, GetFrameTime(), 1);
|
LunarWM_render_hud(wm, GetFrameTime(), hud_size);
|
||||||
}
|
}
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
@@ -1698,6 +1617,7 @@ static void handle_output_frame(struct wl_listener *listener, void *data)
|
|||||||
}
|
}
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
|
DrawFPS(0, 0);
|
||||||
rlDrawRenderBatchActive();
|
rlDrawRenderBatchActive();
|
||||||
}
|
}
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
@@ -1728,20 +1648,8 @@ static void handle_output_frame(struct wl_listener *listener, void *data)
|
|||||||
wm->renderer.camera.target, wm->cman->cfg.space.radius);
|
wm->renderer.camera.target, wm->cman->cfg.space.radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wlr_render_pass_submit(pass)) {
|
wlr_render_pass_submit(pass);
|
||||||
wlr_output_state_finish(&state);
|
wlr_output_commit_state(wlr_output, &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;
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_output_state_finish(&state);
|
wlr_output_state_finish(&state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Submodule wlroots-lunar updated: a9abd5a6e4...00d01dcc29
Reference in New Issue
Block a user