where _display_p is a valid Display* returned from XOpenDisplay() and ks has the value 103 (which was returned by XStringToKeysym(), and corresponds to 'g').
The above line of code hangs indefinitely; I have to kill the job manually.
Question #1: why is this happening? I can't see anything in any documentation that suggests that XKeysymToKeycode() can ever fail to return.
The constructor provides a value for this in the initializer list:
_display_p(XOpenDisplay(NULL)),
The value is tested inside the construstor, just in case the call to XOpenDisplay() failed:
if (!_display_p)
{ cerr << "Fatal error: unable to open display" << endl;
exit (-1);
}
Then, inside a member function called push_key_press, occurs the line that hangs (I have temporarily, while testing, replaced the call to the variable ks of type KeySym with an explicit value, XK_g):
Following the initialisation of _display_p in the class constructor, the only place that _display_p is used is in direct calls to X functions: I never access it myself.
If I remove the line that hangs, and code that depends on it, then everything else -- in particular, all the calls to X functions, both prior to and subsequent to the offending line -- works as expected.