]> git.armaanb.net Git - dmenu.git/blobdiff - dmenu.c
revert IME support
[dmenu.git] / dmenu.c
diff --git a/dmenu.c b/dmenu.c
index 5c835dd383f3bf5472f1c1ac58a60db5c006c018..65f25ce576e819421da9320afd7808c730e84ab4 100644 (file)
--- a/dmenu.c
+++ b/dmenu.c
@@ -6,9 +6,7 @@
 #include <string.h>
 #include <strings.h>
 #include <time.h>
-#ifdef __OpenBSD__
 #include <unistd.h>
-#endif
 
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
@@ -555,9 +553,14 @@ run(void)
        XEvent ev;
 
        while (!XNextEvent(dpy, &ev)) {
-               if (XFilterEvent(&ev, None))
+               if (XFilterEvent(&ev, win))
                        continue;
                switch(ev.type) {
+               case DestroyNotify:
+                       if (ev.xdestroywindow.window != win)
+                               break;
+                       cleanup();
+                       exit(1);
                case Expose:
                        if (ev.xexpose.count == 0)
                                drw_map(drw, win, 0, 0, mw, mh);
@@ -661,15 +664,17 @@ setup(void)
                            CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
        XSetClassHint(dpy, win, &ch);
 
-       /* open input methods */
-       xim = XOpenIM(dpy, NULL, NULL, NULL);
+
+       /* input methods */
+       if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
+               die("XOpenIM failed: could not open input device");
+
        xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
                        XNClientWindow, win, XNFocusWindow, win, NULL);
 
        XMapRaised(dpy, win);
-       XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
        if (embed) {
-               XSelectInput(dpy, parentwin, FocusChangeMask);
+               XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
                if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
                        for (i = 0; i < du && dws[i] != win; ++i)
                                XSelectInput(dpy, dws[i], FocusChangeMask);
@@ -733,8 +738,6 @@ main(int argc, char *argv[])
 
        if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
                fputs("warning: no locale support\n", stderr);
-       if (!XSetLocaleModifiers(""))
-               fputs("warning: no locale modifiers support\n", stderr);
        if (!(dpy = XOpenDisplay(NULL)))
                die("cannot open display");
        screen = DefaultScreen(dpy);
@@ -754,7 +757,7 @@ main(int argc, char *argv[])
                die("pledge");
 #endif
 
-       if (fast) {
+       if (fast && !isatty(0)) {
                grabkeyboard();
                readstdin();
        } else {