mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-10 21:18:19 +03:00
provide CanvasGeometry from View::Positioner
--View::Positioner is now responsible to provide the proper Canvas config window geometry
This commit is contained in:
parent
fa83db7825
commit
e74e013f43
@ -485,8 +485,10 @@ void Positioner::immediateSyncGeometry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_view->effects()->updateEnabledBorders();
|
m_view->effects()->updateEnabledBorders();
|
||||||
|
|
||||||
resizeWindow(availableScreenRect);
|
resizeWindow(availableScreenRect);
|
||||||
updatePosition(availableScreenRect);
|
updatePosition(availableScreenRect);
|
||||||
|
updateCanvasGeometry(availableScreenRect);
|
||||||
|
|
||||||
qDebug() << "syncGeometry() calculations for screen: " << m_view->screen()->name() << " _ " << m_view->screen()->geometry();
|
qDebug() << "syncGeometry() calculations for screen: " << m_view->screen()->name() << " _ " << m_view->screen()->geometry();
|
||||||
qDebug() << "syncGeometry() calculations for edge: " << m_view->location();
|
qDebug() << "syncGeometry() calculations for edge: " << m_view->location();
|
||||||
@ -504,6 +506,22 @@ void Positioner::validateDockGeometry()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRect Positioner::canvasGeometry()
|
||||||
|
{
|
||||||
|
return m_canvasGeometry;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Positioner::setCanvasGeometry(const QRect &geometry)
|
||||||
|
{
|
||||||
|
if (m_canvasGeometry == geometry) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_canvasGeometry = geometry;
|
||||||
|
emit canvasGeometryChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! this is used mainly from vertical panels in order to
|
//! this is used mainly from vertical panels in order to
|
||||||
//! to get the maximum geometry that can be used from the dock
|
//! to get the maximum geometry that can be used from the dock
|
||||||
//! based on their alignment type and the location dock
|
//! based on their alignment type and the location dock
|
||||||
@ -573,6 +591,48 @@ void Positioner::validateTopBottomBorders(QRect availableScreenRect, QRegion ava
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Positioner::updateCanvasGeometry(QRect availableScreenRect)
|
||||||
|
{
|
||||||
|
QRect canvas;
|
||||||
|
QRect screenGeometry{m_view->screen()->geometry()};
|
||||||
|
int thickness{m_view->editThickness()};
|
||||||
|
|
||||||
|
if (m_view->formFactor() == Plasma::Types::Vertical) {
|
||||||
|
canvas.setWidth(thickness);
|
||||||
|
canvas.setHeight(availableScreenRect.height());
|
||||||
|
} else {
|
||||||
|
canvas.setWidth(screenGeometry.width());
|
||||||
|
canvas.setHeight(thickness);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (m_view->location()) {
|
||||||
|
case Plasma::Types::TopEdge:
|
||||||
|
canvas.moveLeft(screenGeometry.x());
|
||||||
|
canvas.moveTop(screenGeometry.y());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Plasma::Types::BottomEdge:
|
||||||
|
canvas.moveLeft(screenGeometry.x());
|
||||||
|
canvas.moveTop(screenGeometry.bottom() - thickness + 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Plasma::Types::RightEdge:
|
||||||
|
canvas.moveLeft(screenGeometry.right() - thickness + 1);
|
||||||
|
canvas.moveTop(availableScreenRect.y());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Plasma::Types::LeftEdge:
|
||||||
|
canvas.moveLeft(availableScreenRect.x());
|
||||||
|
canvas.moveTop(availableScreenRect.y());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
qWarning() << "wrong location, couldn't update the canvas config window geometry " << m_view->location();
|
||||||
|
}
|
||||||
|
|
||||||
|
setCanvasGeometry(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
void Positioner::updatePosition(QRect availableScreenRect)
|
void Positioner::updatePosition(QRect availableScreenRect)
|
||||||
{
|
{
|
||||||
QRect screenGeometry{availableScreenRect};
|
QRect screenGeometry{availableScreenRect};
|
||||||
|
@ -80,6 +80,8 @@ public:
|
|||||||
bool isStickedOnBottomEdge() const;
|
bool isStickedOnBottomEdge() const;
|
||||||
void setIsStickedOnBottomEdge(bool sticked);
|
void setIsStickedOnBottomEdge(bool sticked);
|
||||||
|
|
||||||
|
QRect canvasGeometry();
|
||||||
|
|
||||||
void setScreenToFollow(QScreen *scr, bool updateScreenId = true);
|
void setScreenToFollow(QScreen *scr, bool updateScreenId = true);
|
||||||
|
|
||||||
void reconsiderScreen();
|
void reconsiderScreen();
|
||||||
@ -97,6 +99,7 @@ public slots:
|
|||||||
void initDelayedSignals();
|
void initDelayedSignals();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void canvasGeometryChanged();
|
||||||
void currentScreenChanged();
|
void currentScreenChanged();
|
||||||
void edgeChanged();
|
void edgeChanged();
|
||||||
void screenGeometryChanged();
|
void screenGeometryChanged();
|
||||||
@ -137,13 +140,16 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void initSignalingForLocationChangeSliding();
|
void initSignalingForLocationChangeSliding();
|
||||||
void resizeWindow(QRect availableScreenRect = QRect());
|
|
||||||
|
|
||||||
void updateFormFactor();
|
void updateFormFactor();
|
||||||
|
void resizeWindow(QRect availableScreenRect = QRect());
|
||||||
void updatePosition(QRect availableScreenRect = QRect());
|
void updatePosition(QRect availableScreenRect = QRect());
|
||||||
|
void updateCanvasGeometry(QRect availableScreenRect = QRect());
|
||||||
|
|
||||||
void validateTopBottomBorders(QRect availableScreenRect, QRegion availableScreenRegion);
|
void validateTopBottomBorders(QRect availableScreenRect, QRegion availableScreenRegion);
|
||||||
|
|
||||||
|
void setCanvasGeometry(const QRect &geometry);
|
||||||
|
|
||||||
QRect maximumNormalGeometry();
|
QRect maximumNormalGeometry();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -156,6 +162,7 @@ private:
|
|||||||
|
|
||||||
int m_slideOffset{0};
|
int m_slideOffset{0};
|
||||||
|
|
||||||
|
QRect m_canvasGeometry;
|
||||||
//! it is used in order to enforce X11 to never miss window geometry
|
//! it is used in order to enforce X11 to never miss window geometry
|
||||||
QRect m_validGeometry;
|
QRect m_validGeometry;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ CanvasConfigView::CanvasConfigView(Latte::View *view, PrimaryConfigView *parent)
|
|||||||
{
|
{
|
||||||
setResizeMode(QQuickView::SizeRootObjectToView);
|
setResizeMode(QQuickView::SizeRootObjectToView);
|
||||||
|
|
||||||
connections << connect(m_parent, &PrimaryConfigView::availableScreenGeometryChanged, this, &CanvasConfigView::syncGeometry);
|
//connections << connect(m_parent, &PrimaryConfigView::availableScreenGeometryChanged, this, &CanvasConfigView::syncGeometry);
|
||||||
|
|
||||||
setParentView(view);
|
setParentView(view);
|
||||||
init();
|
init();
|
||||||
@ -79,6 +79,8 @@ void CanvasConfigView::initParentView(Latte::View *view)
|
|||||||
{
|
{
|
||||||
SubConfigView::initParentView(view);
|
SubConfigView::initParentView(view);
|
||||||
|
|
||||||
|
viewconnections << connect(m_latteView->positioner(), &ViewPart::Positioner::canvasGeometryChanged, this, &CanvasConfigView::syncGeometry);
|
||||||
|
|
||||||
updateEnabledBorders();
|
updateEnabledBorders();
|
||||||
syncGeometry();
|
syncGeometry();
|
||||||
|
|
||||||
@ -91,55 +93,9 @@ void CanvasConfigView::syncGeometry()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto location = m_latteView->containment()->location();
|
|
||||||
const auto scrGeometry = m_latteView->screenGeometry();
|
|
||||||
const auto availGeometry = m_parent->availableScreenGeometry();
|
|
||||||
QSize size;
|
|
||||||
|
|
||||||
int editThickness = m_latteView->editThickness();
|
|
||||||
|
|
||||||
QPoint position{0, 0};
|
|
||||||
|
|
||||||
int xPos{0};
|
|
||||||
int yPos{0};
|
|
||||||
|
|
||||||
switch (m_latteView->containment()->formFactor()) {
|
|
||||||
case Plasma::Types::Horizontal: {
|
|
||||||
xPos = availGeometry.x();
|
|
||||||
size.setWidth(availGeometry.width());
|
|
||||||
size.setHeight(editThickness);
|
|
||||||
|
|
||||||
if (location == Plasma::Types::TopEdge) {
|
|
||||||
yPos = scrGeometry.y();
|
|
||||||
} else if (location == Plasma::Types::BottomEdge) {
|
|
||||||
yPos = scrGeometry.y() + scrGeometry.height() - editThickness;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Plasma::Types::Vertical: {
|
|
||||||
yPos = availGeometry.y();
|
|
||||||
size.setWidth(editThickness);
|
|
||||||
size.setHeight(availGeometry.height());
|
|
||||||
|
|
||||||
if (location == Plasma::Types::LeftEdge) {
|
|
||||||
xPos = scrGeometry.x();
|
|
||||||
} else if (location == Plasma::Types::RightEdge) {
|
|
||||||
xPos = scrGeometry.x() + scrGeometry.width() - editThickness;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
qWarning() << "no sync geometry, wrong formFactor";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
position = {xPos, yPos};
|
|
||||||
|
|
||||||
updateEnabledBorders();
|
updateEnabledBorders();
|
||||||
|
|
||||||
auto geometry = QRect(position.x(), position.y(), size.width(), size.height());
|
auto geometry = m_latteView->positioner()->canvasGeometry();
|
||||||
|
|
||||||
if (m_geometryWhenVisible == geometry) {
|
if (m_geometryWhenVisible == geometry) {
|
||||||
return;
|
return;
|
||||||
@ -147,15 +103,15 @@ void CanvasConfigView::syncGeometry()
|
|||||||
|
|
||||||
m_geometryWhenVisible = geometry;
|
m_geometryWhenVisible = geometry;
|
||||||
|
|
||||||
setPosition(position);
|
setPosition(geometry.topLeft());
|
||||||
|
|
||||||
if (m_shellSurface) {
|
if (m_shellSurface) {
|
||||||
m_shellSurface->setPosition(position);
|
m_shellSurface->setPosition(geometry.topLeft());
|
||||||
}
|
}
|
||||||
|
|
||||||
setMaximumSize(size);
|
setMaximumSize(geometry.size());
|
||||||
setMinimumSize(size);
|
setMinimumSize(geometry.size());
|
||||||
resize(size);
|
resize(geometry.size());
|
||||||
|
|
||||||
//! after placement request to activate the main config window in order to avoid
|
//! after placement request to activate the main config window in order to avoid
|
||||||
//! rare cases of closing settings window from secondaryConfigView->focusOutEvent
|
//! rare cases of closing settings window from secondaryConfigView->focusOutEvent
|
||||||
|
@ -168,7 +168,7 @@ void SubConfigView::initParentView(Latte::View *view)
|
|||||||
m_latteView = view;
|
m_latteView = view;
|
||||||
|
|
||||||
viewconnections << connect(m_latteView->visibility(), &VisibilityManager::modeChanged, this, &SubConfigView::syncGeometry);
|
viewconnections << connect(m_latteView->visibility(), &VisibilityManager::modeChanged, this, &SubConfigView::syncGeometry);
|
||||||
viewconnections << connect(m_latteView, &Latte::View::normalThicknessChanged, [&]() {
|
viewconnections << connect(m_latteView, &Latte::View::editThicknessChanged, [&]() {
|
||||||
m_thicknessSyncTimer.start();
|
m_thicknessSyncTimer.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user