revert winit to pre 0.20.0 as it crashes on windows and mac

macos-click-through
keith 5 years ago
parent 20a7320474
commit 234d6fa71d

326
Cargo.lock generated

@ -17,9 +17,9 @@ dependencies = [
[[package]]
name = "aho-corasick"
version = "0.7.6"
version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"
checksum = "5f56c476256dc249def911d6f7580b5fc7e875895b5d7ee88f5d602208035744"
dependencies = [
"memchr",
]
@ -70,9 +70,9 @@ checksum = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff"
[[package]]
name = "arrayref"
version = "0.3.5"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee"
checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
[[package]]
name = "arrayvec"
@ -104,9 +104,9 @@ version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8df72488e87761e772f14ae0c2480396810e51b2c2ade912f97f0f7e5b95e3c"
dependencies = [
"proc-macro2 1.0.7",
"proc-macro2 1.0.8",
"quote 1.0.2",
"syn 1.0.13",
"syn 1.0.14",
]
[[package]]
@ -145,36 +145,11 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
name = "backtrace"
version = "0.3.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4b1549d804b6c73f4817df2ba073709e96e426f12987127c48e6745568c350b"
dependencies = [
"backtrace-sys",
"cfg-if",
"libc",
"rustc-demangle",
]
[[package]]
name = "backtrace-sys"
version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "base64"
version = "0.10.1"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
dependencies = [
"byteorder",
]
checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
[[package]]
name = "bindgen"
@ -192,7 +167,7 @@ dependencies = [
"lazycell",
"log",
"peeking_take_while",
"proc-macro2 1.0.7",
"proc-macro2 1.0.8",
"quote 1.0.2",
"regex",
"rustc-hash",
@ -241,18 +216,9 @@ dependencies = [
[[package]]
name = "bytes"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10004c15deb332055f7a4a208190aed362cf9a7c2f6ab70a305fba50e1105f38"
[[package]]
name = "c2-chacha"
version = "0.2.3"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb"
dependencies = [
"ppv-lite86",
]
checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1"
[[package]]
name = "c_vec"
@ -383,9 +349,9 @@ checksum = "0dbbb57365263e881e805dc77d94697c9118fd94d8da011240555aa7b23445bd"
[[package]]
name = "const-random"
version = "0.1.6"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b641a8c9867e341f3295564203b1c250eb8ce6cb6126e007941f78c4d2ed7fe"
checksum = "2f1af9ac737b2dd2d577701e59fd09ba34822f6f2ebdb30a7647405d9e55e16a"
dependencies = [
"const-random-macro",
"proc-macro-hack",
@ -393,12 +359,12 @@ dependencies = [
[[package]]
name = "const-random-macro"
version = "0.1.6"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c750ec12b83377637110d5a57f5ae08e895b06c4b16e2bdbf1a94ef717428c59"
checksum = "25e4c606eb459dd29f7c57b2e0879f2b6f14ee130918c2b78ccb58a9624e6c7a"
dependencies = [
"getrandom",
"proc-macro-hack",
"rand",
]
[[package]]
@ -476,7 +442,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils 0.7.0",
"crossbeam-utils",
]
[[package]]
@ -487,7 +453,7 @@ checksum = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac"
dependencies = [
"autocfg 0.1.7",
"cfg-if",
"crossbeam-utils 0.7.0",
"crossbeam-utils",
"lazy_static",
"memoffset",
"scopeguard",
@ -500,17 +466,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db"
dependencies = [
"cfg-if",
"crossbeam-utils 0.7.0",
]
[[package]]
name = "crossbeam-utils"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"
dependencies = [
"cfg-if",
"lazy_static",
"crossbeam-utils",
]
[[package]]
@ -570,9 +526,9 @@ version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9"
dependencies = [
"proc-macro2 1.0.7",
"proc-macro2 1.0.8",
"quote 1.0.2",
"syn 1.0.13",
"syn 1.0.14",
]
[[package]]
@ -588,9 +544,9 @@ dependencies = [
[[package]]
name = "dispatch"
version = "0.2.0"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
checksum = "04e93ca78226c51902d7aa8c12c988338aadd9e85ed9c6be8aaac39192ff3605"
[[package]]
name = "dlib"
@ -656,28 +612,6 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "failure"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9"
dependencies = [
"backtrace",
"failure_derive",
]
[[package]]
name = "failure_derive"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08"
dependencies = [
"proc-macro2 1.0.7",
"quote 1.0.2",
"syn 1.0.13",
"synstructure",
]
[[package]]
name = "filetime"
version = "0.2.8"
@ -764,12 +698,6 @@ dependencies = [
"servo-freetype-sys",
]
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[package]]
name = "fuchsia-zircon"
version = "0.3.3"
@ -847,9 +775,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764"
dependencies = [
"proc-macro-hack",
"proc-macro2 1.0.7",
"proc-macro2 1.0.8",
"quote 1.0.2",
"syn 1.0.13",
"syn 1.0.14",
]
[[package]]
@ -1188,9 +1116,9 @@ dependencies = [
[[package]]
name = "itoa"
version = "0.4.4"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e"
[[package]]
name = "jpeg-decoder"
@ -1632,11 +1560,11 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
[[package]]
name = "openssl-sys"
version = "0.9.53"
version = "0.9.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "465d16ae7fc0e313318f7de5cecf57b2fbe7511fd213978b457e1c96ff46736f"
checksum = "1024c0a59774200a555087a6da3f253a9095a5f344e353b212ac4c8b8e450986"
dependencies = [
"autocfg 0.1.7",
"autocfg 1.0.0",
"cc",
"libc",
"pkg-config",
@ -1717,29 +1645,29 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "pin-project"
version = "0.4.6"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94b90146c7216e4cb534069fb91366de4ea0ea353105ee45ed297e2d1619e469"
checksum = "7804a463a8d9572f13453c516a5faea534a2403d7ced2f0c7e100eeff072772c"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "0.4.6"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44ca92f893f0656d3cba8158dd0f2b99b94de256a4a54e870bd6922fcc6c8355"
checksum = "385322a45f2ecf3410c68d2a549a4a2685e8051d0f278e39743ff4e451cb9b3f"
dependencies = [
"proc-macro2 1.0.7",
"proc-macro2 1.0.8",
"quote 1.0.2",
"syn 1.0.13",
"syn 1.0.14",
]
[[package]]
name = "pin-project-lite"
version = "0.1.2"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8822eb8bb72452f038ebf6048efa02c3fe22bf83f76519c9583e47fc194a422"
checksum = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae"
[[package]]
name = "pin-utils"
@ -1765,21 +1693,15 @@ dependencies = [
"inflate",
]
[[package]]
name = "ppv-lite86"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
[[package]]
name = "proc-macro-hack"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5"
dependencies = [
"proc-macro2 1.0.7",
"proc-macro2 1.0.8",
"quote 1.0.2",
"syn 1.0.13",
"syn 1.0.14",
]
[[package]]
@ -1799,9 +1721,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.7"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc"
checksum = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548"
dependencies = [
"unicode-xid 0.2.0",
]
@ -1827,76 +1749,7 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
dependencies = [
"proc-macro2 1.0.7",
]
[[package]]
name = "rand"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
"getrandom",
"rand_chacha",
"rand_core 0.5.1",
"rand_hc",
]
[[package]]
name = "rand_chacha"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853"
dependencies = [
"c2-chacha",
"rand_core 0.5.1",
]
[[package]]
name = "rand_core"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
dependencies = [
"rand_core 0.4.2",
]
[[package]]
name = "rand_core"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]]
name = "rand_core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
"getrandom",
]
[[package]]
name = "rand_hc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
dependencies = [
"rand_core 0.5.1",
]
[[package]]
name = "rand_os"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
dependencies = [
"cloudabi",
"fuchsia-cprng",
"libc",
"rand_core 0.4.2",
"rdrand",
"winapi 0.3.8",
"proc-macro2 1.0.8",
]
[[package]]
@ -1927,20 +1780,11 @@ checksum = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9"
dependencies = [
"crossbeam-deque",
"crossbeam-queue",
"crossbeam-utils 0.7.0",
"crossbeam-utils",
"lazy_static",
"num_cpus",
]
[[package]]
name = "rdrand"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "redox_syscall"
version = "0.1.56"
@ -1949,12 +1793,11 @@ checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
[[package]]
name = "redox_users"
version = "0.3.1"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d"
checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431"
dependencies = [
"failure",
"rand_os",
"getrandom",
"redox_syscall",
"rust-argon2",
]
@ -1999,13 +1842,14 @@ dependencies = [
[[package]]
name = "rust-argon2"
version = "0.5.1"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf"
checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017"
dependencies = [
"base64",
"blake2b_simd",
"crossbeam-utils 0.6.6",
"constant_time_eq",
"crossbeam-utils",
]
[[package]]
@ -2027,7 +1871,7 @@ checksum = "50633968284cfc373661345fc6382e62b738079f045738023ebc5e445cf44357"
dependencies = [
"quote 1.0.2",
"rust-embed-utils",
"syn 1.0.13",
"syn 1.0.14",
"walkdir",
]
@ -2040,12 +1884,6 @@ dependencies = [
"walkdir",
]
[[package]]
name = "rustc-demangle"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
[[package]]
name = "rustc-hash"
version = "1.0.1"
@ -2145,9 +1983,9 @@ checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
[[package]]
name = "serde_json"
version = "1.0.44"
version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7"
checksum = "eab8f15f15d6c41a154c1b128a22f2dfabe350ef53c40953d84e36155c91192b"
dependencies = [
"itoa",
"ryu",
@ -2254,8 +2092,9 @@ dependencies = [
[[package]]
name = "skulpin"
version = "0.6.0"
source = "git+https://github.com/aclysma/skulpin?branch=winit_20#ca72c710628c7ff6a86de5c9997dd7443049dc47"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6825386a1553c4e9da03bae6e6b044090c103bd3e94c5d099b98664c0eb3c23d"
dependencies = [
"ash",
"cocoa",
@ -2276,9 +2115,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
[[package]]
name = "smallvec"
version = "1.1.0"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4"
checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc"
[[package]]
name = "smithay-client-toolkit"
@ -2336,24 +2175,12 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8"
dependencies = [
"proc-macro2 1.0.7",
"quote 1.0.2",
"unicode-xid 0.2.0",
]
[[package]]
name = "synstructure"
version = "0.12.3"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
checksum = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5"
dependencies = [
"proc-macro2 1.0.7",
"proc-macro2 1.0.8",
"quote 1.0.2",
"syn 1.0.13",
"unicode-xid 0.2.0",
]
@ -2410,11 +2237,11 @@ dependencies = [
[[package]]
name = "tokio"
version = "0.2.9"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffa2fdcfa937b20cb3c822a635ceecd5fc1a27a6a474527e5516aa24b8c8820a"
checksum = "8fdd17989496f49cdc57978c96f0c9fe5e4a58a8bddc6813c449a4624f6a030b"
dependencies = [
"bytes 0.5.3",
"bytes 0.5.4",
"fnv",
"iovec",
"lazy_static",
@ -2444,12 +2271,13 @@ dependencies = [
[[package]]
name = "tokio-macros"
version = "0.2.3"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50a61f268a3db2acee8dcab514efc813dc6dbe8a00e86076f935f94304b59a7a"
checksum = "f4b1e7ed7d5d4c2af3d999904b0eebe76544897cdbfb2b9684bed2174ab20f7c"
dependencies = [
"proc-macro2 1.0.8",
"quote 1.0.2",
"syn 1.0.13",
"syn 1.0.14",
]
[[package]]
@ -2463,9 +2291,9 @@ dependencies = [
[[package]]
name = "unicode-normalization"
version = "0.1.11"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b561e267b2326bb4cebfc0ef9e68355c7abe6c6f522aeac2f5bf95d56c59bdcf"
checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4"
dependencies = [
"smallvec",
]
@ -2649,11 +2477,13 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "winit"
version = "0.20.0"
source = "git+https://github.com/rust-windowing/winit?rev=e295104#e2951041990983eb100dde664607de5330e50b13"
version = "0.20.0-alpha6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa4308ca09f50e2f4688c631c36879521bffc39b949238b288ffd932864acbc"
dependencies = [
"android_glue",
"bitflags",
"calloop",
"cocoa",
"core-foundation",
"core-graphics",
@ -2663,8 +2493,6 @@ dependencies = [
"lazy_static",
"libc",
"log",
"mio",
"mio-extras",
"objc",
"parking_lot",
"percent-encoding",
@ -2696,9 +2524,9 @@ dependencies = [
[[package]]
name = "x11-dl"
version = "2.18.4"
version = "2.18.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be65e1342a3baae65439cd03306778831a3d133b0d20243a7fb83fd5cf403c58"
checksum = "2bf981e3a5b3301209754218f962052d4d9ee97e478f4d26d4a6eced34c1fef8"
dependencies = [
"lazy_static",
"libc",

@ -10,7 +10,7 @@ euclid = "0.20.7"
font-kit = "0.4.0"
skribo = { git = "https://github.com/linebender/skribo" }
lru = "0.4.3"
skulpin = { git = "https://github.com/aclysma/skulpin", branch="winit_20" }
skulpin = "0.5.2"
derive-new = "0.5"
env_logger = "0.7.1"
rmpv = "0.4.2"

@ -0,0 +1,129 @@
use std::sync::atomic::{AtomicBool, Ordering};
use skulpin::winit::event::{KeyboardInput, ElementState, ModifiersState, VirtualKeyCode};
use super::{BRIDGE, UiCommand};
lazy_static! {
pub static ref KEYBOARD_MANAGER: KeyboardManager = KeyboardManager::new();
}
pub struct KeyboardManager {
shift: AtomicBool,
ctrl: AtomicBool,
alt: AtomicBool,
logo: AtomicBool
}
impl KeyboardManager {
pub fn new() -> KeyboardManager {
KeyboardManager {
shift: AtomicBool::new(false),
ctrl: AtomicBool::new(false),
alt: AtomicBool::new(false),
logo: AtomicBool::new(false)
}
}
fn apply_modifiers(&self, text: String, escaped: bool) -> String {
let mut escaped = escaped;
let mut result = text;
if self.shift.load(Ordering::Relaxed) {
result = format!("S-{}", result);
escaped = true;
}
if self.ctrl.load(Ordering::Relaxed) {
result = format!("C-{}", result);
escaped = true;
}
if self.alt.load(Ordering::Relaxed) {
result = format!("M-{}", result);
escaped = true;
}
if self.logo.load(Ordering::Relaxed) {
result = format!("D-{}", result);
escaped = true;
}
if escaped {
format!("<{}>", result)
} else {
result
}
}
pub fn handle_keyboard_input(&self, input: KeyboardInput) {
let keycode = match input {
KeyboardInput {
state: ElementState::Pressed,
virtual_keycode: keycode,
..
} => keycode,
_ => None
};
keycode.and_then(|keycode| {
match keycode {
VirtualKeyCode::Escape => Some("ESC"),
VirtualKeyCode::F1 => Some("F1"),
VirtualKeyCode::F2 => Some("F2"),
VirtualKeyCode::F3 => Some("F3"),
VirtualKeyCode::F4 => Some("F4"),
VirtualKeyCode::F5 => Some("F5"),
VirtualKeyCode::F6 => Some("F6"),
VirtualKeyCode::F7 => Some("F7"),
VirtualKeyCode::F8 => Some("F8"),
VirtualKeyCode::F9 => Some("F9"),
VirtualKeyCode::F10 => Some("F10"),
VirtualKeyCode::F11 => Some("F11"),
VirtualKeyCode::F12 => Some("F12"),
VirtualKeyCode::F13 => Some("F13"),
VirtualKeyCode::F14 => Some("F14"),
VirtualKeyCode::F15 => Some("F15"),
VirtualKeyCode::F16 => Some("F16"),
VirtualKeyCode::F17 => Some("F17"),
VirtualKeyCode::F18 => Some("F18"),
VirtualKeyCode::F19 => Some("F19"),
VirtualKeyCode::F20 => Some("F20"),
VirtualKeyCode::F21 => Some("F21"),
VirtualKeyCode::F22 => Some("F22"),
VirtualKeyCode::F23 => Some("F23"),
VirtualKeyCode::F24 => Some("F24"),
VirtualKeyCode::Insert => Some("Insert"),
VirtualKeyCode::Home => Some("Home"),
VirtualKeyCode::Delete => Some("Delete"),
VirtualKeyCode::End => Some("End"),
VirtualKeyCode::PageDown => Some("PageDown"),
VirtualKeyCode::PageUp => Some("PageUp"),
VirtualKeyCode::Left => Some("Left"),
VirtualKeyCode::Up => Some("Up"),
VirtualKeyCode::Right => Some("Right"),
VirtualKeyCode::Down => Some("Down"),
VirtualKeyCode::Back => Some("BS"),
VirtualKeyCode::Return => Some("Enter"),
VirtualKeyCode::Backslash => Some("Bslash"),
VirtualKeyCode::Tab => Some("Tab"),
_ => None
}
}).map(|keyboard_input| {
// let keyboard_input = self.apply_modifiers(keyboard_input.to_string(), true);
// BRIDGE.queue_command(UiCommand::Keyboard(keyboard_input));
});
}
pub fn handle_received_character(&self, character: char) {
let keyboard_input = character.escape_unicode().to_string();
BRIDGE.queue_command(UiCommand::Keyboard(keyboard_input));
}
pub fn handle_modifiers(&self, modifiers: ModifiersState) {
self.shift.store(modifiers.shift(), Ordering::Relaxed);
self.ctrl.store(modifiers.ctrl(), Ordering::Relaxed);
self.alt.store(modifiers.alt(), Ordering::Relaxed);
self.logo.store(modifiers.logo(), Ordering::Relaxed);
}
}

@ -19,7 +19,7 @@ use crate::INITIAL_DIMENSIONS;
#[folder = "assets/"]
struct Asset;
fn handle_new_grid_size(new_size: LogicalSize<f64>, renderer: &Renderer) {
fn handle_new_grid_size(new_size: LogicalSize, renderer: &Renderer) {
if new_size.width > 0.0 && new_size.height > 0.0 {
let new_width = ((new_size.width + 1.0) as f32 / renderer.font_width) as u64;
let new_height = ((new_size.height + 1.0) as f32 / renderer.font_height) as u64;
@ -86,7 +86,7 @@ pub fn ui_loop() {
event: WindowEvent::Resized(new_size),
..
} => {
handle_new_grid_size(new_size.to_logical(window.scale_factor()), &renderer)
handle_new_grid_size(new_size, &renderer)
},
Event::WindowEvent {
@ -108,9 +108,9 @@ pub fn ui_loop() {
},
..
} => {
let position: LogicalPosition<f32> = position.to_logical(window.scale_factor());
let grid_y = (position.x / renderer.font_width) as i64;
let grid_x = (position.y / renderer.font_height) as i64;
let position: LogicalPosition = position;
let grid_y = (position.x / renderer.font_width as f64) as i64;
let grid_x = (position.y / renderer.font_height as f64) as i64;
let (old_x, old_y) = mouse_pos;
mouse_pos = (grid_x, grid_y);
if mouse_down && (old_x != grid_x || old_y != grid_y) {
@ -187,7 +187,7 @@ pub fn ui_loop() {
if REDRAW_SCHEDULER.should_draw() {
if let Err(_) = skulpin_renderer.draw(&window, |canvas, coordinate_system_helper| {
if renderer.draw(canvas, coordinate_system_helper) {
handle_new_grid_size(window.inner_size().to_logical(window.scale_factor()), &renderer)
handle_new_grid_size(window.inner_size(), &renderer)
}
}) {
println!("Render failed. Closing");

Loading…
Cancel
Save