collab ui: Fix notification windows on external monitors (#9817)
Sharing a project displays a notification (window) on every screen. Previously there was an issue with the positioning of windows on all screens except the primary screen. As you can see here:  Now:  @mikayla-maki and I also decided to refactor the `WindowOptions` a bit. Previously you could specify bounds which controlled the positioning and size of the window in the global coordinate space, while also providing a display id (which screen to show the window on). This can lead to unusual behavior because you could theoretically specify a global bound which does not even belong to the display id which was provided. Therefore we changed the api to this: ```rust struct WindowOptions { /// The bounds of the window in screen coordinates /// None -> inherit, Some(bounds) -> set bounds. pub bounds: Option<Bounds<DevicePixels>>, /// The display to create the window on, if this is None, /// the window will be created on the main display pub display_id: Option<DisplayId>, } ``` This lets you specify a display id, which maps to the screen where the window should be created and bounds relative to the upper left of the screen. Release Notes: - Fixed positioning of popup windows (e.g. when sharing a project) when using multiple external displays. --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
co-authored by
Conrad Irwin
parent
ffd698be14
commit
e272acd1bc
@@ -2,7 +2,7 @@ use std::fmt::Debug;
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{Bounds, DisplayId, GlobalPixels, PlatformDisplay, Size};
|
||||
use crate::{Bounds, DevicePixels, DisplayId, PlatformDisplay, Size};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct WaylandDisplay {}
|
||||
@@ -19,12 +19,12 @@ impl PlatformDisplay for WaylandDisplay {
|
||||
}
|
||||
|
||||
// todo(linux)
|
||||
fn bounds(&self) -> Bounds<GlobalPixels> {
|
||||
fn bounds(&self) -> Bounds<DevicePixels> {
|
||||
Bounds {
|
||||
origin: Default::default(),
|
||||
size: Size {
|
||||
width: GlobalPixels(1000f32),
|
||||
height: GlobalPixels(500f32),
|
||||
width: DevicePixels(1000),
|
||||
height: DevicePixels(500),
|
||||
},
|
||||
} // return some fake data so it doesn't panic
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::platform::linux::wayland::display::WaylandDisplay;
|
||||
use crate::platform::{PlatformAtlas, PlatformInputHandler, PlatformWindow};
|
||||
use crate::scene::Scene;
|
||||
use crate::{
|
||||
px, size, Bounds, GlobalPixels, Modifiers, Pixels, PlatformDisplay, PlatformInput, Point,
|
||||
px, size, Bounds, DevicePixels, Modifiers, Pixels, PlatformDisplay, PlatformInput, Point,
|
||||
PromptLevel, Size, WindowAppearance, WindowParams,
|
||||
};
|
||||
|
||||
@@ -274,7 +274,7 @@ impl HasDisplayHandle for WaylandWindow {
|
||||
|
||||
impl PlatformWindow for WaylandWindow {
|
||||
// todo(linux)
|
||||
fn bounds(&self) -> Bounds<GlobalPixels> {
|
||||
fn bounds(&self) -> Bounds<DevicePixels> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@ use anyhow::Result;
|
||||
use uuid::Uuid;
|
||||
use x11rb::{connection::Connection as _, xcb_ffi::XCBConnection};
|
||||
|
||||
use crate::{Bounds, DisplayId, GlobalPixels, PlatformDisplay, Size};
|
||||
use crate::{Bounds, DevicePixels, DisplayId, PlatformDisplay, Size};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct X11Display {
|
||||
x_screen_index: usize,
|
||||
bounds: Bounds<GlobalPixels>,
|
||||
bounds: Bounds<DevicePixels>,
|
||||
uuid: Uuid,
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ impl X11Display {
|
||||
bounds: Bounds {
|
||||
origin: Default::default(),
|
||||
size: Size {
|
||||
width: GlobalPixels(screen.width_in_pixels as f32),
|
||||
height: GlobalPixels(screen.height_in_pixels as f32),
|
||||
width: DevicePixels(screen.width_in_pixels as i32),
|
||||
height: DevicePixels(screen.height_in_pixels as i32),
|
||||
},
|
||||
},
|
||||
uuid: Uuid::from_bytes([0; 16]),
|
||||
@@ -37,7 +37,7 @@ impl PlatformDisplay for X11Display {
|
||||
Ok(self.uuid)
|
||||
}
|
||||
|
||||
fn bounds(&self) -> Bounds<GlobalPixels> {
|
||||
fn bounds(&self) -> Bounds<DevicePixels> {
|
||||
self.bounds
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#![allow(unused)]
|
||||
|
||||
use crate::{
|
||||
platform::blade::BladeRenderer, size, Bounds, GlobalPixels, Modifiers, Pixels, PlatformAtlas,
|
||||
platform::blade::BladeRenderer, size, Bounds, DevicePixels, Modifiers, Pixels, PlatformAtlas,
|
||||
PlatformDisplay, PlatformInput, PlatformInputHandler, PlatformWindow, Point, PromptLevel,
|
||||
Scene, Size, WindowAppearance, WindowOptions, WindowParams,
|
||||
};
|
||||
@@ -245,7 +245,7 @@ impl X11WindowState {
|
||||
x_window,
|
||||
callbacks: RefCell::new(Callbacks::default()),
|
||||
inner: RefCell::new(LinuxWindowInner {
|
||||
bounds: params.bounds.map(|v| v.0 as i32),
|
||||
bounds: params.bounds.map(|v| v.0),
|
||||
scale_factor: 1.0,
|
||||
renderer: BladeRenderer::new(gpu, gpu_extent),
|
||||
input_handler: None,
|
||||
@@ -325,12 +325,8 @@ impl X11WindowState {
|
||||
}
|
||||
|
||||
impl PlatformWindow for X11Window {
|
||||
fn bounds(&self) -> Bounds<GlobalPixels> {
|
||||
self.0
|
||||
.inner
|
||||
.borrow_mut()
|
||||
.bounds
|
||||
.map(|v| GlobalPixels(v as f32))
|
||||
fn bounds(&self) -> Bounds<DevicePixels> {
|
||||
self.0.inner.borrow_mut().bounds.map(|v| v.into())
|
||||
}
|
||||
|
||||
// todo(linux)
|
||||
|
||||
Reference in New Issue
Block a user