summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-08-16 09:15:54 +0200
committerJohan Helsing <johan.helsing@qt.io>2019-01-18 12:56:56 +0000
commitca65a264c8d0259a8699d1c93eee47d840806aad (patch)
treeb49d6cb5de82305daeb9aa9995ba7ac7f561d4fd /src
parenteee7be4e3c7b70524e53f2974f07f99ca65aa5ea (diff)
Compositor xdg-shell: Warn when clients supply invalid anchor rects
From the protocol: "When the xdg_positioner object is used to position a child surface, the rectangle may not extend outside the window geometry of the child's parent surface." Adds a warning for both v6 and stable when clients do this. Change-Id: I575a89785f45c080d488be748ec099569b38ea9b Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Diffstat (limited to 'src')
-rw-r--r--src/compositor/extensions/qwaylandxdgshell.cpp19
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv6.cpp19
2 files changed, 28 insertions, 10 deletions
diff --git a/src/compositor/extensions/qwaylandxdgshell.cpp b/src/compositor/extensions/qwaylandxdgshell.cpp
index 6f0c8312..560f95ac 100644
--- a/src/compositor/extensions/qwaylandxdgshell.cpp
+++ b/src/compositor/extensions/qwaylandxdgshell.cpp
@@ -386,6 +386,7 @@ void QWaylandXdgSurfacePrivate::xdg_surface_get_popup(QtWaylandServer::xdg_surfa
"xdg_surface.get_popup without positioner");
return;
}
+
if (!positioner->m_data.isComplete()) {
QWaylandXdgPositionerData p = positioner->m_data;
wl_resource_post_error(resource->handle, XDG_WM_BASE_ERROR_INVALID_POSITIONER,
@@ -394,6 +395,17 @@ void QWaylandXdgSurfacePrivate::xdg_surface_get_popup(QtWaylandServer::xdg_surfa
return;
}
+ QRect anchorBounds(QPoint(0, 0), parent->windowGeometry().size());
+ if (!anchorBounds.contains(positioner->m_data.anchorRect)) {
+ // TODO: this is a protocol error and should ideally be handled like this:
+ //wl_resource_post_error(resource->handle, XDG_WM_BASE_ERROR_INVALID_POSITIONER,
+ // "xdg_positioner anchor rect extends beyound its parent's window geometry");
+ //return;
+ // However, our own clients currently do this, so we'll settle for a gentle warning instead.
+ qCWarning(qLcWaylandCompositor) << "Ignoring client protocol error: xdg_positioner anchor"
+ << "rect extends beyond its parent's window geometry";
+ }
+
if (!m_surface->setRole(QWaylandXdgPopup::role(), resource->handle, XDG_WM_BASE_ERROR_ROLE))
return;
@@ -1869,16 +1881,13 @@ QWaylandXdgPopupPrivate::QWaylandXdgPopupPrivate(QWaylandXdgSurface *xdgSurface,
QWaylandXdgPositioner *positioner, const QWaylandResource &resource)
: m_xdgSurface(xdgSurface)
, m_parentXdgSurface(parentXdgSurface)
+ , m_positionerData(positioner->m_data)
{
+ Q_ASSERT(m_positionerData.isComplete());
init(resource.resource());
- m_positionerData = positioner->m_data;
-
- if (!m_positionerData.isComplete())
- qWarning() << "Trying to create xdg popup with incomplete positioner";
QWaylandXdgSurfacePrivate::get(m_xdgSurface)->setWindowType(Qt::WindowType::Popup);
- //TODO: positioner rect may not extend parent's window geometry, enforce this?
//TODO: Need an API for sending a different initial configure
sendConfigure(QRect(m_positionerData.unconstrainedPosition(), m_positionerData.size));
}
diff --git a/src/compositor/extensions/qwaylandxdgshellv6.cpp b/src/compositor/extensions/qwaylandxdgshellv6.cpp
index 9aab9b2b..d69ed6ca 100644
--- a/src/compositor/extensions/qwaylandxdgshellv6.cpp
+++ b/src/compositor/extensions/qwaylandxdgshellv6.cpp
@@ -391,6 +391,7 @@ void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_get_popup(QtWaylandServer::zxd
"zxdg_surface_v6.get_popup without positioner");
return;
}
+
if (!positioner->m_data.isComplete()) {
QWaylandXdgPositionerV6Data p = positioner->m_data;
wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER,
@@ -399,6 +400,17 @@ void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_get_popup(QtWaylandServer::zxd
return;
}
+ QRect anchorBounds(QPoint(0, 0), parent->windowGeometry().size());
+ if (!anchorBounds.contains(positioner->m_data.anchorRect)) {
+ // TODO: this is a protocol error and should ideally be handled like this:
+ //wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER,
+ // "zxdg_positioner_v6 anchor rect extends beyound its parent's window geometry");
+ //return;
+ // However, our own clients currently do this, so we'll settle for a gentle warning instead.
+ qCWarning(qLcWaylandCompositor) << "Ignoring client protocol error: zxdg_positioner_v6 anchor"
+ << "rect extends beyond its parent's window geometry";
+ }
+
if (!m_surface->setRole(QWaylandXdgPopupV6::role(), resource->handle, ZXDG_SHELL_V6_ERROR_ROLE))
return;
@@ -1800,16 +1812,13 @@ QWaylandXdgPopupV6Private::QWaylandXdgPopupV6Private(QWaylandXdgSurfaceV6 *xdgSu
QWaylandXdgPositionerV6 *positioner, const QWaylandResource &resource)
: m_xdgSurface(xdgSurface)
, m_parentXdgSurface(parentXdgSurface)
+ , m_positionerData(positioner->m_data)
{
+ Q_ASSERT(m_positionerData.isComplete());
init(resource.resource());
- m_positionerData = positioner->m_data;
-
- if (!m_positionerData.isComplete())
- qWarning() << "Trying to create xdg popup with incomplete positioner";
QWaylandXdgSurfaceV6Private::get(m_xdgSurface)->setWindowType(Qt::WindowType::Popup);
- //TODO: positioner rect may not extend parent's window geometry, enforce this?
//TODO: Need an API for sending a different initial configure
sendConfigure(QRect(m_positionerData.unconstrainedPosition(), m_positionerData.size));
}