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

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