fix #277,use normal dock window from tweaks

-- with this setting the user can disable
the BypassWindowManagerHint flag for specific
docks
v0.6
Michail Vourlakos 8 years ago
parent e0bc661adf
commit f12fc52fd1

@ -48,6 +48,8 @@ DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockV
setIcon(qGuiApp->windowIcon()); setIcon(qGuiApp->windowIcon());
} }
m_previousDockWinBehavior = m_dockView->dockWinBehavior();
connections << connect(dockView, &QObject::destroyed, this, &QObject::deleteLater); connections << connect(dockView, &QObject::destroyed, this, &QObject::deleteLater);
m_screenSyncTimer.setSingleShot(true); m_screenSyncTimer.setSingleShot(true);
m_screenSyncTimer.setInterval(100); m_screenSyncTimer.setInterval(100);
@ -220,9 +222,10 @@ void DockConfigView::hideEvent(QHideEvent *ev)
QQuickWindow::hideEvent(ev); QQuickWindow::hideEvent(ev);
if (m_dockView && m_dockView->visibility()->mode() != m_previousMode if ((m_dockView && m_dockView->visibility()->mode() != m_previousMode
&& ((m_dockView->visibility()->mode() == Dock::AlwaysVisible) && ((m_dockView->visibility()->mode() == Dock::AlwaysVisible)
|| (m_previousMode == 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());

@ -76,6 +76,9 @@ 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;

@ -800,13 +800,14 @@ 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 alwaysVisible{false}; bool alwaysVisible{false};
if (mode == Latte::Dock::AlwaysVisible) { if (mode == Latte::Dock::AlwaysVisible) {
alwaysVisible = true; alwaysVisible = true;
} }
auto dockView = new DockView(this, nextScreen, alwaysVisible); auto dockView = new DockView(this, nextScreen, alwaysVisible, dockWin);
dockView->init(); dockView->init();
dockView->setContainment(containment); dockView->setContainment(containment);

@ -47,7 +47,10 @@
namespace Latte { namespace Latte {
DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool alwaysVisible) //! 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)
: PlasmaQuick::ContainmentView(corona), : PlasmaQuick::ContainmentView(corona),
m_contextMenu(nullptr) m_contextMenu(nullptr)
{ {
@ -58,7 +61,7 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool alwaysVis
setColor(QColor(Qt::transparent)); setColor(QColor(Qt::transparent));
setClearBeforeRendering(true); setClearBeforeRendering(true);
if (!alwaysVisible) { if (!alwaysVisible && !dockWindowBehavior) {
setFlags(Qt::BypassWindowManagerHint setFlags(Qt::BypassWindowManagerHint
| Qt::FramelessWindowHint | Qt::FramelessWindowHint
| Qt::WindowStaysOnTopHint | Qt::WindowStaysOnTopHint
@ -159,6 +162,7 @@ void DockView::init()
connect(this, &DockView::drawShadowsChanged, this, &DockView::syncGeometry); connect(this, &DockView::drawShadowsChanged, this, &DockView::syncGeometry);
connect(this, &DockView::maxLengthChanged, this, &DockView::syncGeometry); connect(this, &DockView::maxLengthChanged, this, &DockView::syncGeometry);
connect(this, &DockView::alignmentChanged, this, &DockView::updateEnabledBorders); connect(this, &DockView::alignmentChanged, this, &DockView::updateEnabledBorders);
connect(this, &DockView::dockWinBehaviorChanged, this, &DockView::saveConfig);
connect(this, &DockView::onPrimaryChanged, this, &DockView::saveConfig); connect(this, &DockView::onPrimaryChanged, this, &DockView::saveConfig);
connect(this, &DockView::onPrimaryChanged, this, &DockView::reconsiderScreen); connect(this, &DockView::onPrimaryChanged, this, &DockView::reconsiderScreen);
connect(this, &DockView::sessionChanged, this, &DockView::saveConfig); connect(this, &DockView::sessionChanged, this, &DockView::saveConfig);
@ -733,6 +737,21 @@ void DockView::updateFormFactor()
} }
} }
bool DockView::dockWinBehavior() const
{
return m_dockWinBehavior;
}
void DockView::setDockWinBehavior(bool dock)
{
if (m_dockWinBehavior == dock) {
return;
}
m_dockWinBehavior = dock;
emit dockWinBehaviorChanged();
}
bool DockView::drawShadows() const bool DockView::drawShadows() const
{ {
return m_drawShadows; return m_drawShadows;
@ -1502,6 +1521,7 @@ void DockView::saveConfig()
auto config = this->containment()->config(); auto config = this->containment()->config();
config.writeEntry("onPrimary", m_onPrimary); config.writeEntry("onPrimary", m_onPrimary);
config.writeEntry("session", (int)m_session); config.writeEntry("session", (int)m_session);
config.writeEntry("dockWindowBehavior", m_dockWinBehavior);
this->containment()->configNeedsSaving(); this->containment()->configNeedsSaving();
} }
@ -1513,6 +1533,7 @@ void DockView::restoreConfig()
auto config = this->containment()->config(); auto config = this->containment()->config();
setOnPrimary(config.readEntry("onPrimary", true)); setOnPrimary(config.readEntry("onPrimary", true));
setSession((Dock::SessionType)config.readEntry("session", (int)Dock::DefaultSession)); setSession((Dock::SessionType)config.readEntry("session", (int)Dock::DefaultSession));
setDockWinBehavior(config.readEntry("dockWindowBehavior", false));
} }
//!END configuration functions //!END configuration functions

@ -45,6 +45,7 @@ namespace Latte {
class DockView : public PlasmaQuick::ContainmentView { class DockView : public PlasmaQuick::ContainmentView {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool dockWinBehavior READ dockWinBehavior WRITE setDockWinBehavior NOTIFY dockWinBehaviorChanged)
Q_PROPERTY(bool drawShadows READ drawShadows WRITE setDrawShadows NOTIFY drawShadowsChanged) Q_PROPERTY(bool drawShadows READ drawShadows WRITE setDrawShadows NOTIFY drawShadowsChanged)
Q_PROPERTY(bool drawEffects READ drawEffects WRITE setDrawEffects NOTIFY drawEffectsChanged) Q_PROPERTY(bool drawEffects READ drawEffects WRITE setDrawEffects NOTIFY drawEffectsChanged)
Q_PROPERTY(bool onPrimary READ onPrimary WRITE setOnPrimary NOTIFY onPrimaryChanged) Q_PROPERTY(bool onPrimary READ onPrimary WRITE setOnPrimary NOTIFY onPrimaryChanged)
@ -76,7 +77,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); DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr, bool alwaysVisible = false, bool dockWindowBehavior = false);
virtual ~DockView(); virtual ~DockView();
void init(); void init();
@ -93,6 +94,9 @@ public:
int docksCount() const; int docksCount() const;
bool dockWinBehavior() const;
void setDockWinBehavior(bool dock);
bool drawShadows() const; bool drawShadows() const;
void setDrawShadows(bool draw); void setDrawShadows(bool draw);
@ -172,6 +176,7 @@ signals:
void currentScreenChanged(); void currentScreenChanged();
void dockLocationChanged(); void dockLocationChanged();
void docksCountChanged(); void docksCountChanged();
void dockWinBehaviorChanged();
void drawShadowsChanged(); void drawShadowsChanged();
void drawEffectsChanged(); void drawEffectsChanged();
void effectsAreaChanged(); void effectsAreaChanged();
@ -214,6 +219,7 @@ private:
Plasma::Containment *containmentById(uint id); Plasma::Containment *containmentById(uint id);
bool m_forceDrawCenteredBorders{false}; bool m_forceDrawCenteredBorders{false};
bool m_dockWinBehavior{false};
bool m_drawShadows{false}; bool m_drawShadows{false};
bool m_drawEffects{false}; bool m_drawEffects{false};
bool m_onPrimary{true}; bool m_onPrimary{true};

@ -89,6 +89,17 @@ PlasmaComponents.Page {
} }
} }
PlasmaComponents.CheckBox {
Layout.leftMargin: units.smallSpacing * 2
text: i18n("Behave as a normal dock window")
checked: dock.dockWinBehavior
tooltip: i18n("Removes the BypassWindowManagerHint flag from the window")
onClicked: {
dock.dockWinBehavior = checked;
}
}
PlasmaComponents.CheckBox { PlasmaComponents.CheckBox {
Layout.leftMargin: units.smallSpacing * 2 Layout.leftMargin: units.smallSpacing * 2
text: i18n("Expose Alternative Session in the context menu") text: i18n("Expose Alternative Session in the context menu")

Loading…
Cancel
Save