Blame SOURCES/0025-session-worker-clear-VT-before-jumping-to-it.patch

400dab
From cabcd21c17ca98e517a3eea7c9d5ce269445e3e0 Mon Sep 17 00:00:00 2001
400dab
From: Ray Strode <rstrode@redhat.com>
400dab
Date: Fri, 31 Aug 2018 15:46:55 -0400
400dab
Subject: [PATCH 25/51] session-worker: clear VT before jumping to it
400dab
400dab
If we're going to jump to a new VT we should make sure it's free
400dab
of residual console text.  That way if there's flicker the user
400dab
will be less likely to notice it.
400dab
400dab
This commit sends a clear screen escape sequence to the tty
400dab
before jumping to it.
400dab
---
400dab
 daemon/gdm-session-worker.c | 7 +++++++
400dab
 1 file changed, 7 insertions(+)
400dab
400dab
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
400dab
index 391969d96..7ed2789da 100644
400dab
--- a/daemon/gdm-session-worker.c
400dab
+++ b/daemon/gdm-session-worker.c
400dab
@@ -943,60 +943,67 @@ fix_terminal_vt_mode (GdmSessionWorker  *worker,
400dab
         }
400dab
 
400dab
         /* VT is in the anti-social state of VT_AUTO + KD_GRAPHICS,
400dab
          * fix it.
400dab
          */
400dab
         succeeded = handle_terminal_vt_switches (worker, tty_fd);
400dab
         mode_fixed = TRUE;
400dab
 out:
400dab
         if (!succeeded) {
400dab
                 g_error ("GdmSessionWorker: couldn't set up terminal, aborting...");
400dab
                 return;
400dab
         }
400dab
 
400dab
         g_debug ("GdmSessionWorker: VT mode did %sneed to be fixed",
400dab
                  mode_fixed? "" : "not ");
400dab
 }
400dab
 
400dab
 static void
400dab
 jump_to_vt (GdmSessionWorker  *worker,
400dab
             int                vt_number)
400dab
 {
400dab
         int fd;
400dab
         int active_vt_tty_fd;
400dab
         int active_vt = -1;
400dab
         struct vt_stat vt_state = { 0 };
400dab
 
400dab
         g_debug ("GdmSessionWorker: jumping to VT %d", vt_number);
400dab
         active_vt_tty_fd = open ("/dev/tty0", O_RDWR | O_NOCTTY);
400dab
 
400dab
         if (worker->priv->session_tty_fd != -1) {
400dab
+                static const char *clear_screen_escape_sequence = "\33[H\33[2J";
400dab
+
400dab
+                /* let's make sure the new VT is clear */
400dab
+                write (worker->priv->session_tty_fd,
400dab
+                       clear_screen_escape_sequence,
400dab
+                       sizeof (clear_screen_escape_sequence));
400dab
+
400dab
                 fd = worker->priv->session_tty_fd;
400dab
 
400dab
                 g_debug ("GdmSessionWorker: first setting graphics mode to prevent flicker");
400dab
                 if (ioctl (fd, KDSETMODE, KD_GRAPHICS) < 0) {
400dab
                         g_debug ("GdmSessionWorker: couldn't set graphics mode: %m");
400dab
                 }
400dab
 
400dab
                 /* It's possible that the current VT was left in a broken
400dab
                  * combination of states (KD_GRAPHICS with VT_AUTO), that
400dab
                  * can't be switched away from.  This call makes sure things
400dab
                  * are set in a way that VT_ACTIVATE should work and
400dab
                  * VT_WAITACTIVE shouldn't hang.
400dab
                  */
400dab
                 fix_terminal_vt_mode (worker, active_vt_tty_fd);
400dab
         } else {
400dab
                 fd = active_vt_tty_fd;
400dab
         }
400dab
 
400dab
         handle_terminal_vt_switches (worker, fd);
400dab
 
400dab
         if (ioctl (fd, VT_GETSTATE, &vt_state) < 0) {
400dab
                 g_debug ("GdmSessionWorker: couldn't get current VT: %m");
400dab
         } else {
400dab
                 active_vt = vt_state.v_active;
400dab
         }
400dab
 
400dab
         if (active_vt != vt_number) {
400dab
                 if (ioctl (fd, VT_ACTIVATE, vt_number) < 0) {
400dab
                         g_debug ("GdmSessionWorker: couldn't initiate jump to VT %d: %m",
400dab
                                  vt_number);
400dab
-- 
400dab
2.27.0
400dab