mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-07-14 11:04:20 -04:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
2c903f3618 | |||
797c8b26ca | |||
32afbcf68a | |||
81782b38e4 | |||
4dfa7b53f1 | |||
aeb8d198ce | |||
f32b64244f |
@ -4,7 +4,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
project(layershellqt)
|
project(layershellqt)
|
||||||
set(PROJECT_VERSION "6.0.1")
|
set(PROJECT_VERSION "6.0.5")
|
||||||
set(PROJECT_VERSION_MAJOR 6)
|
set(PROJECT_VERSION_MAJOR 6)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
@ -41,10 +41,12 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
|||||||
setLayer(m_interface->layer());
|
setLayer(m_interface->layer());
|
||||||
});
|
});
|
||||||
|
|
||||||
set_anchor(m_interface->anchors());
|
setAnchor(m_interface->anchors());
|
||||||
connect(m_interface, &Window::anchorsChanged, this, [this]() {
|
connect(m_interface, &Window::anchorsChanged, this, [this]() {
|
||||||
set_anchor(m_interface->anchors());
|
setAnchor(m_interface->anchors());
|
||||||
|
setDesiredSize(m_window->windowContentGeometry().size());
|
||||||
});
|
});
|
||||||
|
|
||||||
setExclusiveZone(m_interface->exclusionZone());
|
setExclusiveZone(m_interface->exclusionZone());
|
||||||
connect(m_interface, &Window::exclusionZoneChanged, this, [this]() {
|
connect(m_interface, &Window::exclusionZoneChanged, this, [this]() {
|
||||||
setExclusiveZone(m_interface->exclusionZone());
|
setExclusiveZone(m_interface->exclusionZone());
|
||||||
@ -64,17 +66,7 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
|||||||
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
||||||
});
|
});
|
||||||
|
|
||||||
QSize size = window->surfaceSize();
|
setDesiredSize(window->windowContentGeometry().size());
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandLayerSurface::~QWaylandLayerSurface()
|
QWaylandLayerSurface::~QWaylandLayerSurface()
|
||||||
@ -99,7 +91,7 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint
|
|||||||
|
|
||||||
if (!m_configured) {
|
if (!m_configured) {
|
||||||
m_configured = true;
|
m_configured = true;
|
||||||
window()->resizeFromApplyConfigure(m_pendingSize);
|
applyConfigure();
|
||||||
sendExpose();
|
sendExpose();
|
||||||
} else {
|
} else {
|
||||||
// Later configures are resizes, so we have to queue them up for a time when we
|
// Later configures are resizes, so we have to queue them up for a time when we
|
||||||
@ -121,13 +113,29 @@ void QWaylandLayerSurface::attachPopup(QtWaylandClient::QWaylandShellSurface *po
|
|||||||
|
|
||||||
void QWaylandLayerSurface::applyConfigure()
|
void QWaylandLayerSurface::applyConfigure()
|
||||||
{
|
{
|
||||||
|
m_configuring = true;
|
||||||
window()->resizeFromApplyConfigure(m_pendingSize);
|
window()->resizeFromApplyConfigure(m_pendingSize);
|
||||||
|
m_configuring = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QWaylandLayerSurface::setDesiredSize(const QSize &size)
|
||||||
|
{
|
||||||
|
const bool horizontallyConstrained = m_interface->anchors().testFlags({Window::AnchorLeft, Window::AnchorRight});
|
||||||
|
const bool verticallyConstrained = m_interface->anchors().testFlags({Window::AnchorTop, Window::AnchorBottom});
|
||||||
|
|
||||||
|
QSize effectiveSize = size;
|
||||||
|
if (horizontallyConstrained) {
|
||||||
|
effectiveSize.setWidth(0);
|
||||||
|
}
|
||||||
|
if (verticallyConstrained) {
|
||||||
|
effectiveSize.setHeight(0);
|
||||||
|
}
|
||||||
|
set_size(effectiveSize.width(), effectiveSize.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandLayerSurface::setAnchor(uint anchor)
|
void QWaylandLayerSurface::setAnchor(uint anchor)
|
||||||
{
|
{
|
||||||
set_anchor(anchor);
|
set_anchor(anchor);
|
||||||
setWindowGeometry(window()->windowContentGeometry());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandLayerSurface::setExclusiveZone(int32_t zone)
|
void QWaylandLayerSurface::setExclusiveZone(int32_t zone)
|
||||||
@ -160,22 +168,11 @@ void QWaylandLayerSurface::setLayer(uint32_t layer)
|
|||||||
|
|
||||||
void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
||||||
{
|
{
|
||||||
// if we are setting it to the last size we were configured at, we don't need to do anything
|
if (m_configuring) {
|
||||||
if (geometry.size() == m_pendingSize && !m_waitForSyncCallback) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool horizontallyConstrained = m_interface->anchors().testFlags({Window::AnchorLeft, Window::AnchorRight});
|
setDesiredSize(geometry.size());
|
||||||
const bool verticallyConstrained = m_interface->anchors().testFlags({Window::AnchorTop, Window::AnchorBottom});
|
|
||||||
|
|
||||||
QSize size = geometry.size();
|
|
||||||
if (horizontallyConstrained) {
|
|
||||||
size.setWidth(0);
|
|
||||||
}
|
|
||||||
if (verticallyConstrained) {
|
|
||||||
size.setHeight(0);
|
|
||||||
}
|
|
||||||
set_size(size.width(), size.height());
|
|
||||||
requestWaylandSync();
|
requestWaylandSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ 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);
|
||||||
@ -62,6 +63,7 @@ private:
|
|||||||
QString m_activationToken;
|
QString m_activationToken;
|
||||||
|
|
||||||
bool m_configured = false;
|
bool m_configured = false;
|
||||||
|
bool m_configuring = false;
|
||||||
|
|
||||||
static const wl_callback_listener syncCallbackListener;
|
static const wl_callback_listener syncCallbackListener;
|
||||||
struct wl_callback *m_waitForSyncCallback = nullptr;
|
struct wl_callback *m_waitForSyncCallback = nullptr;
|
||||||
|
Reference in New Issue
Block a user