mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 13:33:50 +03:00
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
This commit is contained in:
parent
c0b286f858
commit
b8ce37d4c3
@ -197,6 +197,8 @@ void DockConfigView::showEvent(QShowEvent *ev)
|
||||
m_screenSyncTimer.start();
|
||||
QTimer::singleShot(400, this, &DockConfigView::syncGeometry);
|
||||
|
||||
m_previousMode = m_dockView->visibility()->mode();
|
||||
|
||||
emit showSignal();
|
||||
}
|
||||
|
||||
@ -207,6 +209,17 @@ void DockConfigView::hideEvent(QHideEvent *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();
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
#define NOWDOCKCONFIGVIEW_H
|
||||
|
||||
#include "plasmaquick/configview.h"
|
||||
#include "../liblattedock/dock.h"
|
||||
|
||||
#include <plasma/package.h>
|
||||
|
||||
#include <QObject>
|
||||
@ -76,6 +78,8 @@ private:
|
||||
QTimer m_screenSyncTimer;
|
||||
|
||||
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() << "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->setContainment(containment);
|
||||
|
||||
@ -738,6 +749,17 @@ void DockCorona::addDock(Plasma::Containment *containment)
|
||||
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)
|
||||
{
|
||||
qDebug() << "dock containment destroyed changed!!!!";
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
int screenForContainment(const Plasma::Containment *containment) const override;
|
||||
|
||||
void addDock(Plasma::Containment *containment);
|
||||
void recreateDock(Plasma::Containment *containment);
|
||||
|
||||
void aboutApplication();
|
||||
void closeApplication();
|
||||
|
@ -45,7 +45,7 @@
|
||||
|
||||
namespace Latte {
|
||||
|
||||
DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen)
|
||||
DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool alwaysVisible)
|
||||
: PlasmaQuick::ContainmentView(corona),
|
||||
m_contextMenu(nullptr)
|
||||
{
|
||||
@ -54,10 +54,19 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen)
|
||||
setIcon(QIcon::fromTheme(corona->kPackage().metadata().iconName()));
|
||||
setResizeMode(QuickViewSharedEngine::SizeRootObjectToView);
|
||||
setClearBeforeRendering(true);
|
||||
setFlags(Qt::FramelessWindowHint
|
||||
| Qt::WindowStaysOnTopHint
|
||||
| Qt::NoDropShadowWindowHint
|
||||
| Qt::WindowDoesNotAcceptFocus);
|
||||
|
||||
if (!alwaysVisible) {
|
||||
setFlags(Qt::BypassWindowManagerHint
|
||||
| Qt::FramelessWindowHint
|
||||
| Qt::WindowStaysOnTopHint
|
||||
| Qt::NoDropShadowWindowHint
|
||||
| Qt::WindowDoesNotAcceptFocus);
|
||||
} else {
|
||||
setFlags(Qt::FramelessWindowHint
|
||||
| Qt::WindowStaysOnTopHint
|
||||
| Qt::NoDropShadowWindowHint
|
||||
| Qt::WindowDoesNotAcceptFocus);
|
||||
}
|
||||
|
||||
if (targetScreen)
|
||||
setScreenToFollow(targetScreen);
|
||||
@ -136,9 +145,13 @@ void DockView::init()
|
||||
connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &DockView::screenChanged);
|
||||
connect(this, &DockView::screenGeometryChanged, this, &DockView::syncGeometry);
|
||||
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::updateAbsDockGeometry);
|
||||
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::updateAbsDockGeometry);
|
||||
|
||||
connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, [&]() {
|
||||
if (formFactor() == Plasma::Types::Vertical)
|
||||
@ -481,13 +494,19 @@ void DockView::resizeWindow(QRect availableScreenRect)
|
||||
|
||||
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()
|
||||
, localDockGeometry.width() - 1, localDockGeometry.height() - 1};
|
||||
QRect absGeometry {x() + m_localGeometry.x(), y() + m_localGeometry.y()
|
||||
, m_localGeometry.width() - 1, m_localGeometry.height() - 1};
|
||||
|
||||
if (m_absGeometry == absGeometry)
|
||||
return;
|
||||
|
@ -71,7 +71,7 @@ class DockView : public PlasmaQuick::ContainmentView {
|
||||
Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged)
|
||||
|
||||
public:
|
||||
DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr);
|
||||
DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr, bool alwaysVisible = false);
|
||||
virtual ~DockView();
|
||||
|
||||
void init();
|
||||
@ -109,7 +109,6 @@ public:
|
||||
QRect maskArea() const;
|
||||
void setMaskArea(QRect area);
|
||||
|
||||
void updateAbsDockGeometry(const QRect &localDockGeometry);
|
||||
QRect absGeometry() const;
|
||||
|
||||
QRect screenGeometry() const;
|
||||
@ -139,6 +138,8 @@ public slots:
|
||||
|
||||
Q_INVOKABLE void closeApplication();
|
||||
|
||||
void updateAbsDockGeometry();
|
||||
|
||||
protected slots:
|
||||
void showConfigurationInterface(Plasma::Applet *applet) override;
|
||||
|
||||
@ -203,6 +204,7 @@ private:
|
||||
|
||||
Dock::Alignment m_alignment{Dock::Center};
|
||||
|
||||
QRect m_localGeometry;
|
||||
QRect m_absGeometry;
|
||||
QRect m_maskArea;
|
||||
QMenu *m_contextMenu;
|
||||
|
@ -63,8 +63,6 @@ Item{
|
||||
property int thicknessZoomOriginal: Math.max(statesLineSizeOriginal + ((plasmoid.configuration.iconSize+iconMarginOriginal) * root.zoomFactor) + 2,
|
||||
root.realPanelSize + root.panelShadow)
|
||||
|
||||
property rect localGeometry: Qt.rect(-1,-1,0,0)
|
||||
|
||||
Binding{
|
||||
target: dock
|
||||
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){
|
||||
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);
|
||||
}
|
||||
|
||||
if (localGeometry.x !== tempGeometry.x || localGeometry.y !== tempGeometry.y
|
||||
|| localGeometry.width !== tempGeometry.width || localGeometry.height !== tempGeometry.height) {
|
||||
localGeometry = tempGeometry;
|
||||
dock.setLocalDockGeometry(localGeometry);
|
||||
}
|
||||
// console.log("update dock geometry:"+newMaskArea);
|
||||
//console.log("update geometry ::: "+tempGeometry);
|
||||
dock.setLocalDockGeometry(tempGeometry);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user