summaryrefslogtreecommitdiff
path: root/kde-apps/konsole/files/konsole-21.04.3-no-flash-on-session-close.patch
blob: d8b14f2f1660f8611f8e634a6f56a4fd1fbb082f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
From 302c16791935cc3cf262aee355afce13d694b00f Mon Sep 17 00:00:00 2001
From: Ahmad Samir <a.samirh78@gmail.com>
Date: Thu, 12 Aug 2021 13:58:20 +0200
Subject: [PATCH] Prevent window "flashing" when closing the last session

There are two scenarios when closing a window:
A) clicking the close button on the title bar (or Ctrl+Shift+Q):
~MainWindow()
~ViewManager()
~TabbedViewContainer()
~TerminalDisplay()
~Session()

B) closing the last session/tab in a window:
SessionController::sessionFinished()
~Session()
~TerminalDisplay()
~TabbedViewContainer()
~MainWindow()
~ViewManager()

the issue with the second case is that the TerminalDisplay is torn down
first, which exposes the TabbedViewContainer widget, the latter has the same
Qt::Window colour as the system colour scheme window background colour, if
you're using a dark terminal colour scheme and a light-coloured system colour
scheme, you could see some "flashing" when you close the last session with
e.g. Ctrl+D.

To fix this, in sessionFinished() check if TabbedViewContainer::count() is
1 (i.e. closing last tab/session), and emit the empty() signal in that case,
which is connected to MainwWindow::close(), then the order of tear down
becomes:
SessionController::sessionFinished()
~Session()
~MainWindow()
~ViewManager()
~TabbedViewContainer()
~TerminalDisplay()

BUG: 432077
FIXED-IN: 21.12
(cherry picked from commit bbec72250d080ce286a6762fb9beee4b6e7981c9)
---
 src/MainWindow.cpp  | 2 +-
 src/ViewManager.cpp | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index cc38b3990..0fae334de 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -102,7 +102,7 @@ MainWindow::MainWindow() :
 
     // create view manager
     _viewManager = new ViewManager(this, actionCollection());
-    connect(_viewManager, &Konsole::ViewManager::empty, this, &Konsole::MainWindow::close);
+    connect(_viewManager, &Konsole::ViewManager::empty, this, &QWidget::close);
     connect(_viewManager, &Konsole::ViewManager::activeViewChanged, this,
             &Konsole::MainWindow::activeViewChanged);
     connect(_viewManager, &Konsole::ViewManager::unplugController, this,
diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp
index 751684dc8..4d33a4cf8 100644
--- a/src/ViewManager.cpp
+++ b/src/ViewManager.cpp
@@ -461,6 +461,13 @@ void ViewManager::sessionFinished()
         return;
     }
 
+    // The last session/tab? emit empty() so that close() is called in
+    // MainWindow, fixes #432077
+    if (_viewContainer->count() == 1) {
+        Q_EMIT empty();
+        return;
+    }
+
     auto *session = qobject_cast<Session *>(sender());
     Q_ASSERT(session);
 
-- 
GitLab