fix(core): cancel hints when reloading label size
- commit
- 4b3baffa33267a7830a95240b5788347abde75e8
- author
- brice · · 2026-10-22 20:28 UTC
- parent
- 8f581cc
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +18 -2
M internal/core/core.go +3 -0
| @@ -353,6 +353,9 @@ func (c *Core) apply(cfg ports.Config) error { | |||
| 353 | 353 | for _, s := range c.screens { | |
| 354 | 354 | axes[s.mon] = s.mon.Current().policy() | |
| 355 | 355 | } | |
| 356 | + | if c.cfg.Hint.Size != cfg.Hint.Size { | |
| 357 | + | c.hintCancel() | |
| 358 | + | } | |
| 356 | 359 | c.cfg = cfg | |
| 357 | 360 | c.binds = binds | |
| 358 | 361 | c.cmdMod = map[string]ports.Mods{"super": ports.ModSuper, "alt": ports.ModAlt, "ctrl": ports.ModCtrl}[cfg.Keyboard.CmdKey] | |
| @@ -353,6 +353,9 @@ func (c *Core) apply(cfg ports.Config) error { | |||||
| 353 | for _, s := range c.screens { | 353 | for _, s := range c.screens { | ||
| 354 | axes[s.mon] = s.mon.Current().policy() | 354 | axes[s.mon] = s.mon.Current().policy() | ||
| 355 | } | 355 | } | ||
| 356 | + | if c.cfg.Hint.Size != cfg.Hint.Size { | |||
| 357 | + | c.hintCancel() | |||
| 358 | + | } | |||
| 356 | c.cfg = cfg | 359 | c.cfg = cfg | ||
| 357 | c.binds = binds | 360 | c.binds = binds | ||
| 358 | c.cmdMod = map[string]ports.Mods{"super": ports.ModSuper, "alt": ports.ModAlt, "ctrl": ports.ModCtrl}[cfg.Keyboard.CmdKey] | 361 | c.cmdMod = map[string]ports.Mods{"super": ports.ModSuper, "alt": ports.ModAlt, "ctrl": ports.ModCtrl}[cfg.Keyboard.CmdKey] | ||
M internal/core/hint_test.go +15 -2
| @@ -24,7 +24,9 @@ type hintHarness struct { | |||
| 24 | 24 | hints chan ports.HintScanResult | |
| 25 | 25 | win ports.Rect // window 1, output-local | |
| 26 | 26 | // state is the security state input is stamped with. | |
| 27 | - | state ports.SecurityState | |
| 27 | + | state ports.SecurityState | |
| 28 | + | config chan ports.ConfigChanged | |
| 29 | + | cfg ports.Config | |
| 28 | 30 | } | |
| 29 | 31 | ||
| 30 | 32 | // newHint starts a core with one 1000x800 output "OUT-1" and window 1 mapped. | |
| @@ -42,6 +44,8 @@ func newHintConfig(t *testing.T, opts core.Options, edit func(*ports.Config)) *h | |||
| 42 | 44 | cfg.Layout.Gaps = 20 | |
| 43 | 45 | cfg.Binds["Cmd+g"] = "hint" | |
| 44 | 46 | h := &hintHarness{ | |
| 47 | + | config: make(chan ports.ConfigChanged), | |
| 48 | + | cfg: cfg, | |
| 45 | 49 | t: t, | |
| 46 | 50 | input: make(chan ports.InputEvent, 32), | |
| 47 | 51 | client: make(chan ports.ClientEvent, 32), | |
| @@ -52,7 +56,7 @@ func newHintConfig(t *testing.T, opts core.Options, edit func(*ports.Config)) *h | |||
| 52 | 56 | // Unbuffered: a send returns once core took the result. | |
| 53 | 57 | hints: make(chan ports.HintScanResult), | |
| 54 | 58 | } | |
| 55 | - | ch := core.Channels{Client: h.client, Input: h.input, Output: h.output, Commands: h.commands, Scenes: h.scenes, HintScans: h.scans, Hints: h.hints} | |
| 59 | + | ch := core.Channels{Config: h.config, Client: h.client, Input: h.input, Output: h.output, Commands: h.commands, Scenes: h.scenes, HintScans: h.scans, Hints: h.hints} | |
| 56 | 60 | c, err := core.New(cfg, ch, opts) | |
| 57 | 61 | if err != nil { | |
| 58 | 62 | t.Fatal(err) | |
| @@ -850,3 +854,12 @@ func TestHintOverlappingLabelsDropLowerScore(t *testing.T) { | |||
| 850 | 854 | } | |
| 851 | 855 | } | |
| 852 | 856 | } | |
| 857 | + | ||
| 858 | + | func TestHintSizeReloadCancelsShownHints(t *testing.T) { | |
| 859 | + | h := newHint(t, core.Options{}) | |
| 860 | + | h.show(h.inside(0)) | |
| 861 | + | cfg := h.cfg | |
| 862 | + | cfg.Hint.Size = 40 | |
| 863 | + | h.config <- ports.ConfigChanged{Config: cfg} | |
| 864 | + | h.until(func(s ports.Scene) bool { return s.HintStyle.Size == 40 && len(s.HintLabels) == 0 }) | |
| 865 | + | } | |
| @@ -24,7 +24,9 @@ type hintHarness struct { | |||||
| 24 | hints chan ports.HintScanResult | 24 | hints chan ports.HintScanResult | ||
| 25 | win ports.Rect // window 1, output-local | 25 | win ports.Rect // window 1, output-local | ||
| 26 | // state is the security state input is stamped with. | 26 | // state is the security state input is stamped with. | ||
| 27 | - | state ports.SecurityState | 27 | + | state ports.SecurityState |
| 28 | + | config chan ports.ConfigChanged | |||
| 29 | + | cfg ports.Config | |||
| 28 | } | 30 | } | ||
| 29 | 31 | ||||
| 30 | // newHint starts a core with one 1000x800 output "OUT-1" and window 1 mapped. | 32 | // newHint starts a core with one 1000x800 output "OUT-1" and window 1 mapped. | ||
| @@ -42,6 +44,8 @@ func newHintConfig(t *testing.T, opts core.Options, edit func(*ports.Config)) *h | |||||
| 42 | cfg.Layout.Gaps = 20 | 44 | cfg.Layout.Gaps = 20 | ||
| 43 | cfg.Binds["Cmd+g"] = "hint" | 45 | cfg.Binds["Cmd+g"] = "hint" | ||
| 44 | h := &hintHarness{ | 46 | h := &hintHarness{ | ||
| 47 | + | config: make(chan ports.ConfigChanged), | |||
| 48 | + | cfg: cfg, | |||
| 45 | t: t, | 49 | t: t, | ||
| 46 | input: make(chan ports.InputEvent, 32), | 50 | input: make(chan ports.InputEvent, 32), | ||
| 47 | client: make(chan ports.ClientEvent, 32), | 51 | client: make(chan ports.ClientEvent, 32), | ||
| @@ -52,7 +56,7 @@ func newHintConfig(t *testing.T, opts core.Options, edit func(*ports.Config)) *h | |||||
| 52 | // Unbuffered: a send returns once core took the result. | 56 | // Unbuffered: a send returns once core took the result. | ||
| 53 | hints: make(chan ports.HintScanResult), | 57 | hints: make(chan ports.HintScanResult), | ||
| 54 | } | 58 | } | ||
| 55 | - | ch := core.Channels{Client: h.client, Input: h.input, Output: h.output, Commands: h.commands, Scenes: h.scenes, HintScans: h.scans, Hints: h.hints} | 59 | + | ch := core.Channels{Config: h.config, Client: h.client, Input: h.input, Output: h.output, Commands: h.commands, Scenes: h.scenes, HintScans: h.scans, Hints: h.hints} |
| 56 | c, err := core.New(cfg, ch, opts) | 60 | c, err := core.New(cfg, ch, opts) | ||
| 57 | if err != nil { | 61 | if err != nil { | ||
| 58 | t.Fatal(err) | 62 | t.Fatal(err) | ||
| @@ -850,3 +854,12 @@ func TestHintOverlappingLabelsDropLowerScore(t *testing.T) { | |||||
| 850 | } | 854 | } | ||
| 851 | } | 855 | } | ||
| 852 | } | 856 | } | ||
| 857 | + | ||||
| 858 | + | func TestHintSizeReloadCancelsShownHints(t *testing.T) { | |||
| 859 | + | h := newHint(t, core.Options{}) | |||
| 860 | + | h.show(h.inside(0)) | |||
| 861 | + | cfg := h.cfg | |||
| 862 | + | cfg.Hint.Size = 40 | |||
| 863 | + | h.config <- ports.ConfigChanged{Config: cfg} | |||
| 864 | + | h.until(func(s ports.Scene) bool { return s.HintStyle.Size == 40 && len(s.HintLabels) == 0 }) | |||
| 865 | + | } | |||