Add Copy/Paste keys (#495)

* Add Copy/Paste keys

This is only a tiny update which introduces the `Copy` and `Paste` keys
which are present on X11/Wayland/Windows. I'm not sure if this exists on
MacOS too, but I'm not able to test that and it doesn't have names but
just matches on the hex key values.

The "Copy" element is a reserved keyword in Rust but shouldn't cause any
conflicts in this scenario, this behavior falls in line with
https://docs.rs/winit/0.13.1/winit/enum.MouseCursor.html#variant.Copy,
but it would be possible to rename it. However `Copy` seems like the
most intuitive choice.

* Add Cut key, fix windows and update CHANGELOG

This introduces a bunch of minor fixes:
 * The changes introduced by this branch have been added to the changelog
 * Since related, the `Cut` key has also been added
 * An attempt has been made to fix Windows

* Fix position of fallback comment

The new keys have been inserted at the wrong position, so the fallback
comment has been moved to the `_ => ...` section again.

* Fix windows build

Apparently there are no keys for Cut/Paste on Windows, so for now those
have been removed on Windows and only the `Copy` key has been added on
Windows, the changelog has been updated to reflect that.

Linux still implements Copy/Clone/Paste, but `Copy` is now working
properly on Wayland.

MacOS still does not have any of these keys.

* Remove Windows changes

Because the Windows design wasn't completely clear the VirtualKeyCode
variants are now only used on Linux with X11 and Wayland and ignored on
both MacOS and Windows.

The CHANGELOG has also been updated. Windows has been removed from it
and the Linux section has been clarified a bit.
This commit is contained in:
Christian Duerr 2018-05-02 23:18:52 +00:00 committed by Francesca Frangipane
parent eba888207e
commit fee874b5b7
4 changed files with 10 additions and 0 deletions

View file

@ -1,5 +1,6 @@
# Unreleased # Unreleased
- Created the `Copy`, `Paste` and `Cut` `VirtualKeyCode`s and added support for them on X11 and Wayland
- Fix `.with_decorations(false)` in macOS - Fix `.with_decorations(false)` in macOS
- On Mac, `NSWindow` and supporting objects might be alive long after they were `closed` which resulted in apps consuming more heap then needed. Mainly it was affecting multi window applications. Not expecting any user visible change of behaviour after the fix. - On Mac, `NSWindow` and supporting objects might be alive long after they were `closed` which resulted in apps consuming more heap then needed. Mainly it was affecting multi window applications. Not expecting any user visible change of behaviour after the fix.
- Fix regression of Window platform extensions for macOS where `NSFullSizeContentViewWindowMask` was not being correctly applied to `.fullsize_content_view`. - Fix regression of Window platform extensions for macOS where `NSFullSizeContentViewWindowMask` was not being correctly applied to `.fullsize_content_view`.

View file

@ -431,6 +431,9 @@ pub enum VirtualKeyCode {
WebSearch, WebSearch,
WebStop, WebStop,
Yen, Yen,
Copy,
Paste,
Cut,
} }
/// Represents the current state of the keyboard modifiers /// Represents the current state of the keyboard modifiers

View file

@ -290,6 +290,9 @@ fn keysym_to_vkey(keysym: u32) -> Option<VirtualKeyCode> {
// => Some(VirtualKeyCode::WebSearch), // => Some(VirtualKeyCode::WebSearch),
// => Some(VirtualKeyCode::WebStop), // => Some(VirtualKeyCode::WebStop),
// => Some(VirtualKeyCode::Yen), // => Some(VirtualKeyCode::Yen),
keysyms::XKB_KEY_XF86Copy => Some(VirtualKeyCode::Copy),
keysyms::XKB_KEY_XF86Paste => Some(VirtualKeyCode::Paste),
keysyms::XKB_KEY_XF86Cut => Some(VirtualKeyCode::Cut),
// fallback // fallback
_ => None _ => None
} }

View file

@ -1000,6 +1000,9 @@ pub fn keysym_to_element(keysym: libc::c_uint) -> Option<VirtualKeyCode> {
//ffi::XK_Hebrew_switch => events::VirtualKeyCode::Hebrew_switch, //ffi::XK_Hebrew_switch => events::VirtualKeyCode::Hebrew_switch,
ffi::XF86XK_Back => VirtualKeyCode::NavigateBackward, ffi::XF86XK_Back => VirtualKeyCode::NavigateBackward,
ffi::XF86XK_Forward => VirtualKeyCode::NavigateForward, ffi::XF86XK_Forward => VirtualKeyCode::NavigateForward,
ffi::XF86XK_Copy => VirtualKeyCode::Copy,
ffi::XF86XK_Paste => VirtualKeyCode::Paste,
ffi::XF86XK_Cut => VirtualKeyCode::Cut,
_ => return None _ => return None
}) })
} }