diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-12-10 19:42:01 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-12-10 19:42:01 +0100 |
commit | 4c83972a4f25a1918103e39ade4ef4d5b948db8a (patch) | |
tree | 337484ce3be29589422e2ade03c695f56f340827 /src/Overlay.cpp | |
parent | 0b9858f28ff0681d0fb08217aed6de710ae93902 (diff) |
Timeout window creation position hack, force floating, disable 'all monitors' record option for nowHEADmaster
Diffstat (limited to 'src/Overlay.cpp')
-rw-r--r-- | src/Overlay.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/Overlay.cpp b/src/Overlay.cpp index d306910..88625d6 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -19,6 +19,7 @@ #include <sys/wait.h> #include <limits.h> #include <fcntl.h> +#include <poll.h> #include <stdexcept> #include <X11/Xlib.h> @@ -299,10 +300,11 @@ namespace gsr { } static mgl::vec2i create_window_get_center_position(Display *display) { + const int size = 16; XSetWindowAttributes window_attr; window_attr.event_mask = StructureNotifyMask; window_attr.background_pixel = 0; - const Window window = XCreateWindow(display, DefaultRootWindow(display), 0, 0, 16, 16, 0, CopyFromParent, InputOutput, CopyFromParent, CWBackPixel | CWEventMask, &window_attr); + const Window window = XCreateWindow(display, DefaultRootWindow(display), 0, 0, size, size, 0, CopyFromParent, InputOutput, CopyFromParent, CWBackPixel | CWEventMask, &window_attr); if(!window) return {0, 0}; @@ -321,12 +323,36 @@ namespace gsr { const unsigned long opacity = (unsigned long)(0xFFFFFFFFul * alpha); XChangeProperty(display, window, net_wm_window_opacity, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&opacity, 1L); + XSizeHints *size_hints = XAllocSizeHints(); + size_hints->width = size; + size_hints->min_width = size; + size_hints->max_width = size; + size_hints->height = size; + size_hints->min_height = size; + size_hints->max_height = size; + size_hints->flags = PSize | PMinSize | PMaxSize; + XSetWMNormalHints(display, window, size_hints); + XFree(size_hints); + XMapWindow(display, window); XFlush(display); + const int x_fd = XConnectionNumber(display); mgl::vec2i window_pos; XEvent xev; while(true) { + struct pollfd poll_fd; + poll_fd.fd = x_fd; + poll_fd.events = POLLIN; + poll_fd.revents = 0; + const int fds_ready = poll(&poll_fd, 1, 1000); + if(fds_ready == 0) { + fprintf(stderr, "Error: timed out waiting for ConfigureNotify after XCreateWindow\n"); + break; + } else if(fds_ready == -1 || !(poll_fd.revents & POLLIN)) { + continue; + } + XNextEvent(display, &xev); if(xev.type == ConfigureNotify) { window_pos.x = xev.xconfigure.x + xev.xconfigure.width / 2; |