Minimum size for resizable window

Hi, everyone. Is there any way to specify minimal window size for resizable
windows created with SDL_WINDOW_RESIZABLE flag?
Thanks in advance.

upOn Thu, Nov 15, 2012 at 4:10 PM, Alexey Petruchik wrote:

Hi, everyone. Is there any way to specify minimal window size for
resizable windows created with SDL_WINDOW_RESIZABLE flag?
Thanks in advance.

Quoth Alexey Petruchik , on 2012-11-17 16:41:26 +0300:

up

Stop that!

—> Drake Wilson

Still looking for answer. “No it is not currently implemented” would be
enough for me. Answer questions and nobody will up them.

2012/11/17 Drake Wilson > Quoth Alexey Petruchik , on 2012-11-17 16:41:26 +0300:

up

Stop that!

—> Drake Wilson


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Quoth Alexey Petruchik , on 2012-11-17 19:39:22 +0300:

Still looking for answer. “No it is not currently implemented” would be
enough for me. Answer questions and nobody will up them.

The general mailing list does not have guaranteed service levels and
you have no privilege to make such demands. I certainly don’t
remember subscribing to “meaningless one-word thread bumps that take
no effort for the original poster but badger everyone until an answer
is given”.

All you’ve done from my perspective is ensure that any further mail
from you gets immediately incinerated here. “Good day, sir.”

—> Drake Wilson

While others are busy incinerating emails I decided to make SDL a bit
better and implement missing feature myself. Here is my initial OS X and
Windows implementation of SetWindowMinimumSize() -
https://stopiccot at bitbucket.org/stopiccot/sdl2. Although it works fine for
me in my simple test app I’m not sure that my changes do not break
something (especially on Windows). So it would be great if somebody could
review changes and test them. Also there is no X11 implementation of this
feature because Linux if something very far for me. It would be awesome to
see somebody implementing this feature for X11.

Regards, Alexey.On Sat, Nov 17, 2012 at 7:39 PM, Alexey Petruchik wrote:

Still looking for answer. “No it is not currently implemented” would be
enough for me. Answer questions and nobody will up them.

2012/11/17 Drake Wilson

Quoth Alexey Petruchik , on 2012-11-17 16:41:26 +0300:

up

Stop that!

—> Drake Wilson


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I’d say if window manager tells your app that its window should be of
WxH size, it better listen, or else.

Windows stretching beyond screen without any means to resize them are
just begging for an xkill or equivalent to be brought upon them.

I think the whole point of this function is to prevent the window from
becoming so small it’s unusable.

2012/11/18 Alexander Sabourenkov :> I’d say if window manager tells your app that its window should be of

WxH size, it better listen, or else.

Windows stretching beyond screen without any means to resize them are
just begging for an xkill or equivalent to be brought upon them.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Point is, the code can’t and won’t know what the reasonable minimum
size is on the box it’s currently running on. I’ve had enough of this
with (non-SDL) apps having to be killed anf then apt-get purged
because they didn’t expect 800x600 portable projector instead of
3840x1080 desktop.

If the window manager allows a window to be resized so small that it
can’t be resized aftewards to a reasonable size, then it’s a bug in
the window manager.

If the application expects its window to be less than certain size to
function, then please put up a message to that effect when it gets
resized below that size.

If the application insists on its window being of some arbitrary size
irrespective of window manager’s and thus user’s wishes to the
contrary, then it’s a bug in the application.

I was thinking more about sizes so small that one wonders what was the
user thinking on when trying that. I recall that one of the programs
that comes with Windows (Notepad?) wouldn’t let me shrink it below
certain size. Said size was so small the menubar was spawning like
three rows (or more, can’t remember well right now) and there was
barely enough space left for a single line of text (vertically).

I think that’s what he’s arguing for.

2012/11/18 Alexander Sabourenkov :> Point is, the code can’t and won’t know what the reasonable minimum

size is on the box it’s currently running on. I’ve had enough of this
with (non-SDL) apps having to be killed anf then apt-get purged
because they didn’t expect 800x600 portable projector instead of
3840x1080 desktop.

If the window manager allows a window to be resized so small that it
can’t be resized aftewards to a reasonable size, then it’s a bug in
the window manager.

If the application expects its window to be less than certain size to
function, then please put up a message to that effect when it gets
resized below that size.

If the application insists on its window being of some arbitrary size
irrespective of window manager’s and thus user’s wishes to the
contrary, then it’s a bug in the application.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

A similar idea would be to tell SDL to maintain a specific aspect ratio,
which would be useful for 3D games where you don’t want the user to make
the screen to wide they can see behind them. But anyway, what’s wrong with
doing something in your own code like:

if (event.type == RESIZE)
resize_back_to_the_ultimate_resolution();

in your event loop?On 18 November 2012 23:18, Alexander Sabourenkov wrote:

Point is, the code can’t and won’t know what the reasonable minimum
size is on the box it’s currently running on. I’ve had enough of this
with (non-SDL) apps having to be killed anf then apt-get purged
because they didn’t expect 800x600 portable projector instead of
3840x1080 desktop.

