[SDL] Odd event behavior

Bob Pendleton bob at pendleton.com
Thu Nov 13 15:00:02 PST 2003


I'm writing the code to go with my next article and I have run into some
very odd behavior. In my program the SDL window can be resized. I want
to put some restrictions on the size and shape of the window. I want to
enforce always having the same shape of a window. That is, I always want
height/width == 0.75. And I want to impose both a maximum size and a
minimum size on the window. It all works very well except in one case,
When I grab the corner of the window and push it down to the minimum
size allowed by the window manager (much smaller than my minimum size) I
no longer get expose events and the window does not resize even though I
am calling SDL_SetVideoMode() with a larger window size. Even if I grab
the window and move it around the screen, I get no expose events until I
make the window slightly larger, at which time it pops up to *my*
minimum size. Note, that this only happens if I grab the corner of the
window. If I grab an edge then this doesn't happen. It works perfectly.
Has anyone seen behavior like this before, anyone have a guess as to
what is causing it?

The event code looks like:

 case SDL_VIDEORESIZE:
    eventWidth = event.resize.w;
    eventHeight = event.resize.h;
 
    deltaWidth = abs(lastWidth - eventWidth);
    deltaHeight = abs(lastHeight - eventHeight);
                                                                                               
    if (0 != deltaWidth)
    {
      int width = min(maxWidth, max(minWidth, eventWidth));
      screenWidth = width;
      screenHeight = (width * 3) / 4;
    }
    else if (0 != deltaHeight)
    {
      int height = min(maxHeight, max(minHeight, eventHeight));
      screenWidth = (height * 4) / 3;
      screenHeight = height;
    }
  
    lastWidth = eventWidth;
    lastHeight = eventHeight;
                                
    setVideoModeAndSize(screenWidth, screenHeight);

    break;


I'm using SDL 1.2.6, RedHat 9.0, and Ximian desktop. I will happily send
the complete program to anyone who is interested in looking at this
problem.

		Thanks
			Bob Pendleton


-- 
+---------------------------------------+
+ Bob Pendleton: writer and programmer. +
+ email: Bob at Pendleton.com              +
+ web:   www.GameProgrammer.com         +
+---------------------------------------+





More information about the SDL mailing list