Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 25 additions & 31 deletions crates/processing_glfw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,21 +340,11 @@ impl GlfwContext {
self.window.focus();
}

#[cfg(all(target_os = "linux", feature = "wayland"))]
let frame_pos: Option<IVec2> = None;
#[cfg(not(all(target_os = "linux", feature = "wayland")))]
let frame_pos = {
let (cx, cy) = self.window.get_pos();
let (inset_l, inset_t, _, _) = self.window.get_frame_size();
Some(IVec2::new(cx - inset_l, cy - inset_t))
};

let frame_pos = self.frame_pos();
let _ = app_mut(|app| {
let world = app.world_mut();
if let Some(pos) = frame_pos
&& let Some(mut window) = world.get_mut::<BevyWindow>(surface)
{
window.position = WindowPosition::At(pos);
if let Some(mut window) = world.get_mut::<BevyWindow>(surface) {
window.position = WindowPosition::At(frame_pos);
}
if let Some(mut controls) = world.get_mut::<WindowControls>(surface) {
controls.pending_iconify = false;
Expand All @@ -364,9 +354,19 @@ impl GlfwContext {
}
Ok(())
});
if let Some(pos) = frame_pos {
self.last_applied.position = pos;
}
self.last_applied.position = frame_pos;
}

#[cfg(not(feature = "wayland"))]
fn frame_pos(&self) -> IVec2 {
let (cx, cy) = self.window.get_pos();
let (inset_l, inset_t, _, _) = self.window.get_frame_size();
IVec2::new(cx - inset_l, cy - inset_t)
}

#[cfg(feature = "wayland")]
fn frame_pos(&self) -> IVec2 {
self.last_applied.position
}

fn apply_window(&mut self, desired: &DesiredWindow) {
Expand All @@ -376,14 +376,12 @@ impl GlfwContext {
self.window.set_title(&desired.title);
last.title.clone_from(&desired.title);
}
#[cfg(not(feature = "wayland"))]
if let Some(pos) = desired.position
&& pos != last.position
{
#[cfg(not(all(target_os = "linux", feature = "wayland")))]
{
let (inset_l, inset_t, _, _) = self.window.get_frame_size();
self.window.set_pos(pos.x + inset_l, pos.y + inset_t);
}
let (inset_l, inset_t, _, _) = self.window.get_frame_size();
self.window.set_pos(pos.x + inset_l, pos.y + inset_t);
last.position = pos;
}
if desired.size != last.size && desired.size.x > 0 && desired.size.y > 0 {
Expand Down Expand Up @@ -429,12 +427,9 @@ impl GlfwContext {
match target {
Some(monitor_entity) => {
if self.last_applied.fullscreen_on.is_none() {
#[cfg(all(target_os = "linux", feature = "wayland"))]
let (x, y) = (0, 0);
#[cfg(not(all(target_os = "linux", feature = "wayland")))]
let (x, y) = self.window.get_pos();
let (w, h) = self.window.get_size();
self.windowed_geometry = Some((x, y, w as u32, h as u32));
let pos = self.frame_pos();
self.windowed_geometry = Some((pos.x, pos.y, w as u32, h as u32));
}
let target_name = monitor_name(monitor_entity);
let window = &mut self.window;
Expand All @@ -457,12 +452,9 @@ impl GlfwContext {
}
None => {
let (x, y, w, h) = self.windowed_geometry.take().unwrap_or_else(|| {
#[cfg(all(target_os = "linux", feature = "wayland"))]
let (x, y) = (0, 0);
#[cfg(not(all(target_os = "linux", feature = "wayland")))]
let (x, y) = self.window.get_pos();
let (w, h) = self.window.get_size();
(x, y, w as u32, h as u32)
let pos = self.frame_pos();
(pos.x, pos.y, w as u32, h as u32)
});
self.window
.set_monitor(WindowMode::Windowed, x, y, w, h, None);
Expand Down Expand Up @@ -497,6 +489,7 @@ impl GlfwContext {
#[derive(Clone, Debug)]
struct DesiredWindow {
title: String,
#[cfg(not(feature = "wayland"))]
position: Option<IVec2>,
size: bevy::math::UVec2,
visible: bool,
Expand Down Expand Up @@ -530,6 +523,7 @@ fn read_desired_window(surface: Entity) -> Option<DesiredWindow> {
};
Ok(Some(DesiredWindow {
title: window.title.clone(),
#[cfg(not(feature = "wayland"))]
position: match window.position {
WindowPosition::At(p) => Some(p),
_ => None,
Expand Down
1 change: 0 additions & 1 deletion crates/processing_render/src/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ pub fn destroy(
}
}

/// Update window size when resized.
pub fn resize(
In((window_entity, width, height)): In<(Entity, u32, u32)>,
mut windows: Query<&mut Window>,
Expand Down
Loading