I’m trying to limit the size of the window that a user can resize it to.
Would someone mind pointing out why the code below doesn’t seem to do
this? The user is still able to stretch the window to any size desired.
Thanks,
Aaron
#include #include <stdlib.h> #include <SDL/SDL.h>
using namespace std;
int
main (int argc, char *argv[])
{ //Our main program
SDL_Surface *screen;
SDL_Event event; //Events
bool done = false; //Not done before we’ve started…
if (SDL_Init (SDL_INIT_VIDEO) < 0)
{ //Could we start SDL_VIDEO?
std::cerr << “Couldn’t init SDL”; //Nope, output to stderr and quit
exit (1);
}
atexit (SDL_Quit); //Now that we’re enabled, make sure we cleanup
if (!screen)
{ //Couldn’t create window?
std::cerr << “Couldn’t create screen”; //Output to stderr and quit
exit (1);
}
while (!done)
{ //While program isn’t done
while (SDL_PollEvent (&event))
{ //Poll events
switch (event.type)
{ //Check event type
case SDL_QUIT: //User hit the X (or equivelent)
done = true; //Make the loop end
break; //We handled the event
case SDL_VIDEORESIZE: //User resized window
if(event.resize.w < 800 && event.resize.h < 800) {
screen = SDL_SetVideoMode (event.resize.w, event.resize.h, 32,
SDL_HWSURFACE | SDL_RESIZABLE); // Create new window
}else {
screen = SDL_SetVideoMode (800, 800, 32, SDL_HWSURFACE |
SDL_RESIZABLE); // Create new window
cout << " request to big!" << endl;
}
break; //Event handled, fetch next
} //Finished with current event
} //Done with all events for now
} //Program done, exited
}–
Aaron O. Rosen
Masters Student - Network Communication
306B Fluor Daniel
I’m trying to limit the size of the window that a user can resize it to.
Would someone mind pointing out why the code below doesn’t seem to do
this? The user is still able to stretch the window to any size desired.
Here’s the resize code (attached wrong file before).On Wed, Dec 14, 2011 at 10:42 AM, Aaron Rosen <@Aaron_Rosen> wrote:
Yea that’s now it. It still allows you to resize past 800. Before it was
trigged if both were greater than 800 now only one has to be greater than
800.
On Wed, Dec 14, 2011 at 9:55 AM, Alex Barry <alex.barry at gmail.com> wrote:
Yea that’s now it. It still allows you to resize past 800. Before it was
trigged if both were greater than 800 now only one has to be greater than
800.On Wed, Dec 14, 2011 at 9:55 AM, Alex Barry <alex.barry at gmail.com> wrote:
Now that I think about it, it should be && rather than ||, and it should be
working. I’m guessing the issue here is that linux is firing a resize
event when you actually resize the window. Try changing the if statement
to this:
This will only limit the resizing if it’s over the limit, as i believe the
window resize event changes the video mode internally, so when you were
setting the size, it may have just caught in an infinite loop rather than a
resize issue.
I hope that helps,
-AlexOn Wed, Dec 14, 2011 at 10:43 AM, Aaron Rosen wrote:
Here’s the resize code (attached wrong file before).
On Wed, Dec 14, 2011 at 10:42 AM, Aaron Rosen wrote:
Yea that’s now it. It still allows you to resize past 800. Before it was
trigged if both were greater than 800 now only one has to be greater than
800.
On Wed, Dec 14, 2011 at 9:55 AM, Alex Barry <@Alex_Barry> wrote:
AaronOn Wed, Dec 14, 2011 at 10:55 AM, Alex Barry <alex.barry at gmail.com> wrote:
Now that I think about it, it should be && rather than ||, and it should
be working. I’m guessing the issue here is that linux is firing a resize
event when you actually resize the window. Try changing the if statement
to this:
This will only limit the resizing if it’s over the limit, as i believe the
window resize event changes the video mode internally, so when you were
setting the size, it may have just caught in an infinite loop rather than a
resize issue.
I hope that helps,
-Alex
On Wed, Dec 14, 2011 at 10:43 AM, Aaron Rosen <@Aaron_Rosen> wrote:
Here’s the resize code (attached wrong file before).
On Wed, Dec 14, 2011 at 10:42 AM, Aaron Rosen <@Aaron_Rosen> wrote:
Yea that’s now it. It still allows you to resize past 800. Before it was
trigged if both were greater than 800 now only one has to be greater than
800.
On Wed, Dec 14, 2011 at 9:55 AM, Alex Barry <alex.barry at gmail.com>wrote:
Hope that helps,
-AlexOn Wed, Dec 14, 2011 at 11:00 AM, Aaron Rosen wrote:
Nope same thing.
Aaron
On Wed, Dec 14, 2011 at 10:55 AM, Alex Barry <@Alex_Barry> wrote:
Now that I think about it, it should be && rather than ||, and it should
be working. I’m guessing the issue here is that linux is firing a resize
event when you actually resize the window. Try changing the if statement
to this:
This will only limit the resizing if it’s over the limit, as i believe
the window resize event changes the video mode internally, so when you were
setting the size, it may have just caught in an infinite loop rather than a
resize issue.
I hope that helps,
-Alex
On Wed, Dec 14, 2011 at 10:43 AM, Aaron Rosen wrote:
Here’s the resize code (attached wrong file before).
On Wed, Dec 14, 2011 at 10:42 AM, Aaron Rosen wrote:
Yea that’s now it. It still allows you to resize past 800. Before it
was trigged if both were greater than 800 now only one has to be greater
than 800.
On Wed, Dec 14, 2011 at 9:55 AM, Alex Barry <@Alex_Barry>wrote:
Removing these, and just using the inner call to SDL_SetVideoMode,
using the ternary operator to control the size, “works”. The logic
allows the window to grow bigger than 800x800 temporarily, but then it
snaps back once the user releases the mouse (on Ubuntu). IIRC Windows
behaves the same.
I don’t believe it is possible to prevent the user from temporarily
exceeding this limit, if that is what you want.On 14 December 2011 16:00, Aaron Rosen wrote:
Removing these, and just using the inner call to SDL_SetVideoMode,
using the ternary operator to control the size, “works”. The logic
allows the window to grow bigger than 800x800 temporarily, but then it
snaps back once the user releases the mouse (on Ubuntu). IIRC Windows
behaves the same.
I don’t believe it is possible to prevent the user from temporarily
exceeding this limit, if that is what you want.
On 14 December 2011 16:00, Aaron Rosen <@Aaron_Rosen> wrote:
When we talk to windows it seems like we are talking a different language.
The code there says that if windows tells me the window has gone too big
then I don’t want to update the portion of the screen that’s too large. Am
I right?
I think WM_SIZING is the size message you get and something like
WM_GETMINMAXINFO and SetWindowPos are the things you are looking for in the
windows api. Does sdl have some native way to deal with this as well so we
can stay out of the windows api mess?On Tue, Dec 13, 2011 at 5:20 PM, Aaron Rosen wrote:
Anyone know anything more about this? Could this be a bug?
Thanks,
Aaron
On Mon, Dec 12, 2011 at 1:18 PM, Aaron Rosen wrote:
Linux using libsdl-1.2.14-r6
Thanks,
Aaron
On Mon, Dec 12, 2011 at 1:13 PM, Ryan C. Gordon wrote:
I’m trying to limit the size of the window that a user can resize it to.
Would someone mind pointing out why the code below doesn’t seem to do
this? The user is still able to stretch the window to any size desired.
It is my understanding that X11 window managers often have an extension where you can specify min and max size hints, which greatly improve the user experience.
So I view this as a request for enabling that hint API (in cases where it works) without non-portable code.On 08/03/2012 05:37 PM, Jonathan Dearborn wrote:
Can you respond to a resize event by resizing to the minimum/maximum as necessary?
–
LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier
So the user wants to make the window sized bigger or smaller than you would
like and you want to stop him?On Fri, Aug 3, 2012 at 7:37 PM, Jonathan Dearborn wrote:
Can you respond to a resize event by resizing to the minimum/maximum as
necessary?