mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-06-04 01:28:35 -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 used by https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/5437 CCBUG:489703
This commit is contained in:
parent
b37ac92e9f
commit
80d5e3c935
@ -32,6 +32,7 @@ public:
|
||||
Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityOnDemand;
|
||||
Window::Layer layer = Window::LayerTop;
|
||||
QMargins margins;
|
||||
QSize desiredSize = QSize(0, 0);
|
||||
Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
|
||||
bool closeOnDismissed = true;
|
||||
};
|
||||
@ -97,6 +98,21 @@ QMargins Window::margins() const
|
||||
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)
|
||||
{
|
||||
if (d->keyboardInteractivity != interactivity) {
|
||||
|
@ -86,6 +86,9 @@ public:
|
||||
void setMargins(const QMargins &margins);
|
||||
QMargins margins() const;
|
||||
|
||||
void setDesiredSize(const QSize &size);
|
||||
QSize desiredSize() const;
|
||||
|
||||
void setKeyboardInteractivity(KeyboardInteractivity interactivity);
|
||||
KeyboardInteractivity keyboardInteractivity() const;
|
||||
|
||||
@ -127,6 +130,7 @@ Q_SIGNALS:
|
||||
void exclusionZoneChanged();
|
||||
void exclusiveEdgeChanged();
|
||||
void marginsChanged();
|
||||
void desiredSizeChanged();
|
||||
void keyboardInteractivityChanged();
|
||||
void layerChanged();
|
||||
|
||||
|
@ -44,7 +44,11 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
||||
setAnchor(m_interface->anchors());
|
||||
connect(m_interface, &Window::anchorsChanged, this, [this]() {
|
||||
setAnchor(m_interface->anchors());
|
||||
if (m_interface->desiredSize().isNull()) {
|
||||
setDesiredSize(m_window->windowContentGeometry().size());
|
||||
} else {
|
||||
setDesiredSize(m_interface->desiredSize());
|
||||
}
|
||||
});
|
||||
|
||||
setExclusiveZone(m_interface->exclusionZone());
|
||||
@ -61,12 +65,22 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
||||
setMargins(m_interface->margins());
|
||||
});
|
||||
|
||||
connect(m_interface, &Window::desiredSizeChanged, this, [this]() {
|
||||
if (!m_interface->desiredSize().isNull()) {
|
||||
setDesiredSize(m_interface->desiredSize());
|
||||
}
|
||||
});
|
||||
|
||||
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
||||
connect(m_interface, &Window::keyboardInteractivityChanged, this, [this]() {
|
||||
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
||||
});
|
||||
|
||||
if (m_interface->desiredSize().isNull()) {
|
||||
setDesiredSize(window->windowContentGeometry().size());
|
||||
} else {
|
||||
setDesiredSize(m_interface->desiredSize());
|
||||
}
|
||||
}
|
||||
|
||||
QWaylandLayerSurface::~QWaylandLayerSurface()
|
||||
@ -174,13 +188,17 @@ void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_interface->desiredSize().isNull()) {
|
||||
setDesiredSize(geometry.size());
|
||||
}
|
||||
}
|
||||
#else
|
||||
void QWaylandLayerSurface::setWindowSize(const QSize &size)
|
||||
{
|
||||
if (m_interface->desiredSize().isNull()) {
|
||||
setDesiredSize(size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool QWaylandLayerSurface::requestActivate()
|
||||
|
Loading…
x
Reference in New Issue
Block a user