diff options
author | Joseph Benden <joe@benden.us> | 2019-05-17 11:49:55 -0700 |
---|---|---|
committer | Joseph Benden <joe@benden.us> | 2019-05-17 11:54:04 -0700 |
commit | a96c33e81ef8918743b47511a0488be0d585460a (patch) | |
tree | aea8ac9057f0c62079ad9556504d219681e9d40f /st.c | |
parent | 6c0c86191cf55765b8be07bed9bdf67e1d4d8e96 (diff) |
Add interval timer to XIM updates
Signed-off-by: Joseph Benden <joe@benden.us>
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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 |