What's meaning for synthetic YES in event log? - Xwindows

This is a discussion on What's meaning for synthetic YES in event log? - Xwindows ; I am writing a program to send a event to mplayer to pause the playback, for example, I tried to send a 'p' keypress event to stop the playback, but it seems not working. If I gave a 'p' key ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: What's meaning for synthetic YES in event log?

  1. What's meaning for synthetic YES in event log?

    I am writing a program to send a event to mplayer to pause the
    playback, for example, I tried to send a 'p' keypress event to stop
    the playback, but it seems not working. If I gave a 'p' key stroke
    manually, mplayer will stop. Here is the event log I got from xev. I
    notice that the difference between the simulation and real event is
    that synthetic is YES in simulation, and it is no in real event. I
    don't understand what' the meaning of syntheic? How could I send a
    event with synthetic set as NO?

    -------------------EVENT LOG----------------------------------

    FocusIn event, serial 9, synthetic NO, window 0x2000001,
    mode NotifyNormal, detail NotifyNonlinear

    KeymapNotify event, serial 9, synthetic NO, window 0x0,
    keys: 0 0 0 0 16 0 0 0 0 64 0 0 0 0 0
    0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0

    ---> below is 2 simulated p keypress events, not working

    KeyPress event, serial 9, synthetic YES, window 0x2000001,
    root 0x55, subw 0x0, time 0, (100,100), root106,120),
    state 0x0, keycode 33 (keysym 0x70, p), same_screen YES,
    XLookupString gives 1 bytes: "p"

    KeyRelease event, serial 9, synthetic YES, window 0x2000001,
    root 0x55, subw 0x0, time 0, (100,100), root106,120),
    state 0x0, keycode 33 (keysym 0x70, p), same_screen YES,
    XLookupString gives 1 bytes: "p"
    .......


    ---> below is real p keyboard event, it stops the mplayer.

    KeyPress event, serial 14, synthetic NO, window 0x2000001,
    root 0x55, subw 0x0, time 15061709, (331,763), root337,783),
    state 0x0, keycode 33 (keysym 0x70, p), same_screen YES,
    XLookupString gives 1 bytes: "p"

    KeyRelease event, serial 14, synthetic NO, window 0x2000001,
    root 0x55, subw 0x0, time 15061892, (331,763), root337,783),
    state 0x0, keycode 33 (keysym 0x70, p), same_screen YES,
    XLookupString gives 1 bytes: "p"

    FocusOut event, serial 14, synthetic NO, window 0x2000001,
    mode NotifyNormal, detail NotifyNonlinear

    the following is the code where I initialize the event....

    myEvent1.type = KeyPress;
    150 myEvent1.xkey.type = KeyPress;
    151 myEvent1.xkey.send_event = True;
    152 myEvent1.xkey.display = display;
    153 myEvent1.xkey.window = mplayerWin;
    154 myEvent1.xkey.state = 0;
    155 myEvent1.xkey.root= rootwin;
    156 myEvent1.xkey.same_screen= True;
    158 myEvent1.xkey.keycode = 33;
    159 myEvent1.xkey.subwindow = 0;
    160 myEvent1.xkey.x = 100;
    161 myEvent1.xkey.y = 100;
    162 myEvent1.xkey.x_root = 106;
    163 myEvent1.xkey.y_root = 120;
    164 if ( status = XSendEvent(display, InputFocus, False,
    KeyPress, &myEvent1))

    Thanks for your suggestions....

  2. Re: What's meaning for synthetic YES in event log?

    perry zhou wrote:

    > notice that the difference between the simulation and real event is
    > that synthetic is YES in simulation, and it is no in real event. I
    > don't understand what' the meaning of syntheic? How could I send a
    > event with synthetic set as NO?


    The meaning is what you have observed. A synthetic event is generated by a
    client, a real event is generated by the server. A client can't send a
    real event (synthetic set as NO), not either if you set the event's
    'send_event' member to False. The server will replace the value with True
    (synthetic set as YES).

    Regards,
    Daniel

  3. Re: What's meaning for synthetic YES in event log?

    perry zhou wrote:

    > I am writing a program to send a event to mplayer to pause the
    > playback, for example, I tried to send a 'p' keypress event to stop
    > the playback, but it seems not working. If I gave a 'p' key stroke
    > manually, mplayer will stop. Here is the event log I got from xev. I
    > notice that the difference between the simulation and real event is
    > that synthetic is YES in simulation, and it is no in real event. I
    > don't understand what' the meaning of syntheic? How could I send a
    > event with synthetic set as NO?


    It means the event originate from a client using XSendEvent rather than
    originating from a device via the Xserver. For security purposes
    many/most clients ignore such events. Consider that if what you want
    to do works by default then anyone with access to your X display could
    manipulate your mplayer client or your open terms or your login screen.
    Look at the doc for the client you are trying to drive and see if you
    can enable acceptance of such events. If not, you'll need to use an X
    server test extension (if available) or something even more esoteric
    like a custom input device.

    -- ced

    >
    > -------------------EVENT LOG----------------------------------
    >
    > FocusIn event, serial 9, synthetic NO, window 0x2000001,
    > mode NotifyNormal, detail NotifyNonlinear
    >
    > KeymapNotify event, serial 9, synthetic NO, window 0x0,
    > keys: 0 0 0 0 16 0 0 0 0 64 0 0 0 0 0
    > 0
    > 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    > 0
    >
    > ---> below is 2 simulated p keypress events, not working
    >
    > KeyPress event, serial 9, synthetic YES, window 0x2000001,
    > root 0x55, subw 0x0, time 0, (100,100), root106,120),
    > state 0x0, keycode 33 (keysym 0x70, p), same_screen YES,
    > XLookupString gives 1 bytes: "p"
    >
    > KeyRelease event, serial 9, synthetic YES, window 0x2000001,
    > root 0x55, subw 0x0, time 0, (100,100), root106,120),
    > state 0x0, keycode 33 (keysym 0x70, p), same_screen YES,
    > XLookupString gives 1 bytes: "p"
    > .......
    >
    >
    > ---> below is real p keyboard event, it stops the mplayer.
    >
    > KeyPress event, serial 14, synthetic NO, window 0x2000001,
    > root 0x55, subw 0x0, time 15061709, (331,763), root337,783),
    > state 0x0, keycode 33 (keysym 0x70, p), same_screen YES,
    > XLookupString gives 1 bytes: "p"
    >
    > KeyRelease event, serial 14, synthetic NO, window 0x2000001,
    > root 0x55, subw 0x0, time 15061892, (331,763), root337,783),
    > state 0x0, keycode 33 (keysym 0x70, p), same_screen YES,
    > XLookupString gives 1 bytes: "p"
    >
    > FocusOut event, serial 14, synthetic NO, window 0x2000001,
    > mode NotifyNormal, detail NotifyNonlinear
    >
    > the following is the code where I initialize the event....
    >
    > myEvent1.type = KeyPress;
    > 150 myEvent1.xkey.type = KeyPress;
    > 151 myEvent1.xkey.send_event = True;
    > 152 myEvent1.xkey.display = display;
    > 153 myEvent1.xkey.window = mplayerWin;
    > 154 myEvent1.xkey.state = 0;
    > 155 myEvent1.xkey.root= rootwin;
    > 156 myEvent1.xkey.same_screen= True;
    > 158 myEvent1.xkey.keycode = 33;
    > 159 myEvent1.xkey.subwindow = 0;
    > 160 myEvent1.xkey.x = 100;
    > 161 myEvent1.xkey.y = 100;
    > 162 myEvent1.xkey.x_root = 106;
    > 163 myEvent1.xkey.y_root = 120;
    > 164 if ( status = XSendEvent(display, InputFocus, False,
    > KeyPress, &myEvent1))
    >
    > Thanks for your suggestions....



    --
    Chuck Dillon
    Senior Software Engineer
    NimbleGen Systems Inc.

  4. Re: What's meaning for synthetic YES in event log?

    Daniel Rakel wrote in message news:...
    > perry zhou wrote:
    >
    > > notice that the difference between the simulation and real event is
    > > that synthetic is YES in simulation, and it is no in real event. I
    > > don't understand what' the meaning of syntheic? How could I send a
    > > event with synthetic set as NO?

    >
    > The meaning is what you have observed. A synthetic event is generated by a
    > client, a real event is generated by the server. A client can't send a
    > real event (synthetic set as NO), not either if you set the event's
    > 'send_event' member to False. The server will replace the value with True
    > (synthetic set as YES).
    >
    > Regards,
    > Daniel


    Really appreciate your explanation! By the way, I found an error in my code, i.e.,
    I didn't provide the right event mask in XSendEvent, now it seems working.

    Regards,

    Perry

+ Reply to Thread