You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically this means restricting window size to multiples of some defined size. X11 and OS X provide this feature. Windows doesn't seem to have support for this but it could be emulated with additional code. Not sure about Wayland.
This feature is probably only useful for terminal emulators like Alacritty. So is it worth to be added to the library?
At least for me, setting min and max dimensions to the same size simply creates an unresizable window. The desired behaviour would be the following: when increment size is for instance 20x10, allowed window sizes are 20x10, 40x10, 20x20, 40x20 etc.
I'm unable to find any list, but based on my experience, resize increments are set by many X11 terminal emulators and supported by many (stacking) window managers.
One related property that could also be supported is base size. It works something like this: window_width = base_width + x * width_inc. This is useful if the window has a toolbar or padding. Unfortunately only X11 seems to support it.
I added with_resize_increments(width_inc: i32, height_inc: i32) and with_base_size(base_width: i32, base_height: i32) to WindowBuilderExt. If you don't specify base size, it defaults to the window dimensions.
However base size should not default to the window dimensions because this basically sets the minimum size. Instead base size should not be set at all by default.
Activity
tomaka commentedon Feb 11, 2017
It should be possible already to set both the min and max dimensions to the same size.
siiptuo commentedon Feb 11, 2017
At least for me, setting min and max dimensions to the same size simply creates an unresizable window. The desired behaviour would be the following: when increment size is for instance 20x10, allowed window sizes are 20x10, 40x10, 20x20, 40x20 etc.
francesca64 commentedon Apr 24, 2018
I'd be more inclined to add this to
WinodwBuilderExtthan to try to emulate the feature on Windows, since that sounds like it could get messy easily.Do you know if X11's resize increments actually work? It might sound like a silly question, but it wouldn't surprise me if WM support is poor.
siiptuo commentedon Apr 24, 2018
I'm unable to find any list, but based on my experience, resize increments are set by many X11 terminal emulators and supported by many (stacking) window managers.
francesca64 commentedon Apr 25, 2018
Alright, thanks. This looks really easy to implement, so I can knock this out for both platforms after I finish the X11 refactor I'm working on.
siiptuo commentedon Apr 26, 2018
Sound great!
One related property that could also be supported is base size. It works something like this:
window_width = base_width + x * width_inc. This is useful if the window has a toolbar or padding. Unfortunately only X11 seems to support it.francesca64 commentedon Apr 30, 2018
X11 implementation on this branch: https://github.com/francesca64/winit/tree/x11-resize-inc
I added
with_resize_increments(width_inc: i32, height_inc: i32)andwith_base_size(base_width: i32, base_height: i32)toWindowBuilderExt. If you don't specify base size, it defaults to the window dimensions.siiptuo commentedon May 1, 2018
Thanks! This works as it should.
However base size should not default to the window dimensions because this basically sets the minimum size. Instead base size should not be set at all by default.
francesca64 commentedon May 2, 2018
Gotcha, I've corrected that. #494
You can expect this to be in the next release, though I still need to implement this on macOS.
macOS: Implement with_resize_increments
macOS: Implement with_resize_increments
macOS: Implement with_resize_increments
francesca64 commentedon May 15, 2018
macOS implementation: #519
(Sorry this took so long, considering how simple it was!)
macOS: Implement with_resize_increments
macOS: Implement with_resize_increments (#519)
Merge next back to dev branch (rust-windowing#305)
Cthutu commentedon Mar 20, 2024
Is this coming to Windows any time soon?
madsmtm commentedon Mar 20, 2024
Probably not, unless someone implements it.
You might be able to emulate it yourself by running
window.set_inner_size(...)inside of theResizedevent.Please open a new issue if you encounter problems with doing so.
Cthutu commentedon Mar 21, 2024
That's what I am trying out now and hoping (fingers crossed) that it will work. Just need to write the "calculate the actual size" routine!