fix #198,recreate windows when it is needed

--in order for a dock to be above KeepAbove
windows must contain flag BypassWindowManagerHint.
Unfortunately this flag breaks the experience with
AlwaysVisible state especially the struts and
snapping behavior. This patch recreates a
dockView when a mode is changed and an
update for the flags is needed.
--at the same time move the localGeometry to
dockView in order to trigger properly the
updateAbsGeometry when it is needed, on
window's geometry changes not only when there
is local geometry change
--when a dock is created through corona, the
addDock function reads the mode which is going
to be used and specifys this way the flags that
have to be set during docks creation
pull/1/head
Michail Vourlakos 8 years ago
parent c0b286f858
commit b8ce37d4c3

@ -197,6 +197,8 @@ 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();
} }
@ -207,6 +209,17 @@ void DockConfigView::hideEvent(QHideEvent *ev)
QQuickWindow::hideEvent(ev); QQuickWindow::hideEvent(ev);
if (m_dockView->visibility()->mode() != m_previousMode
&& ((m_dockView->visibility()->mode() == Dock::AlwaysVisible)
|| (m_previousMode == Dock::AlwaysVisible))) {
auto *dockCorona = qobject_cast<DockCorona *>(m_dockView->corona());
if (dockCorona) {
dockCorona->recreateDock(m_dockView->containment());
}
}
deleteLater(); deleteLater();
} }

@ -22,6 +22,8 @@
#define NOWDOCKCONFIGVIEW_H #define NOWDOCKCONFIGVIEW_H
#include "plasmaquick/configview.h" #include "plasmaquick/configview.h"
#include "../liblattedock/dock.h"
#include <plasma/package.h> #include <plasma/package.h>
#include <QObject> #include <QObject>
@ -76,6 +78,8 @@ private:
QTimer m_screenSyncTimer; QTimer m_screenSyncTimer;
QList<QMetaObject::Connection> connections; QList<QMetaObject::Connection> connections;
Dock::Visibility m_previousMode{Dock::None};
}; };
} }

