[hackers] [st][PATCH] Update XIM cursor position only if changed

From: Ivan Tham <pickfire_AT_riseup.net>
Date: Thu, 16 Apr 2020 13:38:02 +0800

Updating XIM cursor position is expensive, so only update it when cursor
position changed.
---
 st.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git st.c st.c
index 3e48410..4f7243f 100644
--- st.c
+++ st.c
_AT_@ -2570,7 +2570,7 @@ drawregion(int x1, int y1, int x2, int y2)
 void
 draw(void)
 {
-	int cx = term.c.x;
+	int cx = term.c.x, ocx = term.ocx, ocy = term.ocy;
 
 	if (!xstartdraw())
 		return;
_AT_@ -2588,7 +2588,8 @@ draw(void)
 			term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
 	term.ocx = cx, term.ocy = term.c.y;
 	xfinishdraw();
-	xximspot(term.ocx, term.ocy);
+	if (ocx != term.ocx || ocy != term.ocy)
+		xximspot(term.ocx, term.ocy);
 }
 
 void
-- 
2.26.1
Received on Thu Apr 16 2020 - 07:38:02 CEST

This archive was generated by hypermail 2.3.0 : Thu Apr 16 2020 - 07:48:35 CEST