Skip to content

set_maximized(true) ignores window maximum size when decorations is set to false #464

Open
@lucasfernog

Description

@lucasfernog

The set_maximized API sets the window to have the full monitor size even when a maximum size is set. This issue only happens when the decorations are disabled. Here's an example to reproduce it:

use tao::{
  event::{ElementState, Event, KeyEvent, WindowEvent},
  event_loop::{ControlFlow, EventLoop},
  keyboard::Key,
  window::WindowBuilder,
};

fn main() {
  env_logger::init();
  let event_loop = EventLoop::new();

  let window = WindowBuilder::new()
    .with_title("Hello world!")
    .with_decorations(false)
    .with_max_inner_size(tao::dpi::LogicalSize::new(500.0, 500.0))
    .build(&event_loop)
    .unwrap();

  event_loop.run(move |event, _, control_flow| {
    *control_flow = ControlFlow::Wait;

    match event {
      Event::WindowEvent { event, .. } => match event {
        WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
        WindowEvent::KeyboardInput {
          event:
            KeyEvent {
              logical_key,
              state: ElementState::Pressed,
              ..
            },
          ..
        } => {
          if Key::Character("m") == logical_key {
            let is_maximized = window.is_maximized();
            window.set_maximized(!is_maximized);
          }
        }
        _ => (),
      },
      _ => {}
    }
  });
}

Just run it and press m to call set_maximized(true). You'll see the window resizing to the monitor size, when it should be constrained by the maximum size. It works if you remove the with_decorations(false) line.

This seems like a regression from the last release, @parker-codes said it used to work.

Found it on macOS.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    📬Proposal

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions