Skip to content

Programmatically resizing the window does not cause the layout to be recomputed #3156

@the10thWiz

Description

@the10thWiz

Is your issue REALLY a bug?

  • My issue is indeed a bug!
  • I am not crazy! I will not fill out this form just to ask a question or request a feature. Pinky promise.

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

When a window is resized programmatically (via iced::window::resize) the widget layout is not recomputed. Resizing the window with the mouse (using the native handles) does correctly recompute the layout.

Example code:

pub fn main() -> iced::Result {
    iced::application(Example::default, Example::update, Example::view)
        .run()
}

#[derive(Default)]
struct Example { }

#[derive(Debug, Clone, Copy)]
enum Message {
    ResizeWindow(Size),
}

impl Example {
    fn update(&mut self, message: Message) -> Task<Message> {
        match message {
            Message::ResizeWindow(size) => {
                return window::latest().and_then(move |id| window::resize(id, size));
            }
        }
        // Task::none()
    }

    fn view(&self) -> Element<'_, Message> {
        let content = column![
            button("Resize to 100x100").on_press(Message::ResizeWindow(Size::new(100., 100.))),
            button("Resize to 200x200").on_press(Message::ResizeWindow(Size::new(200., 200.))),
        ]
        .spacing(20);

        center(content).into()
    }
}

When run, resizing by grabbing the corner and dragging resizes as expected, but pressing either button resizes the window and just scales the contents without recomputing the layout.

Note: I'm on Arch Linux, using KDE + Wayland, so this issue might be specific to that setup.

What is the expected behavior?

I would expect the resize to recompute the layout for the new window size.

Version

master

Operating System

Linux

Do you have any log output?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions