Eric Lucas via plug on 1 Aug 2019 14:12:57 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Catching mouse events in a character app


Here's how I would do it:

1. In a separate terminal (we'll call this the "xev" terminal) run: xwininfo
click on the window you want to see the events for. It produces an output like this:
$ xwininfo

xwininfo: Please select the window about which you
         would like information by clicking the
         mouse in that window.

xwininfo: Window id: 0x8800005 "Downloads — Dolphin"

 Absolute upper-left X:  372
 Absolute upper-left Y:  83
 Relative upper-left X:  0
 Relative upper-left Y:  0
 Width: 1544
 Height: 957
 Depth: 24
 Visual: 0x12b
 Visual Class: TrueColor
 Border width: 0
 Class: InputOutput
 Colormap: 0x8800004 (not installed)
 Bit Gravity State: NorthWestGravity
 Window Gravity State: NorthWestGravity
 Backing Store State: NotUseful
 Save Under State: no
 Map State: IsViewable
 Override Redirect State: no
 Corners:  +372+83  -1924+83  -1924-40  +372-40
 -geometry 1544x957+372-40

2. Using the window id from the above, run:  xev -id 0x8800005 in the xev terminal

Presto - your x events from the target window show up in the xev terminal.

Hope that helps!

Eric


On Thu, Aug 1, 2019 at 4:45 PM K.S. Bhaskar via plug <plug@lists.phillylinux.org> wrote:
I have a character-mode app running in a terminal in an X session (I'm currently working in lxterminal in an LXDE session, but it could be any terminal emulator under any Linux window manager). xev seems to give me the mouse events, but requires the Xwindow id to be specified. There seems to be no easy way to capture the Xwindow id of a terminal session.

Is there a reliable way for a program running in an X terminal session to get the Xwindow id? Or better yet, is there a straightforward way to get mouse events that happen in that application's window?

Searches on DuckDuckGo have not turned up any useful links – the reliable solutions mentioned involve convoluted computation, and the easy solutions are not reliable.

Thank you very much.

Regards
– Bhaskar
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug