Skip to content

Commit

Permalink
Don't exit if no input methods can be found
Browse files Browse the repository at this point in the history
  • Loading branch information
doughdemon committed Aug 27, 2014
1 parent fba5e00 commit 38b2005
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
7 changes: 5 additions & 2 deletions xlib/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,13 @@ _Bool doevent(XEvent event)
KeySym sym = XLookupKeysym(ev, 0);//XKeycodeToKeysym(display, ev->keycode, 0)

wchar_t buffer[16];
Status status_return;
int len;

len = XwcLookupString(xic, ev, buffer, sizeof(buffer), &sym, &status_return);
if (xic) {
len = XwcLookupString(xic, ev, buffer, sizeof(buffer), &sym, NULL);
} else {
len = XLookupString(ev, (char *)buffer, sizeof(buffer), &sym, NULL);
}
if(edit_active()) {
if(ev->state & 4) {
switch(sym) {
Expand Down
16 changes: 10 additions & 6 deletions xlib/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ _Bool _redraw;

uint16_t drawwidth, drawheight;

XIC xic;
XIC xic = NULL;

XImage *screen_image;

Expand Down Expand Up @@ -844,7 +844,6 @@ int main(int argc, char *argv[])
XSetLocaleModifiers("");
if((xim = XOpenIM(display, 0, 0, 0)) == NULL) {
printf("Cannot open input method\n");
return 1;
}

screen = DefaultScreen(display);
Expand Down Expand Up @@ -990,11 +989,13 @@ int main(int argc, char *argv[])
/* make the window visible */
XMapWindow(display, window);

if((xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, window, XNFocusWindow, window, NULL)) == NULL) {
printf("Cannot open input method\n");
return 1;
if (xim) {
if((xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, window, XNFocusWindow, window, NULL)) == NULL) {
printf("Cannot open input method\n");
XCloseIM(xim);
}
XSetICFocus(xic);
}
XSetICFocus(xic);

/* set the width/height of the drawing region */
width = DEFAULT_WIDTH;
Expand Down Expand Up @@ -1082,6 +1083,9 @@ int main(int argc, char *argv[])
XRenderFreePicture(display, renderpic);
XRenderFreePicture(display, colorpic);

if (xic) XDestroyIC(xic);
if (xim) XCloseIM(xim);

XDestroyWindow(display, window);
XCloseDisplay(display);

Expand Down

0 comments on commit 38b2005

Please sign in to comment.