]> git.armaanb.net Git - dmenu.git/commitdiff
merge xim -> default
authorConnor Lane Smith <cls@lubutu.com>
Mon, 17 Oct 2011 09:11:48 +0000 (10:11 +0100)
committerConnor Lane Smith <cls@lubutu.com>
Mon, 17 Oct 2011 09:11:48 +0000 (10:11 +0100)
1  2 
dmenu.c

diff --combined dmenu.c
index dc1f23646281eb4c299988ac1c9706bdb57df743,895542d92ba75982b2de014b123473dc758fd888..671095e54b6c76b02407b53b91b9b81be13483de
+++ b/dmenu.c
@@@ -41,6 -41,7 +41,6 @@@ static void usage(void)
  static char text[BUFSIZ] = "";
  static int bh, mw, mh;
  static int inputw, promptw;
 -static int lines = 0;
  static size_t cursor = 0;
  static const char *font = NULL;
  static const char *prompt = NULL;
@@@ -48,7 -49,6 +48,7 @@@ static const char *normbgcolor = "#cccc
  static const char *normfgcolor = "#000000";
  static const char *selbgcolor  = "#0066ff";
  static const char *selfgcolor  = "#ffffff";
 +static unsigned int lines = 0;
  static unsigned long normcol[ColLast];
  static unsigned long selcol[ColLast];
  static Atom utf8;
@@@ -58,6 -58,7 +58,7 @@@ static Item *items = NULL
  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;
@@@ -229,9 -230,13 +230,13 @@@ insert(const char *str, ssize_t n) 
  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;
  
        switch(ksym) {
        default:
                if(!iscntrl(*buf))
-                       insert(buf, strlen(buf));
+                       insert(buf, len);
                break;
        case XK_Delete:
                if(text[cursor] == '\0')
@@@ -461,7 -466,9 +466,9 @@@ voi
  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)
                                XRaiseWindow(dc->dpy, win);
                        break;
                }
+       }
  }
  
  void
@@@ -486,6 -494,7 +494,7 @@@ setup(void) 
        int x, y, screen = DefaultScreen(dc->dpy);
        Window root = RootWindow(dc->dpy, screen);
        XSetWindowAttributes swa;
+       XIM xim;
  #ifdef XINERAMA
        int n;
        XineramaScreenInfo *info;
                            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();