>From 7fa0a12281f4b595b75e40e497919076497281e8 Mon Sep 17 00:00:00 2001
From: bakkeby <[email protected]>
Date: Tue, 11 May 2021 10:20:23 +0200
Subject: [PATCH] Restore cursor when exiting alt mode.
If the mouse cursor is changed to a bar or an underline then st will use that
when the terminal is first opened. When an application that changes the cursor
via escape sequences is executed, e.g. vim which uses a block cursor by default,
then that cursor will remain after exiting the program.
This change sets the cursor back to default when exiting alt mode.
---
st.c | 2 ++
win.h | 1 +
x.c | 6 ++++++
3 files changed, 9 insertions(+)
diff --git a/st.c b/st.c
index ebdf360..f0db3e0 100644
--- a/st.c
+++ b/st.c
@@ -1057,6 +1057,8 @@ tswapscreen(void)
term.line = term.alt;
term.alt = tmp;
term.mode ^= MODE_ALTSCREEN;
+ if (!IS_SET(MODE_ALTSCREEN))
+ xsetdefaultcursor();
tfulldirt();
}
diff --git a/win.h b/win.h
index e6e4369..320585f 100644
--- a/win.h
+++ b/win.h
@@ -33,6 +33,7 @@ int xsetcolorname(int, const char *);
void xseticontitle(char *);
void xsettitle(char *);
int xsetcursor(int);
+void xsetdefaultcursor(void);
void xsetmode(int, unsigned int);
void xsetpointermotion(int);
void xsetsel(char *);
diff --git a/x.c b/x.c
index 7186040..eae9f95 100644
--- a/x.c
+++ b/x.c
@@ -1712,6 +1712,12 @@ xsetcursor(int cursor)
return 0;
}
+void
+xsetdefaultcursor(void)
+{
+ xsetcursor(cursorshape);
+}
+
void
xseturgency(int add)
{
--
2.31.1