diff options
| author | 2020-03-22 22:22:33 +0100 | |
|---|---|---|
| committer | 2020-03-22 22:26:32 +0100 | |
| commit | 8cf0497d29dcb22e3a8f222405aa26b93dd1ba19 (patch) | |
| tree | d621261502c4143573ef1063a6e3734b9a1018b7 | |
| parent | aa06f437ee07f419942aeea8ee3b1357f9fe19e5 (diff) | |
| download | xkbcat-8cf0497d29dcb22e3a8f222405aa26b93dd1ba19.tar.gz xkbcat-8cf0497d29dcb22e3a8f222405aa26b93dd1ba19.zip | |
Query for specific XInput2 version
This is necessary to guarantee the same API in case future versions of
XInput decide to break backward compatibility in their defaults.
Quoting `man 3 xiqueryversion`:
> Clients are required to use XIQueryVersion instead of
> XGetExtensionVersion if they use XI2 calls. The server may treat a
> client differently depending on the supported version announced by the
> client.
| -rw-r--r-- | xkbcat.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -41,12 +41,22 @@ int main(int argc, char * argv[]) { } // Test for XInput 2 extension - int xiOpcode; - int queryEvent, queryError; + int xiOpcode, queryEvent, queryError; if (! XQueryExtension(disp, "XInputExtension", &xiOpcode, &queryEvent, &queryError)) { - // XXX Test version >=2 - fprintf(stderr, "X Input extension not available\n"); return 1; + fprintf(stderr, "X Input extension not available\n"); + exit(2); + } + { // Request XInput 2.0, guarding against changes in future versions + int major = 2, minor = 0; + int queryResult = XIQueryVersion(disp, &major, &minor); + if (queryResult == BadRequest) { + fprintf(stderr, "Need XI 2.0 support (got %d.%d)\n", major, minor); + exit(3); + } else if (queryResult != Success) { + fprintf(stderr, "Internal error\n"); + exit(4); + } } // Register events |
