set buffer frames to 1 and add extra buffer startup command. Fix bug where mouse position is improperly scaled

macos-click-through
Keith Simmons 5 years ago
parent 260291e8b6
commit 703087fd88

1
.gitignore vendored

@ -1,2 +1,3 @@
/target
**/*.rs.bk
*.log

@ -35,6 +35,9 @@ fn main() {
} else if arg == "--noIdle" {
SETTINGS.no_idle.store(true, Ordering::Relaxed);
false
} else if arg == "--extraBufferFrames" {
SETTINGS.buffer_frames.store(60, Ordering::Relaxed);
false
} else {
true
}

@ -4,12 +4,12 @@ use std::time::Instant;
use log::trace;
use crate::settings::SETTINGS;
lazy_static! {
pub static ref REDRAW_SCHEDULER: RedrawScheduler = RedrawScheduler::new();
}
const BUFFER_FRAMES: u16 = 60;
pub struct RedrawScheduler {
frames_queued: AtomicU16,
scheduled_frame: Mutex<Option<Instant>>
@ -38,7 +38,8 @@ impl RedrawScheduler {
pub fn queue_next_frame(&self) {
trace!("Next frame queued");
self.frames_queued.store(BUFFER_FRAMES, Ordering::Relaxed);
let buffer_frames = SETTINGS.buffer_frames.load(Ordering::Relaxed);
self.frames_queued.store(buffer_frames, Ordering::Relaxed);
}
pub fn should_draw(&self) -> bool {

@ -1,13 +1,23 @@
use std::sync::atomic::AtomicBool;
use std::sync::atomic::{AtomicBool, AtomicU16};
use crossbeam::atomic::AtomicCell;
lazy_static! {
pub static ref SETTINGS: Settings = Settings::default();
pub static ref SETTINGS: Settings = Settings::new();
}
#[derive(Default)]
pub struct Settings {
pub neovim_arguments: AtomicCell<Option<Vec<String>>>,
pub no_idle: AtomicBool
pub no_idle: AtomicBool,
pub buffer_frames: AtomicU16
}
impl Settings {
pub fn new() -> Settings {
Settings {
neovim_arguments: AtomicCell::new(None),
no_idle: AtomicBool::new(false),
buffer_frames: AtomicU16::new(1),
}
}
}

@ -4,7 +4,7 @@ use std::time::{Duration, Instant};
use image::{load_from_memory, GenericImageView, Pixel};
use skulpin::{CoordinateSystem, RendererBuilder, PresentMode};
use skulpin::winit::dpi::LogicalSize;
use skulpin::winit::dpi::{LogicalSize, LogicalPosition};
use skulpin::winit::event::{ElementState, Event, MouseScrollDelta, StartCause, WindowEvent, ModifiersState};
use skulpin::winit::event_loop::{ControlFlow, EventLoop};
use skulpin::winit::window::{Icon, WindowBuilder};
@ -138,6 +138,7 @@ pub fn ui_loop() {
},
..
} => {
let position: LogicalPosition<f64> = position.to_logical(window.scale_factor());
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;

Loading…
Cancel
Save