Skip to content

Setting resizable to false in window config should disable the maximize button #350

@rupakhetibinit

Description

@rupakhetibinit

Platform: Windows

Setting resizable to false in window config should disable the maximize button on the window, as seen in other higher level APIs like Raylib.

For the time being I just added this patch to my own fork which I'm using but ideally this should be
a) handled automatically (common convention is that the maximize button is disabled) or
b) given more control over how to handle through an API, like set_maximizable but that's gonna be even more confusing in my opinion.

I tested this with this patch, when the resizable flag is set to false, then the maximize button is disabled.
Works fine for windows but untested on other platforms.

diff --git a/crates/notan_winit/src/window.rs b/crates/notan_winit/src/window.rs
index e414a0d..a8c3760 100644
--- a/crates/notan_winit/src/window.rs
+++ b/crates/notan_winit/src/window.rs
@@ -7,7 +7,8 @@ use winit::dpi::{LogicalPosition, LogicalSize, PhysicalPosition};
 use winit::event_loop::EventLoop;
 use winit::window::Fullscreen::Borderless;
 use winit::window::{
-    CursorGrabMode, CursorIcon as WCursorIcon, Icon, Window, WindowBuilder, WindowLevel,
+    CursorGrabMode, CursorIcon as WCursorIcon, Icon, Window, WindowBuilder, WindowButtons,
+    WindowLevel,
 };
 
 pub struct WinitWindowBackend {
@@ -273,6 +274,10 @@ impl WinitWindowBackend {
                 &config.window_icon_data,
             ));
 
+        if !config.resizable {
+            builder = builder.with_enabled_buttons(!WindowButtons::MAXIMIZE);
+        }
+
         #[cfg(target_os = "windows")]
         {
             use winit::platform::windows::WindowBuilderExtWindows;

Great library. It's pretty easy to use. Love the out of the box wasm support. Thank you for your work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions