From 192666dd43896ec95918903e4f6cfd711c5e6f5a Mon Sep 17 00:00:00 2001 From: Daniel Legt Date: Thu, 16 Jul 2026 18:06:00 +0300 Subject: [PATCH] fix(overlay): enforce text wrap width to prevent overflow beyond screen Add `gtk_label_set_width_chars` to set a concrete width for label allocation, ensuring long sentences wrap within the configured max-chars bubble width instead of extending off-screen. --- README.md | 2 +- src/output/overlay/overlay_gtk.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 19c4537..1baa2d0 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Use `--output=both` to keep terminal output as well: ./scripts/distrobox/run.sh --mode=vad --output=both ``` -In VAD mode, a 500 ms pause finalizes the current caption and starts the next line. The overlay keeps up to six completed lines above the active provisional caption; each completed line remains visible for at least three seconds and gradually fades from white to a restrained gray as it ages. If a seventh line arrives sooner, the hard six-line cap removes the oldest. Text is left-aligned inside the centered, fixed-width dark bubble. Pointer input passes through the window by default. Empty completed captions hide the overlay. +In VAD mode, a 500 ms pause finalizes the current caption and starts the next line. The overlay keeps up to six completed lines above the active provisional caption; each completed line remains visible for at least three seconds and gradually fades from white to a restrained gray as it ages. If a seventh line arrives sooner, the hard six-line cap removes the oldest. Text is left-aligned inside the centered, fixed-width dark bubble and wraps at its configured width instead of extending off-screen. Pointer input passes through the window by default. Empty completed captions hide the overlay. To build outside the helper script, install GTK4 and GTK4 Layer Shell development packages, then run: diff --git a/src/output/overlay/overlay_gtk.go b/src/output/overlay/overlay_gtk.go index a748c12..441bb67 100644 --- a/src/output/overlay/overlay_gtk.go +++ b/src/output/overlay/overlay_gtk.go @@ -354,6 +354,9 @@ static CaptioneerOverlay *captioneer_overlay_new( gtk_label_set_xalign(GTK_LABEL(labels[i]), 0.0f); gtk_label_set_wrap(GTK_LABEL(labels[i]), TRUE); gtk_label_set_wrap_mode(GTK_LABEL(labels[i]), PANGO_WRAP_WORD_CHAR); + // width-chars gives GTK a concrete allocation width, so wrapping happens + // before a long sentence can widen the bubble beyond the screen. + gtk_label_set_width_chars(GTK_LABEL(labels[i]), max_chars); gtk_label_set_max_width_chars(GTK_LABEL(labels[i]), max_chars); gtk_widget_set_halign(labels[i], GTK_ALIGN_FILL); gtk_box_append(GTK_BOX(box), labels[i]);