sway wezterm nudge

This commit is contained in:
2026-08-04 11:45:05 +02:00
parent 1bee24c168
commit 94a6dc4d40
2 changed files with 44 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
#!/bin/sh
# wezterm-nudge.sh - workaround for the wezterm fractional-scaling bug on sway
# (wezterm#5875 / #6463). On a fractional-scaled output a newly mapped wezterm
# window renders its terminal area as a small rectangle until it receives a
# configure event (manually refocusing or switching workspaces is what normally
# "fixes" it). We force that configure here.
#
# The mis-scaled state is invisible to sway IPC (the window's rect is always the
# correct allocated size), so there is no event to wait on - a short settle delay
# is unavoidable. The matching `for_window ... opacity 0` rule keeps the window
# transparent from its first frame; this script reveals it (opacity 1) only after
# the nudge, so the resize is never visible.
#
# Nudge strategy, cheapest first:
# 1. 1px width resize - works when the window has a horizontal neighbour
# 2. 1px height resize - works when the window has a vertical neighbour
# (both are imperceptible and cause no real reflow once reverted)
# 3. float/unfloat - fallback for a lone window, which cannot be resized
# ("Cannot resize any further"); it has no neighbours, so nothing reflows
c='[con_id=__focused__]'
# Let the window finish mapping and take focus before nudging.
sleep 0.08
if swaymsg "$c resize grow width 1 px" | grep -q '"success": true'; then
swaymsg "$c resize shrink width 1 px" >/dev/null
elif swaymsg "$c resize grow height 1 px" | grep -q '"success": true'; then
swaymsg "$c resize shrink height 1 px" >/dev/null
else
swaymsg "$c floating enable" >/dev/null
swaymsg "$c floating disable" >/dev/null
fi
# Reveal. Target all wezterm windows so none can ever get stuck transparent.
swaymsg '[app_id=org.wezfurlong.wezterm] opacity 1' >/dev/null

View File

@@ -11,3 +11,12 @@ for_window [class="snow_trail_sdl"] floating enable
for_window [app_id="destinations"] floating enable
for_window [class="destinations"] floating enable
for_window [app_id="evidence-quest"] floating enable
# Workaround for wezterm fractional-scaling bug (wezterm#5875 / #6463): on a
# fractional-scaled output (DP-1 @ 1.5x) a newly mapped wezterm window renders its
# terminal area as a small rectangle until it receives a configure event. The
# window is held transparent from its first frame and revealed by the nudge script
# only after it has been forced to re-configure (resize nudge, or float-toggle when
# alone). See scripts/wezterm-nudge.sh for details.
for_window [app_id="org.wezfurlong.wezterm"] opacity 0
for_window [app_id="org.wezfurlong.wezterm"] exec ~/.config/sway/scripts/wezterm-nudge.sh