From 9569fd0d36ff4266556f9f47b4b61f63ae31a8ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Salman?= Date: Mon, 12 Aug 2024 02:44:35 +0300 Subject: [PATCH] added opacity. https://chatgpt.com/share/b7e80cfb-4f06-4192-8a57-bf97c84422ce --- highlight-pointer.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/highlight-pointer.c b/highlight-pointer.c index 8232540..c08ea47 100644 --- a/highlight-pointer.c +++ b/highlight-pointer.c @@ -97,6 +97,7 @@ static struct { int highlight_visible; int outline; int radius; + double opacity; // Add opacity field } options; static void redraw(); @@ -187,6 +188,11 @@ static int init_window() { return 1; } + // Set window opacity + unsigned long opacity_value = (unsigned long)(options.opacity * 0xFFFFFFFF); + Atom opacity_atom = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False); + XChangeProperty(dpy, win, opacity_atom, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&opacity_value, 1); + XClassHint class_hint; XStoreName(dpy, win, "highlight-pointer"); class_hint.res_name = "highlight-pointer"; @@ -493,6 +499,7 @@ static void print_usage(const char* name) { " -p, --pressed-color COLOR dot color when mouse button pressed [default: #1f77b4]\n" " -o, --outline OUTLINE line width of outline or 0 for filled dot [default: 0]\n" " -r, --radius RADIUS dot radius in pixels [default: 5]\n" + " --opacity OPACITY window opacity (0.0 - 1.0) [default: 1.0]\n" " --hide-highlight start with highlighter hidden\n" " --show-cursor start with cursor shown\n" "\n" @@ -527,6 +534,7 @@ static struct option long_options[] = {{"auto-hide-cursor", no_argument, &option {"hide-timeout", required_argument, NULL, 't'}, {"outline", required_argument, NULL, 'o'}, {"pressed-color", required_argument, NULL, 'p'}, + {"opacity", required_argument, NULL, 'a'}, {"radius", required_argument, NULL, 'r'}, {"released-color", required_argument, NULL, 'c'}, {"show-cursor", no_argument, &options.cursor_visible, 1}, @@ -542,6 +550,7 @@ static int set_options(int argc, char* argv[]) { options.auto_hide_highlight = 0; options.cursor_visible = 0; options.highlight_visible = 1; + options.opacity = 1.0; options.radius = 5; options.outline = 0; options.hide_timeout = 3; @@ -564,7 +573,9 @@ static int set_options(int argc, char* argv[]) { switch (c) { case 0: break; - + case 'a': + options.opacity = atof(optarg); + break; case 'c': options.released_color_string = optarg; break;