FakeKeypress in complex functions

Hi:

I want to send a FakeKeypress command (so that it is available outside FVWM as an XEvent) each time a mapped/bound key is pressed (along with switching between 2 different applications when the key is pressed)- unfortunately, in my code, I can only get the FakeKeypress to be sent every other time (whereas the application switching works every time the button is pressed). My code is below. Any suggestions/comments would be welcome.

Key F23 A A FuncMyFoo
DestroyFunc FuncMyFoo
AddToFunc   FuncMyFoo
+ I FocusOnWindow "Foo_1" "Foo_2"
        # Helper function
        DestroyFunc FocusOnWindow
        AddToFunc   FocusOnWindow
        + I Next ($$0, !Focused, CirculateHit) Function MakeFooVisible
        + I TestRc (Match) Break
        + I Next ($$1, !Focused, CirculateHit) Function MakeFooVisible

        # Helper function
        AddToFunc MakeFooVisible
        + I Raise
        + I WindowShade off
        + I Iconify off 
        + I FakeKeypress press F23 
        + I Focus
        + I GoToDesk 0

the function works just fine WITHOUT the FakeKeypress being sent across… but I have to have it for a third party to work correctly. Seriously, anythoughts?

thanks,
Skender

Well, it might very well be that the FakeKeyPress is buggy or unreliable, the fvwm manpage clearly states that it was only intended for testing purposes and that no guarantee of it’s correct functioning is made…

That being said it would be nice to have it working reliably though…

I think you need to re-evaluate what’s happening to your application. It’s not a question of XEvents, and whether they’re being received – because they are. What I suspect is happening is that your application isn’t dealing with them in the correct manner.

Typically, XEvents are dealt with in one big loop:

Window window1;
XEvent report;   // event union reference
while(1){        // event loop
    XNextEvent(display, &report);
    switch (report.type){
    case ButtonEvent:
       .........
    }
}

But I can’t be anymore specific, than this.

– Thomas Adam

Thomas –

You were right. I looked into the code, and found an XEvent consumer/listener.

Apparently my problem is that the once the XEvents go from this X-app, and are then propogated to another machine using udp, the messages are not arriving - I don’t know if this means they are never arriving, or they are not correctly sent… Anyways, thanks for you help on the fvwm side of things.

Skender

Well, UDP as a protocol doesn’t care whether the packets of information arrive or not – it just sends them. It does seem very odd to me, to pass XEvents even further down the line – but I’m sure the application must make sense, at some level.

If you know what port the information is being sent out on, then use ‘nc’ or some other port-listener to determine whether the packets are being received.

You’re welcome.

– Thomas Adam

Thomas,

do you know if it is possible to pass an XEvent, as an object, through FVWM to an application that would act as a consumer?

The guy who worked here before me did something like that with TWM… stupidest design I have ever seen.

But, if it is possible, I would like to know how.
– Skender

If by ‘consumer’, you mean something that just stores the events, then I doubt it. You could certainly get this consumer to make a list of events that were generated, but why would you want to do this?

I might be confusing your teminology as to what a ‘consumer’ is in this instance – if you can provide more details, I might be able to help you further.

– Thomas Adam

All:

So, after reviewing the situation, and the need for the FakeKeypress, here’s the situation, in glorious detail – if anyone can help, just tell me who to write the check to afterwards:

I have an application that I MUST USE that is expecting XEvents from the FVWM. The XEvents are then being put into a proprietary object, and passed off to another machine via UDP - I therefore must use this XEvent receiver/UDP server. This XEvent receiver actually has 2 instances active at all times (to allow for ‘different states of functionality’ – I didn’t write this piece of crap – I would have used a memento to tell the darn thing what state it was in… but thats neither here nor there), one represented by a symbolic link, and the other is just the app in it’s basic state.

I must therefore pass keypresses, change of focus commands, etc. to this XEvent receiver via the FVWM (because it is an app that is dependent on the FVWM)

I have succeeded in being able to pass Change of focus commands successfully to this Xevent Receiver/UDP server. However, The key press and key release xevents are being used by the FVWM to call functions in the .fvw2rc and so I am trying to pass ‘copies’ of these keypresses to the waiting XEvent reveiver using FakeKeypress.

As I have noted in previous posts, I have a keyboard with special keys. One of these special keys has a keycode 205. In an xmodmap augmenting file, I have mapped that keycode to F23.

I then have bound this ‘F23’ keyvalue /keycode to a Function:

Key F23 A A FuncFocusAppSwitch

Now, the functionality that I desire out of this keypress (as I have pointed out earlier, but am apparently just too stupid to make work) is to have two applications ‘toggle’ one in front of each other, regardless of which desk/application is currently in focus. If F23 is pressed, and I am currently on Desk 4, or Desk 7, or Desk332, working on something else,I need the WM to:
[list]

  • GoToDesk 0 0 (where I have placed this Xevent receiver/UDP server)
  • place the focus onto the application entitled ‘simbProxy_AddApps’(by default, app proxyApps is in focus on Desk 0 at startup) which resides on Desk 0
    -pass a keypress event and a key release event to simbProxy_AddApps with value F23
    [/list:u]
    Then, if F23 is pressed again or the focus, in anyway, is removed from simbProxy_AddApps, I need FVWM to do the following:
    [list]
    -Switch the Focus back to the application entitled proxyApps
    -Send a key press, key release event to proxyApps with value F23
    [/list:u]

that’s mostly what I’ve been trying to write for the last week, and I can’t get it to work. I can get the change of focus to work just fine, but I can only get a keypress/keyrelease events sent every other time I press my F23 button. The first time I press F23, a Key press, a key release and a Focus change XEvent are received by the XEvent receiver. The second time I press F23, only the focus Change event is received. The third time, the key press/key release are received, as well as the change focus event.

I am stumped, entirely. Below is the code that I have been trying to get to work, in it’s latest incarnation.

If anyone has any idea, please let me know, and I’ll donate 100 US dollars to the fvwm.org site, or whatever - I just gotta get this to work.

Key F23 A A FuncFocusAppSwitch
DestroyFunc FuncFocusAppSwitch
AddToFunc   FuncFocusAppSwitch

+ I FuncSwitch "proxyApps" "simbProxy_AddApps"

        AddToFunc FuncSwitch
        + I Next ($$0, !Focused, CirculateHit) Function MakeVisible
        + I TestRc (Match) Break
        + I Next ($$1, !Focused, CirculateHit) Function MakeVisible

        # Helper function
        DestroyFunc MakeVisible
        AddToFunc MakeVisible
        + I Iconify off
        + I Raise
        + I Focus
        + I WindowId $[w.id] FakeKeypress press F23 release F23
#       + I FakeKeypress depth 2 press F23  release F23
        + I Break

Any ideas or comments would be greatly, greatly appreciated

Sorry for bothering everyone over the last few weeks with pleas for help.

The problem has been the wanker who wrote the udp server had the wrong udp receiver targeted… so it looked like my stuff wasn’t working…

thanks for everyone’s help.

  • skender

That’s fine – it has been mildly interesting at any rate. Please bear in mind that it’s not the fault of FVWM that causes your problems. :slight_smile:

No surprise there. :stuck_out_tongue:

– Thomas Adam