Looks like Mikhael committed cleaned up version of FvwmButtons so I'm resubmitting my patch for button press simulation. I cleaned the code up as requested.
-- George 'Nephrite' Potapov
Index: AUTHORS =================================================================== RCS file: /home/cvs/fvwm/fvwm/AUTHORS,v retrieving revision 1.112 diff -u -r1.112 AUTHORS --- AUTHORS 9 Feb 2006 11:49:32 -0000 1.112 +++ AUTHORS 10 Feb 2006 08:35:19 -0000 @@ -35,6 +35,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.2669 diff -u -r1.2669 ChangeLog --- ChangeLog 9 Feb 2006 16:01:26 -0000 1.2669 +++ ChangeLog 10 Feb 2006 08:35:22 -0000 @@ -1,3 +1,11 @@ +2006-02-10 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-09 Dominik Vogt <dominik(dot)vogt(at)gmx(dot)de> * fvwm/menus.c (size_menu_horizontally): Index: NEWS =================================================================== RCS file: /home/cvs/fvwm/fvwm/NEWS,v retrieving revision 1.596 diff -u -r1.596 NEWS --- NEWS 9 Feb 2006 11:49:32 -0000 1.596 +++ NEWS 10 Feb 2006 08:35:22 -0000 @@ -9,6 +9,8 @@ - New MenuStyle options TitleFont, TitleColorset and HilightTitleBack. + - New command PressButton in module FvwmButtons for being able to emulate + button press via other means * Bug Fixes: 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 10 Feb 2006 08:35:22 -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.200 diff -u -r1.200 FvwmButtons.c --- modules/FvwmButtons/FvwmButtons.c 9 Feb 2006 23:17:05 -0000 1.200 +++ modules/FvwmButtons/FvwmButtons.c 10 Feb 2006 08:35:23 -0000 @@ -944,6 +944,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 -------------------------------*/ /** @@ -1261,105 +1369,9 @@ Event.xbutton.y, &x, &y, &dummy); } 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 */ + act = GetButtonAction(b,Event.xbutton.button); + + 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.51 diff -u -r1.51 FvwmButtons.h --- modules/FvwmButtons/FvwmButtons.h 9 Feb 2006 23:17:05 -0000 1.51 +++ modules/FvwmButtons/FvwmButtons.h 10 Feb 2006 08:35:23 -0000 @@ -247,6 +247,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 10 Feb 2006 08:35:23 -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,26 @@ 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;