|
|
@ -49,7 +49,8 @@ struct WindowWrapper {
|
|
|
|
title: String,
|
|
|
|
title: String,
|
|
|
|
previous_size: LogicalSize,
|
|
|
|
previous_size: LogicalSize,
|
|
|
|
previous_dpis: (f32, f32),
|
|
|
|
previous_dpis: (f32, f32),
|
|
|
|
ignore_text_input: bool
|
|
|
|
ignore_text_input: bool,
|
|
|
|
|
|
|
|
transparency: f32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl WindowWrapper {
|
|
|
|
impl WindowWrapper {
|
|
|
@ -112,7 +113,8 @@ impl WindowWrapper {
|
|
|
|
title: String::from("Neovide"),
|
|
|
|
title: String::from("Neovide"),
|
|
|
|
previous_size,
|
|
|
|
previous_size,
|
|
|
|
previous_dpis,
|
|
|
|
previous_dpis,
|
|
|
|
ignore_text_input: false
|
|
|
|
ignore_text_input: false,
|
|
|
|
|
|
|
|
transparency: 1.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -124,6 +126,16 @@ impl WindowWrapper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn synchronize_transparency(&mut self) {
|
|
|
|
|
|
|
|
let transparency = { SETTINGS.get::<WindowSettings>().transparency };
|
|
|
|
|
|
|
|
if let Ok(opacity) = self.window.opacity() {
|
|
|
|
|
|
|
|
if opacity != transparency {
|
|
|
|
|
|
|
|
self.window.set_opacity(transparency).ok();
|
|
|
|
|
|
|
|
self.transparency = transparency;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn handle_key_down(&mut self, keycode: Keycode, modifiers: Mod) {
|
|
|
|
pub fn handle_key_down(&mut self, keycode: Keycode, modifiers: Mod) {
|
|
|
|
trace!("KeyDown Received: {}", keycode);
|
|
|
|
trace!("KeyDown Received: {}", keycode);
|
|
|
|
|
|
|
|
|
|
|
@ -265,6 +277,7 @@ impl WindowWrapper {
|
|
|
|
struct WindowSettings {
|
|
|
|
struct WindowSettings {
|
|
|
|
refresh_rate: u64,
|
|
|
|
refresh_rate: u64,
|
|
|
|
no_idle: bool,
|
|
|
|
no_idle: bool,
|
|
|
|
|
|
|
|
transparency: f32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn initialize_settings() {
|
|
|
|
pub fn initialize_settings() {
|
|
|
@ -274,10 +287,12 @@ pub fn initialize_settings() {
|
|
|
|
SETTINGS.set(&WindowSettings {
|
|
|
|
SETTINGS.set(&WindowSettings {
|
|
|
|
refresh_rate: 60,
|
|
|
|
refresh_rate: 60,
|
|
|
|
no_idle,
|
|
|
|
no_idle,
|
|
|
|
|
|
|
|
transparency: 1.0
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
register_nvim_setting!("refresh_rate", WindowSettings::refresh_rate);
|
|
|
|
register_nvim_setting!("refresh_rate", WindowSettings::refresh_rate);
|
|
|
|
register_nvim_setting!("no_idle", WindowSettings::no_idle);
|
|
|
|
register_nvim_setting!("no_idle", WindowSettings::no_idle);
|
|
|
|
|
|
|
|
register_nvim_setting!("transparency", WindowSettings::transparency);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn ui_loop() {
|
|
|
|
pub fn ui_loop() {
|
|
|
@ -289,6 +304,7 @@ pub fn ui_loop() {
|
|
|
|
let frame_start = Instant::now();
|
|
|
|
let frame_start = Instant::now();
|
|
|
|
|
|
|
|
|
|
|
|
window.synchronize_title();
|
|
|
|
window.synchronize_title();
|
|
|
|
|
|
|
|
window.synchronize_transparency();
|
|
|
|
|
|
|
|
|
|
|
|
for event in event_pump.poll_iter() {
|
|
|
|
for event in event_pump.poll_iter() {
|
|
|
|
match event {
|
|
|
|
match event {
|
|
|
@ -309,7 +325,7 @@ pub fn ui_loop() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let elapsed = frame_start.elapsed();
|
|
|
|
let elapsed = frame_start.elapsed();
|
|
|
|
let refresh_rate = SETTINGS.get::<WindowSettings>().refresh_rate as f32;
|
|
|
|
let refresh_rate = { SETTINGS.get::<WindowSettings>().refresh_rate as f32 };
|
|
|
|
let frame_length = Duration::from_secs_f32(1.0 / refresh_rate);
|
|
|
|
let frame_length = Duration::from_secs_f32(1.0 / refresh_rate);
|
|
|
|
if elapsed < frame_length {
|
|
|
|
if elapsed < frame_length {
|
|
|
|
sleep(frame_length - elapsed);
|
|
|
|
sleep(frame_length - elapsed);
|
|
|
|