Commit 1f482174b5340a01d55b8f611b636c04871d8f4f

Ryan C. Gordon 2021-04-25T12:44:35

x11: Mark backing_store as NotUseful when creating windows. This can give some performance boost, and save some resources, as there's no reason to keep a copy of an SDL window's contents on the server: most SDL apps are redrawing completely every frame, and the API allows for expose events to tell an app a redraw is needed anyhow. (And compositors are free to ignore this setting if it makes sense to do so, according to the Xlib docs.) Reference Issue #3776.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index 94085f4..82e48d2 100644
--- a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -445,6 +445,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
     }
 
     xattr.override_redirect = ((window->flags & SDL_WINDOW_TOOLTIP) || (window->flags & SDL_WINDOW_POPUP_MENU)) ? True : False;
+    xattr.backing_store = NotUseful;
     xattr.background_pixmap = None;
     xattr.border_pixel = 0;
 
@@ -531,7 +532,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
                       window->x, window->y, window->w, window->h,
                       0, depth, InputOutput, visual,
                       (CWOverrideRedirect | CWBackPixmap | CWBorderPixel |
-                       CWColormap), &xattr);
+                       CWBackingStore | CWColormap), &xattr);
     if (!w) {
         return SDL_SetError("Couldn't create window");
     }