[hackers] [st][patch] Fix st blinking issue

From: Mohamed Aziz Knani <medazizknani_AT_gmail.com>
Date: Sun, 28 Jan 2018 14:03:53 +0100

Hi,
This patch stops the cursor from blinking when there is a new event
(ie. moving the cursor or redrawing..) and redraws it when it's hidden
and there is a new event.

---
 config.def.h |  2 ++
 x.c          | 20 +++++++++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/config.def.h b/config.def.h
index 877afab..34b9296 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -123,7 +123,9 @@ unsigned int defaultrcs = 257;
 
 /*
  * Default shape of cursor
+ * 1: Blinking Block ("█")
  * 2: Block ("█")
+ * 3: Blinking Underline ("_")
  * 4: Underline ("_")
  * 6: Bar ("|")
  * 7: Snowman ("☃")
diff --git a/x.c b/x.c
index c484dfc..5199008 100644
--- a/x.c
+++ b/x.c
_AT_@ -1325,12 +1325,15 @@ xdrawcursor(void)
 		case 7: /* st extension: snowman */
 			utf8decode("☃", &g.u, UTF_SIZ);
 		case 0: /* Blinking Block */
+		  if (IS_SET(MODE_BLINK)) break;
 		case 1: /* Blinking Block (Default) */
+		  if (IS_SET(MODE_BLINK)) break;
 		case 2: /* Steady Block */
 			g.mode |= term.line[term.c.y][curx].mode & ATTR_WIDE;
 			xdrawglyph(g, term.c.x, term.c.y);
 			break;
 		case 3: /* Blinking Underline */
+		  if (IS_SET(MODE_BLINK)) break;
 		case 4: /* Steady Underline */
 			XftDrawRect(xw.draw, &drawcol,
 					borderpx + curx * win.cw,
_AT_@ -1339,6 +1342,7 @@ xdrawcursor(void)
 					win.cw, cursorthickness);
 			break;
 		case 5: /* Blinking bar */
+		  if (IS_SET(MODE_BLINK)) break;
 		case 6: /* Steady bar */
 			XftDrawRect(xw.draw, &drawcol,
 					borderpx + curx * win.cw,
_AT_@ -1639,11 +1643,9 @@ run(void)
 		}
 		if (FD_ISSET(cmdfd, &rfd)) {
 			ttyread();
-			if (blinktimeout) {
-				blinkset = tattrset(ATTR_BLINK);
-				if (!blinkset)
-					MODBIT(term.mode, 0, MODE_BLINK);
-			}
+			blinkset = blinktimeout || tattrset(ATTR_BLINK);
+			if (!blinkset)
+			  MODBIT(term.mode, 0, MODE_BLINK);
 		}
 
 		if (FD_ISSET(xfd, &rfd))
_AT_@ -1672,8 +1674,12 @@ run(void)
 				XNextEvent(xw.dpy, &ev);
 				if (XFilterEvent(&ev, None))
 					continue;
-				if (handler[ev.type])
-					(handler[ev.type])(&ev);
+				if (handler[ev.type]) {
+				  	(handler[ev.type])(&ev);
+					lastblink = now;
+					if (IS_SET(MODE_BLINK)) MODBIT(term.mode, 0, MODE_BLINK);
+				}
+				
 			}
 
 			draw();
-- 
2.11.0
-- 
Mohamed Aziz Knani
http://www.aziz.tn/
Received on Sun Jan 28 2018 - 14:03:53 CET

This archive was generated by hypermail 2.3.0 : Sun Jan 28 2018 - 14:12:22 CET