diff --git a/panda/src/x11display/config_x11display.cxx b/panda/src/x11display/config_x11display.cxx index d31c4c1c23..e63d394e10 100644 --- a/panda/src/x11display/config_x11display.cxx +++ b/panda/src/x11display/config_x11display.cxx @@ -84,6 +84,10 @@ ConfigVariableString x_wm_class PRC_DESC("Specify the value to use for the res_class field of the window's " "WM_CLASS property.")); +ConfigVariableBool x_detectable_auto_repeat +("x-detectable-auto-repeat", false, + PRC_DESC("Set this true to enable detectable auto-repeat for keyboard input.")); + /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/src/x11display/config_x11display.h b/panda/src/x11display/config_x11display.h index 157f09c5fc..2373d99185 100644 --- a/panda/src/x11display/config_x11display.h +++ b/panda/src/x11display/config_x11display.h @@ -36,5 +36,6 @@ extern ConfigVariableInt x_wheel_right_button; extern ConfigVariableInt x_cursor_size; extern ConfigVariableString x_wm_class_name; extern ConfigVariableString x_wm_class; +extern ConfigVariableBool x_detectable_auto_repeat; #endif diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 531a100e59..f6008e2940 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -97,8 +97,7 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, int flags, GraphicsStateGuardian *gsg, GraphicsOutput *host) : - GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host) -{ + GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host) { x11GraphicsPipe *x11_pipe; DCAST_INTO_V(x11_pipe, _pipe); _display = x11_pipe->get_display(); @@ -123,6 +122,8 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, PT(GraphicsWindowInputDevice) device = GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse"); add_input_device(device); _input = device; + + enable_detectable_auto_repeat(); } /** @@ -2442,3 +2443,62 @@ cleanup: return ret; } + +/** + * + */ +int x11GraphicsWindow:: +xim_preedit_start(XIC ic, XPointer client_data, XPointer call_data) { + x11GraphicsWindow *window = (x11GraphicsWindow *)client_data; + return window->handle_preedit_start(); +} + +/** + * + */ +void x11GraphicsWindow:: +xim_preedit_draw(XIC ic, XPointer client_data, + XIMPreeditDrawCallbackStruct *call_data) { + x11GraphicsWindow *window = (x11GraphicsWindow *)client_data; + nassertv_always(call_data != nullptr); + window->handle_preedit_draw(*call_data); +} + +/** + * + */ +void x11GraphicsWindow:: +xim_preedit_caret(XIC ic, XPointer client_data, + XIMPreeditCaretCallbackStruct *call_data) { + x11GraphicsWindow *window = (x11GraphicsWindow *)client_data; + nassertv_always(call_data != nullptr); + window->handle_preedit_caret(*call_data); +} + +/** + * + */ +void x11GraphicsWindow:: +xim_preedit_done(XIC ic, XPointer client_data, XPointer call_data) { + x11GraphicsWindow *window = (x11GraphicsWindow *)client_data; + window->handle_preedit_done(); +} + +/** + * Enables detectable auto-repeat if supported by the X server. + */ +void x11GraphicsWindow:: +enable_detectable_auto_repeat() { + if (!x_detectable_auto_repeat) { + return; + } + + Bool supported; + if (XkbSetDetectableAutoRepeat(_display, True, &supported)) { + x11display_cat.info() << "Detectable auto-repeat enabled.\n"; + } else if (!supported) { + x11display_cat.warning() << "Detectable auto-repeat is not supported by the X server.\n"; + } else { + x11display_cat.error() << "Failed to set detectable auto-repeat.\n"; + } +} diff --git a/panda/src/x11display/x11GraphicsWindow.h b/panda/src/x11display/x11GraphicsWindow.h index ca44e4d426..2b0ee94e3e 100644 --- a/panda/src/x11display/x11GraphicsWindow.h +++ b/panda/src/x11display/x11GraphicsWindow.h @@ -46,6 +46,8 @@ public: INLINE X11_Window get_xwindow() const; + void enable_detectable_auto_repeat(); + protected: virtual void close_window(); virtual bool open_window();