forked from Mirrors/openclonk
X11: Be more careful regarding input
Also, use Xutf8LookupString instead of XmbLookupString and iconv.stable-5.2
parent
442d5b2c58
commit
cb01137562
|
@ -126,8 +126,6 @@ LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
void C4FullScreen::CharIn(const char * c) { ::pGUI->CharIn(c); }
|
||||
|
||||
#elif defined(USE_X11)
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
@ -371,16 +369,7 @@ void C4FullScreen::HandleMessage (SDL_Event &e)
|
|||
|
||||
#endif // _WIN32, USE_X11, USE_SDL_MAINLOOP
|
||||
|
||||
#ifndef _WIN32
|
||||
void C4FullScreen::CharIn(const char *c)
|
||||
{
|
||||
if (::pGUI)
|
||||
{
|
||||
StdStrBuf c2; c2.Take(Languages.IconvClonk(c));
|
||||
::pGUI->CharIn(c2.getData());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
void C4FullScreen::CharIn(const char * c) { ::pGUI->CharIn(c); }
|
||||
|
||||
C4FullScreen::C4FullScreen()
|
||||
{
|
||||
|
|
|
@ -217,15 +217,20 @@ bool CStdApp::FlushMessages() {
|
|||
void CStdApp::HandleXMessage() {
|
||||
XEvent event;
|
||||
XNextEvent(dpy, &event);
|
||||
// Needed for input methods
|
||||
if (XFilterEvent(&event, event.xany.window)) return;
|
||||
bool filtered = XFilterEvent(&event, event.xany.window);
|
||||
switch (event.type) {
|
||||
case KeyPress: {
|
||||
case EnterNotify:
|
||||
KeyMask = event.xcrossing.state;
|
||||
break;
|
||||
case KeyPress:
|
||||
// Needed for input methods
|
||||
if (!filtered) {
|
||||
char c[10] = "";
|
||||
Status blub;
|
||||
if (Priv->xic) {
|
||||
XSetICFocus(Priv->xic);
|
||||
XmbLookupString(Priv->xic, &event.xkey, c, 10, 0, &blub);
|
||||
Status lsret;
|
||||
Xutf8LookupString(Priv->xic, &event.xkey, c, 10, 0, &lsret);
|
||||
if (lsret == XLookupKeySym) fprintf(stderr, "FIXME: XmbLookupString returned XLookupKeySym\n");
|
||||
if (lsret == XBufferOverflow) fprintf(stderr, "FIXME: XmbLookupString returned XBufferOverflow\n");
|
||||
} else {
|
||||
static XComposeStatus state;
|
||||
XLookupString(&event.xkey, c, 10, 0, &state);
|
||||
|
@ -305,6 +310,7 @@ void CStdApp::HandleXMessage() {
|
|||
break;
|
||||
}
|
||||
case FocusIn:
|
||||
if (Priv->xic) XSetICFocus(Priv->xic);
|
||||
if (Priv->pending_desktop)
|
||||
Priv->pending_desktop = false;
|
||||
if (pWindow && event.xany.window == pWindow->wnd && Priv->tasked_out) {
|
||||
|
@ -312,7 +318,10 @@ void CStdApp::HandleXMessage() {
|
|||
Priv->tasked_out = false;
|
||||
}
|
||||
break;
|
||||
case FocusOut: case UnmapNotify:
|
||||
case FocusOut:
|
||||
if (Priv->xic) XUnsetICFocus(Priv->xic);
|
||||
// fallthrough
|
||||
case UnmapNotify:
|
||||
if (pWindow && event.xany.window == pWindow->wnd && fDspModeSet) {
|
||||
Priv->pending_desktop = true;
|
||||
}
|
||||
|
|
|
@ -130,6 +130,8 @@ CStdWindow * CStdWindow::Init(CStdApp * pApp, const char * Title, CStdWindow * p
|
|||
XNClientWindow, wnd,
|
||||
XNFocusWindow, wnd,
|
||||
XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
||||
XNResourceName, C4ENGINENAME,
|
||||
XNResourceClass, C4ENGINENAME,
|
||||
NULL);
|
||||
if (!pApp->Priv->xic) {
|
||||
Log("Failed to create input context.");
|
||||
|
@ -140,6 +142,7 @@ CStdWindow * CStdWindow::Init(CStdApp * pApp, const char * Title, CStdWindow * p
|
|||
if (XGetICValues(pApp->Priv->xic, XNFilterEvents, &ic_event_mask, NULL) == NULL)
|
||||
attr.event_mask |= ic_event_mask;
|
||||
XSelectInput(dpy, wnd, attr.event_mask);
|
||||
XSetICFocus(pApp->Priv->xic);
|
||||
}
|
||||
}
|
||||
// We want notification of closerequests and be killed if we hang
|
||||
|
@ -153,7 +156,8 @@ CStdWindow * CStdWindow::Init(CStdApp * pApp, const char * Title, CStdWindow * p
|
|||
if (PID != None) XChangeProperty(pApp->dpy, wnd, PID, XA_CARDINAL, 32, PropModeReplace, reinterpret_cast<const unsigned char*>(&pid), 1);
|
||||
// State and Icon
|
||||
XWMHints * wm_hint = XAllocWMHints();
|
||||
wm_hint->flags = StateHint | IconPixmapHint | IconMaskHint;
|
||||
wm_hint->input = 1;
|
||||
wm_hint->flags = StateHint | InputHint | IconPixmapHint | IconMaskHint;
|
||||
wm_hint->initial_state = NormalState;
|
||||
// Trust XpmCreatePixmapFromData to not modify the xpm...
|
||||
XpmCreatePixmapFromData (dpy, wnd, const_cast<char **>(c4x_xpm), &wm_hint->icon_pixmap, &wm_hint->icon_mask, 0);
|
||||
|
|
Loading…
Reference in New Issue