bevyengine / bevyengine/bevy

Window location out of sync with winit when moved outside screen

Open
#17,576 1 comment 0 reactions 0 assignees View on GitHub
A-Windowing C-Bug S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## In short

When programmatically moving or defining windows outside the screen or over the gnome top bar they are moved automatically by the window manager which is good. However internally in bevy that move is not applied and window position is out of sync.

## Bevy version

`bevy = "0.15.1"`

## \[Optional\] Relevant system information

```
AdapterInfo { name: "AMD Radeon RX 7600 (RADV NAVI33)", vendor: 4098, device: 29824, device_type: DiscreteGpu, driver: "radv", driver_info: "Mesa 24.2.3-1ubuntu1", backend: Vulkan }
```

Forcing X11 (XWayland) as there is no such thing as window positioning in Wayland (for now)
Ubuntu Gnome

## What you did

```rust
fn move_all_windows_on_arrow_keys(
mut keyboard_input: EventReader,
mut window_query: Query<(Entity, &mut Window)>,
mut app_exit_event_writer: EventWriter,
) {
for event in keyboard_input.read() {
let mut move_x = 0;
let mut move_y = 0;
match event.key_code {
KeyCode::ArrowLeft => move_x = -10,
KeyCode::ArrowRight => move_x = 10,
KeyCode::ArrowUp => move_y = -10,
KeyCode::ArrowDown => move_y = 10,
KeyCode::Escape => {
app_exit_event_writer.send(AppExit::Success);
},
_ => {}
}

if move_x != 0 || move_y != 0 {
for (_, mut window) in window_query.iter_mut() {
if let WindowPosition::At(position) = window.position {
window.position = WindowPosition::At(position + IVec2::new(move_x, move_y));
}
}
}
}
}
```

## What went wrong

Start with a window at 0,0

* Move window up 10
The window stays at 0,0 on screen
The internal position is not synced with the real position (stays at 0,-10)
No WindowMoved event is fired.

* Move window down by 10
The window stays at 0,0 on screen
No WindowMoved event is fired.

* Move window down by 10
The window moves to 0,10 on screen
WindowMoved event is fired.

So the window y goes negative and once it is positive again the window start moving again

This differs to the behavior in winit. There a move to a negative y will keep the window at y 0.

bevy: up, up, up, down -> window on screen at 0,0 / bevy window position 0,-20
winit: up, up, up, down -> window on screen at 0,10

Same happens on the x axis.

Contributor guide

Open the contributing guide

Research direction

Reproduce the provided arrow-key example on Ubuntu GNOME using X11/XWayland, then compare Bevy's Window position and WindowMoved events with winit's behavior when a window is moved beyond the screen edge. Trace the window-position synchronization path; done means the internally reported position and movement events reflect the window manager's adjusted position.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.