formatting and clippy fixes

macos-click-through
Keith Simmons 3 years ago
parent 80d5ed983c
commit cbdb28b094

@ -66,12 +66,16 @@ impl Handler for NeovimHandler {
#[cfg(windows)]
"neovide.register_right_click" => {
let ui_command_sender = ui_command_sender.lock();
ui_command_sender.send(ParallelCommand::RegisterRightClick.into()).ok();
ui_command_sender
.send(ParallelCommand::RegisterRightClick.into())
.ok();
}
#[cfg(windows)]
"neovide.unregister_right_click" => {
let ui_command_sender = ui_command_sender.lock();
ui_command_sender.send(ParallelCommand::UnregisterRightClick.into()).ok();
ui_command_sender
.send(ParallelCommand::UnregisterRightClick.into())
.ok();
}
_ => {}
});

@ -22,7 +22,7 @@ use crate::{cmd_line::CmdLineSettings, error_handling::ResultPanicExplanation};
pub use events::*;
use handler::NeovimHandler;
pub use tx_wrapper::{TxWrapper, WrapTx};
pub use ui_commands::{UiCommand, SerialCommand, ParallelCommand, start_ui_command_handler};
pub use ui_commands::{start_ui_command_handler, ParallelCommand, SerialCommand, UiCommand};
#[cfg(windows)]
fn set_windows_creation_flags(cmd: &mut Command) {

@ -1,21 +1,11 @@
use std::sync::{
Arc,
atomic::{
AtomicBool,
Ordering,
},
};
use std::sync::Arc;
use log::trace;
#[cfg(windows)]
use log::error;
use log::trace;
use nvim_rs::Neovim;
use tokio::sync::mpsc::{
unbounded_channel,
UnboundedReceiver,
UnboundedSender,
};
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver};
use crate::bridge::TxWrapper;
use crate::running_tracker::RUNNING_TRACKER;
@ -180,7 +170,6 @@ impl ParallelCommand {
}
}
#[derive(Debug, Clone)]
pub enum UiCommand {
Serial(SerialCommand),
@ -199,14 +188,18 @@ impl From<ParallelCommand> for UiCommand {
}
}
pub fn start_ui_command_handler(mut ui_command_receiver: UnboundedReceiver<UiCommand>, nvim: Arc<Neovim<TxWrapper>>) {
pub fn start_ui_command_handler(
mut ui_command_receiver: UnboundedReceiver<UiCommand>,
nvim: Arc<Neovim<TxWrapper>>,
) {
let (serial_tx, mut serial_rx) = unbounded_channel::<SerialCommand>();
let ui_command_nvim = nvim.clone();
tokio::spawn(async move {
while RUNNING_TRACKER.is_running() {
match ui_command_receiver.recv().await {
Some(UiCommand::Serial(serial_command)) =>
serial_tx.send(serial_command).expect("Could not send serial ui command"),
Some(UiCommand::Serial(serial_command)) => serial_tx
.send(serial_command)
.expect("Could not send serial ui command"),
Some(UiCommand::Parallel(parallel_command)) => {
let ui_command_nvim = ui_command_nvim.clone();
tokio::spawn(async move {
@ -220,16 +213,15 @@ pub fn start_ui_command_handler(mut ui_command_receiver: UnboundedReceiver<UiCom
}
});
let serial_command_nvim = nvim.clone();
tokio::spawn(async move {
while RUNNING_TRACKER.is_running() {
match serial_rx.recv().await {
Some(serial_command) => {
serial_command.execute(&serial_command_nvim).await;
},
serial_command.execute(&nvim).await;
}
None => {
RUNNING_TRACKER.quit("serial ui command channel failed");
},
}
}
}
});

@ -19,9 +19,9 @@ mod editor;
mod error_handling;
mod redraw_scheduler;
mod renderer;
mod running_tracker;
mod settings;
mod utils;
mod running_tracker;
mod window;
mod windows_utils;
@ -30,7 +30,7 @@ extern crate derive_new;
#[macro_use]
extern crate lazy_static;
use std::sync::{atomic::AtomicBool, mpsc::channel, Arc};
use std::sync::mpsc::channel;
use log::trace;
use tokio::sync::mpsc::unbounded_channel;

@ -1,9 +1,6 @@
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
atomic::{
AtomicBool,
Ordering,
},
};
use log::info;
@ -13,13 +10,13 @@ lazy_static! {
}
pub struct RunningTracker {
running: Arc<AtomicBool>
running: Arc<AtomicBool>,
}
impl RunningTracker {
fn new() -> Self {
Self {
running: Arc::new(AtomicBool::new(true))
running: Arc::new(AtomicBool::new(true)),
}
}

@ -107,11 +107,15 @@ impl GlutinWindowWrapper {
}
pub fn handle_focus_lost(&mut self) {
self.ui_command_sender.send(ParallelCommand::FocusLost.into()).ok();
self.ui_command_sender
.send(ParallelCommand::FocusLost.into())
.ok();
}
pub fn handle_focus_gained(&mut self) {
self.ui_command_sender.send(ParallelCommand::FocusGained.into()).ok();
self.ui_command_sender
.send(ParallelCommand::FocusGained.into())
.ok();
REDRAW_SCHEDULER.queue_next_frame();
}
@ -144,9 +148,10 @@ impl GlutinWindowWrapper {
..
} => {
self.ui_command_sender
.send(ParallelCommand::FileDrop(
path.into_os_string().into_string().unwrap(),
).into())
.send(
ParallelCommand::FileDrop(path.into_os_string().into_string().unwrap())
.into(),
)
.ok();
}
Event::WindowEvent {
@ -221,10 +226,13 @@ impl GlutinWindowWrapper {
}
self.saved_grid_size = Some(grid_size);
self.ui_command_sender
.send(ParallelCommand::Resize {
.send(
ParallelCommand::Resize {
width: grid_size.width,
height: grid_size.height,
}.into())
}
.into(),
)
.ok();
}

@ -162,12 +162,15 @@ impl MouseManager {
// If dragging and we haven't already sent a position, send a drag command
if self.dragging.is_some() && has_moved {
self.command_sender
.send(SerialCommand::Drag {
.send(
SerialCommand::Drag {
button: self.dragging.as_ref().unwrap().to_owned(),
grid_id: relevant_window_details.id,
position: self.drag_position.into(),
modifier_string: keyboard_manager.format_modifier_string(true),
}.into())
}
.into(),
)
.ok();
} else {
// otherwise, update the window_id_under_mouse to match the one selected
@ -203,13 +206,16 @@ impl MouseManager {
};
self.command_sender
.send(SerialCommand::MouseButton {
.send(
SerialCommand::MouseButton {
button: button_text.clone(),
action,
grid_id: details.id,
position: position.into(),
modifier_string: keyboard_manager.format_modifier_string(true),
}.into())
}
.into(),
)
.ok();
}
@ -247,7 +253,8 @@ impl MouseManager {
.unwrap_or(0),
position: self.drag_position.into(),
modifier_string: keyboard_manager.format_modifier_string(true),
}.into();
}
.into();
for _ in 0..(new_y - previous_y).abs() {
self.command_sender.send(scroll_command.clone()).ok();
}
@ -273,7 +280,8 @@ impl MouseManager {
.unwrap_or(0),
position: self.drag_position.into(),
modifier_string: keyboard_manager.format_modifier_string(true),
}.into();
}
.into();
for _ in 0..(new_x - previous_x).abs() {
self.command_sender.send(scroll_command.clone()).ok();
}

Loading…
Cancel
Save