Linux: Fix slow startup on some systems caused by GLFW searching for joysticks. Since kitty does not use joysticks, disable joystick support.

Fixes #830
This commit is contained in:
Kovid Goyal 2018-08-31 07:50:51 +05:30
parent d276317e3a
commit ab960ea12d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
8 changed files with 26 additions and 6 deletions

View File

@ -70,6 +70,11 @@ Changelog
- macOS: Fix control+tab key combination not working (:iss:`801`) - macOS: Fix control+tab key combination not working (:iss:`801`)
- Linux: Fix slow startup on some systems caused by GLFW searching for
joysticks. Since kitty does not use joysticks, disable joystick support.
(:iss:`830`)
0.11.3 [2018-07-10] 0.11.3 [2018-07-10]
------------------------------ ------------------------------

1
glfw/glfw3.h vendored
View File

@ -1058,6 +1058,7 @@ extern "C" {
* @{ */ * @{ */
#define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001 #define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001
#define GLFW_DEBUG_KEYBOARD 0x00050002 #define GLFW_DEBUG_KEYBOARD 0x00050002
#define GLFW_ENABLE_JOYSTICKS 0x00050003
#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001 #define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
#define GLFW_COCOA_MENUBAR 0x00051002 #define GLFW_COCOA_MENUBAR 0x00051002

4
glfw/init.c vendored
View File

@ -52,6 +52,7 @@ static _GLFWinitconfig _glfwInitHints =
{ {
GLFW_TRUE, // hat buttons GLFW_TRUE, // hat buttons
GLFW_FALSE, // debug keyboard GLFW_FALSE, // debug keyboard
GLFW_TRUE, // enable joystick
{ {
GLFW_TRUE, // macOS menu bar GLFW_TRUE, // macOS menu bar
GLFW_TRUE // macOS bundle chdir GLFW_TRUE // macOS bundle chdir
@ -254,6 +255,9 @@ GLFWAPI void glfwInitHint(int hint, int value)
{ {
switch (hint) switch (hint)
{ {
case GLFW_ENABLE_JOYSTICKS:
_glfwInitHints.enableJoysticks = value;
return;
case GLFW_JOYSTICK_HAT_BUTTONS: case GLFW_JOYSTICK_HAT_BUTTONS:
_glfwInitHints.hatButtons = value; _glfwInitHints.hatButtons = value;
return; return;

1
glfw/internal.h vendored
View File

@ -244,6 +244,7 @@ struct _GLFWinitconfig
{ {
GLFWbool hatButtons; GLFWbool hatButtons;
GLFWbool debugKeyboard; GLFWbool debugKeyboard;
GLFWbool enableJoysticks;
struct { struct {
GLFWbool menubar; GLFWbool menubar;
GLFWbool chdir; GLFWbool chdir;

2
glfw/wl_init.c vendored
View File

@ -688,8 +688,10 @@ int _glfwPlatformInit(void)
wl_display_roundtrip(_glfw.wl.display); wl_display_roundtrip(_glfw.wl.display);
#ifdef __linux__ #ifdef __linux__
if (_glfw.hints.init.enableJoysticks) {
if (!_glfwInitJoysticksLinux()) if (!_glfwInitJoysticksLinux())
return GLFW_FALSE; return GLFW_FALSE;
}
#endif #endif
_glfwInitTimerPOSIX(); _glfwInitTimerPOSIX();

3
glfw/x11_init.c vendored
View File

@ -659,10 +659,13 @@ int _glfwPlatformInit(void)
_glfw.x11.hiddenCursorHandle = createHiddenCursor(); _glfw.x11.hiddenCursorHandle = createHiddenCursor();
#if defined(__linux__) #if defined(__linux__)
if (_glfw.hints.init.enableJoysticks) {
printf("1111111111\n");
if (!_glfwInitJoysticksLinux()) if (!_glfwInitJoysticksLinux())
return GLFW_FALSE; return GLFW_FALSE;
if (_glfw.linjs.inotify > 0) if (_glfw.linjs.inotify > 0)
addWatch(&_glfw.x11.eventLoopData, "joystick", _glfw.linjs.inotify, POLLIN, 1, NULL, NULL); addWatch(&_glfw.x11.eventLoopData, "joystick", _glfw.linjs.inotify, POLLIN, 1, NULL, NULL);
}
#endif #endif
_glfwInitTimerPOSIX(); _glfwInitTimerPOSIX();

1
kitty/glfw-wrapper.h generated
View File

@ -819,6 +819,7 @@ typedef int (* GLFWapplicationshouldhandlereopenfun)(int);
* @{ */ * @{ */
#define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001 #define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001
#define GLFW_DEBUG_KEYBOARD 0x00050002 #define GLFW_DEBUG_KEYBOARD 0x00050002
#define GLFW_ENABLE_JOYSTICKS 0x00050003
#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001 #define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
#define GLFW_COCOA_MENUBAR 0x00051002 #define GLFW_COCOA_MENUBAR 0x00051002

View File

@ -593,6 +593,9 @@ glfw_init(PyObject UNUSED *self, PyObject *args) {
if (err) { PyErr_SetString(PyExc_RuntimeError, err); return NULL; } if (err) { PyErr_SetString(PyExc_RuntimeError, err); return NULL; }
glfwSetErrorCallback(error_callback); glfwSetErrorCallback(error_callback);
glfwInitHint(GLFW_DEBUG_KEYBOARD, debug_keyboard); glfwInitHint(GLFW_DEBUG_KEYBOARD, debug_keyboard);
// Joysticks cause slow startup on some linux systems, see
// https://github.com/kovidgoyal/kitty/issues/830
glfwInitHint(GLFW_ENABLE_JOYSTICKS, 0);
global_state.opts.debug_keyboard = debug_keyboard != 0; global_state.opts.debug_keyboard = debug_keyboard != 0;
#ifdef __APPLE__ #ifdef __APPLE__
glfwInitHint(GLFW_COCOA_CHDIR_RESOURCES, 0); glfwInitHint(GLFW_COCOA_CHDIR_RESOURCES, 0);