Fix issues where screen and window sizes contained Pixels, but were declared as DevicePixels (#12991)
On most platforms, things were working correctly, but had the wrong type. On X11, there were some problems with window and display size calculations. Release Notes: - Fixed issues with window positioning on X11 --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com> Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
22dc88ed3d
commit
da281d6d8f
25 changed files with 331 additions and 367 deletions
|
@ -28,10 +28,10 @@ use futures::{
|
|||
};
|
||||
use gpui::{
|
||||
actions, canvas, impl_actions, point, relative, size, Action, AnyElement, AnyView, AnyWeakView,
|
||||
AppContext, AsyncAppContext, AsyncWindowContext, Bounds, DevicePixels, DragMoveEvent,
|
||||
Entity as _, EntityId, EventEmitter, FocusHandle, FocusableView, Global, KeyContext, Keystroke,
|
||||
ManagedView, Model, ModelContext, PathPromptOptions, Point, PromptLevel, Render, Size,
|
||||
Subscription, Task, View, WeakView, WindowBounds, WindowHandle, WindowOptions,
|
||||
AppContext, AsyncAppContext, AsyncWindowContext, Bounds, DragMoveEvent, Entity as _, EntityId,
|
||||
EventEmitter, FocusHandle, FocusableView, Global, KeyContext, Keystroke, ManagedView, Model,
|
||||
ModelContext, PathPromptOptions, Point, PromptLevel, Render, Size, Subscription, Task, View,
|
||||
WeakView, WindowBounds, WindowHandle, WindowOptions,
|
||||
};
|
||||
use item::{
|
||||
FollowableItem, FollowableItemHandle, Item, ItemHandle, ItemSettings, PreviewTabsSettings,
|
||||
|
@ -79,7 +79,7 @@ use theme::{ActiveTheme, SystemAppearance, ThemeSettings};
|
|||
pub use toolbar::{Toolbar, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView};
|
||||
pub use ui;
|
||||
use ui::{
|
||||
div, h_flex, Context as _, Div, FluentBuilder, InteractiveElement as _, IntoElement,
|
||||
div, h_flex, px, Context as _, Div, FluentBuilder, InteractiveElement as _, IntoElement,
|
||||
ParentElement as _, Pixels, SharedString, Styled as _, ViewContext, VisualContext as _,
|
||||
WindowContext,
|
||||
};
|
||||
|
@ -96,11 +96,11 @@ use crate::persistence::{
|
|||
use crate::{notifications::NotificationId, persistence::model::LocalPathsOrder};
|
||||
|
||||
lazy_static! {
|
||||
static ref ZED_WINDOW_SIZE: Option<Size<DevicePixels>> = env::var("ZED_WINDOW_SIZE")
|
||||
static ref ZED_WINDOW_SIZE: Option<Size<Pixels>> = env::var("ZED_WINDOW_SIZE")
|
||||
.ok()
|
||||
.as_deref()
|
||||
.and_then(parse_pixel_size_env_var);
|
||||
static ref ZED_WINDOW_POSITION: Option<Point<DevicePixels>> = env::var("ZED_WINDOW_POSITION")
|
||||
static ref ZED_WINDOW_POSITION: Option<Point<Pixels>> = env::var("ZED_WINDOW_POSITION")
|
||||
.ok()
|
||||
.as_deref()
|
||||
.and_then(parse_pixel_position_env_var);
|
||||
|
@ -3981,7 +3981,7 @@ impl Workspace {
|
|||
}
|
||||
}
|
||||
|
||||
fn window_bounds_env_override() -> Option<Bounds<DevicePixels>> {
|
||||
fn window_bounds_env_override() -> Option<Bounds<Pixels>> {
|
||||
ZED_WINDOW_POSITION
|
||||
.zip(*ZED_WINDOW_SIZE)
|
||||
.map(|(position, size)| Bounds {
|
||||
|
@ -5158,18 +5158,18 @@ pub fn reload(reload: &Reload, cx: &mut AppContext) {
|
|||
.detach_and_log_err(cx);
|
||||
}
|
||||
|
||||
fn parse_pixel_position_env_var(value: &str) -> Option<Point<DevicePixels>> {
|
||||
fn parse_pixel_position_env_var(value: &str) -> Option<Point<Pixels>> {
|
||||
let mut parts = value.split(',');
|
||||
let x: usize = parts.next()?.parse().ok()?;
|
||||
let y: usize = parts.next()?.parse().ok()?;
|
||||
Some(point((x as i32).into(), (y as i32).into()))
|
||||
Some(point(px(x as f32), px(y as f32)))
|
||||
}
|
||||
|
||||
fn parse_pixel_size_env_var(value: &str) -> Option<Size<DevicePixels>> {
|
||||
fn parse_pixel_size_env_var(value: &str) -> Option<Size<Pixels>> {
|
||||
let mut parts = value.split(',');
|
||||
let width: usize = parts.next()?.parse().ok()?;
|
||||
let height: usize = parts.next()?.parse().ok()?;
|
||||
Some(size((width as i32).into(), (height as i32).into()))
|
||||
Some(size(px(width as f32), px(height as f32)))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue