From 55a5a8da9b0a2b997096319e8d990a70ee31ac94 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine Date: Sun, 30 Oct 2011 16:40:04 +0900 Subject: 2005-01-13 Daniel Forchheimer * transSet.c: (main): Forked transset-df of transset Added flags Added select without clicking Wrote usage * dsimple.c: Added function to select without clicking --- README | 26 ++++++++++++ dsimple.c | 35 ++++++++++++++++ transSet.c | 133 ++++++++++++++++++++++++++++++++++++++++++++----------------- 3 files changed, 158 insertions(+), 36 deletions(-) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..c234a3b --- /dev/null +++ b/README @@ -0,0 +1,26 @@ +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. + +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. + +Features + -select window by clicking (as transset) + -select window by pointing + -force toggle + + +Any questions/sugestions just send me a email + +Cheers +Daniel Forchheimer (upiom) +n04df@efd.lth.se diff --git a/dsimple.c b/dsimple.c index bbdbd93..e388380 100644 --- a/dsimple.c +++ b/dsimple.c @@ -450,6 +450,41 @@ Window Select_Window(dpy) return(target_win); } +/* + * Routine that returns the window currently under the cursor + * Added by Daniel Forchheimer. Last updated 19/12/04 + */ + +Window Get_Window_Under_Cursor(dpy) + Display *dpy; +{ + int status; + Cursor cursor; + XEvent event; + Window target_win = None, root = RootWindow(dpy,screen); + int buttons = 0; + Window tmp; + int rx,ry,cx,cy; + unsigned int mask; + + /* Make the target cursor */ + cursor = XCreateFontCursor(dpy, XC_crosshair); + + /* Grab the pointer using target cursor, letting it room all over */ + status = XGrabPointer(dpy, root, False, + ButtonPressMask|ButtonReleaseMask, GrabModeSync, + GrabModeAsync, root, cursor, CurrentTime); + if (status != GrabSuccess) Fatal_Error("Can't grab the mouse."); + + /* get the window under the cursor */ + XQueryPointer(dpy, root, &tmp, &target_win, &rx, &ry, + &cx, &cy, &mask); + + XUngrabPointer(dpy, CurrentTime); /* Done with pointer */ + + return(target_win); +} + /* * Window_With_Name: routine to locate a window with a given name on a display. diff --git a/transSet.c b/transSet.c index fe7d0b9..8437f2c 100644 --- a/transSet.c +++ b/transSet.c @@ -1,18 +1,21 @@ -/* Simple program to toggle Translucency property on next window clicked - Uses dsimple.h and dsimple.c from xlsfonts. - Based on xprops and xwininfo - - By Matthew Hawn - Use however you want. I can't stop you. +/* Simple program to toggle Translucency property + Based on 'transset' by Matthew Hawn + With some additional features to make it more automatic and integrated + The purpos is to bind it from your wm to a key or mouse-button + + Use however you want. + Written by: Daniel Forchheimer (upiom) + */ - +#define VERSIONSTR "1" #include #include #include #include "dsimple.h" #include +#include Window target_win; @@ -21,7 +24,21 @@ Window target_win; void usage() { - fprintf(stderr, "Bad arguments\n"); + fprintf(stderr,"usage: transset-df [-options ...] [opacity]\n"); + fprintf(stderr,"options:\n"); + + fprintf(stderr, + " -h, --help display this message\n"); + fprintf(stderr, + " -t, --toggle force toggle of opacity\n"); + fprintf(stderr, + " -c, --click select by clicking on window (default)\n"); + fprintf(stderr, + " -p, --point select the window currently under the cursor\n"); + fprintf(stderr, + " -v, --version print version number\n"); + + exit(1); } #define OPAQUE 0xffffffff @@ -33,53 +50,97 @@ int main(int argc, char **argv) int gotd = 0; double d; unsigned int opacity; + unsigned int current_opacity; + int select_method = 0; // 0 = click, 1 = point + int flag_toggle=0; + int o; + + int options_index=0; + static struct option long_options[] = { + {"toggle",0,NULL,'t'}, + {"help",0,NULL,'h'}, + {"point",0,NULL,'p'}, + {"click",0,NULL,'c'}, + {"version",0,NULL,'v'}, + {0,0,0,0} + }; /* wonderful utility */ Setup_Display_And_Screen(&argc, argv); - if (argv[1]) + while ((o = getopt_long(argc, argv, "thpcv",long_options,&options_index)) != -1) + { + switch (o) { + case 't': + flag_toggle=1; + break; + case 'h': + usage(); + break; + case 'c': + select_method=0; + break; + case 'p': + select_method=1; + break; + case 'v': + fprintf(stderr,"version: %s\n",VERSIONSTR); + exit(1); + break; + default: + usage(); + } + } + + if(optind Date: Sun, 30 Oct 2011 16:41:04 +0900 Subject: 2005-01-14 Daniel Forchheimer * transSet.c: Options increase/decrease Options maximum/minimum --- README | 3 +++ transSet.c | 50 +++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/README b/README index c234a3b..c2f9d71 100644 --- a/README +++ b/README @@ -17,8 +17,11 @@ Features -select window by clicking (as transset) -select window by pointing -force toggle + -increase or decrease opacity +Get transset-df from: http://www.forchheimer.se/transset-df/ + Any questions/sugestions just send me a email Cheers diff --git a/transSet.c b/transSet.c index 8437f2c..bfda4f1 100644 --- a/transSet.c +++ b/transSet.c @@ -8,7 +8,7 @@ */ -#define VERSIONSTR "1" +#define VERSIONSTR "2" #include #include @@ -35,6 +35,14 @@ void usage() " -c, --click select by clicking on window (default)\n"); fprintf(stderr, " -p, --point select the window currently under the cursor\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"); + fprintf(stderr, + " -x, --max=OPACITY maximum possible opacity (default = 1)\n"); fprintf(stderr, " -v, --version print version number\n"); @@ -53,7 +61,10 @@ int main(int argc, char **argv) unsigned int current_opacity; int select_method = 0; // 0 = click, 1 = point int flag_toggle=0; + int flag_increase=0; + int flag_decrease=0; int o; + float min=0,max=1; int options_index=0; static struct option long_options[] = { @@ -61,6 +72,10 @@ int main(int argc, char **argv) {"help",0,NULL,'h'}, {"point",0,NULL,'p'}, {"click",0,NULL,'c'}, + {"inc",0,NULL,'1'}, + {"dec",0,NULL,'2'}, + {"min",1,NULL,'m'}, + {"max",1,NULL,'x'}, {"version",0,NULL,'v'}, {0,0,0,0} }; @@ -68,7 +83,7 @@ int main(int argc, char **argv) /* wonderful utility */ Setup_Display_And_Screen(&argc, argv); - while ((o = getopt_long(argc, argv, "thpcv",long_options,&options_index)) != -1) + while ((o = getopt_long(argc, argv, "thpcvm:x:12",long_options,&options_index)) != -1) { switch (o) { case 't': @@ -83,6 +98,18 @@ int main(int argc, char **argv) case 'p': select_method=1; break; + case '1': + flag_increase=1; + break; + case '2': + flag_decrease=1; + break; + case 'm': + min = atof(optarg); + break; + case 'x': + max = atof(optarg); + break; case 'v': fprintf(stderr,"version: %s\n",VERSIONSTR); exit(1); @@ -97,6 +124,7 @@ int main(int argc, char **argv) d = atof (argv[optind]); gotd = 1; } + if(select_method==1) { /* don't wait for click */ @@ -112,11 +140,7 @@ int main(int argc, char **argv) int format; unsigned long n, left; - - if (gotd) - opacity = (unsigned int) (d * OPAQUE); - else - opacity = 0xc0000000; + if (!gotd) d=0.75; /* get property */ XGetWindowProperty(dpy, target_win, XInternAtom(dpy, OPACITY, False), @@ -131,6 +155,18 @@ int main(int argc, char **argv) } else current_opacity = OPAQUE; + + if(flag_increase) { + d = (double)current_opacity/OPAQUE + d; + } else if(flag_decrease) { + d = (double)current_opacity/OPAQUE - d; + } + printf("%f\n",d); + /* check min and max */ + if(dmax) d=max; + + opacity = (unsigned int) (d * OPAQUE); /* for user-compability with transset */ if(!gotd) flag_toggle=1; -- cgit v1.2.3 From 30300bf213557b99bcfd3d92587f6a96e9494124 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine Date: Sun, 30 Oct 2011 16:41:56 +0900 Subject: 2005-01-14 Daniel Forchheimer Release v3 * transSet.c: Select by name (-n, --name) Select by id (-i, --id) --- README | 36 +++++++++++++++++--------------- transSet.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 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 #include @@ -35,14 +35,18 @@ void usage() " -c, --click select by clicking on window (default)\n"); 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(dmax) 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); -- cgit v1.2.3 From 470ea5431ffe0a54995c93506ab5e55ce534e039 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine Date: Sun, 30 Oct 2011 16:43:09 +0900 Subject: 2005-03-13 Daniel Forchheimer Release v4 Bugfix: select by name or id didn't work in many windowmanagers like xfce and wmaker. * transSet.c: Function get_top_window() fixes the bug Options verbose, no-regex * dsimple.c: Window_With_Name_Regex() now takes same arguments as Window_With_Name() * Makefile: Added simple install instructions 2005-02-08 Daniel Forchheimer Select name now takes a regular expression Fixed all warnings * dsimple.c: Window_With_Name_Regex() * transSet.c: use the new regex function print the name (if possible) * dsimple.h: Added the new functions to avoid warnings --- README | 7 ++- dsimple.c | 71 +++++++++++++++++++++++-- dsimple.h | 7 +++ transSet.c | 171 ++++++++++++++++++++++++++++++++++++++----------------------- 4 files changed, 186 insertions(+), 70 deletions(-) diff --git a/README b/README index 8f056fa..4ae16e7 100644 --- a/README +++ b/README @@ -21,8 +21,11 @@ Features *force toggle *increase or decrease opacity -Latest version is: 3 -Updated 2005-01-20 +Instalation + type: + make + make install + Homepage: http://www.forchheimer.se/transset-df/ Any questions/sugestions or if you just want to say hello don't fear to send diff --git a/dsimple.c b/dsimple.c index e388380..2dbdc72 100644 --- a/dsimple.c +++ b/dsimple.c @@ -35,6 +35,9 @@ from The Open Group. #include #include #include + +#include +#include /* * Other_stuff.h: Definitions of routines in other_stuff. * @@ -460,9 +463,9 @@ Window Get_Window_Under_Cursor(dpy) { int status; Cursor cursor; - XEvent event; + //XEvent event; Window target_win = None, root = RootWindow(dpy,screen); - int buttons = 0; + //int buttons = 0; Window tmp; int rx,ry,cx,cy; unsigned int mask; @@ -503,7 +506,7 @@ Window Window_With_Name(dpy, top, name) int i; Window w=0; char *window_name; - + if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name)) return(top); @@ -519,6 +522,68 @@ Window Window_With_Name(dpy, top, name) return(w); } +/* + * Window_With_Name_Regex: Same as above but use regular expressions + * to match a window name. Only returns the first + * result. + * Window_With_Name_Regex_Recurse: Takes regex_t struct as argument + * instead of char* + * Written by Daniel Forchheimer 2005 + * */ +Window Window_With_Name_Regex_Recurse(dpy, top, reg_name) + Display *dpy; + Window top; + regex_t *reg_name; +{ + Window *children, dummy; + unsigned int nchildren; + int i; + Window w=0; + char *window_name; + + if (XFetchName(dpy, top, &window_name) && !regexec(reg_name,window_name,0,NULL,0)) + return(top); + + if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren)) + return(0); + + for (i=0; i /* Global variables used by routines in just_display.c */ extern char *program_name; /* Name of this program */ @@ -91,14 +92,20 @@ void usage(); unsigned long Resolve_Color(Window, char *); Pixmap Bitmap_To_Pixmap(Display *, Drawable, GC, Pixmap, int, int); Window Select_Window(Display *); +Window Get_Window_Under_Cursor(Display *); /*added by Daniel Forchheimer for transset-df*/ void blip(void); Window Window_With_Name(Display *, Window, char *); +Window Window_With_Name_Regex(Display *, Window, char *); /*added by Daniel Forchheimer for transset-df*/ +Window Window_With_Name_Regex_Recurse(Display *, Window, regex_t *); /*added by Daniel Forchheimer for transset-df*/ #else unsigned long Resolve_Color(); Pixmap Bitmap_To_Pixmap(); Window Select_Window(); +Window Get_Window_Under_Cursor(); /*added by Daniel Forchheimer for transset-df*/ void blip(); Window Window_With_Name(); +Window Window_With_Name_Regex(); /*added by Daniel Forchheimer for transset-df*/ +Window Window_With_Name_Regex_Recurse(); /*added by Daniel Forchheimer for transset-df*/ #endif #ifdef __GNUC__ void Fatal_Error(char *, ...) __attribute__((__noreturn__)); diff --git a/transSet.c b/transSet.c index 5daea80..c871472 100644 --- a/transSet.c +++ b/transSet.c @@ -8,7 +8,8 @@ */ -#define VERSIONSTR "3" +#define VERSIONSTR "4" +#define RELEASEDATESTR "2005-03-13" #include #include @@ -16,7 +17,9 @@ #include "dsimple.h" #include #include - +#include +#include +#include Window target_win; @@ -36,7 +39,9 @@ void usage() fprintf(stderr, " -p, --point select the window currently under the cursor\n"); fprintf(stderr, - " -n, --name NAME select by name\n"); + " -n, --name NAME select by name, NAME is matched as regular expression\n"); + fprintf(stderr, + " --no-regex don't use regular expression for matching name\n"); fprintf(stderr, " -i, --id select by window id\n"); fprintf(stderr, @@ -48,7 +53,9 @@ void usage() fprintf(stderr, " -x, --max OPACITY maximum possible opacity (default = 1)\n"); fprintf(stderr, - " -v, --version print version number\n"); + " -v, --verbose print some debug info\n"); + fprintf(stderr, + " -V, --version print version number\n"); exit(1); } @@ -56,6 +63,29 @@ void usage() #define OPAQUE 0xffffffff #define OPACITY "_NET_WM_WINDOW_OPACITY" +/* returns the highest parent of child that is not the root-window */ +Window get_top_window(Display *dpy,Window child) { + Window parent; + Window root; + Window *child_list; + unsigned int num_children; + + if (!XQueryTree(dpy, child, &root, &parent, &child_list, + &num_children)) + Fatal_Error("Can't query window tree."); + if(parent==root) return child; + + while(parent!=root) { + child = parent; + if (!XQueryTree(dpy, child, &root, &parent, &child_list, + &num_children)) + Fatal_Error("Can't query window tree."); + + } + return child; +} + + /* nothing fancy */ int main(int argc, char **argv) { @@ -63,18 +93,17 @@ int main(int argc, char **argv) double d; unsigned int opacity; unsigned int current_opacity; - int select_method = 0; // 0 = click, 1 = point + int select_method = 0; // 0 = click, 1 = point, 2 = id, 3 = name int flag_toggle=0; int flag_increase=0; int flag_decrease=0; + int flag_verbose=0; + int flag_no_regex=0; int o; float min=0,max=1; char *idstr,*namestr; - - Window root_win; - Window *child_list; - unsigned int num_children; - + char *windowname=NULL; + int options_index=0; static struct option long_options[] = { {"toggle",0,NULL,'t'}, @@ -87,56 +116,65 @@ int main(int argc, char **argv) {"dec",0,NULL,'2'}, {"min",1,NULL,'m'}, {"max",1,NULL,'x'}, - {"version",0,NULL,'v'}, + {"no-regex",0,NULL,'4'}, + {"version",0,NULL,'V'}, + {"verbose",0,NULL,'v'}, {0,0,0,0} }; /* wonderful utility */ Setup_Display_And_Screen(&argc, argv); - while ((o = getopt_long(argc, argv, "thpci:n:vm:x:12",long_options,&options_index)) != -1) + /* parse arguments */ + while ((o = getopt_long(argc, argv, "thpci:n:vVm:x:123",long_options,&options_index)) != -1) { switch (o) { case 't': - flag_toggle=1; - break; + flag_toggle=1; + break; case 'h': - usage(); - break; + usage(); + break; case 'c': - select_method=0; - break; + select_method=0; + break; case 'p': - select_method=1; - break; + select_method=1; + break; case 'i': - idstr = malloc(strlen(optarg)+1); - idstr = optarg; - select_method=2; - break; + idstr = malloc(strlen(optarg)+1); + idstr = optarg; + select_method=2; + break; case 'n': - namestr = malloc(strlen(optarg)+1); - namestr = optarg; - select_method=3; - break; + namestr = malloc(strlen(optarg)+1); + namestr = optarg; + select_method=3; + break; case '1': - flag_increase=1; - break; + flag_increase=1; + break; case '2': - flag_decrease=1; - break; + flag_decrease=1; + break; + case 'v': + flag_verbose=1; + break; + case '4': + flag_no_regex=1; + break; case 'm': - min = atof(optarg); - break; + min = atof(optarg); + break; case 'x': - max = atof(optarg); - break; - case 'v': - fprintf(stderr,"version: %s\n",VERSIONSTR); - exit(1); - break; + max = atof(optarg); + break; + case 'V': + fprintf(stderr,"version: %s\nreleased: %s\n",VERSIONSTR,RELEASEDATESTR); + exit(1); + break; default: - usage(); + usage(); } } @@ -146,12 +184,14 @@ int main(int argc, char **argv) gotd = 1; } - + /* select the window to make transparent */ if(select_method==1) { /* don't wait for click */ + if(flag_verbose) printf("Selecting window by click\n"); target_win = Get_Window_Under_Cursor(dpy); } else if(select_method==2) { - /* select by id, pretty much stripped from dsimple.c */ + /* select by id, pretty much ripped from dsimple.c */ + if(flag_verbose) printf("Selecting window by id\n"); sscanf(idstr, "0x%lx", &target_win); if (!target_win) sscanf(idstr, "%ld", &target_win); @@ -159,30 +199,29 @@ int main(int argc, char **argv) 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."); + if(flag_verbose) printf("Selected 0x%x, trying to get top parent ... ",(unsigned int)target_win); + target_win = get_top_window(dpy,target_win); + if(flag_verbose) printf("found 0x%x\n",(unsigned int)target_win); } else if(select_method==3) { - /* select by name, pretty much stripped from dsimple.c */ - target_win = Window_With_Name(dpy, RootWindow(dpy, screen),namestr); + /* select by name, pretty much ripped from dsimple.c */ + if(flag_verbose) printf("Selecting window by name\n"); + + if(flag_no_regex) + target_win = Window_With_Name(dpy, RootWindow(dpy, screen),namestr); + else + target_win = Window_With_Name_Regex(dpy, RootWindow(dpy, screen),namestr); + if (!target_win) { - fprintf(stderr,"No window with name %s exists!\n",namestr); + fprintf(stderr,"No window matching %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."); + /* store the matched window name*/ + XFetchName(dpy,target_win,&windowname); + + if(flag_verbose) printf("Selected 0x%x, trying to get top parent ... ",(unsigned int)target_win); + target_win = get_top_window(dpy,target_win); + if(flag_verbose) printf("found 0x%x\n",(unsigned int)target_win); } else { /* grab mouse and return window that is next clicked */ @@ -206,7 +245,7 @@ int main(int argc, char **argv) { memcpy (¤t_opacity, data, sizeof (unsigned int)); XFree(( void *) data ); - // printf("Found property: %g\n", (double) opacity / OPAQUE); + if(flag_verbose) printf("Found transparency: %g\n", (double) opacity / OPAQUE); } else current_opacity = OPAQUE; @@ -240,9 +279,11 @@ int main(int argc, char **argv) XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1L); XSync(dpy, False); - printf("Set Property to %g\n", (double) opacity / OPAQUE); - + printf("Set Property to %g", (double) opacity / OPAQUE); + if(windowname) printf(" on \n%s\n",windowname); + else printf("\n"); + if(flag_verbose) printf("Propery set on: 0x%x\n",(unsigned int)target_win); /* all done, wasn't that simple */ return 0; } -- cgit v1.2.3 From 88d9e28837f71f391402654c33394635d27d4b30 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine Date: Sun, 30 Oct 2011 16:45:00 +0900 Subject: 2006-01-10 Daniel Forchheimer Release v5 * transSet.c: Applied patch so that transset-df compiles with gcc 2.95 Thanks to Andreas Kohn for the patch --- transSet.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/transSet.c b/transSet.c index c871472..3ed63be 100644 --- a/transSet.c +++ b/transSet.c @@ -3,13 +3,13 @@ With some additional features to make it more automatic and integrated The purpos is to bind it from your wm to a key or mouse-button - Use however you want. + License: Use however you want. Written by: Daniel Forchheimer (upiom) */ -#define VERSIONSTR "4" -#define RELEASEDATESTR "2005-03-13" +#define VERSIONSTR "5" +#define RELEASEDATESTR "2006-01-10" #include #include @@ -121,6 +121,11 @@ int main(int argc, char **argv) {"verbose",0,NULL,'v'}, {0,0,0,0} }; + unsigned char *data; + + Atom actual; + int format; + unsigned long n, left; /* wonderful utility */ Setup_Display_And_Screen(&argc, argv); @@ -228,12 +233,6 @@ int main(int argc, char **argv) target_win = Select_Window(dpy); } - unsigned char *data; - - Atom actual; - int format; - unsigned long n, left; - if (!gotd) d=0.75; /* get property */ -- cgit v1.2.3 From c63bf55e69fc50e08b9bf500e9b05cf36ce48680 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine Date: Sun, 30 Oct 2011 16:46:01 +0900 Subject: 2007-09-21 Daniel Forchheimer Release v6 * transSet.c Select flag: --actual Set transparency to the actual focused X11 window Thanks to Roman Divacky for the patch --- README | 3 ++- transSet.c | 30 +++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/README b/README index 4ae16e7..9671f78 100644 --- a/README +++ b/README @@ -16,6 +16,7 @@ changing any wm-code. And it's a very "unix way" of doing things too :) Features *select window by clicking (as transset) + *select actual focused X11 window *select window by pointing *select by window name or id *force toggle @@ -33,4 +34,4 @@ me a email Cheers Daniel Forchheimer (upiom) -n04df@efd.lth.se +n04df@student.lth.se diff --git a/transSet.c b/transSet.c index 3ed63be..684a752 100644 --- a/transSet.c +++ b/transSet.c @@ -4,12 +4,15 @@ The purpos is to bind it from your wm to a key or mouse-button License: Use however you want. - Written by: Daniel Forchheimer (upiom) - + Authors: + Matthew Hawn + Daniel Forchheimer + Andreas Kohn + Roman Divacky */ -#define VERSIONSTR "5" -#define RELEASEDATESTR "2006-01-10" +#define VERSIONSTR "6" +#define RELEASEDATESTR "2007-09-21" #include #include @@ -38,6 +41,8 @@ void usage() " -c, --click select by clicking on window (default)\n"); fprintf(stderr, " -p, --point select the window currently under the cursor\n"); + fprintf(stderr, + " -a, --actual select the actual window\n"); fprintf(stderr, " -n, --name NAME select by name, NAME is matched as regular expression\n"); fprintf(stderr, @@ -85,6 +90,15 @@ Window get_top_window(Display *dpy,Window child) { return child; } +/* returns the actual window */ +Window get_actual_window(Display *dpy) +{ + int i; + Window w; + + XGetInputFocus(dpy, &w, &i); + return get_top_window(dpy, w); +} /* nothing fancy */ int main(int argc, char **argv) @@ -109,6 +123,7 @@ int main(int argc, char **argv) {"toggle",0,NULL,'t'}, {"help",0,NULL,'h'}, {"point",0,NULL,'p'}, + {"actual",0,NULL,'a'}, {"click",0,NULL,'c'}, {"id",1,NULL,'i'}, {"name",1,NULL,'n'}, @@ -131,7 +146,7 @@ int main(int argc, char **argv) Setup_Display_And_Screen(&argc, argv); /* parse arguments */ - while ((o = getopt_long(argc, argv, "thpci:n:vVm:x:123",long_options,&options_index)) != -1) + while ((o = getopt_long(argc, argv, "thapci:n:vVm:x:123",long_options,&options_index)) != -1) { switch (o) { case 't': @@ -156,6 +171,9 @@ int main(int argc, char **argv) namestr = optarg; select_method=3; break; + case 'a': + select_method=4; + break; case '1': flag_increase=1; break; @@ -228,6 +246,8 @@ int main(int argc, char **argv) target_win = get_top_window(dpy,target_win); if(flag_verbose) printf("found 0x%x\n",(unsigned int)target_win); + } else if(select_method==4) { + target_win = get_actual_window(dpy); } else { /* grab mouse and return window that is next clicked */ target_win = Select_Window(dpy); -- cgit v1.2.3