mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-28 02:44:50 +03:00
Conform to wayland spec on resize (#13243)
Fixes https://github.com/zed-industries/zed/issues/10976 Release Notes: - N/A Co-authored-by: conrad <conrad@zed.dev>
This commit is contained in:
parent
17bc0d1b17
commit
d4891a62bb
@ -62,6 +62,12 @@ impl rwh::HasDisplayHandle for RawWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct InProgressConfigure {
|
||||||
|
size: Option<Size<Pixels>>,
|
||||||
|
fullscreen: bool,
|
||||||
|
maximized: bool,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct WaylandWindowState {
|
pub struct WaylandWindowState {
|
||||||
xdg_surface: xdg_surface::XdgSurface,
|
xdg_surface: xdg_surface::XdgSurface,
|
||||||
acknowledged_first_configure: bool,
|
acknowledged_first_configure: bool,
|
||||||
@ -85,6 +91,7 @@ pub struct WaylandWindowState {
|
|||||||
client: WaylandClientStatePtr,
|
client: WaylandClientStatePtr,
|
||||||
handle: AnyWindowHandle,
|
handle: AnyWindowHandle,
|
||||||
active: bool,
|
active: bool,
|
||||||
|
in_progress_configure: Option<InProgressConfigure>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -157,6 +164,7 @@ impl WaylandWindowState {
|
|||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
maximized: false,
|
maximized: false,
|
||||||
windowed_bounds: options.bounds,
|
windowed_bounds: options.bounds,
|
||||||
|
in_progress_configure: None,
|
||||||
client,
|
client,
|
||||||
appearance,
|
appearance,
|
||||||
handle,
|
handle,
|
||||||
@ -303,6 +311,31 @@ impl WaylandWindowStatePtr {
|
|||||||
pub fn handle_xdg_surface_event(&self, event: xdg_surface::Event) {
|
pub fn handle_xdg_surface_event(&self, event: xdg_surface::Event) {
|
||||||
match event {
|
match event {
|
||||||
xdg_surface::Event::Configure { serial } => {
|
xdg_surface::Event::Configure { serial } => {
|
||||||
|
{
|
||||||
|
let mut state = self.state.borrow_mut();
|
||||||
|
|
||||||
|
if let Some(mut configure) = state.in_progress_configure.take() {
|
||||||
|
let got_unmaximized = state.maximized && !configure.maximized;
|
||||||
|
state.fullscreen = configure.fullscreen;
|
||||||
|
state.maximized = configure.maximized;
|
||||||
|
|
||||||
|
if got_unmaximized {
|
||||||
|
configure.size = Some(state.windowed_bounds.size);
|
||||||
|
} else if !configure.fullscreen && !configure.maximized {
|
||||||
|
if let Some(size) = configure.size {
|
||||||
|
state.windowed_bounds = Bounds {
|
||||||
|
origin: Point::default(),
|
||||||
|
size,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
drop(state);
|
||||||
|
if let Some(size) = configure.size {
|
||||||
|
self.resize(size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
let mut state = self.state.borrow_mut();
|
let mut state = self.state.borrow_mut();
|
||||||
state.xdg_surface.ack_configure(serial);
|
state.xdg_surface.ack_configure(serial);
|
||||||
let request_frame_callback = !state.acknowledged_first_configure;
|
let request_frame_callback = !state.acknowledged_first_configure;
|
||||||
@ -360,25 +393,11 @@ impl WaylandWindowStatePtr {
|
|||||||
let maximized = states.contains(&(xdg_toplevel::State::Maximized as u8));
|
let maximized = states.contains(&(xdg_toplevel::State::Maximized as u8));
|
||||||
|
|
||||||
let mut state = self.state.borrow_mut();
|
let mut state = self.state.borrow_mut();
|
||||||
let got_unmaximized = state.maximized && !maximized;
|
state.in_progress_configure = Some(InProgressConfigure {
|
||||||
state.fullscreen = fullscreen;
|
size,
|
||||||
state.maximized = maximized;
|
fullscreen,
|
||||||
|
maximized,
|
||||||
if got_unmaximized {
|
});
|
||||||
size = Some(state.windowed_bounds.size);
|
|
||||||
} else if !fullscreen && !maximized {
|
|
||||||
if let Some(size) = size {
|
|
||||||
state.windowed_bounds = Bounds {
|
|
||||||
origin: Point::default(),
|
|
||||||
size,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
drop(state);
|
|
||||||
if let Some(size) = size {
|
|
||||||
self.resize(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -803,7 +803,7 @@ impl Workspace {
|
|||||||
.await;
|
.await;
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
if let Some(display) = cx.display() {
|
if let Some(display) = cx.display() {
|
||||||
if let Some(display_uuid) = display.uuid().log_err() {
|
if let Some(display_uuid) = display.uuid().ok() {
|
||||||
let window_bounds = cx.window_bounds();
|
let window_bounds = cx.window_bounds();
|
||||||
if let Some(database_id) = workspace_id {
|
if let Some(database_id) = workspace_id {
|
||||||
cx.background_executor()
|
cx.background_executor()
|
||||||
|
Loading…
Reference in New Issue
Block a user