From adf82df246aadd4d6cd7ad0ed40871846e532568 Mon Sep 17 00:00:00 2001 From: Johan Smith Agudelo Rodriguez Date: Sun, 9 Apr 2017 13:42:39 -0500 Subject: [PATCH] fix #355, Request for new visibility policy: Windows Go Below --- app/dockconfigview.cpp | 30 ++++++++++++------- app/dockconfigview.h | 6 ---- app/dockcorona.cpp | 11 +++---- app/dockview.cpp | 17 +++++------ app/dockview.h | 2 +- app/visibilitymanager.cpp | 3 ++ liblattedock/dock.h | 3 +- .../contents/configuration/BehaviorConfig.qml | 26 ++++++++++------ shell/contents/configuration/TweaksConfig.qml | 6 ++-- 9 files changed, 61 insertions(+), 43 deletions(-) diff --git a/app/dockconfigview.cpp b/app/dockconfigview.cpp index 9e8d79aac..0b24ab689 100644 --- a/app/dockconfigview.cpp +++ b/app/dockconfigview.cpp @@ -48,8 +48,6 @@ DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockV setIcon(qGuiApp->windowIcon()); } - m_previousDockWinBehavior = m_dockView->dockWinBehavior(); - m_screenSyncTimer.setSingleShot(true); m_screenSyncTimer.setInterval(100); connections << connect(dockView, SIGNAL(screenChanged(QScreen *)), &m_screenSyncTimer, SLOT(start())); @@ -209,28 +207,40 @@ void DockConfigView::showEvent(QShowEvent *ev) m_screenSyncTimer.start(); QTimer::singleShot(400, this, &DockConfigView::syncGeometry); - m_previousMode = m_dockView->visibility()->mode(); - emit showSignal(); } void DockConfigView::hideEvent(QHideEvent *ev) { - if (m_dockView && m_dockView->containment()) + if (!m_dockView) { + QQuickWindow::hideEvent(ev); + return; + } + + if (m_dockView->containment()) m_dockView->containment()->setUserConfiguring(false); QQuickWindow::hideEvent(ev); - if ((m_dockView && m_dockView->visibility()->mode() != m_previousMode - && ((m_dockView->visibility()->mode() == Dock::AlwaysVisible) - || (m_previousMode == Dock::AlwaysVisible))) - || (m_previousDockWinBehavior != m_dockView->dockWinBehavior())) { - + auto recreateDock = [&]() noexcept { auto *dockCorona = qobject_cast(m_dockView->corona()); if (dockCorona) { dockCorona->recreateDock(m_dockView->containment()); } + }; + + const auto mode = m_dockView->visibility()->mode(); + const auto previousDockWinBehavior = (m_dockView->flags() & Qt::BypassWindowManagerHint) ? false : true; + + if (mode == Dock::AlwaysVisible || mode == Dock::WindowsGoBelow) { + if (!previousDockWinBehavior) { + recreateDock(); + return; + } + } else if (m_dockView->dockWinBehavior() != previousDockWinBehavior) { + recreateDock(); + return; } deleteLater(); diff --git a/app/dockconfigview.h b/app/dockconfigview.h index 04effc910..eb61420f8 100644 --- a/app/dockconfigview.h +++ b/app/dockconfigview.h @@ -76,16 +76,10 @@ signals: private: bool m_blockFocusLost; - //! it is used to check if we need to recreate the dock window - //! after the configuration window gets closed - bool m_previousDockWinBehavior; QPointer m_dockView; QTimer m_screenSyncTimer; - QList connections; - - Dock::Visibility m_previousMode{Dock::None}; }; } diff --git a/app/dockcorona.cpp b/app/dockcorona.cpp index a49c85ab1..f9dc75a0c 100644 --- a/app/dockcorona.cpp +++ b/app/dockcorona.cpp @@ -814,14 +814,15 @@ void DockCorona::addDock(Plasma::Containment *containment) //! of the window... This of course is also used during //! recreations of the window between different visibility modes auto mode = static_cast(containment->config().readEntry("visibility", static_cast(Dock::DodgeActive))); - bool dockWin = containment->config().readEntry("dockWindowBehavior", false); - bool alwaysVisible{false}; + bool dockWin{false}; - if (mode == Latte::Dock::AlwaysVisible) { - alwaysVisible = true; + if (mode == Dock::AlwaysVisible || mode == Dock::WindowsGoBelow) { + dockWin = true; + } else { + dockWin = containment->config().readEntry("dockWindowBehavior", false); } - auto dockView = new DockView(this, nextScreen, alwaysVisible, dockWin); + auto dockView = new DockView(this, nextScreen, dockWin); dockView->init(); dockView->setContainment(containment); diff --git a/app/dockview.cpp b/app/dockview.cpp index 884821d5b..353f25dd8 100644 --- a/app/dockview.cpp +++ b/app/dockview.cpp @@ -50,7 +50,7 @@ namespace Latte { //! both alwaysVisible and dockWinBehavior are passed through corona because //! during the dock window creation containment hasnt been set, but these variables //! are needed in order for window flags to be set correctly -DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool alwaysVisible, bool dockWindowBehavior) +DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool dockWindowBehavior) : PlasmaQuick::ContainmentView(corona), m_contextMenu(nullptr) { @@ -61,17 +61,16 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool alwaysVis setColor(QColor(Qt::transparent)); setClearBeforeRendering(true); - if (!alwaysVisible && !dockWindowBehavior) { - setFlags(Qt::BypassWindowManagerHint - | Qt::FramelessWindowHint + const auto flags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::NoDropShadowWindowHint - | Qt::WindowDoesNotAcceptFocus); + | Qt::WindowDoesNotAcceptFocus; + + + if (dockWindowBehavior) { + setFlags(flags); } else { - setFlags(Qt::FramelessWindowHint - | Qt::WindowStaysOnTopHint - | Qt::NoDropShadowWindowHint - | Qt::WindowDoesNotAcceptFocus); + setFlags(flags | Qt::BypassWindowManagerHint); } KWindowSystem::setOnAllDesktops(winId(), true); diff --git a/app/dockview.h b/app/dockview.h index 30c025539..a155f2fd6 100644 --- a/app/dockview.h +++ b/app/dockview.h @@ -78,7 +78,7 @@ class DockView : public PlasmaQuick::ContainmentView { Q_PROPERTY(Latte::Dock::SessionType session READ session WRITE setSession NOTIFY sessionChanged) public: - DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr, bool alwaysVisible = false, bool dockWindowBehavior = false); + DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr, bool dockWindowBehavior = false); virtual ~DockView(); void init(); diff --git a/app/visibilitymanager.cpp b/app/visibilitymanager.cpp index 95192b3ff..0a22f5b72 100644 --- a/app/visibilitymanager.cpp +++ b/app/visibilitymanager.cpp @@ -170,6 +170,9 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode) timerCheckWindows.start(); } break; + case Dock::WindowsGoBelow: { + // + } } view->containment()->config().writeEntry("visibility", static_cast(mode)); diff --git a/liblattedock/dock.h b/liblattedock/dock.h index baf5f2bb1..fd0925bdd 100644 --- a/liblattedock/dock.h +++ b/liblattedock/dock.h @@ -40,7 +40,8 @@ public: AutoHide, DodgeActive, DodgeMaximized, - DodgeAllWindows + DodgeAllWindows, + WindowsGoBelow }; Q_ENUM(Visibility) diff --git a/shell/contents/configuration/BehaviorConfig.qml b/shell/contents/configuration/BehaviorConfig.qml index 1320a9f70..90985d6c3 100644 --- a/shell/contents/configuration/BehaviorConfig.qml +++ b/shell/contents/configuration/BehaviorConfig.qml @@ -352,7 +352,7 @@ PlasmaComponents.Page { PlasmaComponents.Button { Layout.fillWidth: true text: i18n("Always Visible") - checked: dock.visibility.mode === mode + checked: parent.mode === mode checkable: true exclusiveGroup: visibilityGroup @@ -361,7 +361,7 @@ PlasmaComponents.Page { PlasmaComponents.Button { Layout.fillWidth: true text: i18n("Auto Hide") - checked: dock.visibility.mode === mode + checked: parent.mode === mode checkable: true exclusiveGroup: visibilityGroup @@ -370,7 +370,7 @@ PlasmaComponents.Page { PlasmaComponents.Button { Layout.fillWidth: true text: i18n("Dodge Active") - checked: dock.visibility.mode === mode + checked: parent.mode === mode checkable: true exclusiveGroup: visibilityGroup @@ -379,7 +379,7 @@ PlasmaComponents.Page { PlasmaComponents.Button { Layout.fillWidth: true text: i18n("Dodge Maximized") - checked: dock.visibility.mode === mode + checked: parent.mode === mode checkable: true exclusiveGroup: visibilityGroup @@ -388,12 +388,21 @@ PlasmaComponents.Page { PlasmaComponents.Button { Layout.fillWidth: true text: i18n("Dodge All Windows") - checked: dock.visibility.mode === mode + checked: parent.mode === mode checkable: true exclusiveGroup: visibilityGroup property int mode: Latte.Dock.DodgeAllWindows } + PlasmaComponents.Button { + Layout.fillWidth: true + text: i18n("Windows Go Below") + checked: parent.mode === mode + checkable: true + exclusiveGroup: visibilityGroup + + property int mode: Latte.Dock.WindowsGoBelow + } } } //! END: Visibility @@ -403,6 +412,9 @@ PlasmaComponents.Page { Layout.fillWidth: true spacing: units.smallSpacing + enabled: !(dock.visibility.mode === Latte.Dock.AlwaysVisible + || dock.visibility.mode === Latte.Dock.WindowsGoBelow) + Header { Layout.fillWidth: true text: i18n("Delay") @@ -424,8 +436,6 @@ PlasmaComponents.Page { } LatteTextField { Layout.preferredWidth: width - enabled: dock.visibility.mode !== Latte.Dock.AlwaysVisible - text: dock.visibility.timerShow onValueChanged: { @@ -441,8 +451,6 @@ PlasmaComponents.Page { } LatteTextField{ Layout.preferredWidth: width - enabled: dock.visibility.mode !== Latte.Dock.AlwaysVisible - text: dock.visibility.timerHide onValueChanged: { diff --git a/shell/contents/configuration/TweaksConfig.qml b/shell/contents/configuration/TweaksConfig.qml index 4bbebd938..859263992 100644 --- a/shell/contents/configuration/TweaksConfig.qml +++ b/shell/contents/configuration/TweaksConfig.qml @@ -116,10 +116,12 @@ PlasmaComponents.Page { Layout.leftMargin: units.smallSpacing * 2 text: i18n("Behave as a normal dock window") checked: dock.dockWinBehavior - enabled: dock.visibility.mode !== Latte.Dock.AlwaysVisible + enabled: !(dock.visibility.mode === Latte.Dock.AlwaysVisible + || dock.visibility.mode === Latte.Dock.WindowsGoBelow) + // tooltip: i18n("Remove the BypassWindowManagerHint flag from the window") - onClicked: { + onCheckedChanged: { dock.dockWinBehavior = checked } }