commit 72c555f605858e6ddb3ff1c34c9914cf9677c34b
parent ec72bbe23e78e94167d72db27b3bbb4afd643672
Author: Luke Smith <luke@lukesmith.xyz>
Date: Fri, 20 Mar 2020 08:40:22 -0400
Merge branch 'master' of github.com:LukeSmithxyz/st
Diffstat:
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/config.h b/config.h
@@ -53,6 +53,13 @@ static unsigned int actionfps = 30;
static unsigned int blinktimeout = 800;
/*
+ * interval (in milliseconds) between each successive call to ximspot. This
+ * improves terminal performance while not reducing functionality to those
+ * whom need XIM support.
+ */
+int ximspot_update_interval = 1000;
+
+/*
* thickness of underline and bar cursors
*/
static unsigned int cursorthickness = 2;
@@ -187,6 +194,7 @@ ResourcePref resources[] = {
{ "cwscale", FLOAT, &cwscale },
{ "chscale", FLOAT, &chscale },
{ "alpha", FLOAT, &alpha },
+ { "ximspot_update_interval", INTEGER, &ximspot_update_interval },
};
/*
diff --git a/st.c b/st.c
@@ -14,6 +14,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <termios.h>
+#include <time.h>
#include <unistd.h>
#include <wchar.h>
@@ -142,6 +143,7 @@ typedef struct {
int charset; /* current charset */
int icharset; /* selected charset for sequence */
int *tabs;
+ struct timespec last_ximspot_update;
} Term;
/* CSI Escape sequence structs */
@@ -1056,6 +1058,7 @@ void
tnew(int col, int row)
{
term = (Term){ .c = { .attr = { .fg = defaultfg, .bg = defaultbg } } };
+ clock_gettime(CLOCK_MONOTONIC, &term.last_ximspot_update);
tresize(col, row);
treset();
}
@@ -2744,7 +2747,13 @@ 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);
+
+ struct timespec now;
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ if (ximspot_update_interval && TIMEDIFF(now, term.last_ximspot_update) > ximspot_update_interval) {
+ xximspot(term.ocx, term.ocy);
+ term.last_ximspot_update = now;
+ }
}
void
diff --git a/st.h b/st.h
@@ -133,3 +133,4 @@ extern unsigned int defaultfg;
extern unsigned int defaultbg;
extern float alpha;
extern MouseKey mkeys[];
+extern int ximspot_update_interval;