Skip to content

Commit 6d46d52

Browse files
committed
Rename "super" key to "meta"
This is inconsistent with the W3C spec, and while it's arguably not the best name, it's worse that Winit is diverging and choosing a different name. --- Full list of changes: KeyCode: - SuperLeft -> MetaLeft - SuperRight -> MetaRight - Meta -> Super NamedKey::Meta is swapped with NamedKey::Super. ModifiersState::SUPER is renamed to ModifiersState::META. ModifiersState::super_key is renamed to ModifiersState::meta_key. ModifiersKeys::LSUPER and RSUPER are renamed to LMETA and RMETA.
1 parent be52984 commit 6d46d52

File tree

14 files changed

+80
-84
lines changed

14 files changed

+80
-84
lines changed

Diff for: examples/window.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ fn modifiers_to_string(mods: ModifiersState) -> String {
11251125
let mut mods_line = String::new();
11261126
// Always add + since it's printed as a part of the bindings.
11271127
for (modifier, desc) in [
1128-
(ModifiersState::SUPER, "Super+"),
1128+
(ModifiersState::META, "Meta+"),
11291129
(ModifiersState::ALT, "Alt+"),
11301130
(ModifiersState::CONTROL, "Ctrl+"),
11311131
(ModifiersState::SHIFT, "Shift+"),
@@ -1224,10 +1224,10 @@ const KEY_BINDINGS: &[Binding<&'static str>] = &[
12241224
Binding::new("Z", ModifiersState::CONTROL, Action::ToggleCursorVisibility),
12251225
// K.
12261226
Binding::new("K", ModifiersState::empty(), Action::SetTheme(None)),
1227-
Binding::new("K", ModifiersState::SUPER, Action::SetTheme(Some(Theme::Light))),
1227+
Binding::new("K", ModifiersState::META, Action::SetTheme(Some(Theme::Light))),
12281228
Binding::new("K", ModifiersState::CONTROL, Action::SetTheme(Some(Theme::Dark))),
12291229
#[cfg(macos_platform)]
1230-
Binding::new("T", ModifiersState::SUPER, Action::CreateNewTab),
1230+
Binding::new("T", ModifiersState::META, Action::CreateNewTab),
12311231
#[cfg(macos_platform)]
12321232
Binding::new("O", ModifiersState::CONTROL, Action::CycleOptionAsAlt),
12331233
Binding::new("S", ModifiersState::CONTROL, Action::Message),

Diff for: src/changelog/unreleased.md

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ changelog entry.
161161
- In the same spirit rename `DeviceEvent::MouseMotion` to `PointerMotion`.
162162
- Remove `Force::Calibrated::altitude_angle`.
163163
- On X11, use bottom-right corner for IME hotspot in `Window::set_ime_cursor_area`.
164+
- Renamed "super" key to "meta", to match the naming in the W3C specification.
164165

165166
### Removed
166167

Diff for: src/event.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -910,12 +910,12 @@ impl Modifiers {
910910

911911
/// The state of the left super key.
912912
pub fn lsuper_state(&self) -> ModifiersKeyState {
913-
self.mod_state(ModifiersKeys::LSUPER)
913+
self.mod_state(ModifiersKeys::LMETA)
914914
}
915915

916916
/// The state of the right super key.
917917
pub fn rsuper_state(&self) -> ModifiersKeyState {
918-
self.mod_state(ModifiersKeys::RSUPER)
918+
self.mod_state(ModifiersKeys::RMETA)
919919
}
920920

921921
fn mod_state(&self, modifier: ModifiersKeys) -> ModifiersKeyState {

Diff for: src/keyboard.rs

+18-27
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,7 @@ impl PartialEq<PhysicalKey> for NativeKeyCode {
283283

284284
/// Code representing the location of a physical key
285285
///
286-
/// This mostly conforms to the UI Events Specification's [`KeyboardEvent.code`] with a few
287-
/// exceptions:
288-
/// - The keys that the specification calls "MetaLeft" and "MetaRight" are named "SuperLeft" and
289-
/// "SuperRight" here.
290-
/// - The key that the specification calls "Super" is reported as `Unidentified` here.
286+
/// This conforms to the UI Events Specification's [`KeyboardEvent.code`].
291287
///
292288
/// [`KeyboardEvent.code`]: https://w3c.github.io/uievents-code/#code-value-tables
293289
#[non_exhaustive]
@@ -420,7 +416,7 @@ pub enum KeyCode {
420416
/// <kbd>CapsLock</kbd> or <kbd>⇪</kbd>
421417
CapsLock,
422418
/// The application context menu key, which is typically found between the right
423-
/// <kbd>Super</kbd> key and the right <kbd>Control</kbd> key.
419+
/// <kbd>Meta</kbd> key and the right <kbd>Control</kbd> key.
424420
ContextMenu,
425421
/// <kbd>Control</kbd> or <kbd>⌃</kbd>
426422
ControlLeft,
@@ -429,9 +425,9 @@ pub enum KeyCode {
429425
/// <kbd>Enter</kbd> or <kbd>↵</kbd>. Labeled <kbd>Return</kbd> on Apple keyboards.
430426
Enter,
431427
/// The Windows, <kbd>⌘</kbd>, <kbd>Command</kbd>, or other OS symbol key.
432-
SuperLeft,
428+
MetaLeft,
433429
/// The Windows, <kbd>⌘</kbd>, <kbd>Command</kbd>, or other OS symbol key.
434-
SuperRight,
430+
MetaRight,
435431
/// <kbd>Shift</kbd> or <kbd>⇧</kbd>
436432
ShiftLeft,
437433
/// <kbd>Shift</kbd> or <kbd>⇧</kbd>
@@ -613,8 +609,8 @@ pub enum KeyCode {
613609
AudioVolumeMute,
614610
AudioVolumeUp,
615611
WakeUp,
616-
// Legacy modifier key. Also called "Super" in certain places.
617-
Meta,
612+
// Legacy modifier key.
613+
Super,
618614
// Legacy modifier key.
619615
Hyper,
620616
Turbo,
@@ -741,10 +737,7 @@ pub enum KeyCode {
741737

742738
/// A [`Key::Named`] value
743739
///
744-
/// This mostly conforms to the UI Events Specification's [`KeyboardEvent.key`] with a few
745-
/// exceptions:
746-
/// - The `Super` variant here, is named `Meta` in the aforementioned specification. (There's
747-
/// another key which the specification calls `Super`. That does not exist here.)
740+
/// This conforms to the UI Events Specification's [`KeyboardEvent.key`].
748741
///
749742
/// [`KeyboardEvent.key`]: https://w3c.github.io/uievents-key/
750743
#[non_exhaustive]
@@ -789,16 +782,14 @@ pub enum NamedKey {
789782
/// The Symbol modifier key (used on some virtual keyboards).
790783
Symbol,
791784
SymbolLock,
792-
// Legacy modifier key. Also called "Super" in certain places.
793-
Meta,
785+
// Legacy modifier key.
786+
Super,
794787
// Legacy modifier key.
795788
Hyper,
796-
/// Used to enable "super" modifier function for interpreting concurrent or subsequent keyboard
789+
/// Used to enable "meta" modifier function for interpreting concurrent or subsequent keyboard
797790
/// input. This key value is used for the "Windows Logo" key and the Apple `Command` or `⌘`
798791
/// key.
799-
///
800-
/// Note: In some contexts (e.g. the Web) this is referred to as the "Meta" key.
801-
Super,
792+
Meta,
802793
/// The `Enter` or `↵` key. Used to activate current selection or accept current input. This
803794
/// key value is also used for the `Return` (Macintosh numpad) key. This key value is also
804795
/// used for the Android `KEYCODE_DPAD_CENTER`.
@@ -860,7 +851,7 @@ pub enum NamedKey {
860851
Attn,
861852
Cancel,
862853
/// Show the application’s context menu.
863-
/// This key is commonly found between the right `Super` key and the right `Control` key.
854+
/// This key is commonly found between the right `Meta` key and the right `Control` key.
864855
ContextMenu,
865856
/// The `Esc` key. This key was originally used to initiate an escape sequence, but is
866857
/// now more generally used to exit or "escape" the current context, such as closing a dialog
@@ -1704,7 +1695,7 @@ bitflags! {
17041695
/// The "alt" key.
17051696
const ALT = 0b100 << 6;
17061697
/// This is the "windows" key on PC and "command" key on Mac.
1707-
const SUPER = 0b100 << 9;
1698+
const META = 0b100 << 9;
17081699
}
17091700
}
17101701

@@ -1724,9 +1715,9 @@ impl ModifiersState {
17241715
self.intersects(Self::ALT)
17251716
}
17261717

1727-
/// Returns `true` if the super key is pressed.
1728-
pub fn super_key(&self) -> bool {
1729-
self.intersects(Self::SUPER)
1718+
/// Returns `true` if the meta key is pressed.
1719+
pub fn meta_key(&self) -> bool {
1720+
self.intersects(Self::META)
17301721
}
17311722
}
17321723

@@ -1759,7 +1750,7 @@ bitflags! {
17591750
const RCONTROL = 0b0000_1000;
17601751
const LALT = 0b0001_0000;
17611752
const RALT = 0b0010_0000;
1762-
const LSUPER = 0b0100_0000;
1763-
const RSUPER = 0b1000_0000;
1753+
const LMETA = 0b0100_0000;
1754+
const RMETA = 0b1000_0000;
17641755
}
17651756
}

Diff for: src/platform_impl/android/keycodes.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ pub fn to_physical_key(keycode: Keycode) -> PhysicalKey {
143143
Keycode::AltLeft => KeyCode::AltLeft,
144144
Keycode::AltRight => KeyCode::AltRight,
145145

146-
Keycode::MetaLeft => KeyCode::SuperLeft,
147-
Keycode::MetaRight => KeyCode::SuperRight,
146+
Keycode::MetaLeft => KeyCode::MetaLeft,
147+
Keycode::MetaRight => KeyCode::MetaRight,
148148

149149
Keycode::LeftBracket => KeyCode::BracketLeft,
150150
Keycode::RightBracket => KeyCode::BracketRight,
@@ -340,8 +340,8 @@ pub fn to_logical(key_char: Option<KeyMapChar>, keycode: Keycode) -> Key {
340340
CtrlRight => Key::Named(NamedKey::Control),
341341
CapsLock => Key::Named(NamedKey::CapsLock),
342342
ScrollLock => Key::Named(NamedKey::ScrollLock),
343-
MetaLeft => Key::Named(NamedKey::Super),
344-
MetaRight => Key::Named(NamedKey::Super),
343+
MetaLeft => Key::Named(NamedKey::Meta),
344+
MetaRight => Key::Named(NamedKey::Meta),
345345
Function => Key::Named(NamedKey::Fn),
346346
Sysrq => Key::Named(NamedKey::PrintScreen),
347347
Break => Key::Named(NamedKey::Pause),

Diff for: src/platform_impl/apple/appkit/event.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ pub fn code_to_key(key: PhysicalKey, scancode: u16) -> Key {
188188
KeyCode::Space => return Key::Character(" ".into()),
189189
KeyCode::Backspace => NamedKey::Backspace,
190190
KeyCode::Escape => NamedKey::Escape,
191-
KeyCode::SuperRight => NamedKey::Super,
192-
KeyCode::SuperLeft => NamedKey::Super,
191+
KeyCode::MetaRight => NamedKey::Meta,
192+
KeyCode::MetaLeft => NamedKey::Meta,
193193
KeyCode::ShiftLeft => NamedKey::Shift,
194194
KeyCode::AltLeft => NamedKey::Alt,
195195
KeyCode::ControlLeft => NamedKey::Control,
@@ -246,8 +246,8 @@ pub fn code_to_location(key: PhysicalKey) -> KeyLocation {
246246
};
247247

248248
match code {
249-
KeyCode::SuperRight => KeyLocation::Right,
250-
KeyCode::SuperLeft => KeyLocation::Left,
249+
KeyCode::MetaRight => KeyLocation::Right,
250+
KeyCode::MetaLeft => KeyLocation::Left,
251251
KeyCode::ShiftLeft => KeyLocation::Left,
252252
KeyCode::AltLeft => KeyLocation::Left,
253253
KeyCode::ControlLeft => KeyLocation::Left,
@@ -335,11 +335,11 @@ pub(super) fn event_mods(event: &NSEvent) -> Modifiers {
335335
pressed_mods.set(ModifiersKeys::RALT, flags.contains(NX_DEVICERALTKEYMASK));
336336

337337
state.set(
338-
ModifiersState::SUPER,
338+
ModifiersState::META,
339339
flags.contains(NSEventModifierFlags::NSEventModifierFlagCommand),
340340
);
341-
pressed_mods.set(ModifiersKeys::LSUPER, flags.contains(NX_DEVICELCMDKEYMASK));
342-
pressed_mods.set(ModifiersKeys::RSUPER, flags.contains(NX_DEVICERCMDKEYMASK));
341+
pressed_mods.set(ModifiersKeys::LMETA, flags.contains(NX_DEVICELCMDKEYMASK));
342+
pressed_mods.set(ModifiersKeys::RMETA, flags.contains(NX_DEVICERCMDKEYMASK));
343343

344344
Modifiers { state, pressed_mods }
345345
}
@@ -419,8 +419,8 @@ pub(crate) fn physicalkey_to_scancode(physical_key: PhysicalKey) -> Option<u32>
419419
KeyCode::Backquote => Some(0x32),
420420
KeyCode::Backspace => Some(0x33),
421421
KeyCode::Escape => Some(0x35),
422-
KeyCode::SuperRight => Some(0x36),
423-
KeyCode::SuperLeft => Some(0x37),
422+
KeyCode::MetaRight => Some(0x36),
423+
KeyCode::MetaLeft => Some(0x37),
424424
KeyCode::ShiftLeft => Some(0x38),
425425
KeyCode::AltLeft => Some(0x3a),
426426
KeyCode::ControlLeft => Some(0x3b),
@@ -538,8 +538,8 @@ pub(crate) fn scancode_to_physicalkey(scancode: u32) -> PhysicalKey {
538538
0x33 => KeyCode::Backspace,
539539
// 0x34 => unknown,
540540
0x35 => KeyCode::Escape,
541-
0x36 => KeyCode::SuperRight,
542-
0x37 => KeyCode::SuperLeft,
541+
0x36 => KeyCode::MetaRight,
542+
0x37 => KeyCode::MetaLeft,
543543
0x38 => KeyCode::ShiftLeft,
544544
0x39 => KeyCode::CapsLock,
545545
0x3a => KeyCode::AltLeft,

Diff for: src/platform_impl/apple/appkit/view.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn key_to_modifier(key: &Key) -> Option<ModifiersState> {
8282
match key {
8383
Key::Named(NamedKey::Alt) => Some(ModifiersState::ALT),
8484
Key::Named(NamedKey::Control) => Some(ModifiersState::CONTROL),
85-
Key::Named(NamedKey::Super) => Some(ModifiersState::SUPER),
85+
Key::Named(NamedKey::Meta) => Some(ModifiersState::META),
8686
Key::Named(NamedKey::Shift) => Some(ModifiersState::SHIFT),
8787
_ => None,
8888
}
@@ -93,7 +93,7 @@ fn get_right_modifier_code(key: &Key) -> KeyCode {
9393
Key::Named(NamedKey::Alt) => KeyCode::AltRight,
9494
Key::Named(NamedKey::Control) => KeyCode::ControlRight,
9595
Key::Named(NamedKey::Shift) => KeyCode::ShiftRight,
96-
Key::Named(NamedKey::Super) => KeyCode::SuperRight,
96+
Key::Named(NamedKey::Meta) => KeyCode::MetaRight,
9797
_ => unreachable!(),
9898
}
9999
}
@@ -103,7 +103,7 @@ fn get_left_modifier_code(key: &Key) -> KeyCode {
103103
Key::Named(NamedKey::Alt) => KeyCode::AltLeft,
104104
Key::Named(NamedKey::Control) => KeyCode::ControlLeft,
105105
Key::Named(NamedKey::Shift) => KeyCode::ShiftLeft,
106-
Key::Named(NamedKey::Super) => KeyCode::SuperLeft,
106+
Key::Named(NamedKey::Meta) => KeyCode::MetaLeft,
107107
_ => unreachable!(),
108108
}
109109
}
@@ -1132,7 +1132,7 @@ fn replace_event(event: &NSEvent, option_as_alt: OptionAsAlt) -> Retained<NSEven
11321132
OptionAsAlt::Both if ev_mods.alt_key() => true,
11331133
_ => false,
11341134
} && !ev_mods.control_key()
1135-
&& !ev_mods.super_key();
1135+
&& !ev_mods.meta_key();
11361136

11371137
if ignore_alt_characters {
11381138
let ns_chars = unsafe {

Diff for: src/platform_impl/linux/common/xkb/keymap.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ pub fn scancode_to_physicalkey(scancode: u32) -> PhysicalKey {
166166
122 => KeyCode::Lang1,
167167
123 => KeyCode::Lang2,
168168
124 => KeyCode::IntlYen,
169-
125 => KeyCode::SuperLeft,
170-
126 => KeyCode::SuperRight,
169+
125 => KeyCode::MetaLeft,
170+
126 => KeyCode::MetaRight,
171171
127 => KeyCode::ContextMenu,
172172
128 => KeyCode::BrowserStop,
173173
129 => KeyCode::Again,
@@ -419,8 +419,8 @@ pub fn physicalkey_to_scancode(key: PhysicalKey) -> Option<u32> {
419419
KeyCode::Lang1 => Some(122),
420420
KeyCode::Lang2 => Some(123),
421421
KeyCode::IntlYen => Some(124),
422-
KeyCode::SuperLeft => Some(125),
423-
KeyCode::SuperRight => Some(126),
422+
KeyCode::MetaLeft => Some(125),
423+
KeyCode::MetaRight => Some(126),
424424
KeyCode::ContextMenu => Some(127),
425425
KeyCode::BrowserStop => Some(128),
426426
KeyCode::Again => Some(129),
@@ -622,16 +622,18 @@ pub fn keysym_to_key(keysym: u32) -> Key {
622622
keysyms::Control_R => NamedKey::Control,
623623
keysyms::Caps_Lock => NamedKey::CapsLock,
624624
// keysyms::Shift_Lock => NamedKey::ShiftLock,
625-
626-
// keysyms::Meta_L => NamedKey::Meta,
627-
// keysyms::Meta_R => NamedKey::Meta,
628625
keysyms::Alt_L => NamedKey::Alt,
629626
keysyms::Alt_R => NamedKey::Alt,
630-
keysyms::Super_L => NamedKey::Super,
631-
keysyms::Super_R => NamedKey::Super,
632627
keysyms::Hyper_L => NamedKey::Hyper,
633628
keysyms::Hyper_R => NamedKey::Hyper,
634629

630+
// Browsers map X11's Super keys to Meta, so we do that as well.
631+
keysyms::Super_L => NamedKey::Meta,
632+
keysyms::Super_R => NamedKey::Meta,
633+
// The actual Meta keys do not seem to be used by browsers, so we don't do that either.
634+
// keysyms::Meta_L => NamedKey::Meta,
635+
// keysyms::Meta_R => NamedKey::Meta,
636+
635637
// XKB function and modifier keys
636638
// keysyms::ISO_Lock => NamedKey::IsoLock,
637639
// keysyms::ISO_Level2_Latch => NamedKey::IsoLevel2Latch,

Diff for: src/platform_impl/linux/common/xkb/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl From<ModifiersState> for crate::keyboard::ModifiersState {
183183
to_mods.set(crate::keyboard::ModifiersState::SHIFT, mods.shift);
184184
to_mods.set(crate::keyboard::ModifiersState::CONTROL, mods.ctrl);
185185
to_mods.set(crate::keyboard::ModifiersState::ALT, mods.alt);
186-
to_mods.set(crate::keyboard::ModifiersState::SUPER, mods.logo);
186+
to_mods.set(crate::keyboard::ModifiersState::META, mods.logo);
187187
to_mods
188188
}
189189
}

Diff for: src/platform_impl/orbital/event_loop.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn convert_scancode(scancode: u8) -> (PhysicalKey, Option<NamedKey>) {
122122
orbclient::K_SEMICOLON => (KeyCode::Semicolon, None),
123123
orbclient::K_SLASH => (KeyCode::Slash, None),
124124
orbclient::K_SPACE => (KeyCode::Space, None),
125-
orbclient::K_SUPER => (KeyCode::SuperLeft, Some(NamedKey::Super)),
125+
orbclient::K_SUPER => (KeyCode::MetaLeft, Some(NamedKey::Meta)),
126126
orbclient::K_TAB => (KeyCode::Tab, Some(NamedKey::Tab)),
127127
orbclient::K_TICK => (KeyCode::Backquote, None),
128128
orbclient::K_UP => (KeyCode::ArrowUp, Some(NamedKey::ArrowUp)),
@@ -152,8 +152,8 @@ bitflags! {
152152
const RCTRL = 1 << 3;
153153
const LALT = 1 << 4;
154154
const RALT = 1 << 5;
155-
const LSUPER = 1 << 6;
156-
const RSUPER = 1 << 7;
155+
const LMETA = 1 << 6;
156+
const RMETA = 1 << 7;
157157
}
158158
}
159159

@@ -203,8 +203,8 @@ impl EventState {
203203
KeyCode::ControlRight => self.keyboard.set(KeyboardModifierState::RCTRL, pressed),
204204
KeyCode::AltLeft => self.keyboard.set(KeyboardModifierState::LALT, pressed),
205205
KeyCode::AltRight => self.keyboard.set(KeyboardModifierState::RALT, pressed),
206-
KeyCode::SuperLeft => self.keyboard.set(KeyboardModifierState::LSUPER, pressed),
207-
KeyCode::SuperRight => self.keyboard.set(KeyboardModifierState::RSUPER, pressed),
206+
KeyCode::MetaLeft => self.keyboard.set(KeyboardModifierState::LMETA, pressed),
207+
KeyCode::MetaRight => self.keyboard.set(KeyboardModifierState::RMETA, pressed),
208208
_ => (),
209209
}
210210
}
@@ -262,14 +262,14 @@ impl EventState {
262262
pressed_mods.set(ModifiersKeys::LALT, self.keyboard.contains(KeyboardModifierState::LALT));
263263
pressed_mods.set(ModifiersKeys::RALT, self.keyboard.contains(KeyboardModifierState::RALT));
264264

265-
if self.keyboard.intersects(KeyboardModifierState::LSUPER | KeyboardModifierState::RSUPER) {
266-
state |= ModifiersState::SUPER
265+
if self.keyboard.intersects(KeyboardModifierState::LMETA | KeyboardModifierState::RMETA) {
266+
state |= ModifiersState::META
267267
}
268268

269269
pressed_mods
270-
.set(ModifiersKeys::LSUPER, self.keyboard.contains(KeyboardModifierState::LSUPER));
270+
.set(ModifiersKeys::LMETA, self.keyboard.contains(KeyboardModifierState::LMETA));
271271
pressed_mods
272-
.set(ModifiersKeys::RSUPER, self.keyboard.contains(KeyboardModifierState::RSUPER));
272+
.set(ModifiersKeys::RMETA, self.keyboard.contains(KeyboardModifierState::RMETA));
273273

274274
Modifiers { state, pressed_mods }
275275
}

0 commit comments

Comments
 (0)