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