aboutsummaryrefslogtreecommitdiff
path: root/x.c
diff options
context:
space:
mode:
authorQuentin Rameau <quinq@fifth.space>2020-02-02 15:38:08 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2020-02-02 22:56:51 +0100
commit2cb539142b97bd2a5c1a322fd7c063c6afb67c9b (patch)
treec67d142e22e780ec30b85609c0ddba9caf5aa898 /x.c
parent99de33395126fc9708f442d155e737b9182f6ef4 (diff)
downloadst-patched-2cb539142b97bd2a5c1a322fd7c063c6afb67c9b.tar.bz2
st-patched-2cb539142b97bd2a5c1a322fd7c063c6afb67c9b.tar.xz
st-patched-2cb539142b97bd2a5c1a322fd7c063c6afb67c9b.zip
x: do not instantiate a new nested list on each cursor move
Diffstat (limited to 'x.c')
-rw-r--r--x.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/x.c b/x.c
index 60eeee1..5af6e4d 100644
--- a/x.c
+++ b/x.c
@@ -97,6 +97,8 @@ typedef struct {
97 struct { 97 struct {
98 XIM xim; 98 XIM xim;
99 XIC xic; 99 XIC xic;
100 XPoint spot;
101 XVaNestedList spotlist;
100 } ime; 102 } ime;
101 Draw draw; 103 Draw draw;
102 Visual *vis; 104 Visual *vis;
@@ -1042,6 +1044,9 @@ ximopen(Display *dpy)
1042 XNClientWindow, xw.win, XNFocusWindow, xw.win, NULL); 1044 XNClientWindow, xw.win, XNFocusWindow, xw.win, NULL);
1043 if (xw.xic == NULL) 1045 if (xw.xic == NULL)
1044 die("XCreateIC failed. Could not obtain input method.\n"); 1046 die("XCreateIC failed. Could not obtain input method.\n");
1047
1048 xw.ime.spotlist = XVaCreateNestedList(0, XNSpotLocation, &xw.ime.spot,
1049 NULL);
1045} 1050}
1046 1051
1047void 1052void
@@ -1058,6 +1063,7 @@ ximdestroy(XIM xim, XPointer client, XPointer call)
1058 xw.ime.xim = NULL; 1063 xw.ime.xim = NULL;
1059 XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, 1064 XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
1060 ximinstantiate, NULL); 1065 ximinstantiate, NULL);
1066 XFree(xw.ime.spotlist);
1061} 1067}
1062 1068
1063void 1069void
@@ -1603,11 +1609,13 @@ xfinishdraw(void)
1603void 1609void
1604xximspot(int x, int y) 1610xximspot(int x, int y)
1605{ 1611{
1606 XPoint spot = { borderpx + x * win.cw, borderpx + (y + 1) * win.ch }; 1612 if (xw.ime.xic == NULL)
1607 XVaNestedList attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); 1613 return;
1614
1615 xw.ime.spot.x = borderpx + x * win.cw;
1616 xw.ime.spot.y = borderpx + (y + 1) * win.ch;
1608 1617
1609 XSetICValues(xw.xic, XNPreeditAttributes, attr, NULL); 1618 XSetICValues(xw.ime.xic, XNPreeditAttributes, xw.ime.spotlist, NULL);
1610 XFree(attr);
1611} 1619}
1612 1620
1613void 1621void