# HG changeset patch # User Sam Lantinga # Date 1297566134 28800 # Node ID 8e421890cdb8703ee860422f317e51910f1739d7 # Parent bad04e4710f60419538e2b52ce0b0eadcc53a693 Fixed bug #1117 There's a new event that's always sent when the window changes size, and that event is what the renderers listen for to determine if they need to rebind their context. diff -r bad04e4710f6 -r 8e421890cdb8 include/SDL_video.h --- a/include/SDL_video.h Sat Feb 12 17:51:47 2011 -0800 +++ b/include/SDL_video.h Sat Feb 12 19:02:14 2011 -0800 @@ -140,7 +140,8 @@ redrawn */ SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2 */ - SDL_WINDOWEVENT_RESIZED, /**< Window size changed to data1xdata2 */ + SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */ + SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as a result of an API call or through the system or user changing the window size. */ SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */ SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */ SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size diff -r bad04e4710f6 -r 8e421890cdb8 src/events/SDL_windowevents.c --- a/src/events/SDL_windowevents.c Sat Feb 12 17:51:47 2011 -0800 +++ b/src/events/SDL_windowevents.c Sat Feb 12 19:02:14 2011 -0800 @@ -35,7 +35,8 @@ SDL_Event *new_event = (SDL_Event *)userdata; if (event->type == SDL_WINDOWEVENT && - event->window.event == SDL_WINDOWEVENT_RESIZED && + (event->window.event == SDL_WINDOWEVENT_RESIZED || + event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) && event->window.windowID == new_event->window.windowID) { /* We're about to post a new size event, drop the old one */ return 0; diff -r bad04e4710f6 -r 8e421890cdb8 src/render/opengl/SDL_render_gl.c --- a/src/render/opengl/SDL_render_gl.c Sat Feb 12 17:51:47 2011 -0800 +++ b/src/render/opengl/SDL_render_gl.c Sat Feb 12 19:02:14 2011 -0800 @@ -348,7 +348,7 @@ { GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - if (event->event == SDL_WINDOWEVENT_RESIZED) { + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { /* Rebind the context to the window area and update matrices */ SDL_CurrentContext = NULL; data->updateSize = SDL_TRUE; diff -r bad04e4710f6 -r 8e421890cdb8 src/render/opengles/SDL_render_gles.c --- a/src/render/opengles/SDL_render_gles.c Sat Feb 12 17:51:47 2011 -0800 +++ b/src/render/opengles/SDL_render_gles.c Sat Feb 12 19:02:14 2011 -0800 @@ -261,7 +261,7 @@ { GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - if (event->event == SDL_WINDOWEVENT_RESIZED) { + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { /* Rebind the context to the window area and update matrices */ SDL_CurrentContext = NULL; data->updateSize = SDL_TRUE; diff -r bad04e4710f6 -r 8e421890cdb8 src/render/opengles2/SDL_render_gles2.c --- a/src/render/opengles2/SDL_render_gles2.c Sat Feb 12 17:51:47 2011 -0800 +++ b/src/render/opengles2/SDL_render_gles2.c Sat Feb 12 19:02:14 2011 -0800 @@ -170,7 +170,7 @@ { GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; - if (event->event == SDL_WINDOWEVENT_RESIZED) { + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { /* Rebind the context to the window area */ SDL_CurrentContext = NULL; rdata->updateSize = SDL_TRUE; diff -r bad04e4710f6 -r 8e421890cdb8 src/render/software/SDL_render_sw.c --- a/src/render/software/SDL_render_sw.c Sat Feb 12 17:51:47 2011 -0800 +++ b/src/render/software/SDL_render_sw.c Sat Feb 12 19:02:14 2011 -0800 @@ -173,7 +173,7 @@ { SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - if (event->event == SDL_WINDOWEVENT_RESIZED) { + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { data->updateSize = SDL_TRUE; } } diff -r bad04e4710f6 -r 8e421890cdb8 src/video/SDL_video.c --- a/src/video/SDL_video.c Sat Feb 12 17:51:47 2011 -0800 +++ b/src/video/SDL_video.c Sat Feb 12 19:02:14 2011 -0800 @@ -1431,10 +1431,15 @@ /* FIXME: Should this change fullscreen modes? */ if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + window->w = w; + window->h = h; if (_this->SetWindowSize) { _this->SetWindowSize(_this, window); } - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, w, h); + if (window->w == w && window->h == h) { + /* We didn't get a SDL_WINDOWEVENT_RESIZED event (by design) */ + SDL_OnWindowResized(window); + } } } @@ -1706,6 +1711,7 @@ SDL_OnWindowResized(SDL_Window * window) { window->surface_valid = SDL_FALSE; + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h); } void diff -r bad04e4710f6 -r 8e421890cdb8 src/video/directfb/SDL_DirectFB_render.c --- a/src/video/directfb/SDL_DirectFB_render.c Sat Feb 12 17:51:47 2011 -0800 +++ b/src/video/directfb/SDL_DirectFB_render.c Sat Feb 12 19:02:14 2011 -0800 @@ -279,7 +279,7 @@ { SDL_DFB_RENDERERDATA(renderer); - if (event->event == SDL_WINDOWEVENT_RESIZED) { + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { /* Rebind the context to the window area and update matrices */ //SDL_CurrentContext = NULL; //data->updateSize = SDL_TRUE;