Skip to content

Commit c701387

Browse files
committedAug 21, 2011
Ignore old ConfigureNotify events during X11 window resize.
Fixes Bugzilla #1049. Thanks to Andrew Church for the patch!
1 parent f5c1ccd commit c701387

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed
 

‎src/video/x11/SDL_x11events.c

+16
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ static SDLKey ODD_keymap[256];
5757
static SDLKey MISC_keymap[256];
5858
SDLKey X11_TranslateKeycode(Display *display, KeyCode kc);
5959

60+
/*
61+
Pending resize target for ConfigureNotify (so outdated events don't
62+
cause inappropriate resize events)
63+
*/
64+
int X11_PendingConfigureNotifyWidth = -1;
65+
int X11_PendingConfigureNotifyHeight = -1;
6066

6167
#ifdef X_HAVE_UTF8_STRING
6268
Uint32 Utf8ToUcs4(const Uint8 *utf8)
@@ -819,6 +825,16 @@ printf("MapNotify!\n");
819825
#ifdef DEBUG_XEVENTS
820826
printf("ConfigureNotify! (resize: %dx%d)\n", xevent.xconfigure.width, xevent.xconfigure.height);
821827
#endif
828+
if ((X11_PendingConfigureNotifyWidth != -1) &&
829+
(X11_PendingConfigureNotifyHeight != -1)) {
830+
if ((xevent.xconfigure.width != X11_PendingConfigureNotifyWidth) &&
831+
(xevent.xconfigure.height != X11_PendingConfigureNotifyHeight)) {
832+
/* Event is from before the resize, so ignore. */
833+
break;
834+
}
835+
X11_PendingConfigureNotifyWidth = -1;
836+
X11_PendingConfigureNotifyHeight = -1;
837+
}
822838
if ( SDL_VideoSurface ) {
823839
if ((xevent.xconfigure.width != SDL_VideoSurface->w) ||
824840
(xevent.xconfigure.height != SDL_VideoSurface->h)) {

‎src/video/x11/SDL_x11events_c.h

+5
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@
2727
extern void X11_InitOSKeymap(_THIS);
2828
extern void X11_PumpEvents(_THIS);
2929
extern void X11_SetKeyboardState(Display *display, const char *key_vec);
30+
31+
/* Variables to be exported */
32+
extern int X11_PendingConfigureNotifyWidth;
33+
extern int X11_PendingConfigureNotifyHeight;
34+

‎src/video/x11/SDL_x11video.c

+2
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,8 @@ SDL_Surface *X11_SetVideoMode(_THIS, SDL_Surface *current,
11611161
current = NULL;
11621162
goto done;
11631163
}
1164+
X11_PendingConfigureNotifyWidth = width;
1165+
X11_PendingConfigureNotifyHeight = height;
11641166
} else {
11651167
if (X11_CreateWindow(this,current,width,height,bpp,flags) < 0) {
11661168
current = NULL;

0 commit comments

Comments
 (0)