avoid overlaping

v0.6
audoban 8 years ago committed by Michail Vourlakos
parent 67e2440aa3
commit e9221f8719

@ -178,58 +178,43 @@ QRect DockCorona::screenGeometry(int id) const
QRegion DockCorona::availableScreenRegion(int id) const
{
return availableScreenRect(id);
//FIXME::: availableGeometry is probably broken
// in Qt, so this have to be updated as plasma is doing it
// for example the availableScreenRect
const auto screens = qGuiApp->screens();
if (id >= 0 && id < screens.count()) {
return screens[id]->geometry();
}
return qGuiApp->primaryScreen()->availableGeometry();
}
QRect DockCorona::availableScreenRect(int id) const
{
const auto screens = qGuiApp->screens();
const QScreen *screen = nullptr;
QScreen *mScreen = 0;
if (id >= 0 && id < screens.count())
screen = screens[id];
else
screen = qGuiApp->primaryScreen();
if (id >= 0 && id < screens.count()) {
mScreen = screens[id];
} else {
mScreen = qGuiApp->primaryScreen();
}
if (!screen)
return {};
QRect r = mScreen->geometry();
auto available = screen->geometry();
foreach (DockView *v, m_dockViews) {
if (v->isVisible() && v->screen() && v->containment()
&& v->screen() == mScreen && v->visibility()->mode() != Latte::Dock::AutoHide) {
switch (v->containment()->location()) {
case Plasma::Types::LeftEdge:
r.setLeft(r.left() + v->normalThickness());
break;
case Plasma::Types::RightEdge:
r.setRight(r.right() - v->normalThickness());
break;
for (const auto *view : m_dockViews) {
if (view && view->containment() && view->screen() == screen) {
auto dockRect = view->absGeometry();
switch (view->location()) {
case Plasma::Types::TopEdge:
r.setTop(r.top() + v->normalThickness());
break;
available.setTopLeft({available.x(), dockRect.bottom()});
break;
case Plasma::Types::BottomEdge:
r.setBottom(r.bottom() - v->normalThickness());
default:
break;
available.setBottomLeft({available.x(), dockRect.top()});
break;
}
}
}
return r;
return available;
}
int DockCorona::primaryScreenId() const
@ -238,9 +223,9 @@ int DockCorona::primaryScreenId() const
int id = -1;
for (int i = 0; i < screens.size(); ++i) {
auto *scr = screens.at(i);
auto *screen = screens.at(i);
if (scr == qGuiApp->primaryScreen()) {
if (screen == qGuiApp->primaryScreen()) {
id = i;
break;
}

@ -113,7 +113,10 @@ void DockView::init()
connect(this, &DockView::screenGeometryChanged, this, &DockView::syncGeometry);
connect(this, &QQuickWindow::widthChanged, this, &DockView::widthChanged);
connect(this, &QQuickWindow::heightChanged, this, &DockView::heightChanged);
connect(this, &DockView::localDockGeometryChanged, this, &DockView::updateAbsDockGeometry);
connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, [&](){
if (formFactor() == Plasma::Types::Vertical)
syncGeometry();
});
connect(this, &DockView::drawShadowsChanged, this, &DockView::syncGeometry);
connect(this, &DockView::maxLengthChanged, this, &DockView::syncGeometry);
connect(this, &DockView::alignmentChanged, this, &DockView::updateEnabledBorders);
@ -230,13 +233,8 @@ void DockView::showConfigurationInterface(Plasma::Applet *applet)
void DockView::resizeWindow()
{
if (!this->screen()) {
return;
}
QSize screenSize = this->screen()->size();
if (formFactor() == Plasma::Types::Vertical) {
QSize screenSize = corona()->availableScreenRect(containment()->screen()).size();
QSize size{maxThickness(), screenSize.height()};
if (m_drawShadows) {
@ -248,6 +246,7 @@ void DockView::resizeWindow()
setMaximumSize(size);
resize(size);
} else {
QSize screenSize = screen()->size();
QSize size{screenSize.width(), maxThickness()};
if (m_drawShadows) {
@ -258,35 +257,33 @@ void DockView::resizeWindow()
setMinimumSize(size);
setMaximumSize(size);
resize(size);
if (corona())
emit corona()->availableScreenRectChanged();
}
}
void DockView::setLocalDockGeometry(const QRect &geometry)
{
if (geometry == m_localDockGeometry) {
return;
}
m_localDockGeometry = geometry;
emit localDockGeometryChanged();
updateAbsDockGeometry(geometry);
}
void DockView::updateAbsDockGeometry()
void DockView::updateAbsDockGeometry(const QRect &localDockGeometry)
{
if (!m_visibility)
QRect absGeometry {x() + localDockGeometry.x(), y() + localDockGeometry.y()
, localDockGeometry.width() - 1, localDockGeometry.height() - 1};
if (m_absGeometry == absGeometry)
return;
QRect absoluteGeometry {x() + m_localDockGeometry.x(), y() + m_localDockGeometry.y(), m_localDockGeometry.width(), m_localDockGeometry.height()};
m_visibility->updateDockGeometry(absoluteGeometry);
m_absGeometry = absGeometry;
syncGeometry();
emit absGeometryChanged(m_absGeometry);
}
void DockView::updatePosition()
{
if (!this->screen() || !this->containment())
return;
const QRect screenGeometry = this->screen()->geometry();
QRect screenGeometry;
QPoint position;
position = {0, 0};
@ -296,6 +293,7 @@ void DockView::updatePosition()
switch (location()) {
case Plasma::Types::TopEdge:
screenGeometry = screen()->geometry();
if (m_drawShadows) {
position = {screenGeometry.x() + (screenGeometry.width() / 2 - maxLengthWidth / 2), screenGeometry.y()};
} else {
@ -305,6 +303,7 @@ void DockView::updatePosition()
break;
case Plasma::Types::BottomEdge:
screenGeometry = screen()->geometry();
if (m_drawShadows) {
position = {screenGeometry.x() + (screenGeometry.width() / 2 - maxLengthWidth / 2),
screenGeometry.y() + screenGeometry.height() - cleanThickness
@ -316,6 +315,7 @@ void DockView::updatePosition()
break;
case Plasma::Types::RightEdge:
screenGeometry = corona()->availableScreenRect(containment()->screen());
if (m_drawShadows && !mask().isNull()) {
position = {screenGeometry.x() + screenGeometry.width() - cleanThickness,
screenGeometry.y() + (screenGeometry.height() / 2 - maxLengthHeight / 2)
@ -327,6 +327,7 @@ void DockView::updatePosition()
break;
case Plasma::Types::LeftEdge:
screenGeometry = corona()->availableScreenRect(containment()->screen());
if (m_drawShadows && !mask().isNull()) {
position = {screenGeometry.x(), screenGeometry.y() + (screenGeometry.height() / 2 - maxLengthHeight / 2)};
} else {
@ -345,10 +346,12 @@ void DockView::updatePosition()
inline void DockView::syncGeometry()
{
if (!(screen() && containment()))
return;
updateEnabledBorders();
resizeWindow();
updatePosition();
updateAbsDockGeometry();
// qDebug() << "dock geometry:" << qRectToStr(geometry());
}
@ -475,14 +478,14 @@ void DockView::setMaxThickness(int thickness)
int DockView::alignment() const
{
return (int)m_alignment;
return m_alignment;
}
void DockView::setAlignment(int alignment)
{
Dock::Alignment align = (Dock::Alignment) alignment;
Dock::Alignment align = static_cast<Dock::Alignment>(alignment);
if (m_alignment == align) {
if (m_alignment == alignment) {
return;
}
@ -506,6 +509,11 @@ void DockView::setMaskArea(QRect area)
emit maskAreaChanged();
}
QRect DockView::absGeometry() const
{
return m_absGeometry;
}
int DockView::shadow() const
{
return m_shadow;
@ -547,7 +555,7 @@ bool DockView::tasksPresent()
return false;
}
VisibilityManager *DockView::visibility()
VisibilityManager * DockView::visibility() const
{
return m_visibility;
}

@ -74,7 +74,6 @@ public:
void syncGeometry();
int currentThickness() const;
void updateAbsDockGeometry();
int docksCount() const;
@ -99,11 +98,14 @@ public:
QRect maskArea() const;
void setMaskArea(QRect area);
void updateAbsDockGeometry(const QRect &localDockGeometry);
QRect absGeometry() const;
Plasma::FrameSvg::EnabledBorders enabledBorders() const;
QStringList debugFlags() const;
VisibilityManager *visibility();
VisibilityManager * visibility() const;
QQmlListProperty<QScreen> screens();
static int countScreens(QQmlListProperty<QScreen> *property);
@ -149,7 +151,7 @@ signals:
void maskAreaChanged();
void shadowChanged();
void localDockGeometryChanged();
void absGeometryChanged(const QRect &geometry);
private slots:
void menuAboutToHide();
@ -172,7 +174,7 @@ private:
Dock::Alignment m_alignment{Dock::Center};
QRect m_localDockGeometry;
QRect m_absGeometry;
QRect m_maskArea;
QMenu *m_contextMenu;
QPointer<PlasmaQuick::ConfigView> m_configView;

@ -36,6 +36,7 @@ VisibilityManagerPrivate::VisibilityManagerPrivate(PlasmaQuick::ContainmentView
if (dockView) {
connect(dockView, &DockView::eventTriggered, this, &VisibilityManagerPrivate::event);
connect(dockView, &DockView::absGeometryChanged, this, &VisibilityManagerPrivate::setDockGeometry);
}
timerCheckWindows.setInterval(350);
@ -85,7 +86,7 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
switch (this->mode) {
case Dock::AlwaysVisible: {
if (view->containment() && !view->containment()->isUserConfiguring())
wm->setDockStruts(dockRect, view->location());
wm->setDockStruts(dockGeometry, view->location());
connections[0] = connect(view->containment(), &Plasma::Containment::locationChanged
, this, [&]() {
@ -95,7 +96,7 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
connections[1] = connect(view->containment(), &Plasma::Containment::userConfiguringChanged
, this, [&](bool configuring) {
if (!configuring)
wm->setDockStruts(dockRect, view->containment()->location());
wm->setDockStruts(dockGeometry, view->containment()->location());
});
raiseDock(true);
}
@ -253,15 +254,15 @@ void VisibilityManagerPrivate::updateHiddenState()
}
}
inline void VisibilityManagerPrivate::setDockRect(const QRect &dockRect)
inline void VisibilityManagerPrivate::setDockGeometry(const QRect &geometry)
{
if (!view->containment() || this->dockRect == dockRect)
if (!view->containment() || this->dockGeometry == geometry)
return;
this->dockRect = dockRect;
this->dockGeometry = geometry;
if (mode == Dock::AlwaysVisible && !view->containment()->isUserConfiguring()) {
wm->setDockStruts(this->dockRect, view->containment()->location());
wm->setDockStruts(this->dockGeometry, view->containment()->location());
}
}
@ -339,7 +340,7 @@ void VisibilityManagerPrivate::checkAllWindows()
inline bool VisibilityManagerPrivate::intersects(const WindowInfoWrap &winfo)
{
return !winfo.isMinimized() && winfo.geometry().intersects(dockRect);
return !winfo.isMinimized() && winfo.geometry().intersects(dockGeometry);
}
inline void VisibilityManagerPrivate::saveConfig()
@ -485,9 +486,5 @@ void VisibilityManager::setTimerHide(int msec)
d->setTimerHide(msec);
}
void VisibilityManager::updateDockGeometry(const QRect &geometry)
{
d->setDockRect(geometry);
}
//! END: VisibilityManager implementation
}

@ -64,11 +64,6 @@ public:
int timerHide() const;
void setTimerHide(int msec);
/**
* @brief updateDockGeometry, the window geometry in absolute coordinates.
*/
void updateDockGeometry(const QRect &geometry);
signals:
void mustBeShown();
void mustBeHide();

@ -37,7 +37,7 @@ public:
void raiseDock(bool raise);
void updateHiddenState();
void setDockRect(const QRect &rect);
void setDockGeometry(const QRect &rect);
void windowAdded(WId id);
void dodgeActive(WId id);
@ -61,7 +61,7 @@ public:
QTimer timerShow;
QTimer timerHide;
QTimer timerCheckWindows;
QRect dockRect;
QRect dockGeometry;
bool isHidden{true};
bool dragEnter{false};
bool blockHiding{false};

Loading…
Cancel
Save