fix #355, Request for new visibility policy: Windows Go Below

pull/1/head
Johan Smith Agudelo Rodriguez 8 years ago
parent b48c74ed08
commit adf82df246

@ -48,8 +48,6 @@ DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockV
setIcon(qGuiApp->windowIcon()); setIcon(qGuiApp->windowIcon());
} }
m_previousDockWinBehavior = m_dockView->dockWinBehavior();
m_screenSyncTimer.setSingleShot(true); m_screenSyncTimer.setSingleShot(true);
m_screenSyncTimer.setInterval(100); m_screenSyncTimer.setInterval(100);
connections << connect(dockView, SIGNAL(screenChanged(QScreen *)), &m_screenSyncTimer, SLOT(start())); connections << connect(dockView, SIGNAL(screenChanged(QScreen *)), &m_screenSyncTimer, SLOT(start()));
@ -209,28 +207,40 @@ void DockConfigView::showEvent(QShowEvent *ev)
m_screenSyncTimer.start(); m_screenSyncTimer.start();
QTimer::singleShot(400, this, &DockConfigView::syncGeometry); QTimer::singleShot(400, this, &DockConfigView::syncGeometry);
m_previousMode = m_dockView->visibility()->mode();
emit showSignal(); emit showSignal();
} }
void DockConfigView::hideEvent(QHideEvent *ev) 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); m_dockView->containment()->setUserConfiguring(false);
QQuickWindow::hideEvent(ev); QQuickWindow::hideEvent(ev);
if ((m_dockView && m_dockView->visibility()->mode() != m_previousMode auto recreateDock = [&]() noexcept {
&& ((m_dockView->visibility()->mode() == Dock::AlwaysVisible)
|| (m_previousMode == Dock::AlwaysVisible)))
|| (m_previousDockWinBehavior != m_dockView->dockWinBehavior())) {
auto *dockCorona = qobject_cast<DockCorona *>(m_dockView->corona()); auto *dockCorona = qobject_cast<DockCorona *>(m_dockView->corona());
if (dockCorona) { if (dockCorona) {
dockCorona->recreateDock(m_dockView->containment()); 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(); deleteLater();

@ -76,16 +76,10 @@ signals:
private: private:
bool m_blockFocusLost; 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<DockView> m_dockView; QPointer<DockView> m_dockView;
QTimer m_screenSyncTimer; QTimer m_screenSyncTimer;
QList<QMetaObject::Connection> connections; QList<QMetaObject::Connection> connections;
Dock::Visibility m_previousMode{Dock::None};
}; };
} }

@ -814,14 +814,15 @@ void DockCorona::addDock(Plasma::Containment *containment)
//! of the window... This of course is also used during //! of the window... This of course is also used during
//! recreations of the window between different visibility modes //! recreations of the window between different visibility modes
auto mode = static_cast<Dock::Visibility>(containment->config().readEntry("visibility", static_cast<int>(Dock::DodgeActive))); auto mode = static_cast<Dock::Visibility>(containment->config().readEntry("visibility", static_cast<int>(Dock::DodgeActive)));
bool dockWin = containment->config().readEntry("dockWindowBehavior", false); bool dockWin{false};
bool alwaysVisible{false};
if (mode == Latte::Dock::AlwaysVisible) { if (mode == Dock::AlwaysVisible || mode == Dock::WindowsGoBelow) {
alwaysVisible = true; 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->init();
dockView->setContainment(containment); dockView->setContainment(containment);

@ -50,7 +50,7 @@ namespace Latte {
//! both alwaysVisible and dockWinBehavior are passed through corona because //! both alwaysVisible and dockWinBehavior are passed through corona because
//! during the dock window creation containment hasnt been set, but these variables //! during the dock window creation containment hasnt been set, but these variables
//! are needed in order for window flags to be set correctly //! 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), : PlasmaQuick::ContainmentView(corona),
m_contextMenu(nullptr) m_contextMenu(nullptr)
{ {
@ -61,17 +61,16 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool alwaysVis
setColor(QColor(Qt::transparent)); setColor(QColor(Qt::transparent));
setClearBeforeRendering(true); setClearBeforeRendering(true);
if (!alwaysVisible && !dockWindowBehavior) { const auto flags = Qt::FramelessWindowHint
setFlags(Qt::BypassWindowManagerHint
| Qt::FramelessWindowHint
| Qt::WindowStaysOnTopHint | Qt::WindowStaysOnTopHint
| Qt::NoDropShadowWindowHint | Qt::NoDropShadowWindowHint
| Qt::WindowDoesNotAcceptFocus); | Qt::WindowDoesNotAcceptFocus;
if (dockWindowBehavior) {
setFlags(flags);
} else { } else {
setFlags(Qt::FramelessWindowHint setFlags(flags | Qt::BypassWindowManagerHint);
| Qt::WindowStaysOnTopHint
| Qt::NoDropShadowWindowHint
| Qt::WindowDoesNotAcceptFocus);
} }
KWindowSystem::setOnAllDesktops(winId(), true); KWindowSystem::setOnAllDesktops(winId(), true);

@ -78,7 +78,7 @@ class DockView : public PlasmaQuick::ContainmentView {
Q_PROPERTY(Latte::Dock::SessionType session READ session WRITE setSession NOTIFY sessionChanged) Q_PROPERTY(Latte::Dock::SessionType session READ session WRITE setSession NOTIFY sessionChanged)
public: 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(); virtual ~DockView();
void init(); void init();

@ -170,6 +170,9 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
timerCheckWindows.start(); timerCheckWindows.start();
} }
break; break;
case Dock::WindowsGoBelow: {
//
}
} }
view->containment()->config().writeEntry("visibility", static_cast<int>(mode)); view->containment()->config().writeEntry("visibility", static_cast<int>(mode));

@ -40,7 +40,8 @@ public:
AutoHide, AutoHide,
DodgeActive, DodgeActive,
DodgeMaximized, DodgeMaximized,
DodgeAllWindows DodgeAllWindows,
WindowsGoBelow
}; };
Q_ENUM(Visibility) Q_ENUM(Visibility)

