merge xim -> default
This commit is contained in:
		
							
								
								
									
										22
									
								
								dmenu.c
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								dmenu.c
									
									
									
									
									
								
							@@ -58,6 +58,7 @@ static Item *items = NULL;
 | 
				
			|||||||
static Item *matches, *matchend;
 | 
					static Item *matches, *matchend;
 | 
				
			||||||
static Item *prev, *curr, *next, *sel;
 | 
					static Item *prev, *curr, *next, *sel;
 | 
				
			||||||
static Window win;
 | 
					static Window win;
 | 
				
			||||||
 | 
					static XIC xic;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
 | 
					static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
 | 
				
			||||||
static char *(*fstrstr)(const char *, const char *) = strstr;
 | 
					static char *(*fstrstr)(const char *, const char *) = strstr;
 | 
				
			||||||
@@ -229,9 +230,13 @@ insert(const char *str, ssize_t n) {
 | 
				
			|||||||
void
 | 
					void
 | 
				
			||||||
keypress(XKeyEvent *ev) {
 | 
					keypress(XKeyEvent *ev) {
 | 
				
			||||||
	char buf[32];
 | 
						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) {
 | 
						if(ev->state & ControlMask) {
 | 
				
			||||||
		KeySym lower, upper;
 | 
							KeySym lower, upper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -273,7 +278,7 @@ keypress(XKeyEvent *ev) {
 | 
				
			|||||||
	switch(ksym) {
 | 
						switch(ksym) {
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		if(!iscntrl(*buf))
 | 
							if(!iscntrl(*buf))
 | 
				
			||||||
			insert(buf, strlen(buf));
 | 
								insert(buf, len);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case XK_Delete:
 | 
						case XK_Delete:
 | 
				
			||||||
		if(text[cursor] == '\0')
 | 
							if(text[cursor] == '\0')
 | 
				
			||||||
@@ -461,7 +466,9 @@ void
 | 
				
			|||||||
run(void) {
 | 
					run(void) {
 | 
				
			||||||
	XEvent ev;
 | 
						XEvent ev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while(!XNextEvent(dc->dpy, &ev))
 | 
						while(!XNextEvent(dc->dpy, &ev)) {
 | 
				
			||||||
 | 
							if(XFilterEvent(&ev, win))
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
		switch(ev.type) {
 | 
							switch(ev.type) {
 | 
				
			||||||
		case Expose:
 | 
							case Expose:
 | 
				
			||||||
			if(ev.xexpose.count == 0)
 | 
								if(ev.xexpose.count == 0)
 | 
				
			||||||
@@ -479,6 +486,7 @@ run(void) {
 | 
				
			|||||||
				XRaiseWindow(dc->dpy, win);
 | 
									XRaiseWindow(dc->dpy, win);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
@@ -486,6 +494,7 @@ setup(void) {
 | 
				
			|||||||
	int x, y, screen = DefaultScreen(dc->dpy);
 | 
						int x, y, screen = DefaultScreen(dc->dpy);
 | 
				
			||||||
	Window root = RootWindow(dc->dpy, screen);
 | 
						Window root = RootWindow(dc->dpy, screen);
 | 
				
			||||||
	XSetWindowAttributes swa;
 | 
						XSetWindowAttributes swa;
 | 
				
			||||||
 | 
						XIM xim;
 | 
				
			||||||
#ifdef XINERAMA
 | 
					#ifdef XINERAMA
 | 
				
			||||||
	int n;
 | 
						int n;
 | 
				
			||||||
	XineramaScreenInfo *info;
 | 
						XineramaScreenInfo *info;
 | 
				
			||||||
@@ -542,6 +551,11 @@ setup(void) {
 | 
				
			|||||||
	                    DefaultVisual(dc->dpy, screen),
 | 
						                    DefaultVisual(dc->dpy, screen),
 | 
				
			||||||
	                    CWOverrideRedirect | CWBackPixmap | CWEventMask, &swa);
 | 
						                    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);
 | 
						XMapRaised(dc->dpy, win);
 | 
				
			||||||
	resizedc(dc, mw, mh);
 | 
						resizedc(dc, mw, mh);
 | 
				
			||||||
	drawmenu();
 | 
						drawmenu();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user