summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-08-15 17:28:56 +0200
committerJohan Helsing <johan.helsing@qt.io>2018-08-16 06:29:17 +0000
commit70f0f02568e3d577452e45b49deee47cf7d465b3 (patch)
tree50e30d59b67fde30a61eca787a5f9303f7426ee4
parentbc9389aba6575a739ccbb7de9c921439d9d6f246 (diff)
Client: Handle conversion from xdg-shell resize edges correctly
There are two different types of edges in xdg-shell. Make it more explicit which ones we are using. Change-Id: I7e18a376b359be8e06f96cae897d7ccbc62e3c3e Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
-rw-r--r--src/compositor/extensions/qwaylandxdgshell.cpp71
-rw-r--r--src/compositor/extensions/qwaylandxdgshell_p.h4
2 files changed, 44 insertions, 31 deletions
diff --git a/src/compositor/extensions/qwaylandxdgshell.cpp b/src/compositor/extensions/qwaylandxdgshell.cpp
index a502cdf34..4f468b0ae 100644
--- a/src/compositor/extensions/qwaylandxdgshell.cpp
+++ b/src/compositor/extensions/qwaylandxdgshell.cpp
@@ -75,33 +75,6 @@ void QWaylandXdgShellPrivate::unregisterXdgSurface(QWaylandXdgSurface *xdgSurfac
qWarning("%s Unexpected state. Can't find registered xdg surface\n", Q_FUNC_INFO);
}
-Qt::Edges QWaylandXdgShellPrivate::convertToEdges(uint xdgEdges)
-{
- switch (xdgEdges) {
- case XDG_POSITIONER_ANCHOR_NONE:
- return Qt::Edges();
- case XDG_POSITIONER_ANCHOR_TOP:
- return Qt::TopEdge;
- case XDG_POSITIONER_ANCHOR_BOTTOM:
- return Qt::BottomEdge;
- case XDG_POSITIONER_ANCHOR_LEFT:
- return Qt::LeftEdge;
- case XDG_POSITIONER_ANCHOR_RIGHT:
- return Qt::RightEdge;
- case XDG_POSITIONER_ANCHOR_TOP_LEFT:
- return Qt::TopEdge | Qt::LeftEdge;
- case XDG_POSITIONER_ANCHOR_BOTTOM_LEFT:
- return Qt::BottomEdge | Qt::LeftEdge;
- case XDG_POSITIONER_ANCHOR_TOP_RIGHT:
- return Qt::TopEdge | Qt::RightEdge;
- case XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT:
- return Qt::BottomEdge | Qt::RightEdge;
- default:
- qWarning() << "Unknown Wayland xdg edge" << xdgEdges;
- return Qt::Edges();
- }
-}
-
QWaylandXdgSurface *QWaylandXdgShellPrivate::xdgSurfaceFromSurface(QWaylandSurface *surface)
{
for (QWaylandXdgSurface *xdgSurface : qAsConst(m_xdgSurfaces)) {
@@ -1296,6 +1269,11 @@ void QWaylandXdgToplevelPrivate::handleFocusReceived()
}
}
+Qt::Edges QWaylandXdgToplevelPrivate::convertToEdges(resize_edge edge)
+{
+ return Qt::Edges(((edge & 0b1100) >> 1) | ((edge & 0b0010) << 2) | (edge & 0b0001));
+}
+
void QWaylandXdgToplevelPrivate::xdg_toplevel_destroy_resource(QtWaylandServer::xdg_toplevel::Resource *resource)
{
Q_UNUSED(resource);
@@ -1379,7 +1357,7 @@ void QWaylandXdgToplevelPrivate::xdg_toplevel_resize(QtWaylandServer::xdg_toplev
Q_UNUSED(serial);
Q_Q(QWaylandXdgToplevel);
QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource);
- emit q->startResize(seat, QWaylandXdgShellPrivate::convertToEdges(edges));
+ emit q->startResize(seat, convertToEdges(resize_edge(edges)));
}
void QWaylandXdgToplevelPrivate::xdg_toplevel_set_max_size(QtWaylandServer::xdg_toplevel::Resource *resource, int32_t width, int32_t height)
@@ -1974,7 +1952,7 @@ void QWaylandXdgPositioner::xdg_positioner_set_anchor_rect(QtWaylandServer::xdg_
void QWaylandXdgPositioner::xdg_positioner_set_anchor(QtWaylandServer::xdg_positioner::Resource *resource, uint32_t anchor)
{
- Qt::Edges anchorEdges = QWaylandXdgShellPrivate::convertToEdges(anchor);
+ Qt::Edges anchorEdges = convertToEdges(xdg_positioner::anchor(anchor));
if ((anchorEdges & Qt::BottomEdge && anchorEdges & Qt::TopEdge) ||
(anchorEdges & Qt::LeftEdge && anchorEdges & Qt::RightEdge)) {
@@ -1988,7 +1966,7 @@ void QWaylandXdgPositioner::xdg_positioner_set_anchor(QtWaylandServer::xdg_posit
void QWaylandXdgPositioner::xdg_positioner_set_gravity(QtWaylandServer::xdg_positioner::Resource *resource, uint32_t gravity)
{
- Qt::Edges gravityEdges = QWaylandXdgShellPrivate::convertToEdges(gravity);
+ Qt::Edges gravityEdges = convertToEdges(xdg_positioner::gravity(gravity));
if ((gravityEdges & Qt::BottomEdge && gravityEdges & Qt::TopEdge) ||
(gravityEdges & Qt::LeftEdge && gravityEdges & Qt::RightEdge)) {
@@ -2017,4 +1995,37 @@ QWaylandXdgPositioner *QWaylandXdgPositioner::fromResource(wl_resource *resource
return static_cast<QWaylandXdgPositioner *>(Resource::fromResource(resource)->xdg_positioner_object);
}
+Qt::Edges QWaylandXdgPositioner::convertToEdges(anchor anchor)
+{
+ switch (anchor) {
+ case anchor_none:
+ return Qt::Edges();
+ case anchor_top:
+ return Qt::TopEdge;
+ case anchor_bottom:
+ return Qt::BottomEdge;
+ case anchor_left:
+ return Qt::LeftEdge;
+ case anchor_right:
+ return Qt::RightEdge;
+ case anchor_top_left:
+ return Qt::TopEdge | Qt::LeftEdge;
+ case anchor_bottom_left:
+ return Qt::BottomEdge | Qt::LeftEdge;
+ case anchor_top_right:
+ return Qt::TopEdge | Qt::RightEdge;
+ case anchor_bottom_right:
+ return Qt::BottomEdge | Qt::RightEdge;
+ default:
+ qWarning() << "Unknown Wayland xdg edge" << anchor;
+ return Qt::Edges();
+ }
+}
+
+Qt::Edges QWaylandXdgPositioner::convertToEdges(QWaylandXdgPositioner::gravity gravity)
+{
+ return convertToEdges(anchor(gravity));
+}
+
+
QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwaylandxdgshell_p.h b/src/compositor/extensions/qwaylandxdgshell_p.h
index f45cb7f46..04d360ee7 100644
--- a/src/compositor/extensions/qwaylandxdgshell_p.h
+++ b/src/compositor/extensions/qwaylandxdgshell_p.h
@@ -81,7 +81,6 @@ public:
void registerXdgSurface(QWaylandXdgSurface *xdgSurface);
void unregisterXdgSurface(QWaylandXdgSurface *xdgSurface);
static QWaylandXdgShellPrivate *get(QWaylandXdgShell *xdgShell) { return xdgShell->d_func(); }
- static Qt::Edges convertToEdges(uint xdgEdges);
QSet<uint32_t> m_pings;
QMultiMap<struct wl_client *, QWaylandXdgSurface *> m_xdgSurfaces;
@@ -147,6 +146,7 @@ public:
void handleFocusReceived();
static QWaylandXdgToplevelPrivate *get(QWaylandXdgToplevel *toplevel) { return toplevel->d_func(); }
+ static Qt::Edges convertToEdges(resize_edge edge);
protected:
@@ -218,6 +218,8 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositioner : public QtWaylandServer
public:
QWaylandXdgPositioner(const QWaylandResource& resource);
static QWaylandXdgPositioner *fromResource(wl_resource *resource);
+ static Qt::Edges convertToEdges(anchor anchor);
+ static Qt::Edges convertToEdges(gravity gravity);
protected:
void xdg_positioner_destroy_resource(Resource *resource) override; //TODO: do something special here?