We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 994 - SDL window restore SDL_VIDEORESIZE event issue...
Summary: SDL window restore SDL_VIDEORESIZE event issue...
Status: RESOLVED WONTFIX
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 1.2.14
Hardware: Other Windows 7
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-24 12:57 UTC by Renato.cron
Modified: 2011-12-29 01:20 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Renato.cron 2010-04-24 12:57:17 UTC
Please, before read, see full bug description here:
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2009-December/073708.html
I guess this is in all windows, not only in windows 7

The problem can be solved on SDL_PrivateResize(int w, int h)


When windows restore, SDL_VideoSurface->h still equal h, but, isn't.

if you add
if ( ! SDL_VideoSurface ||
			 ((w == SDL_VideoSurface->w) && (h == SDL_VideoSurface->h)) ) {
			printf("returned at second...\n");
			return(0);
		}

When you maxime, u will see that this message is printed.

Here, in my code, i put an force param, and, if force is 1, i dont verify.
I don't know the best way to solve this problem, i solved my. My application verfiy if width and old_width is equal, so no problem if resize event post duplicates


So, if anyone can solve in a better way (or in SDL 1.2.15 ?)


/* This is global for SDL_eventloop.c */
int SDL_PrivateResize(int w, int h, int force)
{
	int posted;
	SDL_Event events[32];

	//printf("last_resize.w is %i, last_resize.h is %i    w is %i   h is %i\n", last_resize.w, last_resize.h, w, h);
	
	if(force == 0){
	 // See if this event would change the video surface 
		if ( !w || !h
#ifndef __OS2__
            || ( ((last_resize.w == w) && (last_resize.h == h)))
#endif
		) {
	//printf("returned at first\n");
			return(0);
		}
	}
    
	if(force == 0){
		if ( ! SDL_VideoSurface ||
			 ((w == SDL_VideoSurface->w) && (h == SDL_VideoSurface->h)) ) {
				// printf("returned at second...\n");
			return(0);
		}


		}else{
		if ( !w || !h
#ifndef __OS2__
            || ( ((last_resize.w == w) && (last_resize.h == h)))
#endif
		) {
	//printf("returned at first\n");
			return(0);
		}
		}

	last_resize.w = w;
    last_resize.h = h;

	SDL_SetMouseRange(w, h);

	/* Pull out all old resize events */
	SDL_PeepEvents(events, sizeof(events)/sizeof(events[0]),
	                    SDL_GETEVENT, SDL_VIDEORESIZEMASK);

	/* Post the event, if desired */
	posted = 0;
	if ( SDL_ProcessEvents[SDL_VIDEORESIZE] == SDL_ENABLE ) {
		SDL_Event event;
		event.type = SDL_VIDEORESIZE;
		event.resize.w = w;
		event.resize.h = h;
		if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
			posted = 1;
			SDL_PushEvent(&event);
		}
	}
	return(posted);
}
Comment 1 Renato.cron 2010-04-24 13:12:27 UTC
sorry for duplicate, i won't see http://bugzilla.libsdl.org/show_bug.cgi?id=994 before

But, this bug topic, at least, have a solotion!