Closed phil294 closed 2 years ago
Sorry for spamming your repo, but that should be about it now :-)
Not a problem at all! These have been great issues.
I don't think it's possible (?). I guess an XDo::Window.get_by_id would be quite helpful? It would also need some kind of exists check. It doesn't look like libxdo supports that, so we need begin/rescue on an arbitrary command to check?
Just to clarify: is there a libxdo
API for getting (and validating) a window by WID, or are you proposing that x_do.cr
add a separate API for that that uses Xlib
directly?
I answered your question in the linked PR.
I now think the best solution is to do this in user space:
all_wins = XDo.act do
search { window_name "" }
end
my_win = all_wins.find { |win| win.window == [ID] }
this is probably also not super performant but the best solution (?)
so in my opinion this issue can also be closed.
Thanks for posting your solution. Closing.
I don't think it's possible (?). I guess an
XDo::Window.get_by_id
would be quite helpful? It would also need some kind ofexists
check. It doesn't look like libxdo supports that, so we need begin/rescue on an arbitrary command to check?If you agree with me, I can of course open another PR.
Sorry for spamming your repo, but that should be about it now :-)
Edit six months later: If I am not mistaken, you can just query
window.name
. It will show a warning in the console, but not crash the program, if the window doesn't exist. If it returnsnil
, the window ID does not exist.