@ -352,7 +352,7 @@ PlasmaComponents.Page {
PlasmaComponents.Button { PlasmaComponents.Button {
Layout.fillWidth: true Layout.fillWidth: true
text: i18n("Always Visible") text: i18n("Always Visible")
checked: dock.visibility.mode === mode checked: parent.mode === mode
checkable: true checkable: true
exclusiveGroup: visibilityGroup exclusiveGroup: visibilityGroup
@ -361,7 +361,7 @@ PlasmaComponents.Page {
PlasmaComponents.Button { PlasmaComponents.Button {
Layout.fillWidth: true Layout.fillWidth: true
text: i18n("Auto Hide") text: i18n("Auto Hide")
checked: dock.visibility.mode === mode checked: parent.mode === mode
checkable: true checkable: true
exclusiveGroup: visibilityGroup exclusiveGroup: visibilityGroup
@ -370,7 +370,7 @@ PlasmaComponents.Page {
PlasmaComponents.Button { PlasmaComponents.Button {
Layout.fillWidth: true Layout.fillWidth: true
text: i18n("Dodge Active") text: i18n("Dodge Active")
checked: dock.visibility.mode === mode checked: parent.mode === mode
checkable: true checkable: true
exclusiveGroup: visibilityGroup exclusiveGroup: visibilityGroup
@ -379,7 +379,7 @@ PlasmaComponents.Page {
PlasmaComponents.Button { PlasmaComponents.Button {
Layout.fillWidth: true Layout.fillWidth: true
text: i18n("Dodge Maximized") text: i18n("Dodge Maximized")
checked: dock.visibility.mode === mode checked: parent.mode === mode
checkable: true checkable: true
exclusiveGroup: visibilityGroup exclusiveGroup: visibilityGroup
@ -388,12 +388,21 @@ PlasmaComponents.Page {
PlasmaComponents.Button { PlasmaComponents.Button {
Layout.fillWidth: true Layout.fillWidth: true
text: i18n("Dodge All Windows") text: i18n("Dodge All Windows")
checked: dock.visibility.mode === mode checked: parent.mode === mode
checkable: true checkable: true
exclusiveGroup: visibilityGroup exclusiveGroup: visibilityGroup
property int mode: Latte.Dock.DodgeAllWindows 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 //! END: Visibility
@ -403,6 +412,9 @@ PlasmaComponents.Page {
Layout.fillWidth: true Layout.fillWidth: true
spacing: units.smallSpacing spacing: units.smallSpacing
enabled: !(dock.visibility.mode === Latte.Dock.AlwaysVisible
|| dock.visibility.mode === Latte.Dock.WindowsGoBelow)
Header { Header {
Layout.fillWidth: true Layout.fillWidth: true
text: i18n("Delay") text: i18n("Delay")
@ -424,8 +436,6 @@ PlasmaComponents.Page {
} }
LatteTextField { LatteTextField {
Layout.preferredWidth: width Layout.preferredWidth: width
enabled: dock.visibility.mode !== Latte.Dock.AlwaysVisible
text: dock.visibility.timerShow text: dock.visibility.timerShow
onValueChanged: { onValueChanged: {
@ -441,8 +451,6 @@ PlasmaComponents.Page {
} }
LatteTextField{ LatteTextField{
Layout.preferredWidth: width Layout.preferredWidth: width
enabled: dock.visibility.mode !== Latte.Dock.AlwaysVisible
text: dock.visibility.timerHide text: dock.visibility.timerHide
onValueChanged: { onValueChanged: {

@ -116,10 +116,12 @@ PlasmaComponents.Page {
Layout.leftMargin: units.smallSpacing * 2 Layout.leftMargin: units.smallSpacing * 2
text: i18n("Behave as a normal dock window") text: i18n("Behave as a normal dock window")
checked: dock.dockWinBehavior 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") // tooltip: i18n("Remove the BypassWindowManagerHint flag from the window")
onClicked: { onCheckedChanged: {
dock.dockWinBehavior = checked dock.dockWinBehavior = checked
} }
} }

Loading…
Cancel
Save