Pull app / OS info out of GPUI, add Linux information, make fallible window initialization (#12869)
TODO: - [x] Finish GPUI changes on other operating systems This is a largely internal change to how we report data to our diagnostics and telemetry. This PR also includes an update to our blade backend which allows us to report errors in a more useful way when failing to initialize blade. Release Notes: - N/A --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
ec9e700e70
commit
80c14c9198
50 changed files with 571 additions and 550 deletions
|
@ -70,6 +70,19 @@ pub(crate) fn current_platform() -> Rc<dyn Platform> {
|
|||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
pub(crate) fn current_platform() -> Rc<dyn Platform> {
|
||||
match guess_compositor() {
|
||||
"Wayland" => Rc::new(WaylandClient::new()),
|
||||
"X11" => Rc::new(X11Client::new()),
|
||||
"Headless" => Rc::new(HeadlessClient::new()),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return which compositor we're guessing we'll use.
|
||||
/// Does not attempt to connect to the given compositor
|
||||
#[cfg(target_os = "linux")]
|
||||
#[inline]
|
||||
pub fn guess_compositor() -> &'static str {
|
||||
let wayland_display = std::env::var_os("WAYLAND_DISPLAY");
|
||||
let x11_display = std::env::var_os("DISPLAY");
|
||||
|
||||
|
@ -77,13 +90,14 @@ pub(crate) fn current_platform() -> Rc<dyn Platform> {
|
|||
let use_x11 = x11_display.is_some_and(|display| !display.is_empty());
|
||||
|
||||
if use_wayland {
|
||||
Rc::new(WaylandClient::new())
|
||||
"Wayland"
|
||||
} else if use_x11 {
|
||||
Rc::new(X11Client::new())
|
||||
"X11"
|
||||
} else {
|
||||
Rc::new(HeadlessClient::new())
|
||||
"Headless"
|
||||
}
|
||||
}
|
||||
|
||||
// todo("windows")
|
||||
#[cfg(target_os = "windows")]
|
||||
pub(crate) fn current_platform() -> Rc<dyn Platform> {
|
||||
|
@ -106,14 +120,12 @@ pub(crate) trait Platform: 'static {
|
|||
fn displays(&self) -> Vec<Rc<dyn PlatformDisplay>>;
|
||||
fn primary_display(&self) -> Option<Rc<dyn PlatformDisplay>>;
|
||||
fn active_window(&self) -> Option<AnyWindowHandle>;
|
||||
fn can_open_windows(&self) -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn open_window(
|
||||
&self,
|
||||
handle: AnyWindowHandle,
|
||||
options: WindowParams,
|
||||
) -> Box<dyn PlatformWindow>;
|
||||
) -> anyhow::Result<Box<dyn PlatformWindow>>;
|
||||
|
||||
/// Returns the appearance of the application's windows.
|
||||
fn window_appearance(&self) -> WindowAppearance;
|
||||
|
@ -143,9 +155,9 @@ pub(crate) trait Platform: 'static {
|
|||
fn on_will_open_app_menu(&self, callback: Box<dyn FnMut()>);
|
||||
fn on_validate_app_menu_command(&self, callback: Box<dyn FnMut(&dyn Action) -> bool>);
|
||||
|
||||
fn os_name(&self) -> &'static str;
|
||||
fn os_version(&self) -> Result<SemanticVersion>;
|
||||
fn app_version(&self) -> Result<SemanticVersion>;
|
||||
fn compositor_name(&self) -> &'static str {
|
||||
""
|
||||
}
|
||||
fn app_path(&self) -> Result<PathBuf>;
|
||||
fn local_timezone(&self) -> UtcOffset;
|
||||
fn path_for_auxiliary_executable(&self, name: &str) -> Result<PathBuf>;
|
||||
|
@ -288,19 +300,6 @@ pub(crate) trait PlatformTextSystem: Send + Sync {
|
|||
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout;
|
||||
}
|
||||
|
||||
/// Basic metadata about the current application and operating system.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct AppMetadata {
|
||||
/// The name of the current operating system
|
||||
pub os_name: &'static str,
|
||||
|
||||
/// The operating system's version
|
||||
pub os_version: Option<SemanticVersion>,
|
||||
|
||||
/// The current version of the application
|
||||
pub app_version: Option<SemanticVersion>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Hash, Clone)]
|
||||
pub(crate) enum AtlasKey {
|
||||
Glyph(RenderGlyphParams),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue