mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-27 14:50:21 +03:00
fix #308, Always visible option does not work for side-set dock on unusual multi screen setup
This commit is contained in:
parent
97c52472cf
commit
2487495241
@ -33,6 +33,7 @@
|
||||
#include <QRect>
|
||||
#include <QQuickView>
|
||||
#include <QDialog>
|
||||
#include <QScreen>
|
||||
|
||||
#include <Plasma>
|
||||
#include <KActivities/Consumer>
|
||||
@ -57,7 +58,9 @@ public:
|
||||
virtual ~AbstractWindowInterface();
|
||||
|
||||
virtual void setDockExtraFlags(QQuickWindow &view) = 0;
|
||||
virtual void setDockStruts(WId dockId, const QRect &dockRect, Plasma::Types::Location location) const = 0;
|
||||
virtual void setDockStruts(WId dockId, const QRect &dockRect
|
||||
, const QScreen &screen, Plasma::Types::Location location) const = 0;
|
||||
|
||||
virtual void removeDockStruts(WId dockId) const = 0;
|
||||
|
||||
virtual WId activeWindow() const = 0;
|
||||
|
@ -105,8 +105,9 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
||||
|
||||
switch (this->mode) {
|
||||
case Dock::AlwaysVisible: {
|
||||
if (view->containment() && !view->containment()->isUserConfiguring())
|
||||
wm->setDockStruts(view->winId(), dockGeometry, view->location());
|
||||
if (view->containment() && !view->containment()->isUserConfiguring() && view->screen()) {
|
||||
wm->setDockStruts(view->winId(), dockGeometry, *view->screen(), view->location());
|
||||
}
|
||||
|
||||
connections[0] = connect(view->containment(), &Plasma::Containment::locationChanged
|
||||
, this, [&]() {
|
||||
@ -115,8 +116,8 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
||||
});
|
||||
connections[1] = connect(view->containment(), &Plasma::Containment::userConfiguringChanged
|
||||
, this, [&](bool configuring) {
|
||||
if (!configuring)
|
||||
wm->setDockStruts(view->winId(), dockGeometry, view->containment()->location());
|
||||
if (!configuring && view->screen())
|
||||
wm->setDockStruts(view->winId(), dockGeometry, *view->screen(), view->containment()->location());
|
||||
});
|
||||
raiseDock(true);
|
||||
}
|
||||
@ -311,8 +312,8 @@ inline void VisibilityManagerPrivate::setDockGeometry(const QRect &geometry)
|
||||
|
||||
this->dockGeometry = geometry;
|
||||
|
||||
if (mode == Dock::AlwaysVisible && !view->containment()->isUserConfiguring()) {
|
||||
wm->setDockStruts(view->winId(), this->dockGeometry, view->containment()->location());
|
||||
if (mode == Dock::AlwaysVisible && !view->containment()->isUserConfiguring() && view->screen()) {
|
||||
wm->setDockStruts(view->winId(), this->dockGeometry, *view->screen(), view->containment()->location());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,35 +88,44 @@ void XWindowInterface::setDockExtraFlags(QQuickWindow &view)
|
||||
KWindowSystem::setOnActivities(view.winId(), {"0"});
|
||||
}
|
||||
|
||||
void XWindowInterface::setDockStruts(WId dockId, const QRect &dockRect, Plasma::Types::Location location) const
|
||||
void XWindowInterface::setDockStruts(WId dockId, const QRect &dockRect
|
||||
, const QScreen &screen, Plasma::Types::Location location) const
|
||||
{
|
||||
NETExtendedStrut strut;
|
||||
|
||||
const QRect currentScreen {screen.geometry()};
|
||||
const QRect wholeScreen {{0, 0}, screen.virtualSize()};
|
||||
|
||||
switch (location) {
|
||||
case Plasma::Types::TopEdge:
|
||||
strut.top_width = dockRect.height();
|
||||
case Plasma::Types::TopEdge: {
|
||||
const int topOffset {screen.geometry().top()};
|
||||
strut.top_width = dockRect.height() + topOffset;
|
||||
strut.top_start = dockRect.x();
|
||||
strut.top_end = dockRect.x() + dockRect.width() - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case Plasma::Types::BottomEdge:
|
||||
strut.bottom_width = dockRect.height();
|
||||
case Plasma::Types::BottomEdge: {
|
||||
const int bottomOffset {wholeScreen.bottom() - currentScreen.bottom()};
|
||||
strut.bottom_width = dockRect.height() + bottomOffset;
|
||||
strut.bottom_start = dockRect.x();
|
||||
strut.bottom_end = dockRect.x() + dockRect.width() - 1;
|
||||
break;
|
||||
|
||||
case Plasma::Types::LeftEdge:
|
||||
strut.left_width = dockRect.width();
|
||||
}
|
||||
case Plasma::Types::LeftEdge: {
|
||||
const int leftOffset = {screen.geometry().left()};
|
||||
strut.left_width = dockRect.width() + leftOffset;
|
||||
strut.left_start = dockRect.y();
|
||||
strut.left_end = dockRect.y() + dockRect.height() - 1;
|
||||
break;
|
||||
|
||||
case Plasma::Types::RightEdge:
|
||||
strut.right_width = dockRect.width();
|
||||
}
|
||||
case Plasma::Types::RightEdge: {
|
||||
const int rightOffset = {wholeScreen.right() - currentScreen.right()};
|
||||
strut.right_width = dockRect.width() + rightOffset;
|
||||
strut.right_start = dockRect.y();
|
||||
strut.right_end = dockRect.y() + dockRect.height() - 1;
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
qWarning() << "wrong location:" << qEnumToStr(location);
|
||||
return;
|
||||
|
@ -39,7 +39,9 @@ public:
|
||||
~XWindowInterface() override;
|
||||
|
||||
void setDockExtraFlags(QQuickWindow &view) override;
|
||||
void setDockStruts(WId dockId, const QRect &dockRect, Plasma::Types::Location location) const override;
|
||||
void setDockStruts(WId dockId, const QRect &dockRect
|
||||
, const QScreen &screen, Plasma::Types::Location location) const override;
|
||||
|
||||
void removeDockStruts(WId dockId) const override;
|
||||
|
||||
WId activeWindow() const override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user