bevy/crates
Isse 82aa2e3161
Add the functions start_drag_move and start_drag_resize to Window (#15674)
# Objective
Expose the `winit` functions
[drag_window](https://docs.rs/winit/latest/winit/window/struct.Window.html#method.drag_window)
and
[resize_window](https://docs.rs/winit/latest/winit/window/struct.Window.html#method.drag_resize_window).

Which allows implementing move & resize for windows without decorations.

## Solution

Add the functions `start_drag_move` and `start_drag_resize` to
`bevy_window::Window`, which are then assigned to fields in
`InternalWindowState`, and propagated to `winit` in the
`changed_windows` system.

## Testing

I've tested that both functions works on x11 and wayland. Not sure if
someone needs to test on windows/mac?

---

## Showcase

[Screencast from 2024-10-06 11-49-58
(trimmed).webm](https://github.com/user-attachments/assets/1cdee7b1-22bd-41d3-8a0a-6872a6ebf62c)

(The flickering in the video is some issue with resizing without
decorations on x11)

<details>
  <summary>Click to view showcase</summary>

Not the same code used in the video, but simple way to test moving a
window without decorations.
```rust
use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins.set(WindowPlugin {
            primary_window: Some(Window {
                decorations: false,
                ..default()
            }),
            ..default()
        }))
        .add_systems(Update, move_windows)
        .run();
}

fn move_windows(mut windows: Query<&mut Window>, input: Res<ButtonInput<MouseButton>>) {
    if input.pressed(MouseButton::Left) {
        for mut window in windows.iter_mut() {
            window.start_drag_move();
        }
    }
}
```

</details>

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2024-10-08 16:32:07 +00:00
..
bevy_a11y Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_animation Fixes to animation graph evaluation (#15689) 2024-10-07 07:30:00 +00:00
bevy_app Documentation for variadics (#15387) 2024-10-02 12:48:36 +00:00
bevy_asset Fix doc comment (#15673) 2024-10-06 08:12:58 +00:00
bevy_audio Fix audio not playing (#15638) 2024-10-04 01:07:09 +00:00
bevy_color Eliminate redundant clamping from sample-interpolated curves (#15620) 2024-10-03 18:26:41 +00:00
bevy_core Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_core_pipeline Fix oit webgl (#15728) 2024-10-08 14:50:35 +00:00
bevy_derive move ANDROID_APP to bevy_window (#15585) 2024-10-02 03:01:06 +00:00
bevy_dev_tools Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
bevy_diagnostic Update sysinfo requirement from 0.31.0 to 0.32.0 (#15697) 2024-10-07 07:31:17 +00:00
bevy_dylib Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_ecs bevy_ecs: Replace panics in QueryData derive compile errors (#15691) 2024-10-07 16:30:34 +00:00
bevy_encase_derive Update `glam to 0.29, encase` to 0.10. (#15249) 2024-09-23 19:44:02 +00:00
bevy_gilrs Add some missing features from the gamepads-as-entities change that were needed to update leafwing-input-manager. (#15685) 2024-10-08 12:19:38 +00:00
bevy_gizmos Implement From translation and rotation for isometries (#15733) 2024-10-08 16:09:28 +00:00
bevy_gltf Feature-gate all image formats (#15586) 2024-10-07 16:37:45 +00:00
bevy_hierarchy Add more tools for traversing hierarchies (#15627) 2024-10-07 15:24:57 +00:00
bevy_image Feature-gate all image formats (#15586) 2024-10-07 16:37:45 +00:00
bevy_input Add some missing features from the gamepads-as-entities change that were needed to update leafwing-input-manager. (#15685) 2024-10-08 12:19:38 +00:00
bevy_internal Feature-gate all image formats (#15586) 2024-10-07 16:37:45 +00:00
bevy_log Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_macro_utils Modify derive_label to support no_std environments (#15465) 2024-09-27 20:23:26 +00:00
bevy_math Implement From translation and rotation for isometries (#15733) 2024-10-08 16:09:28 +00:00
bevy_mesh introduction of ConvexPolygon and ConvexPolygonMeshBuilder (#15544) 2024-10-08 15:02:38 +00:00
bevy_mikktspace Add no_std support to bevy_mikktspace (#15528) 2024-09-30 18:17:03 +00:00
bevy_pbr Fix oit webgl (#15728) 2024-10-08 14:50:35 +00:00
bevy_picking Rename the Pickable component and fix incorrect documentation (#15707) 2024-10-07 17:09:57 +00:00
bevy_ptr Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_reflect Serialize and deserialize tuple struct with one field as newtype struct (#15628) 2024-10-07 23:40:03 +00:00
bevy_remote Watching versions of bevy/get and bevy/list with HTTP SSE (#15608) 2024-10-08 16:21:46 +00:00
bevy_render Fix oit webgl (#15728) 2024-10-08 14:50:35 +00:00
bevy_scene Allow World::entity family of functions to take multiple entities and get multiple references back (#15614) 2024-10-07 15:21:40 +00:00
bevy_sprite Rename the Pickable component and fix incorrect documentation (#15707) 2024-10-07 17:09:57 +00:00
bevy_state Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_tasks bump async-channel to 2.3.0 (#15497) 2024-09-28 19:21:59 +00:00
bevy_text Fix text measurement when multiple font sizes are present (#15669) 2024-10-05 22:46:37 +00:00
bevy_time Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_transform Allow World::entity family of functions to take multiple entities and get multiple references back (#15614) 2024-10-07 15:21:40 +00:00
bevy_ui box shadow (#15204) 2024-10-08 16:26:17 +00:00
bevy_utils Minor fixes for bevy_utils in no_std (#15463) 2024-10-04 19:25:49 +00:00
bevy_window Add the functions start_drag_move and start_drag_resize to Window (#15674) 2024-10-08 16:32:07 +00:00
bevy_winit Add the functions start_drag_move and start_drag_resize to Window (#15674) 2024-10-08 16:32:07 +00:00