aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorUli Schlachter <psychon@users.noreply.github.com>2021-05-20 21:37:35 +0200
committerGitHub <noreply@github.com>2021-05-20 21:37:35 +0200
commit60542da0916a62a6daede9293090660b05d4679e (patch)
treea58f2606fd5dbed934a4b0c6cbf2ee69cd9df199 /include
parentfcae64f7fd97c02f36200a4c60ab7ec2fd4410df (diff)
downloadi3-60542da0916a62a6daede9293090660b05d4679e.tar.gz
i3-60542da0916a62a6daede9293090660b05d4679e.zip
Do not "set" the wallpaper during startup (#4373)
"Set" the wallpaper during startup only sometimes Since commit 4f5e0e7, i3 would take a screenshot and set that as the background pixmap of the root window during startup. This is the easy part of setting a proper X11 wallpaper. The code in question was added because something either set the background pixmap of the root window to NONE or the X11 server was started with "-background none". This is apparently done by default by e.g. gdm to avoid some flickering while the X11 server starts up. This commit makes this code conditional: Only when no wallpaper is detected is a screenshot taken. Since I could not find any way to query the background of a window, a more direct approach is taken to detect this situation: First, we find some part of the root window that is not currently covered. Then we open a white window there, close it again and grab a screenshot. If a wallpaper is set, the X11 server will draw this wallpaper after the window is closed and something else will be visible in the screenshot. However, the wallpaper could have a white pixel at the tested position. Thus, this procedure is repeated with a black window. Only when this procedure produces two different pixel values is a screenshot taken and set as the wallpaper. Fixes: https://github.com/i3/i3/issues/4371 Fixes: https://github.com/i3/i3/issues/2869 Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'include')
-rw-r--r--include/libi3.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/libi3.h b/include/libi3.h
index 15f63704..a93b3ff9 100644
--- a/include/libi3.h
+++ b/include/libi3.h
@@ -655,3 +655,16 @@ int create_socket(const char *filename, char **out_socketpath);
*
*/
bool path_exists(const char *path);
+
+/**
+ * Grab a screenshot of the screen's root window and set it as the wallpaper.
+ */
+void set_screenshot_as_wallpaper(xcb_connection_t *conn, xcb_screen_t *screen);
+
+/**
+ * Test whether the screen's root window has a background set.
+ *
+ * This opens & closes a window and test whether the root window still shows the
+ * content of the window.
+ */
+bool is_background_set(xcb_connection_t *conn, xcb_screen_t *screen);