diff options
author | Quentin Rameau <quinq@fifth.space> | 2020-02-02 15:38:08 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2020-02-02 22:56:51 +0100 |
commit | 2cb539142b97bd2a5c1a322fd7c063c6afb67c9b (patch) | |
tree | c67d142e22e780ec30b85609c0ddba9caf5aa898 /x.c | |
parent | 99de33395126fc9708f442d155e737b9182f6ef4 (diff) | |
download | st-2cb539142b97bd2a5c1a322fd7c063c6afb67c9b.tar.gz st-2cb539142b97bd2a5c1a322fd7c063c6afb67c9b.tar.bz2 |
x: do not instantiate a new nested list on each cursor move
Diffstat (limited to 'x.c')
-rw-r--r-- | x.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -97,6 +97,8 @@ typedef struct { struct { XIM xim; XIC xic; + XPoint spot; + XVaNestedList spotlist; } ime; Draw draw; Visual *vis; @@ -1042,6 +1044,9 @@ ximopen(Display *dpy) XNClientWindow, xw.win, XNFocusWindow, xw.win, NULL); if (xw.xic == NULL) die("XCreateIC failed. Could not obtain input method.\n"); + + xw.ime.spotlist = XVaCreateNestedList(0, XNSpotLocation, &xw.ime.spot, + NULL); } void @@ -1058,6 +1063,7 @@ ximdestroy(XIM xim, XPointer client, XPointer call) xw.ime.xim = NULL; XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, ximinstantiate, NULL); + XFree(xw.ime.spotlist); } void @@ -1603,11 +1609,13 @@ xfinishdraw(void) void xximspot(int x, int y) { - XPoint spot = { borderpx + x * win.cw, borderpx + (y + 1) * win.ch }; - XVaNestedList attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); + if (xw.ime.xic == NULL) + return; + + xw.ime.spot.x = borderpx + x * win.cw; + xw.ime.spot.y = borderpx + (y + 1) * win.ch; - XSetICValues(xw.xic, XNPreeditAttributes, attr, NULL); - XFree(attr); + XSetICValues(xw.ime.xic, XNPreeditAttributes, xw.ime.spotlist, NULL); } void |