Commit: 44781c6461d5fa4a1c9868215d3472b4018e9d98
Parent: b3d56a1f2e474df4933ebe4789a5c82764b63c96
Author: Randy Palamar
Date:   Wed, 14 Aug 2024 06:21:45 -0600
fix saved title jank
Diffstat:
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/terminal.c b/terminal.c
@@ -454,11 +454,17 @@ set_colours(Term *t, CSI *csi)
 static void
 window_manipulation(Term *t, CSI *csi)
 {
-	/* TODO: you cannot reuse the title from GLFW after the fact; it needs to be copied */
-	return;
+	const char *s;
+	u32 i;
+
 	switch (csi->argv[0]) {
-	case 22: t->saved_title = glfwGetWindowTitle(t->gl.window); break;
-	case 23: glfwSetWindowTitle(t->gl.window, t->saved_title);  break;
+	case 22:
+		s = glfwGetWindowTitle(t->gl.window);
+		for (i = 0; i < ARRAY_COUNT(t->saved_title) - 1 && s[i]; i++)
+			t->saved_title[i] = s[i];
+		t->saved_title[i] = 0;
+		break;
+	case 23: glfwSetWindowTitle(t->gl.window, t->saved_title); break;
 	default:
 		fprintf(stderr, "unhandled xtwinops: %d\n", csi->argv[0]);
 		dump_csi(csi);
diff --git a/util.h b/util.h
@@ -277,8 +277,7 @@ typedef struct {
 
 	enum terminal_mode mode;
 
-	/* NOTE: owned by GLFW; doesn't need to be freed */
-	const char *saved_title;
+	char saved_title[1024];
 
 	FT_Library ftlib;
 } Term;