Make CosmicTextSystem
Linux-only (#14728)
Since `WindowsDispatcher` requires a minimum Windows version of Windows 10 Fall Creators Update (10.0.16299), and the `alacritty_terminal` dependency relies on conPTY, an API introduced in the same version, additionally, `DirectWriteTextSystem` also relies on Windows 10 Fall Creators Update (10.0.16299), so it seems reasonable to make `CosmicTextSystem` Linux-only. And we can use `DirectWriteTextSystem` on the Windows platform exclusively. I hope this approach makes sense. Release Notes: - N/A
This commit is contained in:
parent
a60b3b9389
commit
82d6ad4616
7 changed files with 11 additions and 28 deletions
|
@ -4,9 +4,6 @@
|
||||||
mod app_menu;
|
mod app_menu;
|
||||||
mod keystroke;
|
mod keystroke;
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
|
||||||
mod cosmic_text;
|
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
mod linux;
|
mod linux;
|
||||||
|
|
||||||
|
@ -51,8 +48,6 @@ use uuid::Uuid;
|
||||||
pub use app_menu::*;
|
pub use app_menu::*;
|
||||||
pub use keystroke::*;
|
pub use keystroke::*;
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
|
||||||
pub(crate) use cosmic_text::*;
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub(crate) use linux::*;
|
pub(crate) use linux::*;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
@ -105,7 +100,6 @@ pub fn guess_compositor() -> &'static str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo("windows")
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
pub(crate) fn current_platform(_headless: bool) -> Rc<dyn Platform> {
|
pub(crate) fn current_platform(_headless: bool) -> Rc<dyn Platform> {
|
||||||
Rc::new(WindowsPlatform::new())
|
Rc::new(WindowsPlatform::new())
|
||||||
|
@ -413,8 +407,6 @@ pub(crate) trait PlatformTextSystem: Send + Sync {
|
||||||
raster_bounds: Bounds<DevicePixels>,
|
raster_bounds: Bounds<DevicePixels>,
|
||||||
) -> Result<(Size<DevicePixels>, Vec<u8>)>;
|
) -> Result<(Size<DevicePixels>, Vec<u8>)>;
|
||||||
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout;
|
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout;
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
fn destroy(&self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Clone)]
|
#[derive(PartialEq, Eq, Hash, Clone)]
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
mod text_system;
|
|
||||||
|
|
||||||
pub(crate) use text_system::*;
|
|
|
@ -1,6 +1,7 @@
|
||||||
mod dispatcher;
|
mod dispatcher;
|
||||||
mod headless;
|
mod headless;
|
||||||
mod platform;
|
mod platform;
|
||||||
|
mod text_system;
|
||||||
mod wayland;
|
mod wayland;
|
||||||
mod x11;
|
mod x11;
|
||||||
mod xdg_desktop_portal;
|
mod xdg_desktop_portal;
|
||||||
|
@ -8,5 +9,6 @@ mod xdg_desktop_portal;
|
||||||
pub(crate) use dispatcher::*;
|
pub(crate) use dispatcher::*;
|
||||||
pub(crate) use headless::*;
|
pub(crate) use headless::*;
|
||||||
pub(crate) use platform::*;
|
pub(crate) use platform::*;
|
||||||
|
pub(crate) use text_system::*;
|
||||||
pub(crate) use wayland::*;
|
pub(crate) use wayland::*;
|
||||||
pub(crate) use x11::*;
|
pub(crate) use x11::*;
|
||||||
|
|
|
@ -177,9 +177,6 @@ impl PlatformTextSystem for CosmicTextSystem {
|
||||||
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
|
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
|
||||||
self.0.write().layout_line(text, font_size, runs)
|
self.0.write().layout_line(text, font_size, runs)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
fn destroy(&self) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CosmicTextSystemState {
|
impl CosmicTextSystemState {
|
|
@ -49,7 +49,7 @@ impl TestPlatform {
|
||||||
let text_system = Arc::new(crate::platform::mac::MacTextSystem::new());
|
let text_system = Arc::new(crate::platform::mac::MacTextSystem::new());
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
let text_system = Arc::new(crate::platform::cosmic_text::CosmicTextSystem::new());
|
let text_system = Arc::new(crate::platform::linux::CosmicTextSystem::new());
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
let text_system = Arc::new(crate::platform::windows::DirectWriteTextSystem::new().unwrap());
|
let text_system = Arc::new(crate::platform::windows::DirectWriteTextSystem::new().unwrap());
|
||||||
|
|
|
@ -171,6 +171,11 @@ impl DirectWriteTextSystem {
|
||||||
font_id_by_identifier: HashMap::default(),
|
font_id_by_identifier: HashMap::default(),
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn destroy(&self) {
|
||||||
|
let mut lock = self.0.write();
|
||||||
|
unsafe { ManuallyDrop::drop(&mut lock.components.bitmap_factory) };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PlatformTextSystem for DirectWriteTextSystem {
|
impl PlatformTextSystem for DirectWriteTextSystem {
|
||||||
|
@ -239,11 +244,6 @@ impl PlatformTextSystem for DirectWriteTextSystem {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn destroy(&self) {
|
|
||||||
let mut lock = self.0.write();
|
|
||||||
unsafe { ManuallyDrop::drop(&mut lock.components.bitmap_factory) };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DirectWriteState {
|
impl DirectWriteState {
|
||||||
|
|
|
@ -49,7 +49,7 @@ pub(crate) struct WindowsPlatform {
|
||||||
icon: HICON,
|
icon: HICON,
|
||||||
background_executor: BackgroundExecutor,
|
background_executor: BackgroundExecutor,
|
||||||
foreground_executor: ForegroundExecutor,
|
foreground_executor: ForegroundExecutor,
|
||||||
text_system: Arc<dyn PlatformTextSystem>,
|
text_system: Arc<DirectWriteTextSystem>,
|
||||||
clipboard_hash_format: u32,
|
clipboard_hash_format: u32,
|
||||||
clipboard_metadata_format: u32,
|
clipboard_metadata_format: u32,
|
||||||
}
|
}
|
||||||
|
@ -90,13 +90,8 @@ impl WindowsPlatform {
|
||||||
let dispatcher = Arc::new(WindowsDispatcher::new());
|
let dispatcher = Arc::new(WindowsDispatcher::new());
|
||||||
let background_executor = BackgroundExecutor::new(dispatcher.clone());
|
let background_executor = BackgroundExecutor::new(dispatcher.clone());
|
||||||
let foreground_executor = ForegroundExecutor::new(dispatcher);
|
let foreground_executor = ForegroundExecutor::new(dispatcher);
|
||||||
let text_system = if let Some(direct_write) = DirectWriteTextSystem::new().log_err() {
|
let text_system =
|
||||||
log::info!("Using direct write text system.");
|
Arc::new(DirectWriteTextSystem::new().expect("Error creating DirectWriteTextSystem"));
|
||||||
Arc::new(direct_write) as Arc<dyn PlatformTextSystem>
|
|
||||||
} else {
|
|
||||||
log::info!("Using cosmic text system.");
|
|
||||||
Arc::new(CosmicTextSystem::new()) as Arc<dyn PlatformTextSystem>
|
|
||||||
};
|
|
||||||
let icon = load_icon().unwrap_or_default();
|
let icon = load_icon().unwrap_or_default();
|
||||||
let state = RefCell::new(WindowsPlatformState::new());
|
let state = RefCell::new(WindowsPlatformState::new());
|
||||||
let raw_window_handles = RwLock::new(SmallVec::new());
|
let raw_window_handles = RwLock::new(SmallVec::new());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue