fix input issues on Linux(#87)

This commit is contained in:
Jinhao
2015-11-16 00:38:03 +08:00
parent f715fb613e
commit 1e6360843e
3 changed files with 129 additions and 78 deletions

View File

@@ -733,6 +733,8 @@ namespace detail
caret_tag * & addr = caret_holder_.carets[wd];
if(0 == addr)
{
::XSetLocaleModifiers("");
addr = new caret_tag(wd);
is_start_routine = (caret_holder_.carets.size() == 1);
addr->input_method = ::XOpenIM(display_, 0, 0, 0);
@@ -783,8 +785,10 @@ namespace detail
::XFree(attr);
}
else
addr->input_context = ::XCreateIC(addr->input_method, XNInputStyle, (XIMPreeditNothing | XIMStatusNothing),
XNClientWindow, reinterpret_cast<Window>(wd), nullptr);
addr->input_context = ::XCreateIC(addr->input_method,
XNInputStyle, (XIMPreeditNothing | XIMStatusNothing),
XNClientWindow, reinterpret_cast<Window>(wd),
XNFocusWindow, reinterpret_cast<Window>(wd), nullptr);
if(addr->input_context)
{
@@ -795,6 +799,8 @@ namespace detail
XSetWindowAttributes new_attr;
new_attr.event_mask = (attr.your_event_mask | addr->input_context_event_mask);
::XChangeWindowAttributes(display_, reinterpret_cast<Window>(wd), CWEventMask, &new_attr);
::XSetICValues(addr->input_context, XNResetState, XIMPreserveState, nullptr);
}
::XFree(preedit_attr);
::XFree(status_attr);
@@ -1254,11 +1260,13 @@ namespace detail
respond.xclient.data.l[2] = self.atombase_.xdnd_action_copy;
}
::XSendEvent(self.display_, self.xdnd_.wd_src, False, NoEventMask, &respond);
::XFlush(self.display_);
if(msg.u.mouse_drop.window)
return 1; //Use the packet directly.
}
}
::XFlush(self.display_);
return 2;
}
else if(SelectionRequest == evt.type)
@@ -1277,7 +1285,7 @@ namespace detail
}
::XChangeProperty(self.display_, evt.xselectionrequest.requestor,
evt.xselectionrequest.property, XA_ATOM, sizeof(Atom) * 8, 0,
evt.xselectionrequest.property, XA_ATOM, 32, 0,
reinterpret_cast<unsigned char*>(atoms.size() ? &atoms[0] : 0), static_cast<int>(atoms.size()));
}
else if(XA_STRING == evt.xselectionrequest.target || self.atombase_.utf8_string == evt.xselectionrequest.target)