x11display: add x-init-threads var to call XInitThreads()

This is off by default, but could be used if you stumble upon a race condition issue with X11 and threading.
This commit is contained in:
rdb 2018-11-23 00:12:22 +01:00
parent 8ad0cb6b57
commit bafb0ac3db
3 changed files with 12 additions and 0 deletions

View File

@ -40,6 +40,11 @@ ConfigVariableBool x_error_abort
"of an error from the X window system. This can make it easier "
"to discover where these errors are generated."));
ConfigVariableBool x_init_threads
("x-init-threads", false,
PRC_DESC("Set this true to ask Panda3D to call XInitThreads() upon loading "
"the display module, which may help with some threading issues."));
ConfigVariableInt x_wheel_up_button
("x-wheel-up-button", 4,
PRC_DESC("This is the mouse button index of the wheel_up event: which "

View File

@ -26,6 +26,7 @@ extern EXPCL_PANDAX11 void init_libx11display();
extern ConfigVariableString display_cfg;
extern ConfigVariableBool x_error_abort;
extern ConfigVariableBool x_init_threads;
extern ConfigVariableInt x_wheel_up_button;
extern ConfigVariableInt x_wheel_down_button;

View File

@ -66,6 +66,12 @@ x11GraphicsPipe(const std::string &display) :
_im = (XIM)nullptr;
_hidden_cursor = None;
// According to the documentation, we should call this before making any
// other Xlib calls if we wish to use the Xlib locking system.
if (x_init_threads) {
XInitThreads();
}
install_error_handlers();
_display = XOpenDisplay(display_spec.c_str());