diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-08-05 02:02:00 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-08-05 02:02:00 +0200 |
commit | 857488e91b588e73d46948988ffce18ed9cb59fc (patch) | |
tree | f1a91c33e5315eb739be3a431c013b9235ab0ddd | |
parent | c4d4d84ac5d8edb03c7b0056aa3cc181acc4eb1e (diff) |
Make window click through
-rw-r--r-- | project.conf | 5 | ||||
-rw-r--r-- | src/main.cpp | 15 |
2 files changed, 17 insertions, 3 deletions
diff --git a/project.conf b/project.conf index c974cd0..c3cfb3e 100644 --- a/project.conf +++ b/project.conf @@ -2,4 +2,7 @@ name = "gpu-screen-recorder-notification" type = "executable" version = "0.1.0" -platforms = ["posix"]
\ No newline at end of file +platforms = ["posix"] + +[dependencies] +xfixes = ">=4"
\ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 7c558fe..b9e81a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,6 +15,8 @@ #include <map> #include <X11/Xlib.h> +#include <X11/extensions/Xfixes.h> +#include <X11/extensions/shape.h> extern "C" { #include <mgl/mgl.h> @@ -83,6 +85,14 @@ static Bool make_window_sticky(Display* display, Window window) { return set_window_wm_state(display, window, net_wm_state_sticky_atom); } +static void make_window_click_through(Display *display, Window window) { + XRectangle rect; + memset(&rect, 0, sizeof(rect)); + XserverRegion region = XFixesCreateRegion(display, &rect, 1); + XFixesSetWindowShapeRegion(display, window, ShapeInput, 0, 0, region); + XFixesDestroyRegion(display, region); +} + static void usage() { fprintf(stderr, "usage: gpu-screen-recorder-notification <--text text> <--timeout timeout> [--icon filepath] [--icon-color color] [--bg-color color]\n"); fprintf(stderr, "options:\n"); @@ -240,6 +250,8 @@ int main(int argc, char **argv) { padding_between_icon_and_text_x = (int)(logo_sprite_padding_x * 0.7f); } + Display *display = (Display*)mgl_get_context()->connection; + // TODO: Use the monitor that the cursor is on or the focused window is on. // TODO: Update position when workspace changes (in dwm, sticky property handles it in real workspaces). // TODO: Make sure the notification always stays on top. Test with starting the notification and then opening youtube in fullscreen. @@ -249,9 +261,8 @@ int main(int argc, char **argv) { window.set_size_limits(window_size, window_size); window.set_size(window_size); window.set_position(window_start_position); + make_window_click_through(display, window.get_system_handle()); window.set_visible(true); - - Display *display = (Display*)mgl_get_context()->connection; make_window_sticky(display, window.get_system_handle()); const int slide_window_start_x = win->monitors[0].size.x; |