mirror of
https://github.com/panda3d/panda3d.git
synced 2026-05-13 01:58:27 -05:00
x11: Add function for detecting auto repeat key events (#1735)
This commit is contained in:
@@ -91,6 +91,10 @@ ConfigVariableBool x_send_startup_notification
|
||||
"lets the window manager know that an application has launched, so "
|
||||
"that it no longer needs to display a spinning mouse cursor."));
|
||||
|
||||
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
|
||||
|
||||
@@ -37,5 +37,6 @@ extern ConfigVariableInt x_cursor_size;
|
||||
extern ConfigVariableString x_wm_class_name;
|
||||
extern ConfigVariableString x_wm_class;
|
||||
extern ConfigVariableBool x_send_startup_notification;
|
||||
extern ConfigVariableBool x_detectable_auto_repeat;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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();
|
||||
@@ -126,6 +125,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2745,3 +2746,22 @@ 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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user