tony / oxwm

removed unneeded comments Browse files
tonybtw committed 2025-10-29 parent 2809716 commit c07ef1146c5e30b3fca93419618a5a0fc6636e29
Showing 3 changed files with 15 additions and 33 deletions. UnifiedSplit
+1 −3 src/bar/bar.rs
@@ -259,13 +259,11 @@ impl Bar {
259 259 self.scheme_normal.foreground,
260 260 text_x,
261 261 text_y,
262 - layout_symbol
262 + layout_symbol,
263 263 );
264 264
265 - // Update x_position after layout symbol
266 265 x_position += font.text_width(layout_symbol) as i16;
267 266
268 - // Draw keychord indicator if present
269 267 if let Some(indicator) = keychord_indicator {
270 268 x_position += 10;
271 269
+6 −6 src/config/mod.rs
@@ -199,11 +199,11 @@ struct ConfigData {
199 199 #[derive(Debug, Deserialize)]
200 200 struct KeybindingData {
201 201 #[serde(default)]
202 - keys: Option<Vec<KeyPressData>>, // New format
202 + keys: Option<Vec<KeyPressData>>,
203 203 #[serde(default)]
204 - modifiers: Option<Vec<ModKey>>, // Old format (backwards compat)
204 + modifiers: Option<Vec<ModKey>>,
205 205 #[serde(default)]
206 - key: Option<KeyData>, // Old format (backwards compat)
206 + key: Option<KeyData>,
207 207 action: KeyAction,
208 208 #[serde(default)]
209 209 arg: ArgData,
@@ -263,7 +263,6 @@ fn config_data_to_config(data: ConfigData) -> Result<crate::Config, ConfigError>
263 263 let mut keybindings = Vec::new();
264 264 for kb_data in data.keybindings {
265 265 let keys = if let Some(keys_data) = kb_data.keys {
266 - // New format: multiple keys
267 266 keys_data
268 267 .into_iter()
269 268 .map(|kp| {
@@ -283,7 +282,6 @@ fn config_data_to_config(data: ConfigData) -> Result<crate::Config, ConfigError>
283 282 })
284 283 .collect()
285 284 } else if let (Some(modifiers), Some(key)) = (kb_data.modifiers, kb_data.key) {
286 - // Old format: single key (backwards compatibility)
287 285 vec![KeyPress {
288 286 modifiers: modifiers
289 287 .iter()
@@ -295,7 +293,9 @@ fn config_data_to_config(data: ConfigData) -> Result<crate::Config, ConfigError>
295 293 key: key.to_keycode(),
296 294 }]
297 295 } else {
298 - return Err(ConfigError::ValidationError("Keybinding must have either 'keys' or 'modifiers'+'key'".to_string()));
296 + return Err(ConfigError::ValidationError(
297 + "Keybinding must have either 'keys' or 'modifiers'+'key'".to_string(),
298 + ));
299 299 };
300 300
301 301 let action = kb_data.action;
+8 −24 src/keyboard/handlers.rs
@@ -45,14 +45,12 @@ impl Arg {
45 45 }
46 46 }
47 47
48 -// Individual key press in a sequence
49 48 #[derive(Clone, Debug)]
50 49 pub struct KeyPress {
51 50 pub(crate) modifiers: Vec<KeyButMask>,
52 51 pub(crate) key: Keycode,
53 52 }
54 53
55 -// Keybinding that can be a single key or a chord (sequence of keys)
56 54 #[derive(Clone)]
57 55 pub struct KeyBinding {
58 56 pub(crate) keys: Vec<KeyPress>,
@@ -65,7 +63,6 @@ impl KeyBinding {
65 63 Self { keys, func, arg }
66 64 }
67 65
68 - // Helper for backwards compatibility with single-key bindings
69 66 pub fn single_key(modifiers: Vec<KeyButMask>, key: Keycode, func: KeyAction, arg: Arg) -> Self {
70 67 Self {
71 68 keys: vec![KeyPress { modifiers, key }],
@@ -75,16 +72,13 @@ impl KeyBinding {
75 72 }
76 73 }
77 74
78 -// For backwards compatibility during migration
79 75 pub type Key = KeyBinding;
80 76
81 77 #[derive(Debug, Clone)]
82 78 pub enum KeychordState {
83 79 Idle,
84 80 InProgress {
85 - // Indices of keybindings that could still match
86 81 candidates: Vec<usize>,
87 - // How many keys have been pressed in the sequence
88 82 keys_pressed: usize,
89 83 },
90 84 }
@@ -155,19 +149,15 @@ pub fn handle_key_press(
155 149 }
156 150
157 151 match keychord_state {
158 - KeychordState::Idle => {
159 - handle_first_key(event, keybindings)
160 - }
161 - KeychordState::InProgress { candidates, keys_pressed } => {
162 - handle_next_key(event, keybindings, candidates, *keys_pressed)
163 - }
152 + KeychordState::Idle => handle_first_key(event, keybindings),
153 + KeychordState::InProgress {
154 + candidates,
155 + keys_pressed,
156 + } => handle_next_key(event, keybindings, candidates, *keys_pressed),
164 157 }
165 158 }
166 159
167 -fn handle_first_key(
168 - event: KeyPressEvent,
169 - keybindings: &[KeyBinding],
170 -) -> KeychordResult {
160 +fn handle_first_key(event: KeyPressEvent, keybindings: &[KeyBinding]) -> KeychordResult {
171 161 let mut candidates = Vec::new();
172 162
173 163 for (keybinding_index, keybinding) in keybindings.iter().enumerate() {
@@ -180,10 +170,7 @@ fn handle_first_key(
180 170
181 171 if event.detail == first_key.key && event.state == modifier_mask.into() {
182 172 if keybinding.keys.len() == 1 {
183 - return KeychordResult::Completed(
184 - keybinding.func,
185 - keybinding.arg.clone(),
186 - );
173 + return KeychordResult::Completed(keybinding.func, keybinding.arg.clone());
187 174 } else {
188 175 candidates.push(keybinding_index);
189 176 }
@@ -224,10 +211,7 @@ fn handle_next_key(
224 211
225 212 if event.detail == next_key.key && modifiers_match {
226 213 if keys_pressed + 1 == keybinding.keys.len() {
227 - return KeychordResult::Completed(
228 - keybinding.func,
229 - keybinding.arg.clone(),
230 - );
214 + return KeychordResult::Completed(keybinding.func, keybinding.arg.clone());
231 215 } else {
232 216 new_candidates.push(candidate_index);
233 217 }