@ -717,7 +717,18 @@ void DockCorona::addDock(Plasma::Containment *containment)
qDebug() << "Adding dock for container..."; qDebug() << "Adding dock for container...";
qDebug() << "onPrimary: " << onPrimary << "screen!!! :" << containment->screen() << " - " << m_screenPool->connector(containment->screen()); qDebug() << "onPrimary: " << onPrimary << "screen!!! :" << containment->screen() << " - " << m_screenPool->connector(containment->screen());
auto dockView = new DockView(this, nextScreen);
//! it is used to set the correct flag during the creation
//! of the window... This of course is also used during
//! recreations of the window between different visibility modes
auto mode = static_cast<Dock::Visibility>(containment->config().readEntry("visibility", static_cast<int>(Dock::DodgeActive)));
bool alwaysVisible{false};
if (mode == Latte::Dock::AlwaysVisible) {
alwaysVisible = true;
}
auto dockView = new DockView(this, nextScreen, alwaysVisible);
dockView->init(); dockView->init();
dockView->setContainment(containment); dockView->setContainment(containment);
@ -738,6 +749,17 @@ void DockCorona::addDock(Plasma::Containment *containment)
emit docksCountChanged(); emit docksCountChanged();
} }
void DockCorona::recreateDock(Plasma::Containment *containment)
{
auto view = m_dockViews.take(containment);
if (view) {
view->setVisible(false);
view->deleteLater();
addDock(view->containment());
}
}
void DockCorona::destroyedChanged(bool destroyed) void DockCorona::destroyedChanged(bool destroyed)
{ {
qDebug() << "dock containment destroyed changed!!!!"; qDebug() << "dock containment destroyed changed!!!!";

@ -63,6 +63,7 @@ public:
int screenForContainment(const Plasma::Containment *containment) const override; int screenForContainment(const Plasma::Containment *containment) const override;
void addDock(Plasma::Containment *containment); void addDock(Plasma::Containment *containment);
void recreateDock(Plasma::Containment *containment);
void aboutApplication(); void aboutApplication();
void closeApplication(); void closeApplication();

@ -45,7 +45,7 @@
namespace Latte { namespace Latte {
DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen) DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool alwaysVisible)
: PlasmaQuick::ContainmentView(corona), : PlasmaQuick::ContainmentView(corona),
m_contextMenu(nullptr) m_contextMenu(nullptr)
{ {
@ -54,10 +54,19 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen)
setIcon(QIcon::fromTheme(corona->kPackage().metadata().iconName())); setIcon(QIcon::fromTheme(corona->kPackage().metadata().iconName()));
setResizeMode(QuickViewSharedEngine::SizeRootObjectToView); setResizeMode(QuickViewSharedEngine::SizeRootObjectToView);
setClearBeforeRendering(true); setClearBeforeRendering(true);
if (!alwaysVisible) {
setFlags(Qt::BypassWindowManagerHint
| Qt::FramelessWindowHint
| Qt::WindowStaysOnTopHint
| Qt::NoDropShadowWindowHint
| Qt::WindowDoesNotAcceptFocus);
} else {
setFlags(Qt::FramelessWindowHint setFlags(Qt::FramelessWindowHint
| Qt::WindowStaysOnTopHint | Qt::WindowStaysOnTopHint
| Qt::NoDropShadowWindowHint | Qt::NoDropShadowWindowHint
| Qt::WindowDoesNotAcceptFocus); | Qt::WindowDoesNotAcceptFocus);
}
if (targetScreen) if (targetScreen)
setScreenToFollow(targetScreen); setScreenToFollow(targetScreen);
@ -136,9 +145,13 @@ void DockView::init()
connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &DockView::screenChanged); connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &DockView::screenChanged);
connect(this, &DockView::screenGeometryChanged, this, &DockView::syncGeometry); connect(this, &DockView::screenGeometryChanged, this, &DockView::syncGeometry);
connect(this, &QQuickWindow::xChanged, this, &DockView::xChanged); connect(this, &QQuickWindow::xChanged, this, &DockView::xChanged);
connect(this, &QQuickWindow::xChanged, this, &DockView::updateAbsDockGeometry);
connect(this, &QQuickWindow::yChanged, this, &DockView::yChanged); connect(this, &QQuickWindow::yChanged, this, &DockView::yChanged);
connect(this, &QQuickWindow::yChanged, this, &DockView::updateAbsDockGeometry);
connect(this, &QQuickWindow::widthChanged, this, &DockView::widthChanged); connect(this, &QQuickWindow::widthChanged, this, &DockView::widthChanged);
connect(this, &QQuickWindow::widthChanged, this, &DockView::updateAbsDockGeometry);
connect(this, &QQuickWindow::heightChanged, this, &DockView::heightChanged); connect(this, &QQuickWindow::heightChanged, this, &DockView::heightChanged);
connect(this, &QQuickWindow::heightChanged, this, &DockView::updateAbsDockGeometry);
connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, [&]() { connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, [&]() {
if (formFactor() == Plasma::Types::Vertical) if (formFactor() == Plasma::Types::Vertical)
@ -481,13 +494,19 @@ void DockView::resizeWindow(QRect availableScreenRect)
void DockView::setLocalDockGeometry(const QRect &geometry) void DockView::setLocalDockGeometry(const QRect &geometry)
{ {
updateAbsDockGeometry(geometry); if (m_localGeometry == geometry) {
return;
}
m_localGeometry = geometry;
updateAbsDockGeometry();
} }
void DockView::updateAbsDockGeometry(const QRect &localDockGeometry) void DockView::updateAbsDockGeometry()
{ {
QRect absGeometry {x() + localDockGeometry.x(), y() + localDockGeometry.y() QRect absGeometry {x() + m_localGeometry.x(), y() + m_localGeometry.y()
, localDockGeometry.width() - 1, localDockGeometry.height() - 1}; , m_localGeometry.width() - 1, m_localGeometry.height() - 1};
if (m_absGeometry == absGeometry) if (m_absGeometry == absGeometry)
return; return;

@ -71,7 +71,7 @@ class DockView : public PlasmaQuick::ContainmentView {
Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged) Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged)
public: public:
DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr); DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr, bool alwaysVisible = false);
virtual ~DockView(); virtual ~DockView();
void init(); void init();
@ -109,7 +109,6 @@ public:
QRect maskArea() const; QRect maskArea() const;
void setMaskArea(QRect area); void setMaskArea(QRect area);
void updateAbsDockGeometry(const QRect &localDockGeometry);
QRect absGeometry() const; QRect absGeometry() const;
QRect screenGeometry() const; QRect screenGeometry() const;
@ -139,6 +138,8 @@ public slots:
Q_INVOKABLE void closeApplication(); Q_INVOKABLE void closeApplication();
void updateAbsDockGeometry();
protected slots: protected slots:
void showConfigurationInterface(Plasma::Applet *applet) override; void showConfigurationInterface(Plasma::Applet *applet) override;
@ -203,6 +204,7 @@ private:
Dock::Alignment m_alignment{Dock::Center}; Dock::Alignment m_alignment{Dock::Center};
QRect m_localGeometry;
QRect m_absGeometry; QRect m_absGeometry;
QRect m_maskArea; QRect m_maskArea;
QMenu *m_contextMenu; QMenu *m_contextMenu;

@ -63,8 +63,6 @@ Item{
property int thicknessZoomOriginal: Math.max(statesLineSizeOriginal + ((plasmoid.configuration.iconSize+iconMarginOriginal) * root.zoomFactor) + 2, property int thicknessZoomOriginal: Math.max(statesLineSizeOriginal + ((plasmoid.configuration.iconSize+iconMarginOriginal) * root.zoomFactor) + 2,
root.realPanelSize + root.panelShadow) root.realPanelSize + root.panelShadow)
property rect localGeometry: Qt.rect(-1,-1,0,0)
Binding{ Binding{
target: dock target: dock
property:"maxThickness" property:"maxThickness"
@ -309,7 +307,7 @@ Item{
} }
} }
// console.log("update mask area:"+newMaskArea); //console.log("reached updating geometry ::: "+dock.maskArea);
if((normalState && !dock.visibility.isHidden) || root.editMode){ if((normalState && !dock.visibility.isHidden) || root.editMode){
var tempGeometry = Qt.rect(dock.maskArea.x, dock.maskArea.y, dock.maskArea.width, dock.maskArea.height); var tempGeometry = Qt.rect(dock.maskArea.x, dock.maskArea.y, dock.maskArea.width, dock.maskArea.height);
@ -338,12 +336,8 @@ Item{
tempGeometry.height = Math.min(tempGeometry.height, dock.height); tempGeometry.height = Math.min(tempGeometry.height, dock.height);
} }
if (localGeometry.x !== tempGeometry.x || localGeometry.y !== tempGeometry.y //console.log("update geometry ::: "+tempGeometry);
|| localGeometry.width !== tempGeometry.width || localGeometry.height !== tempGeometry.height) { dock.setLocalDockGeometry(tempGeometry);
localGeometry = tempGeometry;
dock.setLocalDockGeometry(localGeometry);
}
// console.log("update dock geometry:"+newMaskArea);
} }
} }

Loading…
Cancel
Save