Skip to content

Conversation

@kchibisov
Copy link
Member

This makes X11 and Wayland follow Windows and macOS, so the size of the
window could be set even though it has resizable attribute set to false.

Fixes #2242.

@kchibisov kchibisov requested a review from maroider April 9, 2022 23:14
@kchibisov
Copy link
Member Author

kchibisov commented Apr 9, 2022

@sourcebox would you mind testing this PR and tell whether it resolves your issue? I think it should resize the window now with set_inner_size.

Also, if you could send me a client to use for testing, I can test Wayland part, since I think you have something working already?

@sourcebox
Copy link

@kchibisov I just tested your PR and it works as expected so far. I'm typically not using winit directly but via egui. For testing I just modified the min_max_size example. Here's the full code:

use simple_logger::SimpleLogger;
use winit::{
    dpi::LogicalSize,
    event::{Event, WindowEvent},
    event_loop::{ControlFlow, EventLoop},
    window::WindowBuilder,
};

fn main() {
    SimpleLogger::new().init().unwrap();
    let event_loop = EventLoop::new();

    let window = WindowBuilder::new().build(&event_loop).unwrap();

    window.set_resizable(false);
    window.set_inner_size(LogicalSize::new(200.0, 200.0));

    event_loop.run(move |event, _, control_flow| {
        *control_flow = ControlFlow::Wait;
        println!("{:?}", event);

        match event {
            Event::WindowEvent {
                event: WindowEvent::CloseRequested,
                ..
            } => *control_flow = ControlFlow::Exit,
            Event::WindowEvent {
                event: WindowEvent::KeyboardInput { .. },
                ..
            } => {
                window.set_inner_size(LogicalSize::new(550.0, 550.0));
            }
            _ => (),
        }
    });
}

With your patch, window.set_inner_size() changes the dimensions accordingly, both on initialization and within the event loop when pressing a key.

@kchibisov kchibisov added this to the Version 0.27 milestone Apr 11, 2022
@msiglreith msiglreith added DS - x11 Affects the X11 backend, or generally free Unix platforms DS - wayland Affects the Wayland backend, or generally free Unix platforms labels Apr 13, 2022
This makes X11 and Wayland follow Windows and macOS, so the size of the
window could be set even though it has resizable attribute set to false.

Fixes rust-windowing#2242.
@kchibisov kchibisov merged commit ce890c3 into rust-windowing:master Apr 24, 2022
@kchibisov kchibisov deleted the min-max-size branch April 24, 2022 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DS - wayland Affects the Wayland backend, or generally free Unix platforms DS - x11 Affects the X11 backend, or generally free Unix platforms

Development

Successfully merging this pull request may close these issues.

Behaviour of resizable is different across platforms

3 participants