Commit 1f20e1b8 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

xdg-shell: Drop support for v6

It's been deprecated for quite a while and all major toolkit already
support xdg_wm_base.
parent b3c7f9ab
......@@ -342,17 +342,6 @@ target_link_libraries( testXdgForeign Qt5::Test Qt5::Gui Plasma::KWaylandServer
add_test(NAME kwayland-testXdgForeign COMMAND testXdgForeign)
ecm_mark_as_test(testXdgForeign)
########################################################
# Test XdgShellV6
########################################################
set( testXdgShellV6_SRCS
test_xdg_shell.cpp
test_xdg_shell_v6.cpp
)
add_executable(testXdgShellV6 ${testXdgShellV6_SRCS})
target_link_libraries( testXdgShellV6 Qt5::Test Qt5::Gui Plasma::KWaylandServer KF5::WaylandClient Wayland::Client)
add_test(NAME kwayland-testXdgShellV6 COMMAND testXdgShellV6)
ecm_mark_as_test(testXdgShellV6)
########################################################
# Test XdgShellStable
########################################################
......
/*
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2017 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "test_xdg_shell.h"
#include <wayland-xdg-shell-v6-client-protocol.h>
class XdgShellTestV6 : public XdgShellTest {
Q_OBJECT
public:
XdgShellTestV6() :
XdgShellTest(KWaylandServer::XdgShellInterfaceVersion::UnstableV6) {}
private Q_SLOTS:
void testMaxSize();
void testMinSize();
void testPopup_data();
void testPopup();
void testMultipleRoles1();
void testMultipleRoles2();
};
void XdgShellTestV6::testMaxSize()
{
qRegisterMetaType<OutputInterface*>();
// this test verifies changing the window maxSize
QSignalSpy xdgSurfaceCreatedSpy(m_xdgShellInterface, &XdgShellInterface::surfaceCreated);
QVERIFY(xdgSurfaceCreatedSpy.isValid());
QScopedPointer<Surface> surface(m_compositor->createSurface());
QScopedPointer<XdgShellSurface> xdgSurface(m_xdgShell->createSurface(surface.data()));
QVERIFY(xdgSurfaceCreatedSpy.wait());
auto serverXdgSurface = xdgSurfaceCreatedSpy.first().first().value<XdgShellSurfaceInterface*>();
QVERIFY(serverXdgSurface);
QSignalSpy maxSizeSpy(serverXdgSurface, &XdgShellSurfaceInterface::maxSizeChanged);
QVERIFY(maxSizeSpy.isValid());
xdgSurface->setMaxSize(QSize(100, 100));
surface->commit(Surface::CommitFlag::None);
QVERIFY(maxSizeSpy.wait());
QCOMPARE(maxSizeSpy.count(), 1);
QCOMPARE(maxSizeSpy.last().at(0).value<QSize>(), QSize(100,100));
QCOMPARE(serverXdgSurface->maximumSize(), QSize(100, 100));
xdgSurface->setMaxSize(QSize(200, 200));
surface->commit(Surface::CommitFlag::None);
QVERIFY(maxSizeSpy.wait());
QCOMPARE(maxSizeSpy.count(), 2);
QCOMPARE(maxSizeSpy.last().at(0).value<QSize>(), QSize(200,200));
QCOMPARE(serverXdgSurface->maximumSize(), QSize(200, 200));
}
void XdgShellTestV6::testPopup_data()
{
QTest::addColumn<XdgPositioner>("positioner");
XdgPositioner positioner(QSize(10,10), QRect(100,100,50,50));
QTest::newRow("default") << positioner;
XdgPositioner positioner2(QSize(20,20), QRect(101,102,51,52));
QTest::newRow("sizeAndAnchorRect") << positioner2;
positioner.setAnchorEdge(Qt::TopEdge | Qt::RightEdge);
QTest::newRow("anchorEdge") << positioner;
positioner.setGravity(Qt::BottomEdge);
QTest::newRow("gravity") << positioner;
positioner.setGravity(Qt::TopEdge | Qt::RightEdge);
QTest::newRow("gravity2") << positioner;
positioner.setConstraints(XdgPositioner::Constraint::SlideX | XdgPositioner::Constraint::FlipY);
QTest::newRow("constraints") << positioner;
positioner.setConstraints(XdgPositioner::Constraint::SlideX | XdgPositioner::Constraint::SlideY | XdgPositioner::Constraint::FlipX | XdgPositioner::Constraint::FlipY | XdgPositioner::Constraint::ResizeX | XdgPositioner::Constraint::ResizeY);
QTest::newRow("constraints2") << positioner;
positioner.setAnchorOffset(QPoint(4,5));
QTest::newRow("offset") << positioner;
}
void XdgShellTestV6::testPopup()
{
QSignalSpy xdgTopLevelCreatedSpy(m_xdgShellInterface, &XdgShellInterface::surfaceCreated);
QSignalSpy xdgPopupCreatedSpy(m_xdgShellInterface, &XdgShellInterface::xdgPopupCreated);
QScopedPointer<Surface> parentSurface(m_compositor->createSurface());
QScopedPointer<XdgShellSurface> xdgParentSurface(m_xdgShell->createSurface(parentSurface.data()));
QVERIFY(xdgTopLevelCreatedSpy.wait());
auto serverXdgTopLevel = xdgTopLevelCreatedSpy.first().first().value<XdgShellSurfaceInterface*>();
QFETCH(XdgPositioner, positioner);
QScopedPointer<Surface> surface(m_compositor->createSurface());
QScopedPointer<XdgShellPopup> xdgSurface(m_xdgShell->createPopup(surface.data(), xdgParentSurface.data(), positioner));
QVERIFY(xdgPopupCreatedSpy.wait());
auto serverXdgPopup = xdgPopupCreatedSpy.first().first().value<XdgShellPopupInterface*>();
QVERIFY(serverXdgPopup);
QCOMPARE(serverXdgPopup->initialSize(), positioner.initialSize());
QCOMPARE(serverXdgPopup->anchorRect(), positioner.anchorRect());
QCOMPARE(serverXdgPopup->anchorEdge(), positioner.anchorEdge());
QCOMPARE(serverXdgPopup->gravity(), positioner.gravity());
QCOMPARE(serverXdgPopup->anchorOffset(), positioner.anchorOffset());
//we have different enums for client server, but they share the same values
QCOMPARE((int)serverXdgPopup->constraintAdjustments(), (int)positioner.constraints());
QCOMPARE(serverXdgPopup->transientFor().data(), serverXdgTopLevel->surface());
}
void XdgShellTestV6::testMinSize()
{
qRegisterMetaType<OutputInterface*>();
// this test verifies changing the window minSize
QSignalSpy xdgSurfaceCreatedSpy(m_xdgShellInterface, &XdgShellInterface::surfaceCreated);
QVERIFY(xdgSurfaceCreatedSpy.isValid());
QScopedPointer<Surface> surface(m_compositor->createSurface());
QScopedPointer<XdgShellSurface> xdgSurface(m_xdgShell->createSurface(surface.data()));
QVERIFY(xdgSurfaceCreatedSpy.wait());
auto serverXdgSurface = xdgSurfaceCreatedSpy.first().first().value<XdgShellSurfaceInterface*>();
QVERIFY(serverXdgSurface);
QSignalSpy minSizeSpy(serverXdgSurface, &XdgShellSurfaceInterface::minSizeChanged);
QVERIFY(minSizeSpy.isValid());
xdgSurface->setMinSize(QSize(200, 200));
surface->commit(Surface::CommitFlag::None);
QVERIFY(minSizeSpy.wait());
QCOMPARE(minSizeSpy.count(), 1);
QCOMPARE(minSizeSpy.last().at(0).value<QSize>(), QSize(200,200));
QCOMPARE(serverXdgSurface->minimumSize(), QSize(200, 200));
xdgSurface->setMinSize(QSize(100, 100));
surface->commit(Surface::CommitFlag::None);
QVERIFY(minSizeSpy.wait());
QCOMPARE(minSizeSpy.count(), 2);
QCOMPARE(minSizeSpy.last().at(0).value<QSize>(), QSize(100,100));
QCOMPARE(serverXdgSurface->minimumSize(), QSize(100, 100));
}
//top level then toplevel
void XdgShellTestV6::testMultipleRoles1()
{
//setting multiple roles on an xdg surface should fail
QSignalSpy xdgSurfaceCreatedSpy(m_xdgShellInterface, &XdgShellInterface::surfaceCreated);
QSignalSpy xdgPopupCreatedSpy(m_xdgShellInterface, &XdgShellInterface::xdgPopupCreated);
QVERIFY(xdgSurfaceCreatedSpy.isValid());
QVERIFY(xdgPopupCreatedSpy.isValid());
QScopedPointer<Surface> surface(m_compositor->createSurface());
//This is testing we work when a client does something stupid
//we can't use KWayland API here because by design that stops you from doing anything stupid
auto xdgSurface = zxdg_shell_v6_get_xdg_surface(*m_xdgShell, *surface.data());
//create a top level
auto xdgTopLevel1 = zxdg_surface_v6_get_toplevel(xdgSurface);
QVERIFY(xdgSurfaceCreatedSpy.wait());
//now try to create another top level for the same xdg surface. It should fail
auto xdgTopLevel2 = zxdg_surface_v6_get_toplevel(xdgSurface);
QVERIFY(!xdgSurfaceCreatedSpy.wait(10));
zxdg_toplevel_v6_destroy(xdgTopLevel1);
zxdg_toplevel_v6_destroy(xdgTopLevel2);
zxdg_surface_v6_destroy(xdgSurface);
}
//toplevel then popup
void XdgShellTestV6::testMultipleRoles2()
{
QSignalSpy xdgSurfaceCreatedSpy(m_xdgShellInterface, &XdgShellInterface::surfaceCreated);
QSignalSpy xdgPopupCreatedSpy(m_xdgShellInterface, &XdgShellInterface::xdgPopupCreated);
QVERIFY(xdgSurfaceCreatedSpy.isValid());
QVERIFY(xdgPopupCreatedSpy.isValid());
QScopedPointer<Surface> surface(m_compositor->createSurface());
QScopedPointer<Surface> parentSurface(m_compositor->createSurface());
auto parentXdgSurface = zxdg_shell_v6_get_xdg_surface(*m_xdgShell, *parentSurface.data());
auto xdgTopLevelParent = zxdg_surface_v6_get_toplevel(parentXdgSurface);
QVERIFY(xdgSurfaceCreatedSpy.wait());
auto xdgSurface = zxdg_shell_v6_get_xdg_surface(*m_xdgShell, *surface.data());
//create a top level
auto xdgTopLevel1 = zxdg_surface_v6_get_toplevel(xdgSurface);
QVERIFY(xdgSurfaceCreatedSpy.wait());
//now try to create a popup on the same xdg surface. It should fail
auto positioner = zxdg_shell_v6_create_positioner(*m_xdgShell);
zxdg_positioner_v6_set_anchor_rect(positioner,10, 10, 10, 10);
zxdg_positioner_v6_set_size(positioner,10, 100);
auto xdgPopup2 = zxdg_surface_v6_get_popup(xdgSurface, parentXdgSurface, positioner);
QVERIFY(!xdgPopupCreatedSpy.wait(10));
zxdg_positioner_v6_destroy(positioner);
zxdg_toplevel_v6_destroy(xdgTopLevel1);
zxdg_toplevel_v6_destroy(xdgTopLevelParent);
zxdg_popup_v6_destroy(xdgPopup2);
zxdg_surface_v6_destroy(xdgSurface);
}
QTEST_GUILESS_MAIN(XdgShellTestV6)
#include "test_xdg_shell_v6.moc"
......@@ -64,7 +64,6 @@ set(SERVER_LIB_SRCS
xdgoutput_interface.cpp
xdgshell_interface.cpp
xdgshell_stable_interface.cpp
xdgshell_v6_interface.cpp
)
ecm_qt_declare_logging_category(SERVER_LIB_SRCS
......@@ -160,11 +159,6 @@ ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
BASENAME text-input-unstable-v2
)
ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/xdg-shell/xdg-shell-unstable-v6.xml
BASENAME xdg-shell-v6
)
ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml
BASENAME pointer-gestures-unstable-v1
......@@ -300,8 +294,6 @@ set(SERVER_GENERATED_SRCS
${CMAKE_CURRENT_BINARY_DIR}/wayland-xdg-foreign-unstable-v2-server-protocol.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-xdg-shell-client-protocol.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-xdg-shell-server-protocol.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-xdg-shell-v6-client-protocol.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-xdg-shell-v6-server-protocol.h
${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-tablet-unstable-v2.h
${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-tablet-unstable-v2.cpp
${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-keyboard-shortcuts-inhibit-unstable-v1.h
......
......@@ -9,6 +9,7 @@
#include "blur_interface.h"
#include "compositor_interface.h"
#include "contrast_interface.h"
#include "datacontroldevicemanager_v1_interface.h"
#include "datadevicemanager_interface.h"
#include "dpms_interface.h"
#include "eglstream_controller_interface.h"
......@@ -42,11 +43,6 @@
#include "xdgforeign_interface.h"
#include "xdgoutput_interface.h"
#include "xdgshell_stable_interface_p.h"
#include "xdgshell_v6_interface_p.h"
#include "xdgdecoration_interface.h"
#include "eglstream_controller_interface.h"
#include "keystate_interface.h"
#include "datacontroldevicemanager_v1_interface.h"
#include <QCoreApplication>
#include <QDebug>
......@@ -388,8 +384,7 @@ XdgShellInterface *Display::createXdgShell(const XdgShellInterfaceVersion &versi
case XdgShellInterfaceVersion::UnstableV5:
return nullptr;
case XdgShellInterfaceVersion::UnstableV6:
x = new XdgShellV6Interface(this, parent);
break;
return nullptr;
case XdgShellInterfaceVersion::Stable:
x = new XdgShellStableInterface(this, parent);
break;
......
This diff is collapsed.
/*
SPDX-FileCopyrightText: 2017 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef KWAYLAND_SERVER_XDGSHELL_V6_INTERFACE_P_H
#define KWAYLAND_SERVER_XDGSHELL_V6_INTERFACE_P_H
#include "global.h"
#include "resource.h"
#include "xdgshell_interface.h"
#include <KWaylandServer/kwaylandserver_export.h>
#include <QSize>
namespace KWaylandServer
{
class Display;
class OutputInterface;
class SeatInterface;
class SurfaceInterface;
class XdgTopLevelV6Interface;
class XdgPopupV6Interface;
class XdgPositionerV6Interface;
class XdgSurfaceV6Interface;
template <typename T>
class GenericShellSurface;
class XdgShellV6Interface : public XdgShellInterface
{
Q_OBJECT
public:
virtual ~XdgShellV6Interface();
/**
* @returns The XdgTopLevelV6Interface for the @p native resource.
**/
XdgTopLevelV6Interface *getSurface(wl_resource *native);
//DAVE we want to rename this, as it's bloody confusing. But XdgShellInterface::getSurface exists and expects that
//also use a less terrible argument name than native. It's obvious it's native from the type
XdgPositionerV6Interface *getPositioner(wl_resource *native);
XdgSurfaceV6Interface *realGetSurface(wl_resource *native);
Display *display() const;
void ping(XdgShellSurfaceInterface * surface);
private:
explicit XdgShellV6Interface(Display *display, QObject *parent = nullptr);
friend class Display;
class Private;
Private *d_func() const;
};
class XdgSurfaceV6Interface : public KWaylandServer::Resource
{
Q_OBJECT
public:
virtual ~XdgSurfaceV6Interface();
SurfaceInterface* surface() const;
XdgTopLevelV6Interface* topLevel() const;
XdgPopupV6Interface *popup() const;
private:
explicit XdgSurfaceV6Interface(XdgShellV6Interface *parent, SurfaceInterface *surface, wl_resource *parentResource);
friend class XdgShellV6Interface;
class Private;
Private *d_func() const;
};
class XdgTopLevelV6Interface : public
XdgShellSurfaceInterface
{
Q_OBJECT
public:
virtual ~XdgTopLevelV6Interface();
private:
explicit XdgTopLevelV6Interface(XdgShellV6Interface *parent, SurfaceInterface *surface, wl_resource *parentResource);
friend class XdgShellV6Interface;
friend class XdgSurfaceV6Interface;
class Private;
Private *d_func() const;
};
class XdgPopupV6Interface : public XdgShellPopupInterface
{
Q_OBJECT
public:
virtual ~XdgPopupV6Interface();
private:
explicit XdgPopupV6Interface(XdgShellV6Interface *parent, SurfaceInterface *surface, wl_resource *parentResource);
friend class XdgShellV6Interface;
friend class XdgSurfaceV6Interface;
friend class GenericShellSurface<XdgPopupV6Interface>;
class Private;
Private *d_func() const;
};
/*
* This is a private internal class that keeps track of sent data
* At the time of PopupCreation these values are copied to the popup
*/
class XdgPositionerV6Interface: public KWaylandServer::Resource
{
public:
QSize initialSize() const;
QRect anchorRect() const;
Qt::Edges anchorEdge() const;
Qt::Edges gravity() const;
PositionerConstraints constraintAdjustments() const;
QPoint anchorOffset() const;
private:
explicit XdgPositionerV6Interface(XdgShellV6Interface *parent, wl_resource *parentResource);
friend class XdgShellV6Interface;
class Private;
Private *d_func() const;
};
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment