mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-07-27 01:14:42 -04:00
Expose setDesiredSize to the C++ API
Making it possible for clients to call setDesiredSize directly, The idea is that under Wayland, the panel calls this intead of setGeometry, not trying to set an abosulute geometry that might cause the panel sized wrongly, but just sets an hint which will ensure the panel won't overlap another one
This commit is contained in:
@ -32,6 +32,7 @@ public:
|
|||||||
Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityOnDemand;
|
Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityOnDemand;
|
||||||
Window::Layer layer = Window::LayerTop;
|
Window::Layer layer = Window::LayerTop;
|
||||||
QMargins margins;
|
QMargins margins;
|
||||||
|
QSize desiredSize;
|
||||||
Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
|
Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
|
||||||
bool closeOnDismissed = true;
|
bool closeOnDismissed = true;
|
||||||
};
|
};
|
||||||
@ -97,6 +98,21 @@ QMargins Window::margins() const
|
|||||||
return d->margins;
|
return d->margins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::setDesiredSize(const QSize &size)
|
||||||
|
{
|
||||||
|
if (size == d->desiredSize) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->desiredSize = size;
|
||||||
|
Q_EMIT desiredSizeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize Window::desiredSize() const
|
||||||
|
{
|
||||||
|
return d->desiredSize;
|
||||||
|
}
|
||||||
|
|
||||||
void Window::setKeyboardInteractivity(KeyboardInteractivity interactivity)
|
void Window::setKeyboardInteractivity(KeyboardInteractivity interactivity)
|
||||||
{
|
{
|
||||||
if (d->keyboardInteractivity != interactivity) {
|
if (d->keyboardInteractivity != interactivity) {
|
||||||
|
@ -86,6 +86,9 @@ public:
|
|||||||
void setMargins(const QMargins &margins);
|
void setMargins(const QMargins &margins);
|
||||||
QMargins margins() const;
|
QMargins margins() const;
|
||||||
|
|
||||||
|
void setDesiredSize(const QSize &size);
|
||||||
|
QSize desiredSize() const;
|
||||||
|
|
||||||
void setKeyboardInteractivity(KeyboardInteractivity interactivity);
|
void setKeyboardInteractivity(KeyboardInteractivity interactivity);
|
||||||
KeyboardInteractivity keyboardInteractivity() const;
|
KeyboardInteractivity keyboardInteractivity() const;
|
||||||
|
|
||||||
@ -127,6 +130,7 @@ Q_SIGNALS:
|
|||||||
void exclusionZoneChanged();
|
void exclusionZoneChanged();
|
||||||
void exclusiveEdgeChanged();
|
void exclusiveEdgeChanged();
|
||||||
void marginsChanged();
|
void marginsChanged();
|
||||||
|
void desiredSizeChanged();
|
||||||
void keyboardInteractivityChanged();
|
void keyboardInteractivityChanged();
|
||||||
void layerChanged();
|
void layerChanged();
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
|||||||
setAnchor(m_interface->anchors());
|
setAnchor(m_interface->anchors());
|
||||||
connect(m_interface, &Window::anchorsChanged, this, [this]() {
|
connect(m_interface, &Window::anchorsChanged, this, [this]() {
|
||||||
setAnchor(m_interface->anchors());
|
setAnchor(m_interface->anchors());
|
||||||
setDesiredSize(m_window->windowContentGeometry().size());
|
m_interface->setDesiredSize(m_window->windowContentGeometry().size());
|
||||||
});
|
});
|
||||||
|
|
||||||
setExclusiveZone(m_interface->exclusionZone());
|
setExclusiveZone(m_interface->exclusionZone());
|
||||||
@ -61,12 +61,17 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
|||||||
setMargins(m_interface->margins());
|
setMargins(m_interface->margins());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// setDesiredSize is called only by this connection, everywhere else we use m_interface->setDesiredSize()
|
||||||
|
connect(m_interface, &Window::desiredSizeChanged, this, [this]() {
|
||||||
|
setDesiredSize(m_interface->desiredSize());
|
||||||
|
});
|
||||||
|
|
||||||
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
||||||
connect(m_interface, &Window::keyboardInteractivityChanged, this, [this]() {
|
connect(m_interface, &Window::keyboardInteractivityChanged, this, [this]() {
|
||||||
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
||||||
});
|
});
|
||||||
|
|
||||||
setDesiredSize(window->windowContentGeometry().size());
|
m_interface->setDesiredSize(window->windowContentGeometry().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandLayerSurface::~QWaylandLayerSurface()
|
QWaylandLayerSurface::~QWaylandLayerSurface()
|
||||||
@ -132,6 +137,8 @@ void QWaylandLayerSurface::setDesiredSize(const QSize &size)
|
|||||||
effectiveSize.setHeight(0);
|
effectiveSize.setHeight(0);
|
||||||
}
|
}
|
||||||
set_size(effectiveSize.width(), effectiveSize.height());
|
set_size(effectiveSize.width(), effectiveSize.height());
|
||||||
|
|
||||||
|
m_window->window()->requestUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandLayerSurface::setAnchor(uint anchor)
|
void QWaylandLayerSurface::setAnchor(uint anchor)
|
||||||
@ -174,12 +181,12 @@ void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setDesiredSize(geometry.size());
|
m_interface->setDesiredSize(geometry.size());
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void QWaylandLayerSurface::setWindowSize(const QSize &size)
|
void QWaylandLayerSurface::setWindowSize(const QSize &size)
|
||||||
{
|
{
|
||||||
setDesiredSize(size);
|
m_interface->setDesiredSize(size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ public:
|
|||||||
}
|
}
|
||||||
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
|
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
|
||||||
|
|
||||||
void setDesiredSize(const QSize &size);
|
|
||||||
void setAnchor(uint32_t anchor);
|
void setAnchor(uint32_t anchor);
|
||||||
void setExclusiveZone(int32_t zone);
|
void setExclusiveZone(int32_t zone);
|
||||||
void setExclusiveEdge(uint32_t edge);
|
void setExclusiveEdge(uint32_t edge);
|
||||||
@ -54,6 +53,7 @@ public:
|
|||||||
void requestXdgActivationToken(quint32 serial) override;
|
void requestXdgActivationToken(quint32 serial) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setDesiredSize(const QSize &size);
|
||||||
void sendExpose();
|
void sendExpose();
|
||||||
void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override;
|
void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override;
|
||||||
void zwlr_layer_surface_v1_closed() override;
|
void zwlr_layer_surface_v1_closed() override;
|
||||||
|
Reference in New Issue
Block a user