@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?
Top-level
@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
@drj my goal is to make an on-screen keyboard in Uxn, it's something I'd use daily. 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 @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. @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? @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 https://gitlab.freedesktop.org/xorg/app/xev/-/blob/master/xev.c#L1479 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. @drj aaah! amazing, thank you so much, that should be enough for me to get it working :) |
@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.