diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index f0e31b77a..86d04de17 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -56,23 +56,12 @@ #include "SessionManager.h" #include "ProfileManager.h" #include "KonsoleSettings.h" +#include "WindowSystemInfo.h" #include "settings/GeneralSettings.h" #include "settings/TabBarSettings.h" using namespace Konsole; -/* Normally it would be enough to just have this determined via the window - manager. But there exist GPU drivers (NVIDIA) that have serious performance - issues if transparency is enabled inside Konsole. The rest of the system - works fine. NVIDIA users might want to use --notransparency to work - around such issues. */ -static bool useTransparency() -{ - const KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); - const bool compositingAvailable = false; // bko 332408 KWindowSystem::compositingActive(); - return compositingAvailable && args->isSet("transparency"); -} - MainWindow::MainWindow() : KXmlGuiWindow() , _bookmarkHandler(0) @@ -97,12 +86,9 @@ MainWindow::MainWindow() } } - if (useTransparency()) { - // It is useful to have translucent terminal area - setAttribute(Qt::WA_TranslucentBackground, true); - // But it is mostly annoying to have translucent menubar and tabbar - setAttribute(Qt::WA_NoSystemBackground, false); - } + connect(KWindowSystem::self(), SIGNAL(compositingChanged(bool)), this, SLOT(updateUseTransparency())); + + updateUseTransparency(); // create actions for menus setupActions(); @@ -151,6 +137,18 @@ MainWindow::MainWindow() connect(KonsoleSettings::self(), &Konsole::KonsoleSettings::configChanged, this, &Konsole::MainWindow::applyKonsoleSettings); } +void MainWindow::updateUseTransparency() +{ + const KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); + + bool useTranslucency = KWindowSystem::compositingActive() && args->isSet("transparency"); + + setAttribute(Qt::WA_TranslucentBackground, useTranslucency); + setAttribute(Qt::WA_NoSystemBackground, false); + + WindowSystemInfo::HAVE_TRANSPARENCY = useTranslucency; +} + void MainWindow::rememberMenuAccelerators() { foreach(QAction* menuItem, menuBar()->actions()) { diff --git a/src/MainWindow.h b/src/MainWindow.h index 1a84a1a40..474e6878a 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -169,6 +169,8 @@ private slots: void applyKonsoleSettings(); + void updateUseTransparency(); + public slots: void viewFullScreen(bool fullScreen); diff --git a/src/WindowSystemInfo.cpp b/src/WindowSystemInfo.cpp index 02d03d37a..4e206198d 100644 --- a/src/WindowSystemInfo.cpp +++ b/src/WindowSystemInfo.cpp @@ -26,5 +26,5 @@ using Konsole::WindowSystemInfo; -const bool WindowSystemInfo::HAVE_TRANSPARENCY = false; // bko 332408 KWindowSystem::compositingActive(); +bool WindowSystemInfo::HAVE_TRANSPARENCY = false; diff --git a/src/WindowSystemInfo.h b/src/WindowSystemInfo.h index f7d961d73..30be603f5 100644 --- a/src/WindowSystemInfo.h +++ b/src/WindowSystemInfo.h @@ -28,7 +28,7 @@ namespace Konsole class KONSOLEPRIVATE_EXPORT WindowSystemInfo { public: - static const bool HAVE_TRANSPARENCY; + static bool HAVE_TRANSPARENCY; }; }