On Wed, Feb 08, 2006 at 04:01:15PM +0100, Dominik Vogt wrote: > > Here is the correct one. I'm very very sorry. > > Thats a nice patch with an important feature. > > I have some minor change requests though: > > 1) Please supply ChangeLog and NEWS entries for the patch (and > optionally an AUTHORS entry).
Here it goes in new attached patch. > I think there shouldn't be a NULL "pointer" at the end of an int > array. Yes, you're right. What was I thinking... > Please do not hard-code the number of mouse buttons. The macro I did it mainly to keep Button1, Button2 etc constants opaque. [skip] > This reads past the end or beginning of the array if the user > requests a button < 0 or > 5. And because Button1 == 1, ..., > Button5 == 5 you can as well just write > if (mousebutton <= 0 || > mousebutton > NUMBER_OF_EXTENDED_MOUSE_BUTTONS) > { > mousebutton = 1; > } > /*...*/ > act = GetButtonAction(b, mousebutton); > > and remove the buttons[] array. I did just like you said. -- George 'Nephrite' Potapov
Index: AUTHORS =================================================================== RCS file: /home/cvs/fvwm/fvwm/AUTHORS,v retrieving revision 1.110 diff -u -r1.110 AUTHORS --- AUTHORS 21 Dec 2005 10:05:33 -0000 1.110 +++ AUTHORS 8 Feb 2006 15:28:05 -0000 @@ -29,6 +29,7 @@ George Potapov: ShowOnlyFocused option for FvwmIconMan. +PressButton command in FvwmButtons Jim C. Brown: MailDir option in FvwmTaskBar. Index: ChangeLog =================================================================== RCS file: /home/cvs/fvwm/fvwm/ChangeLog,v retrieving revision 1.2666 diff -u -r1.2666 ChangeLog --- ChangeLog 2 Feb 2006 07:39:32 -0000 1.2666 +++ ChangeLog 8 Feb 2006 15:28:07 -0000 @@ -1,3 +1,11 @@ +2006-02-08 George Potapov <[EMAIL PROTECTED]> + + * modules/FvwmButtons/FvwmButtons.1.in + * modules/FvwmButtons/FvwmButtons.c + * modules/FvwmButtons/FvwmButtons.h + * modules/FvwmButtons/dynamic.c + Added command PressButton to module FvwmButtons + 2006-02-02 Dominik Vogt <dominik(dot)vogt(at)gmx(dot)de> * libs/Module.h: Index: NEWS =================================================================== RCS file: /home/cvs/fvwm/fvwm/NEWS,v retrieving revision 1.595 diff -u -r1.595 NEWS --- NEWS 29 Jan 2006 09:57:18 -0000 1.595 +++ NEWS 8 Feb 2006 15:28:08 -0000 @@ -5,6 +5,11 @@ Changes in beta release 2.5.17 (not released yet) +* New features: + + - New command PressButton in module FvwmButtons for being able to emulate + button press via other means + * Bug Fixes: - Fixed detection of running non-ICCCM2 wm (bug #3151). Index: modules/FvwmButtons/FvwmButtons.1.in =================================================================== RCS file: /home/cvs/fvwm/fvwm/modules/FvwmButtons/FvwmButtons.1.in,v retrieving revision 1.2 diff -u -r1.2 FvwmButtons.1.in --- modules/FvwmButtons/FvwmButtons.1.in 27 Feb 2005 07:47:25 -0000 1.2 +++ modules/FvwmButtons/FvwmButtons.1.in 8 Feb 2006 15:28:08 -0000 @@ -1015,6 +1015,19 @@ above. Command may be any fvwm command with variables $var that are expanded if supported. +.IP "PressButton \fIbutton_id\fP [\fImouse_button\fP]" +where +.I button_id +is the id of the button to press as specified using the +.B Id +button option and +.I mouse_button +is the number of mouse button used to click on the button e.g "1" for left +mouse button etc. Quotes around the number is not needed. If +.I mouse_button +option is omitted "1" assumed. This command behaves exactly like if +the button in question was pressed using the mouse. + .IP Silent This prefix may be specified before other actions. It disables all possible error and warning messages. Index: modules/FvwmButtons/FvwmButtons.c =================================================================== RCS file: /home/cvs/fvwm/fvwm/modules/FvwmButtons/FvwmButtons.c,v retrieving revision 1.199 diff -u -r1.199 FvwmButtons.c --- modules/FvwmButtons/FvwmButtons.c 27 Feb 2005 07:47:25 -0000 1.199 +++ modules/FvwmButtons/FvwmButtons.c 8 Feb 2006 15:28:09 -0000 @@ -880,6 +880,114 @@ return b; } +void ButtonPressProcess (b, act) + button_info *b; + char **act; +{ + FlocaleNameString tmp; + int i,i2; + + memset(&tmp, 0, sizeof(tmp)); + if (b && !*act && b->flags.b_Panel) + { + ActiveButton = b; + HandlePanelPress(b); + if (b->newflags.panel_mapped == 0) + { + if (is_transient) + { + /* terminate if transient and panel has been unmapped */ + exit(0); + } + else if (is_transient_panel) + { + XWithdrawWindow(Dpy, MyWindow, screen); + } + } + } /* panel */ + else + { + if (!*act) + *act=GetButtonAction(b,0); + if (b && b == CurrentButton && *act) + { + if (strncasecmp(*act,"Exec",4) == 0 && + isspace((*act)[4])) + { + + /* Look for Exec "identifier", in which case the button + stays down until window "identifier" materializes */ + i = 4; + while(isspace((unsigned char)(*act)[i])) + i++; + if((*act)[i] == '"') + { + i2=i+1; + while((*act)[i2]!=0 && (*act)[i2]!='"') + i2++; + + if(i2-i>1) + { + b->flags.b_Hangon = 1; + b->hangon = mymalloc(i2-i); + strncpy(b->hangon,&(*act)[i+1],i2-i-1); + b->hangon[i2-i-1] = 0; + } + i2++; + } + else + i2=i; + + tmp.name = mymalloc(strlen(*act)+1); + strcpy(tmp.name, "Exec "); + while((*act)[i2]!=0 && isspace((unsigned char)(*act)[i2])) + i2++; + strcat(tmp.name ,&(*act)[i2]); + if (is_transient) + { + /* delete the window before continuing */ + XDestroyWindow(Dpy, MyWindow); + XSync(Dpy, 0); + } + SendText(fd,tmp.name,0); + if (is_transient) + { + /* and exit */ + exit(0); + } + if (is_transient_panel) + { + XWithdrawWindow(Dpy, MyWindow, screen); + } + free(tmp.name); + } /* exec */ + else if(strncasecmp(*act,"DumpButtons",11)==0) + DumpButtons(UberButton); + else if(strncasecmp(*act,"SaveButtons",11)==0) + SaveButtons(UberButton); + else + { + if (is_transient) + { + /* delete the window before continuing */ + XDestroyWindow(Dpy, MyWindow); + XSync(Dpy, 0); + } + SendText(fd,*act,0); + if (is_transient) + { + /* and exit */ + exit(0); + } + if (is_transient_panel) + { + XWithdrawWindow(Dpy, MyWindow, screen); + } + } + } /* *act */ + } /* !panel */ +} + /* -------------------------------- Main Loop -------------------------------*/ /** @@ -1171,104 +1279,8 @@ } b = select_button(UberButton, x, y); act = GetButtonAction(b,Event.xbutton.button); - if (b && !act && b->flags.b_Panel) - { - ActiveButton = b; - HandlePanelPress(b); - if (b->newflags.panel_mapped == 0) - { - if (is_transient) - { - /* terminate if transient and panel has been unmapped */ - exit(0); - } - else if (is_transient_panel) - { - XWithdrawWindow(Dpy, MyWindow, screen); - } - } - } /* panel */ - else - { - if (!act) - act=GetButtonAction(b,0); - if (b && b == CurrentButton && act) - { - if (strncasecmp(act,"Exec",4) == 0 && - isspace(act[4])) - { - - /* Look for Exec "identifier", in which case the button - stays down until window "identifier" materializes */ - i = 4; - while(isspace((unsigned char)act[i])) - i++; - if(act[i] == '"') - { - i2=i+1; - while(act[i2]!=0 && act[i2]!='"') - i2++; - - if(i2-i>1) - { - b->flags.b_Hangon = 1; - b->hangon = mymalloc(i2-i); - strncpy(b->hangon,&act[i+1],i2-i-1); - b->hangon[i2-i-1] = 0; - } - i2++; - } - else - i2=i; - - tmp.name = mymalloc(strlen(act)+1); - strcpy(tmp.name, "Exec "); - while(act[i2]!=0 && isspace((unsigned char)act[i2])) - i2++; - strcat(tmp.name ,&act[i2]); - if (is_transient) - { - /* delete the window before continuing */ - XDestroyWindow(Dpy, MyWindow); - XSync(Dpy, 0); - } - SendText(fd,tmp.name,0); - if (is_transient) - { - /* and exit */ - exit(0); - } - if (is_transient_panel) - { - XWithdrawWindow(Dpy, MyWindow, screen); - } - free(tmp.name); - } /* exec */ - else if(strncasecmp(act,"DumpButtons",11)==0) - DumpButtons(UberButton); - else if(strncasecmp(act,"SaveButtons",11)==0) - SaveButtons(UberButton); - else - { - if (is_transient) - { - /* delete the window before continuing */ - XDestroyWindow(Dpy, MyWindow); - XSync(Dpy, 0); - } - SendText(fd,act,0); - if (is_transient) - { - /* and exit */ - exit(0); - } - if (is_transient_panel) - { - XWithdrawWindow(Dpy, MyWindow, screen); - } - } - } /* act */ - } /* !panel */ + + ButtonPressProcess(b, &act); if (act != NULL) { Index: modules/FvwmButtons/FvwmButtons.h =================================================================== RCS file: /home/cvs/fvwm/fvwm/modules/FvwmButtons/FvwmButtons.h,v retrieving revision 1.50 diff -u -r1.50 FvwmButtons.h --- modules/FvwmButtons/FvwmButtons.h 27 Feb 2005 07:47:25 -0000 1.50 +++ modules/FvwmButtons/FvwmButtons.h 8 Feb 2006 15:28:09 -0000 @@ -246,6 +246,9 @@ void SetTransparentBackground(button_info *ub,int w,int h); void exec_swallow(char *action, button_info *b); +char *GetButtonAction(button_info*,int); +void ButtonPressProcess(button_info *b, char **act); + /* ----------------------------- global variables -------------------------- */ extern Display *Dpy; Index: modules/FvwmButtons/dynamic.c =================================================================== RCS file: /home/cvs/fvwm/fvwm/modules/FvwmButtons/dynamic.c,v retrieving revision 1.14 diff -u -r1.14 dynamic.c --- modules/FvwmButtons/dynamic.c 26 Nov 2005 21:55:12 -0000 1.14 +++ modules/FvwmButtons/dynamic.c 8 Feb 2006 15:28:09 -0000 @@ -195,7 +195,7 @@ static char *actions[] = { - "Silent", "ChangeButton", "ExpandButtonVars", NULL + "Silent", "ChangeButton", "ExpandButtonVars", "PressButton", NULL }; static char *button_options[] = @@ -208,6 +208,9 @@ char *rest; int action = -1; button_info *b; + char *act; + char *buttonn; + int mousebutton; silent = False; do @@ -365,6 +368,30 @@ free(line); } break; + case 3: + /* PressButton */ + rest = GetQuotedString( + rest, &buttonn, "", NULL, NULL, NULL); + if (buttonn) { + mousebutton = atoi(buttonn); + + free(buttonn); + } + if (mousebutton<= 0 || + mousebutton > NUMBER_OF_EXTENDED_MOUSE_BUTTONS + ) { + mousebutton = 1; + } + + CurrentButton = b; + act = GetButtonAction(b, mousebutton); + ButtonPressProcess(b, &act); + if (act) { + free(act); + } + CurrentButton = NULL; + + break; } return;