Fixed bug 2101 - CWBackPixel causes weird window flickering on window resize
authorSam Lantinga <slouken@libsdl.org>
Fri, 27 Sep 2013 23:47:57 -0700
changeset 775048acb5c00c4b
parent 7749 6073ad385c9b
child 7751 2f679aa69aea
Fixed bug 2101 - CWBackPixel causes weird window flickering on window resize

aBothe

I tried to experiment a bit with SDL2 and OpenGL today and noticed that something caused some weird flickering when resizing my nicely drawn SDL2/OpenGL window:
Just after resizing, the background went black and I had to let my OpenGL code redraw the contents..
However, after some hours spent with googling I found out that in OpenGL examples where this CWBackPixel flag was not used when creating X windows, there was no flickering while resizing the window.

See http://www.sbin.org/doc/Xlib/chapt_04.html @ "The Window Background" for more info.
src/video/x11/SDL_x11window.c
     1.1 --- a/src/video/x11/SDL_x11window.c	Fri Sep 27 23:35:17 2013 -0700
     1.2 +++ b/src/video/x11/SDL_x11window.c	Fri Sep 27 23:47:57 2013 -0700
     1.3 @@ -395,7 +395,7 @@
     1.4      }
     1.5  
     1.6      xattr.override_redirect = False;
     1.7 -    xattr.background_pixel = 0;
     1.8 +    xattr.background_pixmap = None;
     1.9      xattr.border_pixel = 0;
    1.10  
    1.11      if (visual->class == DirectColor) {
    1.12 @@ -480,7 +480,7 @@
    1.13      w = XCreateWindow(display, RootWindow(display, screen),
    1.14                        window->x, window->y, window->w, window->h,
    1.15                        0, depth, InputOutput, visual,
    1.16 -                      (CWOverrideRedirect | CWBackPixel | CWBorderPixel |
    1.17 +                      (CWOverrideRedirect | CWBackPixmap | CWBorderPixel |
    1.18                         CWColormap), &xattr);
    1.19      if (!w) {
    1.20          return SDL_SetError("Couldn't create window");