Problem(s) with "xev"

14 views
Skip to first unread message

Kenny McCormack

unread,
Jan 20, 2021, 8:25:52 AM1/20/21
to
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

Winston

unread,
Jan 20, 2021, 12:37:18 PM1/20/21
to
gaz...@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

Kenny McCormack

unread,
Jan 20, 2021, 1:49:45 PM1/20/21
to
In article <ydy2gn3...@UBEblock.psr.com>,
Winston <w...@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 -

Winston

unread,
Jan 20, 2021, 2:49:50 PM1/20/21
to
gaz...@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 gaz...@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

Winston

unread,
Jan 20, 2021, 3:19:03 PM1/20/21
to
gaz...@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

Kenny McCormack

unread,
Jan 20, 2021, 3:22:39 PM1/20/21
to
In article <ydpn1z2...@UBEblock.psr.com>,
Winston <w...@UBEBLOCK.psr.com.invalid> wrote:
>gaz...@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

Kenny McCormack

unread,
Jan 20, 2021, 3:24:45 PM1/20/21
to
In article <ydturb2...@UBEblock.psr.com>,
Winston <w...@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?"

Reply all
Reply to author
Forward
0 new messages