Open new windows with a default size and position (#9204)
This PR changes GPUI to open windows with a default size and location, and to otherwise inherit from their spawning window. Note: The linux build now crashes on startup. Release Notes: - N/A --------- Co-authored-by: Nathan <nathan@zed.dev> Co-authored-by: Ezekiel Warren <zaucy@users.noreply.github.com>
This commit is contained in:
parent
9a2dceeea1
commit
e792c1a5c5
30 changed files with 443 additions and 347 deletions
|
@ -22,8 +22,8 @@ use crate::platform::linux::wayland::display::WaylandDisplay;
|
|||
use crate::platform::{PlatformAtlas, PlatformInputHandler, PlatformWindow};
|
||||
use crate::scene::Scene;
|
||||
use crate::{
|
||||
px, size, Bounds, Modifiers, Pixels, PlatformDisplay, PlatformInput, Point, PromptLevel, Size,
|
||||
WindowAppearance, WindowBounds, WindowOptions,
|
||||
px, size, Bounds, GlobalPixels, Modifiers, Pixels, PlatformDisplay, PlatformInput, Point,
|
||||
PromptLevel, Size, WindowAppearance, WindowParams,
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -125,24 +125,9 @@ impl WaylandWindowState {
|
|||
wl_surf: Arc<wl_surface::WlSurface>,
|
||||
viewport: Option<wp_viewport::WpViewport>,
|
||||
toplevel: Arc<xdg_toplevel::XdgToplevel>,
|
||||
options: WindowOptions,
|
||||
options: WindowParams,
|
||||
) -> Self {
|
||||
if options.bounds == WindowBounds::Maximized {
|
||||
toplevel.set_maximized();
|
||||
} else if options.bounds == WindowBounds::Fullscreen {
|
||||
toplevel.set_fullscreen(None);
|
||||
}
|
||||
|
||||
let bounds: Bounds<u32> = match options.bounds {
|
||||
WindowBounds::Fullscreen | WindowBounds::Maximized => Bounds {
|
||||
origin: Point::default(),
|
||||
size: Size {
|
||||
width: 500,
|
||||
height: 500,
|
||||
}, // todo(implement)
|
||||
},
|
||||
WindowBounds::Fixed(bounds) => bounds.map(|p| p.0 as u32),
|
||||
};
|
||||
let bounds = options.bounds.map(|p| p.0 as u32);
|
||||
|
||||
Self {
|
||||
surface: Arc::clone(&wl_surf),
|
||||
|
@ -290,8 +275,8 @@ impl HasDisplayHandle for WaylandWindow {
|
|||
|
||||
impl PlatformWindow for WaylandWindow {
|
||||
// todo(linux)
|
||||
fn bounds(&self) -> WindowBounds {
|
||||
WindowBounds::Maximized
|
||||
fn bounds(&self) -> Bounds<GlobalPixels> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn content_size(&self) -> Size<Pixels> {
|
||||
|
@ -331,9 +316,8 @@ impl PlatformWindow for WaylandWindow {
|
|||
crate::Modifiers::default()
|
||||
}
|
||||
|
||||
// todo(linux)
|
||||
fn as_any_mut(&mut self) -> &mut dyn Any {
|
||||
unimplemented!()
|
||||
self
|
||||
}
|
||||
|
||||
fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
|
||||
|
@ -379,13 +363,17 @@ impl PlatformWindow for WaylandWindow {
|
|||
}
|
||||
|
||||
fn toggle_full_screen(&self) {
|
||||
if !self.0.inner.borrow_mut().fullscreen {
|
||||
if !self.0.inner.borrow().fullscreen {
|
||||
self.0.toplevel.set_fullscreen(None);
|
||||
} else {
|
||||
self.0.toplevel.unset_fullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
fn is_full_screen(&self) -> bool {
|
||||
self.0.inner.borrow_mut().fullscreen
|
||||
}
|
||||
|
||||
fn on_request_frame(&self, callback: Box<dyn FnMut()>) {
|
||||
self.0.callbacks.borrow_mut().request_frame = Some(callback);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue