fix mouse location

macos-click-through
Keith Simmons 5 years ago
parent 514a9ca254
commit 72aefd4730

@ -22,13 +22,13 @@ impl UiCommand {
.expect("Input failed"); .expect("Input failed");
}, },
UiCommand::MouseButton { action, position: (grid_x, grid_y) } => UiCommand::MouseButton { action, position: (grid_x, grid_y) } =>
nvim.input_mouse("left", action, "", 0, *grid_y, *grid_x).await nvim.input_mouse("left", action, "", 0, *grid_x, *grid_y).await
.expect("Mouse Input Failed"), .expect("Mouse Input Failed"),
UiCommand::Scroll { direction, position: (grid_x, grid_y) } => UiCommand::Scroll { direction, position: (grid_x, grid_y) } =>
nvim.input_mouse("wheel", direction, "", 0, *grid_y, *grid_x).await nvim.input_mouse("wheel", direction, "", 0, *grid_x, *grid_y).await
.expect("Mouse Scroll Failed"), .expect("Mouse Scroll Failed"),
UiCommand::Drag(grid_x, grid_y) => UiCommand::Drag(grid_x, grid_y) =>
nvim.input_mouse("left", "drag", "", 0, *grid_y, *grid_x).await nvim.input_mouse("left", "drag", "", 0, *grid_x, *grid_y).await
.expect("Mouse Drag Failed") .expect("Mouse Drag Failed")
} }
} }

@ -117,11 +117,11 @@ pub fn ui_loop(editor: Arc<Mutex<Editor>>, mut command_channel: Sender<UiCommand
}, },
.. ..
} => { } => {
let grid_x = (position.x as f32 / renderer.font_width) as i64; let grid_y = (position.x as f32 / renderer.font_width) as i64;
let grid_y = (position.y as f32 / renderer.font_height) as i64; let grid_x = (position.y as f32 / renderer.font_height) as i64;
mouse_pos = (grid_x, grid_y); mouse_pos = (grid_x, grid_y);
if mouse_down { if mouse_down {
command_channel.send(UiCommand::Drag(grid_y, grid_x)); command_channel.send(UiCommand::Drag(grid_x, grid_y));
} }
} }
@ -162,7 +162,7 @@ pub fn ui_loop(editor: Arc<Mutex<Editor>>, mut command_channel: Sender<UiCommand
}; };
if let Some(input_type) = vertical_input_type { if let Some(input_type) = vertical_input_type {
let (grid_x, grid_y) = mouse_pos; let (grid_y, grid_x) = mouse_pos;
command_channel.send(UiCommand::Scroll { direction: input_type.to_string(), position: (grid_x, grid_y) }); command_channel.send(UiCommand::Scroll { direction: input_type.to_string(), position: (grid_x, grid_y) });
} }
@ -175,7 +175,7 @@ pub fn ui_loop(editor: Arc<Mutex<Editor>>, mut command_channel: Sender<UiCommand
}; };
if let Some(input_type) = horizontal_input_type { if let Some(input_type) = horizontal_input_type {
let (grid_x, grid_y) = mouse_pos; let (grid_y, grid_x) = mouse_pos;
command_channel.send(UiCommand::Scroll { direction: input_type.to_string(), position: (grid_x, grid_y) }); command_channel.send(UiCommand::Scroll { direction: input_type.to_string(), position: (grid_x, grid_y) });
} }
} }

Loading…
Cancel
Save