• Problem(s) with "xev"

    From Kenny McCormack@21:1/5 to All on Wed Jan 20 13:25:51 2021
    I am using "xev" to monitor a program running under X. I use:

    xev -id 0xNNNNNNNN -event mouse -event keyboard

    It all works fine, except for one thing. If the window (program) exits,
    the xev process continues running. I would like for xev to exit if/when
    the program/window it is monitoring goes away.

    It seems to me that it should - i.e., that the behavior I want should be
    the default - but it isn't. I suppose it is sort of like when a program
    opens up a file, then the file gets deleted; the handle (i.e.,, file descriptor) still references the file, even though the file is now gone.
    So, I suppose once xev has translated the id into some kind of "handle" to
    the window, it no longer cares if that id becomes invalid.

    So, first, I'd like to know if there is some easy way to make this work.
    I.e., to make "xev" exit when the window goes away.

    Failing that, I'd like to know what to put as the "event mask" to make it
    catch the "DestroyNotify" event. I.e., I have tested, and if I don't
    specify any "event mask(s)" at all, then it does generate "DestroyNotify"
    when the window goes away. I would like to retain the event masking for
    only mouse and keyboard and whatever else I need to add to get
    DestroyNotify events reported.

    --
    The randomly chosen signature file that would have appeared here is more than 4 lines long. As such, it violates one or more Usenet RFCs. In order to remain in compliance with said RFCs, the actual sig can be found at the following URL:
    http://user.xmission.com/~gazelle/Sigs/Aspergers

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Winston@21:1/5 to Kenny McCormack on Wed Jan 20 12:37:28 2021
    gazelle@shell.xmission.com (Kenny McCormack) wrote:
    I am using "xev" to monitor a program running under X. I use:

    xev -id 0xNNNNNNNN -event mouse -event keyboard

    It all works fine, except for one thing. If the window (program)
    exits, the xev process continues running. I would like for xev to
    exit if/when the program/window it is monitoring goes away.
    ...
    So, first, I'd like to know if there is some easy way to make this
    work. I.e., to make "xev" exit when the window goes away.

    Maybe someone else can answer that, or maybe catching the DestroyNotify
    event would do that.

    Failing that, I'd like to know what to put as the "event mask" to make
    it catch the "DestroyNotify" event.

    It looks like "-event structure" (or, if that doesn't work, then try
    "-event substructure") would catch DestroyNotify events when
    the window is destroyed, but I haven't tried it.
    -WBE

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to wbe@UBEBLOCK.psr.com.invalid on Wed Jan 20 18:49:43 2021
    In article <ydy2gn33xj.fsf@UBEblock.psr.com>,
    Winston <wbe@UBEBLOCK.psr.com.invalid> wrote:
    ...
    Failing that, I'd like to know what to put as the "event mask" to make
    it catch the "DestroyNotify" event.

    It looks like "-event structure" (or, if that doesn't work, then try
    "-event substructure") would catch DestroyNotify events when
    the window is destroyed, but I haven't tried it.

    Thank you! It looks like either one (structure or substructure) works,
    with the later (substructure) preferable, since it generates less noise (extraneous events) while still delivering the DestroyNotify event.

    So, that's good. Thanks again.

    So now I just have to change my program so that xev exits (i.e, is killed)
    when it sees the DestroyNotify event.

    P.S. How did you figure this out (if other than by trial and error)?
    "man xev" lists the event masks, but gives no info as to what they actually mean.

    --
    Indeed, most .NET developers couldn't pass CS101 at a third-rate
    community college.
    - F. Russell -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Winston@21:1/5 to Kenny McCormack on Wed Jan 20 14:50:00 2021
    gazelle@shell.xmission.com (Kenny McCormack) asked:
    Failing that, I'd like to know what to put as the "event mask" to make
    it catch the "DestroyNotify" event.

    to which I replied:
    It looks like "-event structure" (or, if that doesn't work, then try >>"-event substructure") would catch DestroyNotify events when
    the window is destroyed, but I haven't tried it.

    to which gazelle@shell.xmission.com (Kenny McCormack) replied:
    Thank you! It looks like either one (structure or substructure) works,
    with the later (substructure) preferable, since it generates less noise (extraneous events) while still delivering the DestroyNotify event.

    So, that's good. Thanks again.

    So now I just have to change my program so that xev exits (i.e, is killed) when it sees the DestroyNotify event.

    P.S. How did you figure this out (if other than by trial and error)?
    "man xev" lists the event masks, but gives no info as to what they actually mean.

    Initially, by looking at X.h and Xproto.h for clues, which didn't help
    much, and then by what used to be called "apropos":

    # man -k DestroyNotify
    XDestroyWindowEvent(3) - DestroyNotify event structure

    # man XDestroyWindowEvent

    which near the end said that it would be either a structure or
    substructure notification depending on who/what was to receive the notification.
    -WBE

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to wbe@UBEBLOCK.psr.com.invalid on Wed Jan 20 20:22:38 2021
    In article <ydpn1z2wfy.fsf@UBEblock.psr.com>,
    Winston <wbe@UBEBLOCK.psr.com.invalid> wrote:
    gazelle@shell.xmission.com (Kenny McCormack) writes:
    P.S. How did you figure this out (if other than by trial and error)?
    "man xev" lists the event masks, but gives no info as to what they
    actually mean.

    I'll add that:

    * I've written X11 code, so verifying before I posted the reply didn't
    take long, but I took your question to mean how can one figure that
    out; and

    Yep.

    * the last sentence in the paragraph describing -event in the xev man
    page could use a bunch of commas and a period. :-/ :)
    -WBE

    Heh heh. So true.

    --
    "You can safely assume that you have created God in your own image when
    it turns out that God hates all the same people you do." -- Anne Lamott

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to wbe@UBEBLOCK.psr.com.invalid on Wed Jan 20 20:24:44 2021
    In article <ydturb2xsn.fsf@UBEblock.psr.com>,
    Winston <wbe@UBEBLOCK.psr.com.invalid> wrote:
    ...
    Initially, by looking at X.h and Xproto.h for clues, which didn't help
    much, and then by what used to be called "apropos":

    # man -k DestroyNotify
    XDestroyWindowEvent(3) - DestroyNotify event structure

    # man XDestroyWindowEvent

    Yep. That (the XDestroyWindowEvent man page) works on my system.
    Should make good reading...

    --
    A racist, a Nazi, and a Klansman walk into a bar...

    Bartender says, "What will it be, Mr. Trump?"

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Winston@21:1/5 to Kenny McCormack on Wed Jan 20 15:19:13 2021
    gazelle@shell.xmission.com (Kenny McCormack) writes:
    P.S. How did you figure this out (if other than by trial and error)?
    "man xev" lists the event masks, but gives no info as to what they
    actually mean.

    I'll add that:

    * I've written X11 code, so verifying before I posted the reply didn't
    take long, but I took your question to mean how can one figure that
    out; and

    * the last sentence in the paragraph describing -event in the xev man
    page could use a bunch of commas and a period. :-/ :)
    -WBE

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)