From f0253633d3cdde994b48c25692707e1df2f1e1e7 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Sat, 4 Jan 2025 22:26:00 -0500 Subject: [PATCH 1/3] render: Expose render_overlay This function updates the overlay that foot uses. It will be used to update the overlay when the flash effect ends. --- pgo/pgo.c | 2 ++ render.c | 2 +- render.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pgo/pgo.c b/pgo/pgo.c index aab18847..24154277 100644 --- a/pgo/pgo.c +++ b/pgo/pgo.c @@ -72,6 +72,8 @@ void render_refresh_title(struct terminal *term) {} void render_refresh_app_id(struct terminal *term) {} void render_refresh_icon(struct terminal *term) {} +void render_overlay(struct terminal *term) {} + bool render_xcursor_is_valid(const struct seat *seat, const char *cursor) { diff --git a/render.c b/render.c index 5a924743..020dee79 100644 --- a/render.c +++ b/render.c @@ -1862,7 +1862,7 @@ render_overlay_single_pixel(struct terminal *term, enum overlay_style style, } } -static void +void render_overlay(struct terminal *term) { struct wayl_sub_surface *overlay = &term->window->overlay; diff --git a/render.h b/render.h index 1898351c..81d2a905 100644 --- a/render.h +++ b/render.h @@ -31,6 +31,8 @@ bool render_xcursor_set( struct seat *seat, struct terminal *term, enum cursor_shape shape); bool render_xcursor_is_valid(const struct seat *seat, const char *cursor); +void render_overlay(struct terminal *term); + struct render_worker_context { int my_id; struct terminal *term; From c2add346ad5c1673ba0334264300e86eb50b2293 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Sat, 4 Jan 2025 21:59:19 -0500 Subject: [PATCH 2/3] terminal: Refresh only overlay when flash expires If we call render_refresh, that will wait for a callback to the main surface. In the case of a flash, the main surface might not get callbacks if the compositor implements fancy culling optimizations like wlroots wlr_scene compositors such as sway version >=1.10. --- terminal.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/terminal.c b/terminal.c index 5a74631a..7b5a4d2d 100644 --- a/terminal.c +++ b/terminal.c @@ -419,7 +419,12 @@ fdm_flash(struct fdm *fdm, int fd, int events, void *data) (unsigned long long)expiration_count); term->flash.active = false; - render_refresh(term); + render_overlay(term); + + // since the overlay surface is synced with the main window surface, we have + // to commit the main surface for the compositor to acknowledge the new + // overlay state. + wl_surface_commit(term->window->surface.surf); return true; } From 301101e7d9d9675b48b874128a36ecf3005b727e Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Sat, 4 Jan 2025 21:36:33 -0500 Subject: [PATCH 3/3] Revert "config: don't allow colors.flash-alpha to be 1.0" This reverts commit 56d2c3e990509d18de31e6009e0d0c6254f99b67. --- CHANGELOG.md | 3 --- config.c | 4 ++-- render.c | 21 --------------------- 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc1d3bc3..508174b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,9 +80,6 @@ * Runtime changes to the app-id (OSC-176) now limits the app-id string to 2048 characters ([#1897][1897]). -* `colors.flash-alpha` can no longer be set to 1.0 (i.e. fully - opaque). This fixes an issue where the window would be stuck in the - flash state. [1897]: https://codeberg.org/dnkl/foot/issues/1897 diff --git a/config.c b/config.c index 3b8ce7e8..7f1ce055 100644 --- a/config.c +++ b/config.c @@ -1445,8 +1445,8 @@ parse_section_colors(struct context *ctx) if (!value_to_float(ctx, &alpha)) return false; - if (alpha < 0. || alpha >= 1.) { - LOG_CONTEXTUAL_ERR("not in range 0.0-0.999"); + if (alpha < 0. || alpha > 1.) { + LOG_CONTEXTUAL_ERR("not in range 0.0-1.0"); return false; } diff --git a/render.c b/render.c index 020dee79..b1791a90 100644 --- a/render.c +++ b/render.c @@ -1898,27 +1898,6 @@ render_overlay(struct terminal *term) break; case OVERLAY_FLASH: - /* - * A compositor will not send a frame callback for our main - * window if it is fully occluded (for example, by a fully - * opaque overlay...). This causes the overlay to stuck. - * - * For regular buffers, it _should_ be enough to *not* hint - * the compositor it's opaque. But at least some compositor - * special cases single-pixel buffers, and actually look at - * their pixel value. - * - * Thus, we have two options: implement frame callback - * handling for the overlay sub-surface, or ensure we don't - * use a fully opaque surface. Since no overlays are fully - * opaque by default, and the flash surface is the only one - * that can be configured to be opaque (colors.flash-alpha), - * and since adding frame callback handling adds a lot of - * boilerplate code... let's go with the simpler solution of - * not allowing colors.flash-alpha to be 1.0. - */ - xassert(term->conf->colors.flash_alpha != 0xffff); - color = color_hex_to_pixman_with_alpha( term->conf->colors.flash, term->conf->colors.flash_alpha);