mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
workaround problem when unable to get input context
This commit is contained in:
parent
89d07d7c4a
commit
81bef7355c
@ -699,14 +699,18 @@ open_window() {
|
|||||||
// nicer if we could support fancy IM's that want preedit callbacks,
|
// nicer if we could support fancy IM's that want preedit callbacks,
|
||||||
// etc., but that can wait until we have an X server that actually
|
// etc., but that can wait until we have an X server that actually
|
||||||
// supports these to test it on.
|
// supports these to test it on.
|
||||||
|
XIM im = glx_pipe->get_im();
|
||||||
|
_ic = NULL;
|
||||||
|
if (im) {
|
||||||
_ic = XCreateIC
|
_ic = XCreateIC
|
||||||
(glx_pipe->get_im(),
|
(im,
|
||||||
XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
||||||
NULL);
|
NULL);
|
||||||
if (_ic == (XIC)NULL) {
|
if (_ic == (XIC)NULL) {
|
||||||
glxdisplay_cat.warning()
|
glxdisplay_cat.warning()
|
||||||
<< "Couldn't create input context.\n";
|
<< "Couldn't create input context.\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_properties.get_cursor_hidden()) {
|
if (_properties.get_cursor_hidden()) {
|
||||||
XDefineCursor(_display, _xwindow, glx_pipe->get_hidden_cursor());
|
XDefineCursor(_display, _xwindow, glx_pipe->get_hidden_cursor());
|
||||||
@ -1205,6 +1209,7 @@ void glxGraphicsWindow::
|
|||||||
handle_keystroke(XKeyEvent &event) {
|
handle_keystroke(XKeyEvent &event) {
|
||||||
_input_devices[0].set_pointer_in_window(event.x, event.y);
|
_input_devices[0].set_pointer_in_window(event.x, event.y);
|
||||||
|
|
||||||
|
if (_ic) {
|
||||||
// First, get the keystroke as a wide-character sequence.
|
// First, get the keystroke as a wide-character sequence.
|
||||||
static const int buffer_size = 256;
|
static const int buffer_size = 256;
|
||||||
wchar_t buffer[buffer_size];
|
wchar_t buffer[buffer_size];
|
||||||
@ -1221,6 +1226,14 @@ handle_keystroke(XKeyEvent &event) {
|
|||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
_input_devices[0].keystroke(buffer[i]);
|
_input_devices[0].keystroke(buffer[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Without an input context, just get the ascii keypress.
|
||||||
|
ButtonHandle button = get_button(event);
|
||||||
|
if (button.has_ascii_equivalent()) {
|
||||||
|
_input_devices[0].keystroke(button.get_ascii_equivalent());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user