summaryrefslogtreecommitdiff
path: root/transSet.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2004-01-20 20:03:02 +0000
committerKeith Packard <keithp@keithp.com>2004-01-20 20:03:02 +0000
commitbb69f00c4876d80daf0c01706bbcc52dc30302d5 (patch)
treef47d620f3831e945016cf5c5ae81cb2bd9c409c2 /transSet.c
parent59e751294611cb043252e6b8180601ac71b17bcf (diff)
2004-01-20 Keith Packard <keithp@keithp.com>
* transSet.c: (main): Change property name to _NET_WM_WINDOW_OPACITY Report values as doubles. Delete property when opaque.
Diffstat (limited to 'transSet.c')
-rw-r--r--transSet.c72
1 files changed, 47 insertions, 25 deletions
diff --git a/transSet.c b/transSet.c
index 3418c69..fe7d0b9 100644
--- a/transSet.c
+++ b/transSet.c
@@ -12,6 +12,7 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include "dsimple.h"
+#include <stdlib.h>
Window target_win;
@@ -23,50 +24,71 @@ void usage()
fprintf(stderr, "Bad arguments\n");
}
+#define OPAQUE 0xffffffff
+#define OPACITY "_NET_WM_WINDOW_OPACITY"
/* nothing fancy */
int main(int argc, char **argv)
{
+ int gotd = 0;
+ double d;
+ unsigned int opacity;
/* wonderful utility */
Setup_Display_And_Screen(&argc, argv);
+ if (argv[1])
+ {
+ printf ("got arg %s\n", argv[1]);
+ d = atof (argv[1]);
+ printf ("d is %g\n", d);
+ gotd = 1;
+ }
+
/* grab mouse and return window that is next clicked */
target_win = Select_Window(dpy);
- int val = 15;
-
unsigned char *data;
Atom actual;
int format;
unsigned long n, left;
- /* get property */
- XGetWindowProperty(dpy, target_win, XInternAtom(dpy, "CM_TRANSLUCENCY", False),
- 0L, 1L, False, XA_INTEGER, &actual, &format, &n, &left,
- (unsigned char **) &data);
-
- if (data != None)
- {
-
- printf("Found property: %d\n", (int) *data );
-
- /* toggle */
- if ((int) *data > 0)
- val = 0;
-
- XFree(( void *) data );
-
- }
-
-
+ if (gotd)
+ opacity = (unsigned int) (d * OPAQUE);
+ else
+ {
+ /* get property */
+ XGetWindowProperty(dpy, target_win, XInternAtom(dpy, OPACITY, False),
+ 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left,
+ (unsigned char **) &data);
+
+ if (data != None)
+ {
+ memcpy (&opacity, data, sizeof (unsigned int));
+ XFree(( void *) data );
+ printf("Found property: %g\n", (double) opacity / OPAQUE);
+ }
+ else
+ opacity = OPAQUE;
+
+ /* toggle */
+ if (opacity != OPAQUE)
+ opacity = OPAQUE;
+ else
+ opacity = 0xc0000000;
+ }
+
+ printf ("opacity 0x%x\n", opacity);
+ if (opacity == OPAQUE)
+ XDeleteProperty (dpy, target_win, XInternAtom(dpy, OPACITY, False));
/* set it */
- XChangeProperty(dpy, target_win, XInternAtom(dpy, "CM_TRANSLUCENCY", False),
- XA_INTEGER, 32, PropModeReplace,
- (unsigned char *) &val, 1L);
+ else
+ XChangeProperty(dpy, target_win, XInternAtom(dpy, OPACITY, False),
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) &opacity, 1L);
XSync(dpy, False);
- printf("Set Property to %d\n", val);
+ printf("Set Property to %g\n", (double) opacity / OPAQUE);
/* all done, wasn't that simple */