mirror of
https://github.com/neovide/neovide.git
synced 2026-09-10 07:16:25 -04:00
refactor: windows settings and functions - [8/20]
- remove `windows_utils` module - add `windows_fix_dpi` function for windows platform - restructure windows settings into separate file
This commit is contained in:
parent
a129880575
commit
eefefee1c6
|
|
@ -11,7 +11,7 @@ use log::error;
|
|||
use winit::event_loop::EventLoop;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::windows_attach_to_console;
|
||||
use crate::platform::windows::windows_attach_to_console;
|
||||
|
||||
use crate::{
|
||||
bridge::{send_ui, ParallelCommand},
|
||||
|
|
|
|||
|
|
@ -31,9 +31,6 @@ mod units;
|
|||
mod utils;
|
||||
mod window;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
mod windows_utils;
|
||||
|
||||
#[macro_use]
|
||||
extern crate derive_new;
|
||||
|
||||
|
|
@ -63,6 +60,8 @@ use backtrace::Backtrace;
|
|||
use bridge::NeovimRuntime;
|
||||
use cmd_line::CmdLineSettings;
|
||||
use error_handling::handle_startup_errors;
|
||||
#[cfg(target_os = "windows")]
|
||||
use platform::windows::windows_fix_dpi;
|
||||
use renderer::{cursor_renderer::CursorSettings, RendererSettings};
|
||||
use running_tracker::RunningTracker;
|
||||
use window::{
|
||||
|
|
@ -70,8 +69,6 @@ use window::{
|
|||
};
|
||||
|
||||
pub use channel_utils::*;
|
||||
#[cfg(target_os = "windows")]
|
||||
pub use windows_utils::*;
|
||||
|
||||
use crate::settings::{load_last_window_settings, Config, PersistentWindowSettings, Settings};
|
||||
|
||||
|
|
@ -215,6 +212,8 @@ fn setup(
|
|||
settings.register::<WindowSettings>();
|
||||
settings.register::<RendererSettings>();
|
||||
settings.register::<CursorSettings>();
|
||||
#[cfg(target_os = "windows")]
|
||||
settings.register::<crate::platform::windows::settings::WindowsSettings>();
|
||||
|
||||
let config = Config::init();
|
||||
Config::watch_config_file(config.clone(), proxy.clone());
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
#[cfg(target_os = "macos")]
|
||||
pub mod macos;
|
||||
#[cfg(target_os = "windows")]
|
||||
pub mod windows;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
pub mod settings;
|
||||
|
||||
use windows::Win32::{
|
||||
System::Console::{AttachConsole, ATTACH_PARENT_PROCESS},
|
||||
UI::HiDpi::{SetProcessDpiAwarenessContext, DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2},
|
||||
24
src/platform/windows/settings.rs
Normal file
24
src/platform/windows/settings.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
use crate::settings::*;
|
||||
use neovide_derive::SettingGroup;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Clone, SettingGroup, PartialEq)]
|
||||
pub struct WindowsSettings {
|
||||
pub title_background_color: String,
|
||||
pub title_text_color: String,
|
||||
}
|
||||
|
||||
impl Default for WindowsSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
title_background_color: "".to_string(),
|
||||
title_text_color: "".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn neovide_config_dir() -> PathBuf {
|
||||
let mut path = dirs::config_dir().unwrap();
|
||||
path.push("neovide");
|
||||
path
|
||||
}
|
||||
|
|
@ -14,6 +14,9 @@ use std::path::{Path, PathBuf};
|
|||
|
||||
use super::font::FontSettings;
|
||||
|
||||
#[cfg(windows)]
|
||||
use crate::platform::windows::settings::neovide_config_dir;
|
||||
|
||||
const CONFIG_FILE: &str = "config.toml";
|
||||
|
||||
#[cfg(unix)]
|
||||
|
|
@ -22,13 +25,6 @@ fn neovide_config_dir() -> PathBuf {
|
|||
xdg_dirs.get_config_home().unwrap()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn neovide_config_dir() -> PathBuf {
|
||||
let mut path = dirs::config_dir().unwrap();
|
||||
path.push("neovide");
|
||||
path
|
||||
}
|
||||
|
||||
pub fn config_path() -> PathBuf {
|
||||
env::var("NEOVIDE_CONFIG")
|
||||
.ok()
|
||||
|
|
|
|||
|
|
@ -189,6 +189,8 @@ pub enum SettingsChanged {
|
|||
Window(crate::window::WindowSettingsChanged),
|
||||
Cursor(crate::renderer::cursor_renderer::CursorSettingsChanged),
|
||||
Renderer(crate::renderer::RendererSettingsChanged),
|
||||
#[cfg(target_os = "windows")]
|
||||
Windows(crate::platform::windows::settings::WindowsSettingsChanged),
|
||||
#[cfg(test)]
|
||||
Test(tests::TestSettingsChanged),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,14 @@ use {
|
|||
winit::platform::macos::{self, WindowExtMacOS},
|
||||
};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use {
|
||||
crate::platform::windows::{register_right_click, unregister_right_click},
|
||||
winit::platform::windows::BackdropType,
|
||||
winit::platform::windows::Color,
|
||||
winit::platform::windows::WindowExtWindows,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
bridge::{send_ui, ParallelCommand, SerialCommand},
|
||||
profiling::{tracy_frame, tracy_gpu_collect, tracy_gpu_zone, tracy_plot, tracy_zone},
|
||||
|
|
@ -33,11 +41,6 @@ use crate::{
|
|||
window::{create_window, PhysicalSize, ShouldRender, WindowSize},
|
||||
CmdLineSettings,
|
||||
};
|
||||
#[cfg(windows)]
|
||||
use {
|
||||
crate::windows_utils::{register_right_click, unregister_right_click},
|
||||
winit::platform::windows::{BackdropType, Color, WindowExtWindows},
|
||||
};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use super::macos::MacosWindowFeature;
|
||||
|
|
|
|||
Loading…
Reference in a new issue