summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Fontaine <arnau@debian.org>2011-10-30 16:41:56 +0900
committerArnaud Fontaine <arnau@debian.org>2011-10-30 16:41:56 +0900
commit30300bf213557b99bcfd3d92587f6a96e9494124 (patch)
treef6fc2cbefd38b0d8b50d5551f3e1ae037840dcd0
parented0236ce0b9fcdbd7e7874327c65610b3f13d47e (diff)
2005-01-14 Daniel Forchheimer <n04df@efd.lth.se>
Release v3 * transSet.c: Select by name (-n, --name) Select by id (-i, --id)
-rw-r--r--README36
-rw-r--r--transSet.c69
2 files changed, 82 insertions, 23 deletions
diff --git a/README b/README
index c2f9d71..8f056fa 100644
--- a/README
+++ b/README
@@ -1,28 +1,32 @@
This is a patched version of xorg's transset
I wanted to integrate transset into my windowmanager and to
be able to set and unset transparency by just pressing a key.
-To make that possible I didn't want transset to wait for me to
-click on a window but instead setting transparency immidietly on
-the window under the cursor.
+To make that possible I added several different 'select methods'.
+The first one was 'select by point' and lets the user run transset
+directly on the window curently under the cursor without bringing
+up the crosshair. Later select by name and id was added after insperation
+from other transset patches.
In the future I guess it's ment for the windowmanagers to handle
-transparency. Then we will hopefully see this function and many other
-now imposible functions (like opacity following the mousepointer).
-But this will require you to wait untill this is implementet in
-your favorite wm. This patch is my way of "scratching where it itches",
-with only minor changes transset can now be used with any windowmanager
-to make it do somethink actually usefull.
+transparency. Then we will hopefully see these functions and many other
+now imposible function. This will however require you to wait untill this is
+implementet in your favorite wm. This patch is a way of "scratching where it
+itches", by creating a usefull integration with every windowmanager without
+changing any wm-code. And it's a very "unix way" of doing things too :)
Features
- -select window by clicking (as transset)
- -select window by pointing
- -force toggle
- -increase or decrease opacity
+ *select window by clicking (as transset)
+ *select window by pointing
+ *select by window name or id
+ *force toggle
+ *increase or decrease opacity
+Latest version is: 3
+Updated 2005-01-20
+Homepage: http://www.forchheimer.se/transset-df/
-Get transset-df from: http://www.forchheimer.se/transset-df/
-
-Any questions/sugestions just send me a email
+Any questions/sugestions or if you just want to say hello don't fear to send
+me a email
Cheers
Daniel Forchheimer (upiom)
diff --git a/transSet.c b/transSet.c
index bfda4f1..5daea80 100644
--- a/transSet.c
+++ b/transSet.c
@@ -8,7 +8,7 @@
*/
-#define VERSIONSTR "2"
+#define VERSIONSTR "3"
#include <stdio.h>
#include <X11/Xlib.h>
@@ -36,13 +36,17 @@ void usage()
fprintf(stderr,
" -p, --point select the window currently under the cursor\n");
fprintf(stderr,
+ " -n, --name NAME select by name\n");
+ fprintf(stderr,
+ " -i, --id select by window id\n");
+ fprintf(stderr,
" --inc increase by the given opacity\n");
fprintf(stderr,
" --dec decrease by given opacity\n");
fprintf(stderr,
- " -m, --min=OPACITY minimum possible opacity (default = 0)\n");
+ " -m, --min OPACITY minimum possible opacity (default = 0)\n");
fprintf(stderr,
- " -x, --max=OPACITY maximum possible opacity (default = 1)\n");
+ " -x, --max OPACITY maximum possible opacity (default = 1)\n");
fprintf(stderr,
" -v, --version print version number\n");
@@ -65,6 +69,11 @@ int main(int argc, char **argv)
int flag_decrease=0;
int o;
float min=0,max=1;
+ char *idstr,*namestr;
+
+ Window root_win;
+ Window *child_list;
+ unsigned int num_children;
int options_index=0;
static struct option long_options[] = {
@@ -72,6 +81,8 @@ int main(int argc, char **argv)
{"help",0,NULL,'h'},
{"point",0,NULL,'p'},
{"click",0,NULL,'c'},
+ {"id",1,NULL,'i'},
+ {"name",1,NULL,'n'},
{"inc",0,NULL,'1'},
{"dec",0,NULL,'2'},
{"min",1,NULL,'m'},
@@ -83,7 +94,7 @@ int main(int argc, char **argv)
/* wonderful utility */
Setup_Display_And_Screen(&argc, argv);
- while ((o = getopt_long(argc, argv, "thpcvm:x:12",long_options,&options_index)) != -1)
+ while ((o = getopt_long(argc, argv, "thpci:n:vm:x:12",long_options,&options_index)) != -1)
{
switch (o) {
case 't':
@@ -98,6 +109,16 @@ int main(int argc, char **argv)
case 'p':
select_method=1;
break;
+ case 'i':
+ idstr = malloc(strlen(optarg)+1);
+ idstr = optarg;
+ select_method=2;
+ break;
+ case 'n':
+ namestr = malloc(strlen(optarg)+1);
+ namestr = optarg;
+ select_method=3;
+ break;
case '1':
flag_increase=1;
break;
@@ -129,6 +150,40 @@ int main(int argc, char **argv)
if(select_method==1) {
/* don't wait for click */
target_win = Get_Window_Under_Cursor(dpy);
+ } else if(select_method==2) {
+ /* select by id, pretty much stripped from dsimple.c */
+ sscanf(idstr, "0x%lx", &target_win);
+ if (!target_win)
+ sscanf(idstr, "%ld", &target_win);
+ if (!target_win) {
+ fprintf(stderr,"Invalid window id format: %s.\n", idstr);
+ exit(0);
+ }
+ /* apparently we want the grandparent of this window, otherwise
+ * deleting the property won't work, cudos to another transset patch
+ * for leading me in this direction */
+ if (!XQueryTree(dpy, target_win, &root_win, &target_win, &child_list,
+ &num_children))
+ Fatal_Error("Can't query window tree.");
+ if (!XQueryTree(dpy, target_win, &root_win, &target_win, &child_list,
+ &num_children))
+ Fatal_Error("Can't query window tree.");
+
+ } else if(select_method==3) {
+ /* select by name, pretty much stripped from dsimple.c */
+ target_win = Window_With_Name(dpy, RootWindow(dpy, screen),namestr);
+ if (!target_win) {
+ fprintf(stderr,"No window with name %s exists!\n",namestr);
+ exit(0);
+ }
+ /* get grandparent */
+ if (!XQueryTree(dpy, target_win, &root_win, &target_win, &child_list,
+ &num_children))
+ Fatal_Error("Can't query window tree.");
+ if (!XQueryTree(dpy, target_win, &root_win, &target_win, &child_list,
+ &num_children))
+ Fatal_Error("Can't query window tree.");
+
} else {
/* grab mouse and return window that is next clicked */
target_win = Select_Window(dpy);
@@ -161,7 +216,7 @@ int main(int argc, char **argv)
} else if(flag_decrease) {
d = (double)current_opacity/OPAQUE - d;
}
- printf("%f\n",d);
+ //printf("%f\n",d);
/* check min and max */
if(d<min) d=min;
if(d>max) d=max;
@@ -178,9 +233,9 @@ int main(int argc, char **argv)
// printf ("opacity 0x%x\n", opacity);
if (opacity == OPAQUE)
- XDeleteProperty (dpy, target_win, XInternAtom(dpy, OPACITY, False));
+ XDeleteProperty (dpy, target_win, XInternAtom(dpy, OPACITY, False));
/* set it */
- else
+ else
XChangeProperty(dpy, target_win, XInternAtom(dpy, OPACITY, False),
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &opacity, 1L);