-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Viewer] Make search for X11 window IDs more robust #2417
Conversation
This commit adds three new functions: - `xdo_find_win_id_by_class`, - `xdo_find_win_id_by_name`, and - `xdo_find_win_id_by_pid`, which will later be called from `xdo_exists` and `xdo_get_id` for the purposes of identifying a viewer's X11 window ID. Motivation: similar winID-finding logic is used by both `xdo_exists` and `xdo_get_id`, so it makes sense to outsource this to "atomic" functions to avoid code repetition. TODO: refactor `xdo_exists` and `xdo_get_id` to actually use the new functions.
This commit outsources the existing X11 window ID finding code in the `xdo_exists` function to the dedicated functions `xdo_find_win_id_by_pid` and `xdo_find_win_id_by_pid` introduced previously in commit c036aa5. There should be no externally visible change in VimTeX's behavior as a result of this commit.
This commit makes the `xdo_get_id` function attempt to search for a viewer's X11 window ID in the following order 1. By viewer's PID 2. By viewer's window name 3. By viewer's class Previously, `xdo_get_id` only attempted a search by viewer class, which could lead to unexpected results. For details see [#2415](#2415) refer: [#2415](#2415)
Thanks! I think this looks very good and is almost ready for merge already. I only had a few minor comments and suggestions. |
Thanks! I made a few adjustments on top, I hope you don't mind. Let me know if I accidentily broke something :p |
Looks good! Just tested locally and everything seems to work. Thanks for your suggestions and help implementing this! |
My pleasure; and thanks to you for both the issue and the PR contribution! :) |
This PR addresses and solves #2415, wherein the variable
b:vimtex.viewer.xwin_id
would sometimes be set to an X11 window ID that was not the ID of the actual viewer. The issue is solved on my end (Arch Linux 5.18.2 with Zathura), but it would be prudent to test on other systems.The PR is a refactor of existing code more than anything else; here is a quick summary:
xdo_get_id
function in_template.vim
attempt search by PID and search by window name before attempting search by class (previously only search by class was used).More details in the commit messages.
refer: #2415