mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-27 14:50:21 +03:00
wm:provide setWindowPosition() function
This commit is contained in:
parent
e2f4122a95
commit
259f6afb95
@ -526,7 +526,7 @@ void Positioner::immediateSyncGeometry()
|
||||
QRect maximumRect;
|
||||
QRect availableScreenRect = m_view->screen()->geometry();
|
||||
|
||||
if (m_inStartup) {
|
||||
if (m_inStartup && KWindowSystem::isPlatformX11()) {
|
||||
//! paint out-of-screen
|
||||
availableScreenRect = QRect(-9999, -9999, m_view->screen()->geometry().width(), m_view->screen()->geometry().height());
|
||||
}
|
||||
@ -558,7 +558,7 @@ void Positioner::immediateSyncGeometry()
|
||||
}
|
||||
|
||||
QString activityid = m_view->layout() ? m_view->layout()->lastUsedActivity() : QString();
|
||||
if (m_inStartup) {
|
||||
if (m_inStartup && KWindowSystem::isPlatformX11()) {
|
||||
//! paint out-of-screen
|
||||
freeRegion = availableScreenRect;
|
||||
} else {
|
||||
@ -855,14 +855,7 @@ void Positioner::updatePosition(QRect availableScreenRect)
|
||||
}
|
||||
}
|
||||
|
||||
if (KWindowSystem::isPlatformWayland()) {
|
||||
auto layerWindow = LayerShellQt::Window::get(m_view);
|
||||
layerWindow->setAnchors(LayerShellQt::Window::AnchorBottom);
|
||||
layerWindow->setLayer(LayerShellQt::Window::LayerTop);
|
||||
qDebug() << "org.kde.layer ::: " << layerWindow->anchors() << " __ " << layerWindow->layer() << " :: " << m_validGeometry;
|
||||
}
|
||||
|
||||
m_view->setPosition(position);
|
||||
m_corona->wm()->setWindowPosition(m_view, m_view->location(), m_validGeometry);
|
||||
}
|
||||
|
||||
int Positioner::slideOffset() const
|
||||
|
@ -127,6 +127,7 @@ public:
|
||||
virtual void switchToNextVirtualDesktop() = 0;
|
||||
virtual void switchToPreviousVirtualDesktop() = 0;
|
||||
|
||||
virtual void setWindowPosition(QWindow *window, const Plasma::Types::Location &location, const QRect &geometry) = 0;
|
||||
virtual void setFrameExtents(QWindow *view, const QMargins &margins) = 0;
|
||||
virtual void setInputMask(QWindow *window, const QRect &rect) = 0;
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <KWindowSystem>
|
||||
#include <KWindowInfo>
|
||||
#include <KWayland/Client/surface.h>
|
||||
#include <LayerShellQt/Window>
|
||||
|
||||
#if KF5_VERSION_MINOR >= 52
|
||||
#include <KWayland/Client/plasmavirtualdesktop.h>
|
||||
@ -491,6 +492,43 @@ void WaylandInterface::setActiveEdge(QWindow *view, bool active)
|
||||
}*/
|
||||
}
|
||||
|
||||
void WaylandInterface::setWindowPosition(QWindow *window, const Plasma::Types::Location &location, const QRect &geometry)
|
||||
{
|
||||
if (!window || !window->screen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto layerWindow = LayerShellQt::Window::get(window);
|
||||
|
||||
QMargins margins;
|
||||
LayerShellQt::Window::Anchors anchors = 0;
|
||||
|
||||
if (location == Plasma::Types::TopEdge || location == Plasma::Types::LeftEdge) {
|
||||
anchors = LayerShellQt::Window::AnchorTop;
|
||||
anchors = anchors | LayerShellQt::Window::AnchorLeft;
|
||||
margins.setTop(geometry.top() - window->screen()->geometry().top());
|
||||
margins.setLeft(geometry.left() - window->screen()->geometry().left());
|
||||
} else if (location == Plasma::Types::RightEdge) {
|
||||
anchors = LayerShellQt::Window::AnchorTop;
|
||||
anchors = anchors | LayerShellQt::Window::AnchorRight;
|
||||
margins.setTop(geometry.top() - window->screen()->geometry().top());
|
||||
margins.setRight(geometry.right() - window->screen()->geometry().right());
|
||||
} else {
|
||||
// bottom case
|
||||
anchors = LayerShellQt::Window::AnchorBottom;
|
||||
anchors = anchors | LayerShellQt::Window::AnchorLeft;
|
||||
margins.setBottom(geometry.bottom() - window->screen()->geometry().bottom());
|
||||
margins.setLeft(geometry.left() - window->screen()->geometry().left());
|
||||
}
|
||||
|
||||
layerWindow->setAnchors(anchors);
|
||||
layerWindow->setMargins(margins);
|
||||
layerWindow->setLayer(LayerShellQt::Window::LayerTop);
|
||||
window->setPosition(geometry.topLeft());
|
||||
|
||||
qDebug() << "org.kde.layer ::: " << layerWindow->anchors() << " __ " << layerWindow->layer() << " :: " << geometry << " :: " << margins;
|
||||
}
|
||||
|
||||
void WaylandInterface::setFrameExtents(QWindow *view, const QMargins &extents)
|
||||
{
|
||||
//! do nothing until there is a wayland way to provide this
|
||||
|
@ -83,6 +83,7 @@ public:
|
||||
void switchToNextVirtualDesktop() override;
|
||||
void switchToPreviousVirtualDesktop() override;
|
||||
|
||||
void setWindowPosition(QWindow *window, const Plasma::Types::Location &location, const QRect &geometry) override;
|
||||
void setFrameExtents(QWindow *view, const QMargins &margins) override;
|
||||
void setInputMask(QWindow *window, const QRect &rect) override;
|
||||
|
||||
|
@ -339,6 +339,14 @@ QRect XWindowInterface::visibleGeometry(const WindowId &wid, const QRect &frameG
|
||||
}
|
||||
#endif
|
||||
|
||||
void XWindowInterface::setWindowPosition(QWindow *window, const Plasma::Types::Location &location, const QRect &geometry)
|
||||
{
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
|
||||
window->setPosition(geometry.topLeft());
|
||||
}
|
||||
|
||||
void XWindowInterface::setFrameExtents(QWindow *view, const QMargins &margins)
|
||||
{
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
void switchToNextVirtualDesktop() override;
|
||||
void switchToPreviousVirtualDesktop() override;
|
||||
|
||||
void setWindowPosition(QWindow *window, const Plasma::Types::Location &location, const QRect &geometry) override;
|
||||
void setFrameExtents(QWindow *view, const QMargins &margins) override;
|
||||
void setInputMask(QWindow *window, const QRect &rect) override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user