2015-10-02 13:04:57 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2015 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#ifndef KWIN_WAYLAND_TEST_H
|
|
|
|
#define KWIN_WAYLAND_TEST_H
|
|
|
|
|
|
|
|
#include "../../main.h"
|
|
|
|
|
|
|
|
// Qt
|
2018-06-05 10:52:57 +00:00
|
|
|
#include <QtTest>
|
2015-10-02 13:04:57 +00:00
|
|
|
|
2018-10-19 22:21:54 +00:00
|
|
|
// KWayland
|
|
|
|
#include <KWayland/Client/xdgshell.h>
|
|
|
|
|
2016-06-30 11:32:54 +00:00
|
|
|
namespace KWayland
|
|
|
|
{
|
|
|
|
namespace Client
|
|
|
|
{
|
2017-12-22 14:22:24 +00:00
|
|
|
class AppMenuManager;
|
2016-06-30 11:32:54 +00:00
|
|
|
class ConnectionThread;
|
|
|
|
class Compositor;
|
2017-11-16 20:48:19 +00:00
|
|
|
class IdleInhibitManager;
|
2016-06-30 11:32:54 +00:00
|
|
|
class PlasmaShell;
|
|
|
|
class PlasmaWindowManagement;
|
2016-11-25 06:17:43 +00:00
|
|
|
class PointerConstraints;
|
2016-06-30 11:32:54 +00:00
|
|
|
class Seat;
|
|
|
|
class ServerSideDecorationManager;
|
2018-06-07 09:08:15 +00:00
|
|
|
class ShadowManager;
|
2016-06-30 11:32:54 +00:00
|
|
|
class Shell;
|
|
|
|
class ShellSurface;
|
|
|
|
class ShmPool;
|
2019-02-21 22:25:19 +00:00
|
|
|
class SubCompositor;
|
|
|
|
class SubSurface;
|
2016-06-30 11:32:54 +00:00
|
|
|
class Surface;
|
2019-01-01 17:37:18 +00:00
|
|
|
class XdgDecorationManager;
|
2016-06-30 11:32:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-02 13:04:57 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
2018-08-22 00:20:16 +00:00
|
|
|
namespace Xwl
|
|
|
|
{
|
|
|
|
class Xwayland;
|
|
|
|
}
|
2015-10-02 13:04:57 +00:00
|
|
|
|
2016-07-01 10:37:09 +00:00
|
|
|
class AbstractClient;
|
2016-07-01 07:54:44 +00:00
|
|
|
class ShellClient;
|
|
|
|
|
2018-08-22 00:20:16 +00:00
|
|
|
class WaylandTestApplication : public ApplicationWaylandAbstract
|
2015-10-02 13:04:57 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-09-30 14:35:52 +00:00
|
|
|
WaylandTestApplication(OperationMode mode, int &argc, char **argv);
|
2015-10-02 13:04:57 +00:00
|
|
|
virtual ~WaylandTestApplication();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void performStartup() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void createBackend();
|
|
|
|
void continueStartupWithScreens();
|
2019-02-20 00:02:08 +00:00
|
|
|
void continueStartupWithScene();
|
2019-02-23 12:17:50 +00:00
|
|
|
void finalizeStartup();
|
2015-10-02 13:04:57 +00:00
|
|
|
|
2018-08-22 00:20:16 +00:00
|
|
|
Xwl::Xwayland *m_xwayland = nullptr;
|
2015-10-02 13:04:57 +00:00
|
|
|
};
|
|
|
|
|
2016-06-30 11:32:54 +00:00
|
|
|
namespace Test
|
|
|
|
{
|
|
|
|
|
|
|
|
enum class AdditionalWaylandInterface {
|
|
|
|
Seat = 1 << 0,
|
|
|
|
Decoration = 1 << 1,
|
|
|
|
PlasmaShell = 1 << 2,
|
2016-11-25 06:17:43 +00:00
|
|
|
WindowManagement = 1 << 3,
|
2017-11-16 20:48:19 +00:00
|
|
|
PointerConstraints = 1 << 4,
|
2017-12-22 14:22:24 +00:00
|
|
|
IdleInhibition = 1 << 5,
|
2018-06-07 09:08:15 +00:00
|
|
|
AppMenu = 1 << 6,
|
2019-01-01 17:37:18 +00:00
|
|
|
ShadowManager = 1 << 7,
|
|
|
|
XdgDecoration = 1 << 8,
|
2016-06-30 11:32:54 +00:00
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(AdditionalWaylandInterfaces, AdditionalWaylandInterface)
|
|
|
|
/**
|
|
|
|
* Creates a Wayland Connection in a dedicated thread and creates various
|
|
|
|
* client side objects which can be used to create windows.
|
|
|
|
* @returns @c true if created successfully, @c false if there was an error
|
|
|
|
* @see destroyWaylandConnection
|
|
|
|
**/
|
2016-12-03 13:31:14 +00:00
|
|
|
bool setupWaylandConnection(AdditionalWaylandInterfaces flags = AdditionalWaylandInterfaces());
|
2016-06-30 11:32:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys the Wayland Connection created with @link{setupWaylandConnection}.
|
|
|
|
* This can be called from cleanup in order to ensure that no Wayland Connection
|
|
|
|
* leaks into the next test method.
|
|
|
|
* @see setupWaylandConnection
|
|
|
|
*/
|
|
|
|
void destroyWaylandConnection();
|
|
|
|
|
|
|
|
KWayland::Client::ConnectionThread *waylandConnection();
|
|
|
|
KWayland::Client::Compositor *waylandCompositor();
|
2019-02-21 22:25:19 +00:00
|
|
|
KWayland::Client::SubCompositor *waylandSubCompositor();
|
2018-06-07 09:08:15 +00:00
|
|
|
KWayland::Client::ShadowManager *waylandShadowManager();
|
2016-06-30 11:32:54 +00:00
|
|
|
KWayland::Client::Shell *waylandShell();
|
|
|
|
KWayland::Client::ShmPool *waylandShmPool();
|
|
|
|
KWayland::Client::Seat *waylandSeat();
|
|
|
|
KWayland::Client::ServerSideDecorationManager *waylandServerSideDecoration();
|
|
|
|
KWayland::Client::PlasmaShell *waylandPlasmaShell();
|
|
|
|
KWayland::Client::PlasmaWindowManagement *waylandWindowManagement();
|
2016-11-25 06:17:43 +00:00
|
|
|
KWayland::Client::PointerConstraints *waylandPointerConstraints();
|
2017-11-16 20:48:19 +00:00
|
|
|
KWayland::Client::IdleInhibitManager *waylandIdleInhibitManager();
|
2017-12-22 14:22:24 +00:00
|
|
|
KWayland::Client::AppMenuManager *waylandAppMenuManager();
|
2019-01-01 17:37:18 +00:00
|
|
|
KWayland::Client::XdgDecorationManager *xdgDecorationManager();
|
2016-06-30 11:32:54 +00:00
|
|
|
|
|
|
|
bool waitForWaylandPointer();
|
|
|
|
bool waitForWaylandTouch();
|
2016-08-11 09:17:09 +00:00
|
|
|
bool waitForWaylandKeyboard();
|
2016-06-30 11:32:54 +00:00
|
|
|
|
|
|
|
void flushWaylandConnection();
|
|
|
|
|
|
|
|
KWayland::Client::Surface *createSurface(QObject *parent = nullptr);
|
2019-02-21 22:25:19 +00:00
|
|
|
KWayland::Client::SubSurface *createSubSurface(KWayland::Client::Surface *surface,
|
|
|
|
KWayland::Client::Surface *parentSurface, QObject *parent = nullptr);
|
2016-04-22 12:13:37 +00:00
|
|
|
enum class ShellSurfaceType {
|
|
|
|
WlShell,
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
XdgShellV5,
|
2018-09-14 11:04:33 +00:00
|
|
|
XdgShellV6,
|
|
|
|
XdgShellStable
|
2016-04-22 12:13:37 +00:00
|
|
|
};
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
|
|
enum class CreationSetup {
|
|
|
|
CreateOnly,
|
|
|
|
CreateAndConfigure, /// commit and wait for the configure event, making this surface ready to commit buffers
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates either a ShellSurface * or XdgShellSurface * as defined by @arg type
|
|
|
|
* For XDG top levels this method will block for a configure event, make this surface ready to commit buffers
|
|
|
|
*/
|
2016-04-22 12:13:37 +00:00
|
|
|
QObject *createShellSurface(ShellSurfaceType type, KWayland::Client::Surface *surface, QObject *parent = nullptr);
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
|
|
KWayland::Client::XdgShellSurface *createXdgShellSurface(ShellSurfaceType type,
|
|
|
|
KWayland::Client::Surface *surface,
|
|
|
|
QObject *parent = nullptr,
|
|
|
|
CreationSetup creationSetup = CreationSetup::CreateAndConfigure);
|
|
|
|
|
|
|
|
KWayland::Client::ShellSurface *createShellSurface(KWayland::Client::Surface *surface,
|
|
|
|
QObject *parent = nullptr);
|
|
|
|
KWayland::Client::XdgShellSurface *createXdgShellV5Surface(KWayland::Client::Surface *surface,
|
|
|
|
QObject *parent = nullptr,
|
|
|
|
CreationSetup = CreationSetup::CreateAndConfigure);
|
|
|
|
KWayland::Client::XdgShellSurface *createXdgShellV6Surface(KWayland::Client::Surface *surface,
|
|
|
|
QObject *parent = nullptr,
|
|
|
|
CreationSetup = CreationSetup::CreateAndConfigure);
|
|
|
|
KWayland::Client::XdgShellSurface *createXdgShellStableSurface(KWayland::Client::Surface *surface,
|
|
|
|
QObject *parent = nullptr,
|
|
|
|
CreationSetup = CreationSetup::CreateAndConfigure);
|
|
|
|
KWayland::Client::XdgShellPopup *createXdgShellStablePopup(KWayland::Client::Surface *surface,
|
|
|
|
KWayland::Client::XdgShellSurface *parentSurface,
|
|
|
|
const KWayland::Client::XdgPositioner &positioner,
|
|
|
|
QObject *parent = nullptr,
|
|
|
|
CreationSetup = CreationSetup::CreateAndConfigure);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Commits the XdgShellSurface to the given surface, and waits for the configure event from the compositor
|
|
|
|
*/
|
|
|
|
void initXdgShellSurface(KWayland::Client::Surface *surface, KWayland::Client::XdgShellSurface *shellSurface);
|
|
|
|
void initXdgShellPopup(KWayland::Client::Surface *surface, KWayland::Client::XdgShellPopup *popup);
|
|
|
|
|
|
|
|
|
2017-07-31 14:12:37 +00:00
|
|
|
|
2016-06-30 11:32:54 +00:00
|
|
|
/**
|
|
|
|
* Creates a shared memory buffer of @p size in @p color and attaches it to the @p surface.
|
|
|
|
* The @p surface gets damaged and committed, thus it's rendered.
|
|
|
|
**/
|
2017-08-30 09:01:55 +00:00
|
|
|
void render(KWayland::Client::Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format = QImage::Format_ARGB32_Premultiplied);
|
2016-07-01 07:54:44 +00:00
|
|
|
|
2017-07-31 14:12:37 +00:00
|
|
|
/**
|
|
|
|
* Creates a shared memory buffer using the supplied image @p img and attaches it to the @p surface
|
|
|
|
*/
|
|
|
|
void render(KWayland::Client::Surface *surface, const QImage &img);
|
|
|
|
|
2016-07-01 07:54:44 +00:00
|
|
|
/**
|
|
|
|
* Waits till a new ShellClient is shown and returns the created ShellClient.
|
|
|
|
* If no ShellClient gets shown during @p timeout @c null is returned.
|
|
|
|
**/
|
|
|
|
ShellClient *waitForWaylandWindowShown(int timeout = 5000);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Combination of @link{render} and @link{waitForWaylandWindowShown}.
|
|
|
|
**/
|
|
|
|
ShellClient *renderAndWaitForShown(KWayland::Client::Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format = QImage::Format_ARGB32, int timeout = 5000);
|
2016-07-01 10:37:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Waits for the @p client to be destroyed.
|
|
|
|
**/
|
|
|
|
bool waitForWindowDestroyed(AbstractClient *client);
|
2016-08-16 06:19:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Locks the screen and waits till the screen is locked.
|
|
|
|
* @returns @c true if the screen could be locked, @c false otherwise
|
|
|
|
**/
|
|
|
|
bool lockScreen();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unlocks the screen and waits till the screen is unlocked.
|
|
|
|
* @returns @c true if the screen could be unlocked, @c false otherwise
|
|
|
|
**/
|
|
|
|
bool unlockScreen();
|
2016-06-30 11:32:54 +00:00
|
|
|
}
|
|
|
|
|
2015-10-02 13:04:57 +00:00
|
|
|
}
|
|
|
|
|
2016-06-30 11:32:54 +00:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Test::AdditionalWaylandInterfaces)
|
2016-04-22 12:13:37 +00:00
|
|
|
Q_DECLARE_METATYPE(KWin::Test::ShellSurfaceType)
|
2016-06-30 11:32:54 +00:00
|
|
|
|
2017-09-30 14:35:52 +00:00
|
|
|
#define WAYLANDTEST_MAIN_HELPER(TestObject, DPI, OperationMode) \
|
2015-10-02 13:04:57 +00:00
|
|
|
int main(int argc, char *argv[]) \
|
|
|
|
{ \
|
|
|
|
setenv("QT_QPA_PLATFORM", "wayland-org.kde.kwin.qpa", true); \
|
2017-08-25 16:18:20 +00:00
|
|
|
setenv("QT_QPA_PLATFORM_PLUGIN_PATH", QFileInfo(QString::fromLocal8Bit(argv[0])).absolutePath().toLocal8Bit().constData(), true); \
|
2016-01-30 11:31:19 +00:00
|
|
|
setenv("KWIN_FORCE_OWN_QPA", "1", true); \
|
2018-11-17 08:48:51 +00:00
|
|
|
qunsetenv("KDE_FULL_SESSION"); \
|
|
|
|
qunsetenv("KDE_SESSION_VERSION"); \
|
|
|
|
qunsetenv("XDG_SESSION_DESKTOP"); \
|
|
|
|
qunsetenv("XDG_CURRENT_DESKTOP"); \
|
2015-11-10 09:58:33 +00:00
|
|
|
DPI; \
|
2017-09-30 14:35:52 +00:00
|
|
|
KWin::WaylandTestApplication app(OperationMode, argc, argv); \
|
2015-10-02 13:04:57 +00:00
|
|
|
app.setAttribute(Qt::AA_Use96Dpi, true); \
|
|
|
|
TestObject tc; \
|
|
|
|
return QTest::qExec(&tc, argc, argv); \
|
|
|
|
}
|
|
|
|
|
2017-09-30 14:35:52 +00:00
|
|
|
#ifdef NO_XWAYLAND
|
2019-01-11 22:48:04 +00:00
|
|
|
#define WAYLANDTEST_MAIN(TestObject) WAYLANDTEST_MAIN_HELPER(TestObject, QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps), KWin::Application::OperationModeWaylandOnly)
|
2017-09-30 14:35:52 +00:00
|
|
|
#else
|
2019-01-11 22:48:04 +00:00
|
|
|
#define WAYLANDTEST_MAIN(TestObject) WAYLANDTEST_MAIN_HELPER(TestObject, QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps), KWin::Application::OperationModeXwayland)
|
2017-09-30 14:35:52 +00:00
|
|
|
#endif
|
2015-11-10 09:58:33 +00:00
|
|
|
|
2015-10-02 13:04:57 +00:00
|
|
|
#endif
|