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 | |
| parent | 99de33395126fc9708f442d155e737b9182f6ef4 (diff) | |
| download | st-2cb539142b97bd2a5c1a322fd7c063c6afb67c9b.tar.gz st-2cb539142b97bd2a5c1a322fd7c063c6afb67c9b.zip | |
x: do not instantiate a new nested list on each cursor move
| -rw-r--r-- | x.c | 16 |
1 files changed, 12 insertions, 4 deletions
| @@ -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 | ||
| 1047 | void | 1052 | void |
| @@ -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 | ||
| 1063 | void | 1069 | void |
| @@ -1603,11 +1609,13 @@ xfinishdraw(void) | |||
| 1603 | void | 1609 | void |
| 1604 | xximspot(int x, int y) | 1610 | xximspot(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 | ||
| 1613 | void | 1621 | void |
