2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2015-10-02 13:04:57 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
2015-10-02 13:04:57 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2015-10-02 13:04:57 +00:00
|
|
|
#ifndef KWIN_WAYLAND_TEST_H
|
|
|
|
#define KWIN_WAYLAND_TEST_H
|
|
|
|
|
2022-02-23 12:53:23 +00:00
|
|
|
#include "inputdevice.h"
|
2021-02-09 18:18:36 +00:00
|
|
|
#include "main.h"
|
2022-04-22 17:39:12 +00:00
|
|
|
#include "window.h"
|
2015-10-02 13:04:57 +00:00
|
|
|
|
|
|
|
// Qt
|
2018-06-05 10:52:57 +00:00
|
|
|
#include <QtTest>
|
2015-10-02 13:04:57 +00:00
|
|
|
|
2021-12-23 08:42:00 +00:00
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
|
2021-05-13 19:59:22 +00:00
|
|
|
#include "qwayland-idle-inhibit-unstable-v1.h"
|
2021-12-23 08:42:00 +00:00
|
|
|
#include "qwayland-input-method-unstable-v1.h"
|
|
|
|
#include "qwayland-kde-output-device-v2.h"
|
|
|
|
#include "qwayland-kde-output-management-v2.h"
|
2020-09-25 06:51:04 +00:00
|
|
|
#include "qwayland-text-input-unstable-v3.h"
|
2021-12-23 08:42:00 +00:00
|
|
|
#include "qwayland-wlr-layer-shell-unstable-v1.h"
|
2021-05-11 05:26:51 +00:00
|
|
|
#include "qwayland-xdg-decoration-unstable-v1.h"
|
2020-09-02 09:27:08 +00:00
|
|
|
#include "qwayland-xdg-shell.h"
|
2020-08-07 19:01:42 +00:00
|
|
|
|
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;
|
2021-05-11 05:26:51 +00:00
|
|
|
class Output;
|
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 ShmPool;
|
2019-02-21 22:25:19 +00:00
|
|
|
class SubCompositor;
|
|
|
|
class SubSurface;
|
2016-06-30 11:32:54 +00:00
|
|
|
class Surface;
|
2020-09-01 08:58:46 +00:00
|
|
|
class TextInputManager;
|
2016-06-30 11:32:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-01 08:58:46 +00:00
|
|
|
namespace QtWayland
|
|
|
|
{
|
|
|
|
class zwp_input_panel_surface_v1;
|
2020-09-25 06:51:04 +00:00
|
|
|
class zwp_text_input_v3;
|
|
|
|
class zwp_text_input_manager_v3;
|
2020-09-01 08:58:46 +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
|
|
|
|
2022-02-26 08:22:31 +00:00
|
|
|
namespace Test
|
|
|
|
{
|
|
|
|
class VirtualInputDevice;
|
|
|
|
}
|
2016-07-01 07:54:44 +00:00
|
|
|
|
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);
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~WaylandTestApplication() override;
|
2015-10-02 13:04:57 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void setInputMethodServerToStart(const QString &inputMethodServer)
|
|
|
|
{
|
2020-09-01 08:58:46 +00:00
|
|
|
m_inputMethodServerToStart = inputMethodServer;
|
|
|
|
}
|
2022-02-26 08:22:31 +00:00
|
|
|
|
|
|
|
Test::VirtualInputDevice *virtualPointer() const;
|
|
|
|
Test::VirtualInputDevice *virtualKeyboard() const;
|
|
|
|
Test::VirtualInputDevice *virtualTouch() const;
|
|
|
|
|
2015-10-02 13:04:57 +00:00
|
|
|
protected:
|
|
|
|
void performStartup() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
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
|
|
|
|
2022-02-26 08:22:31 +00:00
|
|
|
void createVirtualInputDevices();
|
|
|
|
void destroyVirtualInputDevices();
|
|
|
|
|
2018-08-22 00:20:16 +00:00
|
|
|
Xwl::Xwayland *m_xwayland = nullptr;
|
2020-09-01 08:58:46 +00:00
|
|
|
QString m_inputMethodServerToStart;
|
2022-02-26 08:22:31 +00:00
|
|
|
|
|
|
|
QScopedPointer<Test::VirtualInputDevice> m_virtualPointer;
|
|
|
|
QScopedPointer<Test::VirtualInputDevice> m_virtualKeyboard;
|
|
|
|
QScopedPointer<Test::VirtualInputDevice> m_virtualTouch;
|
2015-10-02 13:04:57 +00:00
|
|
|
};
|
|
|
|
|
2016-06-30 11:32:54 +00:00
|
|
|
namespace Test
|
|
|
|
{
|
|
|
|
|
2020-09-01 08:58:46 +00:00
|
|
|
class MockInputMethod;
|
|
|
|
|
2020-09-25 06:51:04 +00:00
|
|
|
class TextInputManagerV3 : public QtWayland::zwp_text_input_manager_v3
|
|
|
|
{
|
|
|
|
public:
|
2022-03-23 10:13:38 +00:00
|
|
|
~TextInputManagerV3() override
|
|
|
|
{
|
|
|
|
destroy();
|
|
|
|
}
|
2020-09-25 06:51:04 +00:00
|
|
|
};
|
|
|
|
|
2021-12-23 08:42:00 +00:00
|
|
|
class TextInputV3 : public QObject, public QtWayland::zwp_text_input_v3
|
2020-09-25 06:51:04 +00:00
|
|
|
{
|
2021-12-23 08:42:00 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2022-03-23 10:13:38 +00:00
|
|
|
~TextInputV3() override
|
|
|
|
{
|
|
|
|
destroy();
|
|
|
|
}
|
2021-12-23 08:42:00 +00:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void preeditString(const QString &text, int cursor_begin, int cursor_end);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void zwp_text_input_v3_preedit_string(const QString &text, int32_t cursor_begin, int32_t cursor_end) override
|
|
|
|
{
|
|
|
|
Q_EMIT preeditString(text, cursor_begin, cursor_end);
|
|
|
|
}
|
2020-09-25 06:51:04 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 19:01:42 +00:00
|
|
|
class LayerShellV1 : public QtWayland::zwlr_layer_shell_v1
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~LayerShellV1() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LayerSurfaceV1 : public QObject, public QtWayland::zwlr_layer_surface_v1
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
~LayerSurfaceV1() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override;
|
|
|
|
void zwlr_layer_surface_v1_closed() override;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void closeRequested();
|
|
|
|
void configureRequested(quint32 serial, const QSize &size);
|
|
|
|
};
|
|
|
|
|
2020-09-02 09:27:08 +00:00
|
|
|
/**
|
|
|
|
* The XdgShell class represents the @c xdg_wm_base global.
|
|
|
|
*/
|
|
|
|
class XdgShell : public QtWayland::xdg_wm_base
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~XdgShell() override;
|
2021-05-12 01:11:27 +00:00
|
|
|
void xdg_wm_base_ping(uint32_t serial) override
|
|
|
|
{
|
|
|
|
pong(serial);
|
|
|
|
}
|
2020-09-02 09:27:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The XdgSurface class represents an xdg_surface object.
|
|
|
|
*/
|
|
|
|
class XdgSurface : public QObject, public QtWayland::xdg_surface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit XdgSurface(XdgShell *shell, KWayland::Client::Surface *surface, QObject *parent = nullptr);
|
|
|
|
~XdgSurface() override;
|
|
|
|
|
|
|
|
KWayland::Client::Surface *surface() const;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void configureRequested(quint32 serial);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void xdg_surface_configure(uint32_t serial) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
KWayland::Client::Surface *m_surface;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The XdgToplevel class represents an xdg_toplevel surface. Note that the XdgToplevel surface
|
|
|
|
* takes the ownership of the underlying XdgSurface object.
|
|
|
|
*/
|
|
|
|
class XdgToplevel : public QObject, public QtWayland::xdg_toplevel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum class State {
|
2022-03-23 10:13:38 +00:00
|
|
|
Maximized = 1 << 0,
|
2020-09-02 09:27:08 +00:00
|
|
|
Fullscreen = 1 << 1,
|
2022-03-23 10:13:38 +00:00
|
|
|
Resizing = 1 << 2,
|
|
|
|
Activated = 1 << 3
|
2020-09-02 09:27:08 +00:00
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(States, State)
|
|
|
|
|
|
|
|
explicit XdgToplevel(XdgSurface *surface, QObject *parent = nullptr);
|
|
|
|
~XdgToplevel() override;
|
|
|
|
|
|
|
|
XdgSurface *xdgSurface() const;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void configureRequested(const QSize &size, KWin::Test::XdgToplevel::States states);
|
|
|
|
void closeRequested();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void xdg_toplevel_configure(int32_t width, int32_t height, wl_array *states) override;
|
|
|
|
void xdg_toplevel_close() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QScopedPointer<XdgSurface> m_xdgSurface;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The XdgPositioner class represents an xdg_positioner object.
|
|
|
|
*/
|
|
|
|
class XdgPositioner : public QtWayland::xdg_positioner
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit XdgPositioner(XdgShell *shell);
|
|
|
|
~XdgPositioner() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The XdgPopup class represents an xdg_popup surface. Note that the XdgPopup surface takes
|
|
|
|
* the ownership of the underlying XdgSurface object.
|
|
|
|
*/
|
|
|
|
class XdgPopup : public QObject, public QtWayland::xdg_popup
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
XdgPopup(XdgSurface *surface, XdgSurface *parentSurface, XdgPositioner *positioner, QObject *parent = nullptr);
|
|
|
|
~XdgPopup() override;
|
|
|
|
|
|
|
|
XdgSurface *xdgSurface() const;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void configureRequested(const QRect &rect);
|
2021-05-11 05:26:51 +00:00
|
|
|
void doneReceived();
|
2020-09-02 09:27:08 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void xdg_popup_configure(int32_t x, int32_t y, int32_t width, int32_t height) override;
|
2021-05-11 05:26:51 +00:00
|
|
|
void xdg_popup_popup_done() override;
|
2020-09-02 09:27:08 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QScopedPointer<XdgSurface> m_xdgSurface;
|
|
|
|
};
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
class XdgDecorationManagerV1 : public QtWayland::zxdg_decoration_manager_v1
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~XdgDecorationManagerV1() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class XdgToplevelDecorationV1 : public QObject, public QtWayland::zxdg_toplevel_decoration_v1
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
XdgToplevelDecorationV1(XdgDecorationManagerV1 *manager, XdgToplevel *toplevel, QObject *parent = nullptr);
|
|
|
|
~XdgToplevelDecorationV1() override;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void configureRequested(QtWayland::zxdg_toplevel_decoration_v1::mode mode);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void zxdg_toplevel_decoration_v1_configure(uint32_t mode) override;
|
|
|
|
};
|
|
|
|
|
2021-05-13 19:59:22 +00:00
|
|
|
class IdleInhibitManagerV1 : public QtWayland::zwp_idle_inhibit_manager_v1
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~IdleInhibitManagerV1() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IdleInhibitorV1 : public QtWayland::zwp_idle_inhibitor_v1
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
IdleInhibitorV1(IdleInhibitManagerV1 *manager, KWayland::Client::Surface *surface);
|
|
|
|
~IdleInhibitorV1() override;
|
|
|
|
};
|
|
|
|
|
2021-09-08 09:04:44 +00:00
|
|
|
class WaylandOutputConfigurationV2 : public QObject, public QtWayland::kde_output_configuration_v2
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
WaylandOutputConfigurationV2(struct ::kde_output_configuration_v2 *object);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void applied();
|
|
|
|
void failed();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void kde_output_configuration_v2_applied() override;
|
|
|
|
void kde_output_configuration_v2_failed() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WaylandOutputManagementV2 : public QObject, public QtWayland::kde_output_management_v2
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
WaylandOutputManagementV2(struct ::wl_registry *registry, int id, int version);
|
|
|
|
|
|
|
|
WaylandOutputConfigurationV2 *createConfiguration();
|
|
|
|
};
|
|
|
|
|
|
|
|
class WaylandOutputDeviceV2Mode : public QObject, public QtWayland::kde_output_device_mode_v2
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
WaylandOutputDeviceV2Mode(struct ::kde_output_device_mode_v2 *object);
|
|
|
|
~WaylandOutputDeviceV2Mode() override;
|
|
|
|
|
|
|
|
int refreshRate() const;
|
|
|
|
QSize size() const;
|
|
|
|
bool preferred() const;
|
|
|
|
|
|
|
|
bool operator==(const WaylandOutputDeviceV2Mode &other);
|
|
|
|
|
|
|
|
static WaylandOutputDeviceV2Mode *get(struct ::kde_output_device_mode_v2 *object);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void removed();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void kde_output_device_mode_v2_size(int32_t width, int32_t height) override;
|
|
|
|
void kde_output_device_mode_v2_refresh(int32_t refresh) override;
|
|
|
|
void kde_output_device_mode_v2_preferred() override;
|
|
|
|
void kde_output_device_mode_v2_removed() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_refreshRate = 60000;
|
|
|
|
QSize m_size;
|
|
|
|
bool m_preferred = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WaylandOutputDeviceV2 : public QObject, public QtWayland::kde_output_device_v2
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
WaylandOutputDeviceV2(int id);
|
|
|
|
~WaylandOutputDeviceV2() override;
|
|
|
|
|
|
|
|
QByteArray edid() const;
|
|
|
|
bool enabled() const;
|
|
|
|
int id() const;
|
|
|
|
QString name() const;
|
|
|
|
QString model() const;
|
|
|
|
QString manufacturer() const;
|
|
|
|
qreal scale() const;
|
|
|
|
QPoint globalPosition() const;
|
|
|
|
QSize pixelSize() const;
|
|
|
|
int refreshRate() const;
|
|
|
|
uint32_t vrrPolicy() const;
|
|
|
|
uint32_t overscan() const;
|
|
|
|
uint32_t capabilities() const;
|
|
|
|
uint32_t rgbRange() const;
|
|
|
|
|
|
|
|
QString modeId() const;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void enabledChanged();
|
|
|
|
void done();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void kde_output_device_v2_geometry(int32_t x,
|
|
|
|
int32_t y,
|
|
|
|
int32_t physical_width,
|
|
|
|
int32_t physical_height,
|
|
|
|
int32_t subpixel,
|
|
|
|
const QString &make,
|
|
|
|
const QString &model,
|
|
|
|
int32_t transform) override;
|
|
|
|
void kde_output_device_v2_current_mode(struct ::kde_output_device_mode_v2 *mode) override;
|
|
|
|
void kde_output_device_v2_mode(struct ::kde_output_device_mode_v2 *mode) override;
|
|
|
|
void kde_output_device_v2_done() override;
|
|
|
|
void kde_output_device_v2_scale(wl_fixed_t factor) override;
|
|
|
|
void kde_output_device_v2_edid(const QString &raw) override;
|
|
|
|
void kde_output_device_v2_enabled(int32_t enabled) override;
|
|
|
|
void kde_output_device_v2_uuid(const QString &uuid) override;
|
|
|
|
void kde_output_device_v2_serial_number(const QString &serialNumber) override;
|
|
|
|
void kde_output_device_v2_eisa_id(const QString &eisaId) override;
|
|
|
|
void kde_output_device_v2_capabilities(uint32_t flags) override;
|
|
|
|
void kde_output_device_v2_overscan(uint32_t overscan) override;
|
|
|
|
void kde_output_device_v2_vrr_policy(uint32_t vrr_policy) override;
|
|
|
|
void kde_output_device_v2_rgb_range(uint32_t rgb_range) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString modeName(const WaylandOutputDeviceV2Mode *m) const;
|
|
|
|
WaylandOutputDeviceV2Mode *deviceModeFromId(const int modeId) const;
|
|
|
|
|
|
|
|
WaylandOutputDeviceV2Mode *m_mode;
|
|
|
|
QList<WaylandOutputDeviceV2Mode *> m_modes;
|
|
|
|
|
|
|
|
int m_id;
|
|
|
|
QPoint m_pos;
|
|
|
|
QSize m_physicalSize;
|
|
|
|
int32_t m_subpixel;
|
|
|
|
QString m_manufacturer;
|
|
|
|
QString m_model;
|
|
|
|
int32_t m_transform;
|
|
|
|
qreal m_factor;
|
|
|
|
QByteArray m_edid;
|
|
|
|
int32_t m_enabled;
|
|
|
|
QString m_uuid;
|
|
|
|
QString m_serialNumber;
|
|
|
|
QString m_eisaId;
|
|
|
|
uint32_t m_flags;
|
|
|
|
uint32_t m_overscan;
|
|
|
|
uint32_t m_vrr_policy;
|
|
|
|
uint32_t m_rgbRange;
|
|
|
|
};
|
|
|
|
|
2021-12-23 08:42:00 +00:00
|
|
|
class MockInputMethod : public QObject, QtWayland::zwp_input_method_v1
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
MockInputMethod(struct wl_registry *registry, int id, int version);
|
|
|
|
~MockInputMethod();
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *client() const
|
2021-12-23 08:42:00 +00:00
|
|
|
{
|
|
|
|
return m_client;
|
|
|
|
}
|
|
|
|
KWayland::Client::Surface *inputPanelSurface() const
|
|
|
|
{
|
|
|
|
return m_inputSurface;
|
|
|
|
}
|
|
|
|
auto *context() const
|
|
|
|
{
|
|
|
|
return m_context;
|
|
|
|
}
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void activate();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void zwp_input_method_v1_activate(struct ::zwp_input_method_context_v1 *context) override;
|
|
|
|
void zwp_input_method_v1_deactivate(struct ::zwp_input_method_context_v1 *context) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QPointer<KWayland::Client::Surface> m_inputSurface;
|
|
|
|
QtWayland::zwp_input_panel_surface_v1 *m_inputMethodSurface = nullptr;
|
2022-04-22 17:39:12 +00:00
|
|
|
QPointer<Window> m_client;
|
2021-12-23 08:42:00 +00:00
|
|
|
struct ::zwp_input_method_context_v1 *m_context = nullptr;
|
|
|
|
};
|
|
|
|
|
2016-06-30 11:32:54 +00:00
|
|
|
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,
|
2021-05-13 19:59:22 +00:00
|
|
|
IdleInhibitV1 = 1 << 5,
|
2018-06-07 09:08:15 +00:00
|
|
|
AppMenu = 1 << 6,
|
2019-01-01 17:37:18 +00:00
|
|
|
ShadowManager = 1 << 7,
|
2021-05-11 05:26:51 +00:00
|
|
|
XdgDecorationV1 = 1 << 8,
|
2021-09-08 09:04:44 +00:00
|
|
|
OutputManagementV2 = 1 << 9,
|
2020-09-01 08:58:46 +00:00
|
|
|
TextInputManagerV2 = 1 << 10,
|
2020-08-07 19:01:42 +00:00
|
|
|
InputMethodV1 = 1 << 11,
|
|
|
|
LayerShellV1 = 1 << 12,
|
2021-01-14 08:21:59 +00:00
|
|
|
TextInputManagerV3 = 1 << 13,
|
2021-09-08 09:04:44 +00:00
|
|
|
OutputDeviceV2 = 1 << 14,
|
2016-06-30 11:32:54 +00:00
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(AdditionalWaylandInterfaces, AdditionalWaylandInterface)
|
2022-02-23 12:53:23 +00:00
|
|
|
|
|
|
|
class VirtualInputDevice : public InputDevice
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit VirtualInputDevice(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
void setPointer(bool set);
|
|
|
|
void setKeyboard(bool set);
|
|
|
|
void setTouch(bool set);
|
|
|
|
void setName(const QString &name);
|
|
|
|
|
|
|
|
QString sysName() const override;
|
|
|
|
QString name() const override;
|
|
|
|
|
|
|
|
bool isEnabled() const override;
|
|
|
|
void setEnabled(bool enabled) override;
|
|
|
|
|
|
|
|
LEDs leds() const override;
|
|
|
|
void setLeds(LEDs leds) override;
|
|
|
|
|
|
|
|
bool isKeyboard() const override;
|
|
|
|
bool isAlphaNumericKeyboard() const override;
|
|
|
|
bool isPointer() const override;
|
|
|
|
bool isTouchpad() const override;
|
|
|
|
bool isTouch() const override;
|
|
|
|
bool isTabletTool() const override;
|
|
|
|
bool isTabletPad() const override;
|
|
|
|
bool isTabletModeSwitch() const override;
|
|
|
|
bool isLidSwitch() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_name;
|
|
|
|
bool m_pointer = false;
|
|
|
|
bool m_keyboard = false;
|
|
|
|
bool m_touch = false;
|
|
|
|
};
|
|
|
|
|
2022-03-10 10:15:26 +00:00
|
|
|
void keyboardKeyPressed(quint32 key, quint32 time);
|
|
|
|
void keyboardKeyReleased(quint32 key, quint32 time);
|
2022-03-10 10:27:35 +00:00
|
|
|
void pointerAxisHorizontal(qreal delta,
|
|
|
|
quint32 time,
|
|
|
|
qint32 discreteDelta = 0,
|
|
|
|
InputRedirection::PointerAxisSource source = InputRedirection::PointerAxisSourceUnknown);
|
|
|
|
void pointerAxisVertical(qreal delta,
|
|
|
|
quint32 time,
|
|
|
|
qint32 discreteDelta = 0,
|
|
|
|
InputRedirection::PointerAxisSource source = InputRedirection::PointerAxisSourceUnknown);
|
2022-03-10 10:15:26 +00:00
|
|
|
void pointerButtonPressed(quint32 button, quint32 time);
|
|
|
|
void pointerButtonReleased(quint32 button, quint32 time);
|
|
|
|
void pointerMotion(const QPointF &position, quint32 time);
|
|
|
|
void touchCancel();
|
|
|
|
void touchDown(qint32 id, const QPointF &pos, quint32 time);
|
|
|
|
void touchMotion(qint32 id, const QPointF &pos, quint32 time);
|
|
|
|
void touchUp(qint32 id, quint32 time);
|
|
|
|
|
2016-06-30 11:32:54 +00:00
|
|
|
/**
|
|
|
|
* 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
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
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::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-12-22 14:22:24 +00:00
|
|
|
KWayland::Client::AppMenuManager *waylandAppMenuManager();
|
2021-09-08 09:04:44 +00:00
|
|
|
WaylandOutputManagementV2 *waylandOutputManagementV2();
|
2020-09-01 08:58:46 +00:00
|
|
|
KWayland::Client::TextInputManager *waylandTextInputManager();
|
2020-08-07 19:01:42 +00:00
|
|
|
QVector<KWayland::Client::Output *> waylandOutputs();
|
2021-09-08 09:04:44 +00:00
|
|
|
QVector<WaylandOutputDeviceV2 *> waylandOutputDevicesV2();
|
2016-06-30 11:32:54 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
bool waitForWaylandSurface(Window *client);
|
2021-05-15 08:43:37 +00:00
|
|
|
|
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);
|
2020-08-07 19:01:42 +00:00
|
|
|
|
|
|
|
LayerSurfaceV1 *createLayerSurfaceV1(KWayland::Client::Surface *surface,
|
|
|
|
const QString &scope,
|
|
|
|
KWayland::Client::Output *output = nullptr,
|
|
|
|
LayerShellV1::layer layer = LayerShellV1::layer_top);
|
|
|
|
|
2020-09-25 06:51:04 +00:00
|
|
|
TextInputManagerV3 *waylandTextInputManagerV3();
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2020-09-01 08:58:46 +00:00
|
|
|
QtWayland::zwp_input_panel_surface_v1 *createInputPanelSurfaceV1(KWayland::Client::Surface *surface,
|
|
|
|
KWayland::Client::Output *output);
|
|
|
|
|
2021-12-09 07:47:55 +00:00
|
|
|
XdgToplevel *createXdgToplevelSurface(KWayland::Client::Surface *surface, QObject *parent = nullptr);
|
|
|
|
XdgToplevel *createXdgToplevelSurface(KWayland::Client::Surface *surface,
|
|
|
|
CreationSetup configureMode,
|
|
|
|
QObject *parent = nullptr);
|
2020-09-02 09:27:08 +00:00
|
|
|
|
|
|
|
XdgPositioner *createXdgPositioner();
|
|
|
|
|
|
|
|
XdgPopup *createXdgPopupSurface(KWayland::Client::Surface *surface, XdgSurface *parentSurface,
|
2021-12-09 07:47:55 +00:00
|
|
|
XdgPositioner *positioner,
|
|
|
|
CreationSetup configureMode = CreationSetup::CreateAndConfigure,
|
|
|
|
QObject *parent = nullptr);
|
2020-09-02 09:27:08 +00:00
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
XdgToplevelDecorationV1 *createXdgToplevelDecorationV1(XdgToplevel *toplevel, QObject *parent = nullptr);
|
2021-05-13 19:59:22 +00:00
|
|
|
IdleInhibitorV1 *createIdleInhibitorV1(KWayland::Client::Surface *surface);
|
2019-02-26 13:41:07 +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.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
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
|
|
|
/**
|
2022-04-22 17:39:12 +00:00
|
|
|
* Waits till a new Window is shown and returns the created Window.
|
|
|
|
* If no Window gets shown during @p timeout @c null is returned.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *waitForWaylandWindowShown(int timeout = 5000);
|
2016-07-01 07:54:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Combination of @link{render} and @link{waitForWaylandWindowShown}.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *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.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-04-22 17:39:12 +00:00
|
|
|
bool waitForWindowDestroyed(Window *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
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-08-16 06:19:45 +00:00
|
|
|
bool lockScreen();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unlocks the screen and waits till the screen is unlocked.
|
|
|
|
* @returns @c true if the screen could be unlocked, @c false otherwise
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-08-16 06:19:45 +00:00
|
|
|
bool unlockScreen();
|
2021-05-08 00:08:22 +00:00
|
|
|
|
|
|
|
void initWaylandWorkspace();
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *inputPanelClient();
|
2021-12-23 08:42:00 +00:00
|
|
|
MockInputMethod *inputMethod();
|
2021-07-20 23:37:58 +00:00
|
|
|
KWayland::Client::Surface *inputPanelSurface();
|
|
|
|
|
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)
|
2020-09-02 09:27:08 +00:00
|
|
|
Q_DECLARE_METATYPE(KWin::Test::XdgToplevel::States)
|
2021-05-11 05:26:51 +00:00
|
|
|
Q_DECLARE_METATYPE(QtWayland::zxdg_toplevel_decoration_v1::mode)
|
2016-06-30 11:32:54 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
#define WAYLANDTEST_MAIN_HELPER(TestObject, DPI, OperationMode) \
|
|
|
|
int main(int argc, char *argv[]) \
|
|
|
|
{ \
|
|
|
|
setenv("QT_QPA_PLATFORM", "wayland-org.kde.kwin.qpa", true); \
|
|
|
|
setenv("QT_QPA_PLATFORM_PLUGIN_PATH", QFileInfo(QString::fromLocal8Bit(argv[0])).absolutePath().toLocal8Bit().constData(), true); \
|
|
|
|
setenv("KWIN_FORCE_OWN_QPA", "1", true); \
|
|
|
|
qunsetenv("KDE_FULL_SESSION"); \
|
|
|
|
qunsetenv("KDE_SESSION_VERSION"); \
|
|
|
|
qunsetenv("XDG_SESSION_DESKTOP"); \
|
|
|
|
qunsetenv("XDG_CURRENT_DESKTOP"); \
|
|
|
|
DPI; \
|
|
|
|
KWin::WaylandTestApplication app(OperationMode, argc, argv); \
|
|
|
|
app.setAttribute(Qt::AA_Use96Dpi, true); \
|
|
|
|
TestObject tc; \
|
|
|
|
return QTest::qExec(&tc, argc, argv); \
|
|
|
|
}
|
2015-10-02 13:04:57 +00:00
|
|
|
|
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
|