Skip to content
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

Detect if the X server is XWayland and report an error. #342

Merged
merged 5 commits into from
Aug 3, 2021

Conversation

jordansissel
Copy link
Owner

Also: Detect if $DISPLAY env is not set and report a more informative
error message.

For the purposes of libxdo/xdotool, XWayland does not work, so it's best
to notify the user accordingly if detected.

This adds a dependency on XInput libxi because the only[1] way I have
found to detect XWayland is through this extension

[1] There is another detection method which uses
XFree86-VidModeExtension, but I don't know how common that extension is
compared to XInput2.

Fixes #341.
Related to #337.

Also: Detect if $DISPLAY env is not set and report a more informative
error message.

For the purposes of libxdo/xdotool, XWayland does not work, so it's best
to notify the user accordingly if detected.

This adds a dependency on XInput `libxi` because the only[1] way I have
found to detect XWayland is through this extension

[1] There is another detection method which uses
  XFree86-VidModeExtension, but I don't know how common that extension is
  compared to XInput2.

Fixes #341.
Related to #337.
@jordansissel
Copy link
Owner Author

With this change, the following errors are now present:

When XWayland is detected

% xdotool search Firefox
The X server at :0 appears to be XWayland. Unfortunately, XWayland does not correctly support the features used by libxdo and xdotool.
Failed creating new xdo instance.

When DISPLAY is empty

% export DISPLAY=
% ./xdotool search Firefox
Error: DISPLAY environment variable is empty. Is there an Xorg or other X server running? You can try setting 'export DISPLAY=:0' and trying again.

@jordansissel
Copy link
Owner Author

I just noticed that xinput will also warn if it detects XWayland, so I wanted to see how it worked, and it uses the same mechanism that I discovered (nice!):

https://github.com/freedesktop/xorg-xinput/blob/cef07c0c8280d7e7b82c3bcc62a1dfbe8cc43ff8/src/xinput.c#L364-L382

@jordansissel jordansissel merged commit 9d9be33 into master Aug 3, 2021
buldi pushed a commit to buldi/xdotool that referenced this pull request Apr 23, 2022
…#342)

* Detect if the X server is XWayland and report an error.

Also: Detect if $DISPLAY env is not set and report a more informative
error message.

For the purposes of libxdo/xdotool, XWayland does not work, so it's best
to notify the user accordingly if detected.

This adds a dependency on XInput `libxi` because the only[1] way I have
found to detect XWayland is through this extension

[1] There is another detection method which uses
  XFree86-VidModeExtension, but I don't know how common that extension is
  compared to XInput2.

Fixes jordansissel#341.
Related to jordansissel#337.

* xdo_version.h update when VERSION updates

* Fix typo in version.sh which leaves an extra plus '+' character in the date

* Run help or version commands without trying to connect to the X11 display

* Free when detecting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn/error when running on wayland
1 participant