keymap: Work around sending keycode 0
If keycode 0 resolves to a letter, the the press is ignored by the compositor. This works around the bug.
This commit is contained in:
		@ -51,14 +51,16 @@ pub struct KeyState {
 | 
				
			|||||||
    pub action: Action,
 | 
					    pub action: Action,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Generates a mapping where each key gets a keycode, starting from 8
 | 
					/// Generates a mapping where each key gets a keycode, starting from ~~8~~
 | 
				
			||||||
 | 
					/// HACK: starting from 9, because 8 results in keycode 0,
 | 
				
			||||||
 | 
					/// which the compositor likes to discard
 | 
				
			||||||
pub fn generate_keycodes<'a, C: IntoIterator<Item=&'a str>>(
 | 
					pub fn generate_keycodes<'a, C: IntoIterator<Item=&'a str>>(
 | 
				
			||||||
    key_names: C
 | 
					    key_names: C
 | 
				
			||||||
) -> HashMap<String, u32> {
 | 
					) -> HashMap<String, u32> {
 | 
				
			||||||
    HashMap::from_iter(
 | 
					    HashMap::from_iter(
 | 
				
			||||||
        key_names.into_iter()
 | 
					        key_names.into_iter()
 | 
				
			||||||
            .map(|name| String::from(name))
 | 
					            .map(|name| String::from(name))
 | 
				
			||||||
            .zip(8..)
 | 
					            .zip(9..)
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user