Detailed changes
@@ -4,9 +4,6 @@
mod app_menu;
mod keystroke;
-#[cfg(not(target_os = "macos"))]
-mod cosmic_text;
-
#[cfg(target_os = "linux")]
mod linux;
@@ -51,8 +48,6 @@ use uuid::Uuid;
pub use app_menu::*;
pub use keystroke::*;
-#[cfg(not(target_os = "macos"))]
-pub(crate) use cosmic_text::*;
#[cfg(target_os = "linux")]
pub(crate) use linux::*;
#[cfg(target_os = "macos")]
@@ -105,7 +100,6 @@ pub fn guess_compositor() -> &'static str {
}
}
-// todo("windows")
#[cfg(target_os = "windows")]
pub(crate) fn current_platform(_headless: bool) -> Rc<dyn Platform> {
Rc::new(WindowsPlatform::new())
@@ -413,8 +407,6 @@ pub(crate) trait PlatformTextSystem: Send + Sync {
raster_bounds: Bounds<DevicePixels>,
) -> Result<(Size<DevicePixels>, Vec<u8>)>;
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout;
- #[cfg(target_os = "windows")]
- fn destroy(&self);
}
#[derive(PartialEq, Eq, Hash, Clone)]
@@ -1,3 +0,0 @@
-mod text_system;
-
-pub(crate) use text_system::*;
@@ -1,6 +1,7 @@
mod dispatcher;
mod headless;
mod platform;
+mod text_system;
mod wayland;
mod x11;
mod xdg_desktop_portal;
@@ -8,5 +9,6 @@ mod xdg_desktop_portal;
pub(crate) use dispatcher::*;
pub(crate) use headless::*;
pub(crate) use platform::*;
+pub(crate) use text_system::*;
pub(crate) use wayland::*;
pub(crate) use x11::*;
@@ -177,9 +177,6 @@ impl PlatformTextSystem for CosmicTextSystem {
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
self.0.write().layout_line(text, font_size, runs)
}
-
- #[cfg(target_os = "windows")]
- fn destroy(&self) {}
}
impl CosmicTextSystemState {
@@ -49,7 +49,7 @@ impl TestPlatform {
let text_system = Arc::new(crate::platform::mac::MacTextSystem::new());
#[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")]
let text_system = Arc::new(crate::platform::windows::DirectWriteTextSystem::new().unwrap());
@@ -171,6 +171,11 @@ impl DirectWriteTextSystem {
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 {
@@ -239,11 +244,6 @@ impl PlatformTextSystem for DirectWriteTextSystem {
..Default::default()
})
}
-
- fn destroy(&self) {
- let mut lock = self.0.write();
- unsafe { ManuallyDrop::drop(&mut lock.components.bitmap_factory) };
- }
}
impl DirectWriteState {
@@ -49,7 +49,7 @@ pub(crate) struct WindowsPlatform {
icon: HICON,
background_executor: BackgroundExecutor,
foreground_executor: ForegroundExecutor,
- text_system: Arc<dyn PlatformTextSystem>,
+ text_system: Arc<DirectWriteTextSystem>,
clipboard_hash_format: u32,
clipboard_metadata_format: u32,
}
@@ -90,13 +90,8 @@ impl WindowsPlatform {
let dispatcher = Arc::new(WindowsDispatcher::new());
let background_executor = BackgroundExecutor::new(dispatcher.clone());
let foreground_executor = ForegroundExecutor::new(dispatcher);
- let text_system = if let Some(direct_write) = DirectWriteTextSystem::new().log_err() {
- log::info!("Using direct write text system.");
- Arc::new(direct_write) as Arc<dyn PlatformTextSystem>
- } else {
- log::info!("Using cosmic text system.");
- Arc::new(CosmicTextSystem::new()) as Arc<dyn PlatformTextSystem>
- };
+ let text_system =
+ Arc::new(DirectWriteTextSystem::new().expect("Error creating DirectWriteTextSystem"));
let icon = load_icon().unwrap_or_default();
let state = RefCell::new(WindowsPlatformState::new());
let raw_window_handles = RwLock::new(SmallVec::new());