fix key binding issue, text scaling, and maybe render bug

macos-click-through
keith 5 years ago
parent 0f10f186e8
commit 8448d1b5a9

2
Cargo.lock generated

@ -1635,7 +1635,6 @@ dependencies = [
"bitflags", "bitflags",
"lazy_static", "lazy_static",
"libc", "libc",
"raw-window-handle",
"sdl2-sys", "sdl2-sys",
] ]
@ -1785,7 +1784,6 @@ dependencies = [
[[package]] [[package]]
name = "skulpin" name = "skulpin"
version = "0.5.2" version = "0.5.2"
source = "git+https://github.com/Kethku/skulpin?branch=sdl2#396bc7d52240a05384c73de1e117a601b1e2e5ff"
dependencies = [ dependencies = [
"ash", "ash",
"cocoa", "cocoa",

@ -12,6 +12,7 @@ font-kit = "0.5.0"
skribo = { git = "https://github.com/linebender/skribo" } skribo = { git = "https://github.com/linebender/skribo" }
lru = "0.4.3" lru = "0.4.3"
skulpin = { git = "https://github.com/Kethku/skulpin", branch = "sdl2" } skulpin = { git = "https://github.com/Kethku/skulpin", branch = "sdl2" }
# skulpin = { path = "../skulpin" }
derive-new = "0.5" derive-new = "0.5"
rmpv = "0.4.4" rmpv = "0.4.4"
rust-embed = { version = "5.2.0", features = ["debug-embed"] } rust-embed = { version = "5.2.0", features = ["debug-embed"] }

@ -113,7 +113,7 @@ pub struct Settings {
impl Settings { impl Settings {
pub async fn read_initial_values(&self, nvim: &Neovim<Compat<ChildStdin>>) { pub async fn read_initial_values(&self, nvim: &Neovim<Compat<ChildStdin>>) {
let keys : Vec<String>= self.settings.lock().keys().cloned().collect(); let keys : Vec<String> = self.settings.lock().keys().cloned().collect();
for name in keys { for name in keys {
let variable_name = format!("neovide_{}", name.to_string()); let variable_name = format!("neovide_{}", name.to_string());
match nvim.get_var(&variable_name).await { match nvim.get_var(&variable_name).await {
@ -128,7 +128,7 @@ impl Settings {
} }
pub async fn setup_changed_listeners(&self, nvim: &Neovim<Compat<ChildStdin>>) { pub async fn setup_changed_listeners(&self, nvim: &Neovim<Compat<ChildStdin>>) {
let keys : Vec<String>= self.settings.lock().keys().cloned().collect(); let keys : Vec<String> = self.settings.lock().keys().cloned().collect();
for name in keys { for name in keys {
let vimscript = let vimscript =
format!("function NeovideNotify{}Changed(d, k, z)\n", name) + format!("function NeovideNotify{}Changed(d, k, z)\n", name) +

@ -76,7 +76,7 @@ pub fn ui_loop() {
let mut skulpin_renderer = RendererBuilder::new() let mut skulpin_renderer = RendererBuilder::new()
.prefer_integrated_gpu() .prefer_integrated_gpu()
.use_vulkan_debug_layer(true) .use_vulkan_debug_layer(true)
.present_mode_priority(vec![PresentMode::Mailbox, PresentMode::Immediate]) .present_mode_priority(vec![PresentMode::Immediate])
.coordinate_system(CoordinateSystem::Logical) .coordinate_system(CoordinateSystem::Logical)
.build(&window) .build(&window)
.expect("Failed to create renderer"); .expect("Failed to create renderer");
@ -100,6 +100,7 @@ pub fn ui_loop() {
window.set_title(&title).expect("Could not set title"); window.set_title(&title).expect("Could not set title");
} }
let mut ignore_text_input = false;
for event in event_pump.poll_iter() { for event in event_pump.poll_iter() {
match event { match event {
Event::Quit {..} => break 'running, Event::Quit {..} => break 'running,
@ -107,6 +108,7 @@ pub fn ui_loop() {
Event::KeyDown { keycode: Some(keycode), keymod: modifiers, .. } => { Event::KeyDown { keycode: Some(keycode), keymod: modifiers, .. } => {
if let Some((key_text, special)) = parse_keycode(keycode) { if let Some((key_text, special)) = parse_keycode(keycode) {
let will_text_input = let will_text_input =
!modifiers.contains(Mod::LCTRLMOD) && !modifiers.contains(Mod::LCTRLMOD) &&
!modifiers.contains(Mod::RCTRLMOD) && !modifiers.contains(Mod::RCTRLMOD) &&
!modifiers.contains(Mod::LALTMOD) && !modifiers.contains(Mod::LALTMOD) &&
@ -118,15 +120,20 @@ pub fn ui_loop() {
} }
BRIDGE.queue_command(UiCommand::Keyboard(append_modifiers(modifiers, key_text, special))); BRIDGE.queue_command(UiCommand::Keyboard(append_modifiers(modifiers, key_text, special)));
ignore_text_input = true;
} }
}, },
Event::TextInput { text, .. } => { Event::TextInput { text, .. } => {
let text = if text == "<" { if ignore_text_input {
String::from("<lt>") ignore_text_input = false;
} else { } else {
text let text = if text == "<" {
}; String::from("<lt>")
BRIDGE.queue_command(UiCommand::Keyboard(text)) } else {
text
};
BRIDGE.queue_command(UiCommand::Keyboard(text))
}
}, },
Event::MouseMotion { x, y, .. } => { Event::MouseMotion { x, y, .. } => {
let grid_x = (x as f32 / renderer.font_width) as i64; let grid_x = (x as f32 / renderer.font_width) as i64;

Loading…
Cancel
Save