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

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