Email or username:

Password:

Forgot your password?
Top-level
Devil Lu Linvega

@drj I'm not sure, is there a way I could send events to a particular window by recording which window I could out to, from my program? Like, if I loose focus to focus on a second window, is there a way to know that window's id?

8 comments
David JONES

@neauoire a) what are you up to?; b) i'm not sure; c) any X program knows the IDs of any windows it creates, and it is free to tell anyone (you, me, another program) about those IDs. And given an ID (they are 32-bit numbers i think) any program can now send events to that window. I think xterm for example advertises its Window ID in its env so that cli programs can, in principle, do X things to their containing xterm.; d) i don't use X any more so i can't poke around easily.

Devil Lu Linvega

@drj my goal is to make an on-screen keyboard in Uxn, it's something I'd use daily.
The uxn emulator I have is written in x11 itself, but I would like not to have to modify the emulator, ideally I'd use a small intermediate program, like:

uxn11 keyboard.rom | some_little_program

The keyboard rom will send stdout events, and some_little_program will be the bit that handles the logic of which keycode to send, and which window to send it to

David JONES

@neauoire so some_little_program needs to know the X window ID to send events to. Some ideas: you could just type it in; some_little_program could observe what window has focus at the moment it starts and use that one forever; one of the programs (I'm not sure which one) could make you click on the target window and listen for the event and use the target of the click for all future events.

Devil Lu Linvega

@drj Oooh! Yes, okay, let say I wanted to make it so some_little_program waits for a click on a window(`click on any window`), do you know how I can do this?

David JONES

@neauoire I only ever wrote 1 X11 program, but it was using XLib and none of the new-fangled framework nonsense (it was on a DEC Ultrix machine in about 1994). I _think_ you "simply" call XNextEvent; see how xev.c does it gitlab.freedesktop.org/xorg/ap

I _think_ by default an X11 client gets all events (for all windows!) unless it has requested only events for particular windows (like their own, which most apps would do); i think that's XSelectInput.

Devil Lu Linvega

@drj aaah! amazing, thank you so much, that should be enough for me to get it working :)

ArBe

@neauoire @drj Not sure if this is helpful, but the `xprop` allows you to click on a window, and then it prints its properties to stdout. You could probably hook it up with a shell script, or maybe look into the source if you want to do something similar with the API

Go Up