If the window manager allows a window to be resized so small that it
can’t be resized aftewards to a reasonable size, then it’s a bug in
the window manager.

If the application expects its window to be less than certain size to
function, then please put up a message to that effect when it gets
resized below that size.

If the application insists on its window being of some arbitrary size
irrespective of window manager’s and thus user’s wishes to the
contrary, then it’s a bug in the application.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

In my opinion having window resizable in some sane limits is better than
having not resizable at all. And if window managers expose functions to
declare minimal window size why not to use it? It’s better to have handy
SDL function than coding hacks through obtaining native window handle from
SDL. Any thoughts about the code?On Mon, Nov 19, 2012 at 3:47 AM, Sik the hedgehog < sik.the.hedgehog at gmail.com> wrote:

I was thinking more about sizes so small that one wonders what was the
user thinking on when trying that. I recall that one of the programs
that comes with Windows (Notepad?) wouldn’t let me shrink it below
certain size. Said size was so small the menubar was spawning like
three rows (or more, can’t remember well right now) and there was
barely enough space left for a single line of text (vertically).

I think that’s what he’s arguing for.

2012/11/18 Alexander Sabourenkov :

Point is, the code can’t and won’t know what the reasonable minimum
size is on the box it’s currently running on. I’ve had enough of this
with (non-SDL) apps having to be killed anf then apt-get purged
because they didn’t expect 800x600 portable projector instead of
3840x1080 desktop.

If the window manager allows a window to be resized so small that it
can’t be resized aftewards to a reasonable size, then it’s a bug in
the window manager.

If the application expects its window to be less than certain size to
function, then please put up a message to that effect when it gets
resized below that size.

If the application insists on its window being of some arbitrary size
irrespective of window manager’s and thus user’s wishes to the
contrary, then it’s a bug in the application.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I can see that looking really weird as the window constantly toggles
between the size the user is trying to set and the size the program
wants to use (only an issue when the user is actively resizing the
window and the window manager constantly resizes the window to match,
but still).

Also back on the topic of the function, probably there should be a big
warning in the documentation advising against using it for any sizes
that aren’t really small (if the size is above 100px you probably
should reconsider what you’re doing).

2012/11/18 Robin Kaup <k.robin64 at gmail.com>:> A similar idea would be to tell SDL to maintain a specific aspect ratio,

which would be useful for 3D games where you don’t want the user to make the
screen to wide they can see behind them. But anyway, what’s wrong with doing
something in your own code like:

if (event.type == RESIZE)
resize_back_to_the_ultimate_resolution();

in your event loop?

On 18 November 2012 23:18, Alexander Sabourenkov wrote:

Point is, the code can’t and won’t know what the reasonable minimum
size is on the box it’s currently running on. I’ve had enough of this
with (non-SDL) apps having to be killed anf then apt-get purged
because they didn’t expect 800x600 portable projector instead of
3840x1080 desktop.

If the window manager allows a window to be resized so small that it
can’t be resized aftewards to a reasonable size, then it’s a bug in
the window manager.

If the application expects its window to be less than certain size to
function, then please put up a message to that effect when it gets
resized below that size.

If the application insists on its window being of some arbitrary size
irrespective of window manager’s and thus user’s wishes to the
contrary, then it’s a bug in the application.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I don’t know anything about the Windows or OS X API, so I can’t comment on
that. I’m only worried about what should happen on systems where minimum
window sizes are not available. I can only think of two solutions: either
use the hack I mentioned above on those systems but from within SDL itself,
or have SDL_SetMinimumWindowSize() return -1 when it’s not possible.On 19 November 2012 01:32, Alexey Petruchik wrote:

In my opinion having window resizable in some sane limits is better than
having not resizable at all. And if window managers expose functions to
declare minimal window size why not to use it? It’s better to have handy
SDL function than coding hacks through obtaining native window handle from
SDL. Any thoughts about the code?

On Mon, Nov 19, 2012 at 3:47 AM, Sik the hedgehog < sik.the.hedgehog at gmail.com> wrote:

I was thinking more about sizes so small that one wonders what was the
user thinking on when trying that. I recall that one of the programs
that comes with Windows (Notepad?) wouldn’t let me shrink it below
certain size. Said size was so small the menubar was spawning like
three rows (or more, can’t remember well right now) and there was
barely enough space left for a single line of text (vertically).

I think that’s what he’s arguing for.

2012/11/18 Alexander Sabourenkov :

Point is, the code can’t and won’t know what the reasonable minimum
size is on the box it’s currently running on. I’ve had enough of this
with (non-SDL) apps having to be killed anf then apt-get purged
because they didn’t expect 800x600 portable projector instead of
3840x1080 desktop.

If the window manager allows a window to be resized so small that it
can’t be resized aftewards to a reasonable size, then it’s a bug in
the window manager.

If the application expects its window to be less than certain size to
function, then please put up a message to that effect when it gets
resized below that size.

