Xinqi Bao's Git
projects
/
st.git
/ diff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (parent:
99de333
)
x: do not instantiate a new nested list on each cursor move
author
Quentin Rameau <
[email protected]
>
Sun, 2 Feb 2020 14:38:08 +0000
(15:38 +0100)
committer
Hiltjo Posthuma <
[email protected]
>
Sun, 2 Feb 2020 21:56:51 +0000
(22:56 +0100)
x.c
diff
|
blob
|
history
diff --git
a/x.c
b/x.c
index
60eeee1
..
5af6e4d
100644
(file)
--- a/
x.c
+++ b/
x.c
@@
-97,6
+97,8
@@
typedef struct {
struct {
XIM xim;
XIC xic;
struct {
XIM xim;
XIC xic;
+ XPoint spot;
+ XVaNestedList spotlist;
} ime;
Draw draw;
Visual *vis;
} 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");
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
}
void
@@
-1058,6
+1063,7
@@
ximdestroy(XIM xim, XPointer client, XPointer call)
xw.ime.xim = NULL;
XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
ximinstantiate, NULL);
xw.ime.xim = NULL;
XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
ximinstantiate, NULL);
+ XFree(xw.ime.spotlist);
}
void
}
void
@@
-1603,11
+1609,13
@@
xfinishdraw(void)
void
xximspot(int x, int y)
{
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
}
void