diff options
| author | 2025-06-17 11:26:22 -0400 | |
|---|---|---|
| committer | 2025-06-17 11:26:22 -0400 | |
| commit | 234e3cb390c7bb149ddd281d695d81a368e1a441 (patch) | |
| tree | f1db0267d1770fd111b8b4e9e8480e1724f48d86 /src | |
| parent | 7ca439ea9c2a3a323310fbe256583e2f7577d974 (diff) | |
| download | stela-234e3cb390c7bb149ddd281d695d81a368e1a441.tar.gz stela-234e3cb390c7bb149ddd281d695d81a368e1a441.tar.bz2 stela-234e3cb390c7bb149ddd281d695d81a368e1a441.zip | |
Improve X11 wallpaper window
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src')
| -rw-r--r-- | src/window_x11.c | 80 | ||||
| -rw-r--r-- | src/window_x11.h | 1 |
2 files changed, 66 insertions, 15 deletions
diff --git a/src/window_x11.c b/src/window_x11.c index cf54ba1..413e9bd 100644 --- a/src/window_x11.c +++ b/src/window_x11.c @@ -1,6 +1,5 @@ #define AL_LOG_SECTION "x11" #include <al/log.h> -#include <sys/eventfd.h> #include "window_x11.h" #include "common.h" @@ -36,7 +35,8 @@ bool stl_global_init(bool skip_graphics) if (!stl_maybe_load_egl()) return false; global.egl.display = eglGetDisplay((EGLNativeDisplayType)global.x11_d); if (!global.egl.display) { - log_error("Failed to get x11 EGL display."); + log_error("Failed to get X11-native EGL display."); + return false; } if (!stl_load_egl(&global.egl)) return false; #endif @@ -76,7 +76,7 @@ bool stl_global_init(bool skip_graphics) s32 stl_global_get_poll_fd() { - return XConnectionNumber(global.x11_d); + return ConnectionNumber(global.x11_d); } void stl_global_process_events() @@ -147,9 +147,6 @@ static bool window_x11_create_window(struct stl_window *window, u32 width, u32 h xattr.override_redirect = False; XChangeWindowAttributes(global.x11_d, xw->window, CWOverrideRedirect, &xattr); - XMapWindow(global.x11_d, xw->window); - XFlush(global.x11_d); - XWindowAttributes gwa; XGetWindowAttributes(global.x11_d, xw->window, &gwa); al_assert(gwa.width > 0 && gwa.height > 0); @@ -158,16 +155,10 @@ static bool window_x11_create_window(struct stl_window *window, u32 width, u32 h if (flags & STELA_WINDOW_WALLPAPER) { Atom net_wm_type = XInternAtom(global.x11_d, "_NET_WM_WINDOW_TYPE", False); if (net_wm_type) { - Atom desktop_type = XInternAtom(global.x11_d, "_NET_WM_WINDOW_TYPE_DESKTOP", False); + //Atom window_type = XInternAtom(global.x11_d, "_NET_WM_WINDOW_TYPE_DESKTOP", False); + Atom window_type = XInternAtom(global.x11_d, "_NET_WM_WINDOW_TYPE_SPLASH", False); XChangeProperty(global.x11_d, xw->window, net_wm_type, XA_ATOM, 32, - PropModeReplace, (u8 *)&desktop_type, 1); - } - - Atom net_wm_state = XInternAtom(global.x11_d, "_NET_WM_STATE", False); - if (net_wm_state) { - Atom net_wm_sticky = XInternAtom(global.x11_d, "_NET_WM_STATE_STICKY", False); - XChangeProperty(global.x11_d, xw->window, net_wm_state, XA_ATOM, 32, - PropModeAppend, (u8*)&net_wm_sticky, 1); + PropModeReplace, (u8 *)&window_type, 1); } Atom motif_wm_hints = XInternAtom(global.x11_d, "_MOTIF_WM_HINTS", False); @@ -185,6 +176,16 @@ static bool window_x11_create_window(struct stl_window *window, u32 width, u32 h PropModeReplace, (u8 *)&hints, sizeof(hints) / sizeof(long)); } + Atom net_wm_state = XInternAtom(global.x11_d, "_NET_WM_STATE", False); + if (net_wm_state) { + Atom net_wm_below = XInternAtom(global.x11_d, "_NET_WM_STATE_BELOW", False); + XChangeProperty(global.x11_d, xw->window, net_wm_state, XA_ATOM, 32, + PropModeAppend, (u8 *)&net_wm_below, 1); + Atom net_wm_sticky = XInternAtom(global.x11_d, "_NET_WM_STATE_STICKY", False); + XChangeProperty(global.x11_d, xw->window, net_wm_state, XA_ATOM, 32, + PropModeAppend, (u8 *)&net_wm_sticky, 1); + } + Atom net_wm_desktop = XInternAtom(global.x11_d, "_NET_WM_DESKTOP", False); if (net_wm_desktop) { ulong all_desktops = XWIN_ALL_DESKTOPS; @@ -193,6 +194,55 @@ static bool window_x11_create_window(struct stl_window *window, u32 width, u32 h } } + XMapWindow(global.x11_d, xw->window); + XFlush(global.x11_d); + + if (flags & STELA_WINDOW_WALLPAPER) { + Window root = DefaultRootWindow(global.x11_d); + + /* + XEvent event; + event.xclient.type = ClientMessage; + event.xclient.serial = 0; + event.xclient.send_event = True; + event.xclient.display = global.x11_d; + event.xclient.window = xw->window; + event.xclient.message_type = XInternAtom(global.x11_d, "_NET_WM_STATE", False); + event.xclient.format = 32; + + event.xclient.data.l[0] = _NET_WM_STATE_ADD; + event.xclient.data.l[1] = XInternAtom(global.x11_d, "_NET_WM_STATE_BELOW", False); + event.xclient.data.l[2] = 0; + event.xclient.data.l[3] = 0; + event.xclient.data.l[4] = 0; + XSendEvent(global.x11_d, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &event); + + //event.xclient.data.l[1] = XInternAtom(global.x11_d, "_NET_WM_STATE_STICKY", False); + //XSendEvent(global.x11_d, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &event); + */ + + // Enable click-through by making the window shape 0x0. + Window win = xw->window; + while (win != None) { + Region region; + if ((region = XCreateRegion())) { + XShapeCombineRegion(global.x11_d, xw->window, ShapeInput, 0, 0, region, ShapeSet); + XDestroyRegion(region); + } + + Window parent, *children = NULL; + u32 num_children; + if (XQueryTree(global.x11_d, win, &root, &parent, &children, &num_children)) { + if (children) XFree(children); + } + + win = (parent == root) ? None : parent; + } + + // Not sure if this flush matters. + XFlush(global.x11_d); + } + #ifdef STELA_API_OPENGL if (!x11_egl_init(xw)) return false; #endif diff --git a/src/window_x11.h b/src/window_x11.h index f8305dd..32749cd 100644 --- a/src/window_x11.h +++ b/src/window_x11.h @@ -6,6 +6,7 @@ #include <X11/Xlib.h> #include <X11/Xatom.h> #include <X11/extensions/Xrandr.h> +#include <X11/extensions/shape.h> #include "window.h" #include "egl_common.h" |