authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-10-03 04:10:27-07:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-10-03 05:19:31-07:00
log9e7bdc20de0836d4c71aaf9014f4130ec523a635
tree92326f2ab26938a778257d59f93d5336e004eaa0
parentb60e999838e28bdf93ac01346599a386226ddf7d
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

fix: the web build leaves developer tools, view source and reloading to the browser, and takes only the chords Snowbound binds

Assisted-by: claude-opus-5.5

1 files changed, 41 insertions(+), 9 deletions(-)

crates/snowbound/src/web.rs+41-9
......@@ -1143,19 +1143,51 @@ fn queue(input: Input) {
11431143}
11441144
11451145/// Whether the page takes the key `key` with modifier bits `held` (Shift, Control, Alt, Meta
1146/// from the lowest), rather than leaving it to the browser: the browser keeps its own tab
1147/// and window chords, and pastes through its paste event.
1146/// from the lowest), rather than leaving it to the browser. Typing and moving about are the
1147/// page's, other chords only where Snowbound binds them; developer tools, view source,
1148/// reloading, pasting (through the browser's paste event) and the browser's tab and window
1149/// chords always stay the browser's.
11481150#[wasm_bindgen]
11491151pub fn takes(key: &str, held: u8) -> bool {
1150 let command = held & if MAC.get() { 8 } else { 2 } != 0;
1151 // The browser's own chords take Ctrl or ⌘ without Alt (see `commands::BROWSER`).
1152 if !command || held & 4 != 0 {
1152 let [shift, control, alt, meta] = [1, 2, 4, 8].map(|bit| held & bit != 0);
1153 let mac = MAC.get();
1154 let command = if mac { meta } else { control };
1155 let lower = key.to_ascii_lowercase();
1156 let tools = if mac {
1157 meta && alt && matches!(lower.as_str(), "i" | "j" | "c" | "u" | "k")
1158 } else {
1159 control && shift && matches!(lower.as_str(), "i" | "j" | "c" | "k")
1160 || control && lower == "u"
1161 };
1162 let browser = command
1163 && !alt
1164 && matches!(
1165 lower.as_str(),
1166 "r" | "v" | "w" | "t" | "n" | "q" | "l" | "tab"
1167 );
1168 if tools || browser || matches!(key, "F5" | "F12") {
1169 return false;
1170 }
1171 let function = key
1172 .strip_prefix('F')
1173 .is_some_and(|number| number.parse::<u8>().is_ok());
1174 // A Mac's Option types characters.
1175 if !function && !command && (mac || !alt) {
11531176 return true;
11541177 }
1155 !matches!(
1156 key.to_ascii_lowercase().as_str(),
1157 "v" | "w" | "t" | "n" | "q" | "r" | "l" | "tab"
1158 )
1178 let pressed = ui::edit_key(&logical_key(key));
1179 let modifiers = draw::edit::Modifiers {
1180 shift,
1181 control: command,
1182 option: alt,
1183 command,
1184 };
1185 // F6 steps between the window's groups and the page.
1186 key == "F6"
1187 || commands::find(&pressed, modifiers).is_some()
1188 || draw::edit::Platform::CURRENT
1189 .command(&pressed, modifiers)
1190 .is_some()
11591191}
11601192
11611193/// Reports modifier bits `held` where they changed.