mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-05-25 09:30:22 -04:00
Introduce Window::desiredSize property
This commit is contained in:
parent
143fd1755a
commit
4cc1b9cbaa
@ -29,6 +29,7 @@ public:
|
||||
|
||||
QWindow *parentWindow;
|
||||
QString scope = QStringLiteral("window");
|
||||
QSize desiredSize = QSize(0, 0);
|
||||
Window::Anchors anchors = {Window::AnchorTop | Window::AnchorBottom | Window::AnchorLeft | Window::AnchorRight};
|
||||
int32_t exclusionZone = 0;
|
||||
Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityNone;
|
||||
@ -141,6 +142,19 @@ void Window::setCloseOnDismissed(bool close)
|
||||
d->closeOnDismissed = close;
|
||||
}
|
||||
|
||||
void Window::setDesiredSize(const QSize &size)
|
||||
{
|
||||
if (d->desiredSize != size) {
|
||||
d->desiredSize = size;
|
||||
Q_EMIT desiredSizeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QSize Window::desiredSize() const
|
||||
{
|
||||
return d->desiredSize;
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
|
||||
void Window::attachPopup(QWindow *window, xdg_popup *popup)
|
||||
{
|
||||
|
@ -114,6 +114,13 @@ public:
|
||||
void setCloseOnDismissed(bool close);
|
||||
bool closeOnDismissed() const;
|
||||
|
||||
/**
|
||||
* Sets the desired window size. This size indicates how much space the compositor is going
|
||||
* to reserve for the window.
|
||||
*/
|
||||
void setDesiredSize(const QSize &size);
|
||||
QSize desiredSize() const;
|
||||
|
||||
/**
|
||||
* Gets the LayerShell Window for a given Qt Window
|
||||
* Ownership is not transferred
|
||||
@ -132,6 +139,7 @@ Q_SIGNALS:
|
||||
void marginsChanged();
|
||||
void keyboardInteractivityChanged();
|
||||
void layerChanged();
|
||||
void desiredSizeChanged();
|
||||
|
||||
private:
|
||||
Window(QWindow *window);
|
||||
|
@ -55,17 +55,10 @@ QWaylandLayerSurface::QWaylandLayerSurface(QtWayland::zwlr_layer_shell_v1 *shell
|
||||
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
||||
});
|
||||
|
||||
QSize size = window->surfaceSize();
|
||||
const Window::Anchors anchors = m_interface->anchors();
|
||||
if ((anchors & Window::AnchorLeft) && (anchors & Window::AnchorRight)) {
|
||||
size.setWidth(0);
|
||||
}
|
||||
if ((anchors & Window::AnchorTop) && (anchors & Window::AnchorBottom)) {
|
||||
size.setHeight(0);
|
||||
}
|
||||
if (size.isValid() && size != QSize(0, 0)) {
|
||||
set_size(size.width(), size.height());
|
||||
}
|
||||
setDesiredSize(m_interface->desiredSize());
|
||||
connect(m_interface, &Window::desiredSizeChanged, this, [this]() {
|
||||
setDesiredSize(m_interface->desiredSize());
|
||||
});
|
||||
}
|
||||
|
||||
QWaylandLayerSurface::~QWaylandLayerSurface()
|
||||
@ -141,18 +134,8 @@ void QWaylandLayerSurface::setLayer(uint32_t layer)
|
||||
set_layer(layer);
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
||||
void QWaylandLayerSurface::setDesiredSize(const QSize &size)
|
||||
{
|
||||
const bool horizontallyConstrained = m_interface->anchors() & (Window::AnchorLeft & Window::AnchorRight);
|
||||
const bool verticallyConstrained = m_interface->anchors() & (Window::AnchorTop & Window::AnchorBottom);
|
||||
|
||||
QSize size = geometry.size();
|
||||
if (horizontallyConstrained) {
|
||||
size.setWidth(0);
|
||||
}
|
||||
if (verticallyConstrained) {
|
||||
size.setHeight(0);
|
||||
}
|
||||
set_size(size.width(), size.height());
|
||||
}
|
||||
|
||||
|
@ -39,9 +39,9 @@ public:
|
||||
void setMargins(const QMargins &margins);
|
||||
void setKeyboardInteractivity(uint32_t interactivity);
|
||||
void setLayer(uint32_t layer);
|
||||
void setDesiredSize(const QSize &size);
|
||||
|
||||
void applyConfigure() override;
|
||||
void setWindowGeometry(const QRect &geometry) override;
|
||||
|
||||
private:
|
||||
void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override;
|
||||
|
Loading…
Reference in New Issue
Block a user