[hackers] [dmenu] merge xim -> default || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Mon, 17 Oct 2011 11:12:09 +0200 (CEST)

changeset: 453:029984c6031d
tag: tip
parent: 452:b780f6cf5a73
parent: 449:93cf81e50cf2
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Mon Oct 17 10:11:48 2011 +0100
files: dmenu.c
description:
merge xim -> default


diff -r b780f6cf5a73 -r 029984c6031d dmenu.c
--- a/dmenu.c Mon Oct 17 10:08:04 2011 +0100
+++ b/dmenu.c Mon Oct 17 10:11:48 2011 +0100
_AT_@ -58,6 +58,7 @@
 static Item *matches, *matchend;
 static Item *prev, *curr, *next, *sel;
 static Window win;
+static XIC xic;
 
 static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
 static char *(*fstrstr)(const char *, const char *) = strstr;
_AT_@ -229,9 +230,13 @@
 void
 keypress(XKeyEvent *ev) {
         char buf[32];
- KeySym ksym;
+ int len;
+ KeySym ksym = NoSymbol;
+ Status status;
 
- XLookupString(ev, buf, sizeof buf, &ksym, NULL);
+ len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
+ if(status == XBufferOverflow)
+ return;
         if(ev->state & ControlMask) {
                 KeySym lower, upper;
 
_AT_@ -273,7 +278,7 @@
         switch(ksym) {
         default:
                 if(!iscntrl(*buf))
- insert(buf, strlen(buf));
+ insert(buf, len);
                 break;
         case XK_Delete:
                 if(text[cursor] == '\0')
_AT_@ -461,7 +466,9 @@
 run(void) {
         XEvent ev;
 
- while(!XNextEvent(dc->dpy, &ev))
+ while(!XNextEvent(dc->dpy, &ev)) {
+ if(XFilterEvent(&ev, win))
+ continue;
                 switch(ev.type) {
                 case Expose:
                         if(ev.xexpose.count == 0)
_AT_@ -479,6 +486,7 @@
                                 XRaiseWindow(dc->dpy, win);
                         break;
                 }
+ }
 }
 
 void
_AT_@ -486,6 +494,7 @@
         int x, y, screen = DefaultScreen(dc->dpy);
         Window root = RootWindow(dc->dpy, screen);
         XSetWindowAttributes swa;
+ XIM xim;
 #ifdef XINERAMA
         int n;
         XineramaScreenInfo *info;
_AT_@ -542,6 +551,11 @@
                             DefaultVisual(dc->dpy, screen),
                             CWOverrideRedirect | CWBackPixmap | CWEventMask, &swa);
 
+ /* input methods */
+ xim = XOpenIM(dc->dpy, NULL, NULL, NULL);
+ xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
+ XNClientWindow, win, XNFocusWindow, win, NULL);
+
         XMapRaised(dc->dpy, win);
         resizedc(dc, mw, mh);
         drawmenu();
Received on Mon Oct 17 2011 - 11:12:09 CEST

This archive was generated by hypermail 2.3.0 : Mon Oct 17 2011 - 11:24:06 CEST