If the application insists on its window being of some arbitrary size
irrespective of window manager’s and thus user’s wishes to the
contrary, then it’s a bug in the application.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I don’t know anything about the Windows or OS X API, so I can’t comment
on that.

Win32 can use WM_GETMINMAXINFO.

Mac OS X can use -[NSWindow setContentMinSize] (and MaxSize).

X11 has window “size hints” which the Window Manager (probably) respects.

BeOS and Haiku have BWindow::SetSizeLimits().

An SDL_SetWindowMinMaxSize() API could be interesting. It can just fail
on things like iOS and Android, but I think all platforms that support
resizable windows supports this functionality.

–ryan.

I pushed a couple of patches that implement setting the minimum size on OSX
and Win32 for iteration. In general if you’re setting a minimum size, do
you also want to set the maximum size? And vice versa?On Thu, Nov 22, 2012 at 10:38 AM, Ryan C. Gordon wrote:

I don’t know anything about the Windows or OS X API, so I can’t comment

on that.

Win32 can use WM_GETMINMAXINFO.

Mac OS X can use -[NSWindow setContentMinSize] (and MaxSize).

X11 has window “size hints” which the Window Manager (probably) respects.

BeOS and Haiku have BWindow::SetSizeLimits().

An SDL_SetWindowMinMaxSize() API could be interesting. It can just fail on
things like iOS and Android, but I think all platforms that support
resizable windows supports this functionality.

–ryan.

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Do all of those platforms also have a way of preserving aspect ratio in
resize?On Thu, Nov 22, 2012 at 10:38 AM, Ryan C. Gordon wrote:

I don’t know anything about the Windows or OS X API, so I can’t comment

on that.

Win32 can use WM_GETMINMAXINFO.

Mac OS X can use -[NSWindow setContentMinSize] (and MaxSize).

X11 has window “size hints” which the Window Manager (probably) respects.

BeOS and Haiku have BWindow::SetSizeLimits().

An SDL_SetWindowMinMaxSize() API could be interesting. It can just fail on
things like iOS and Android, but I think all platforms that support
resizable windows supports this functionality.

–ryan.

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

No, because generally you set the minimum size to ensure the UI can
fit within the window in a reasonably usable state (a maximum size
doesn’t make any sense since the UI would always have enough room in
such a case - at worst it’ll be too spaced, but not unusable).

2012/11/22 Sam Lantinga :> I pushed a couple of patches that implement setting the minimum size on OSX

and Win32 for iteration. In general if you’re setting a minimum size, do
you also want to set the maximum size? And vice versa?

On Thu, Nov 22, 2012 at 10:38 AM, Ryan C. Gordon wrote:

I don’t know anything about the Windows or OS X API, so I can’t comment
on that.

Win32 can use WM_GETMINMAXINFO.

Mac OS X can use -[NSWindow setContentMinSize] (and MaxSize).

X11 has window “size hints” which the Window Manager (probably) respects.

BeOS and Haiku have BWindow::SetSizeLimits().

An SDL_SetWindowMinMaxSize() API could be interesting. It can just fail on
things like iOS and Android, but I think all platforms that support
resizable windows supports this functionality.

–ryan.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I pushed a couple of patches that implement setting the minimum size on
OSX and Win32 for iteration. In general if you’re setting a minimum
size, do you also want to set the maximum size? And vice versa?

Mostly, I don’t think both are required (in fact, you could have a great
reason to set a minimum, and not care about maximum).

For Windows, you can leave the defaults in the MINMAXINFO struct.

For Cocoa, just don’t call the method you don’t care about.

For BeOS/Haiku, You can probably just specify the screen size for the
maximum, or query the values with BWindow::GetSizeLimits() at startup.

For X11, don’t set the PMinSize or PMaxSize bits in the XSizeHints struct.

I wouldn’t count on any automatic aspect ratio handling; you’d probably
have to handle that yourself on all platforms.

–ryan.

I wouldn’t count on any automatic aspect ratio handling; you’d probably
have to handle that yourself on all platforms.

I did a little research, and X11 supports this through window hints
(whatever they are exactly I don’t know, I’m not getting deep into ugly X11
stuff). It looks like it’s up to the window manager whether it obeys them,
which I suppose complicates things.On 22 November 2012 23:25, Ryan C. Gordon wrote:

I pushed a couple of patches that implement setting the minimum size on

OSX and Win32 for iteration. In general if you’re setting a minimum
size, do you also want to set the maximum size? And vice versa?

Mostly, I don’t think both are required (in fact, you could have a great
reason to set a minimum, and not care about maximum).

For Windows, you can leave the defaults in the MINMAXINFO struct.

For Cocoa, just don’t call the method you don’t care about.

For BeOS/Haiku, You can probably just specify the screen size for the
maximum, or query the values with BWindow::GetSizeLimits() at startup.

For X11, don’t set the PMinSize or PMaxSize bits in the XSizeHints struct.

I wouldn’t count on any automatic aspect ratio handling; you’d probably
have to handle that yourself on all platforms.

–ryan.

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org