Warning, file /plasma/kwin/autotests/integration/kwin_wayland_test.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #ifndef KWIN_WAYLAND_TEST_H 0010 #define KWIN_WAYLAND_TEST_H 0011 0012 #include "core/inputdevice.h" 0013 #include "main.h" 0014 #include "window.h" 0015 0016 // Qt 0017 #include <QtTest> 0018 0019 #include <KWayland/Client/surface.h> 0020 0021 #include "qwayland-fractional-scale-v1.h" 0022 #include "qwayland-idle-inhibit-unstable-v1.h" 0023 #include "qwayland-input-method-unstable-v1.h" 0024 #include "qwayland-kde-output-device-v2.h" 0025 #include "qwayland-kde-output-management-v2.h" 0026 #include "qwayland-text-input-unstable-v3.h" 0027 #include "qwayland-wlr-layer-shell-unstable-v1.h" 0028 #include "qwayland-xdg-decoration-unstable-v1.h" 0029 #include "qwayland-xdg-shell.h" 0030 0031 namespace KWayland 0032 { 0033 namespace Client 0034 { 0035 class AppMenuManager; 0036 class ConnectionThread; 0037 class Compositor; 0038 class Output; 0039 class PlasmaShell; 0040 class PlasmaWindowManagement; 0041 class PointerConstraints; 0042 class Seat; 0043 class ServerSideDecorationManager; 0044 class ShadowManager; 0045 class ShmPool; 0046 class SubCompositor; 0047 class SubSurface; 0048 class Surface; 0049 class TextInputManager; 0050 } 0051 } 0052 0053 namespace QtWayland 0054 { 0055 class zwp_input_panel_surface_v1; 0056 class zwp_text_input_v3; 0057 class zwp_text_input_manager_v3; 0058 } 0059 0060 namespace KWin 0061 { 0062 namespace Xwl 0063 { 0064 class Xwayland; 0065 } 0066 0067 namespace Test 0068 { 0069 class VirtualInputDevice; 0070 } 0071 0072 class WaylandTestApplication : public Application 0073 { 0074 Q_OBJECT 0075 public: 0076 WaylandTestApplication(OperationMode mode, int &argc, char **argv); 0077 ~WaylandTestApplication() override; 0078 0079 void setInputMethodServerToStart(const QString &inputMethodServer) 0080 { 0081 m_inputMethodServerToStart = inputMethodServer; 0082 } 0083 0084 Test::VirtualInputDevice *virtualPointer() const; 0085 Test::VirtualInputDevice *virtualKeyboard() const; 0086 Test::VirtualInputDevice *virtualTouch() const; 0087 XwaylandInterface *xwayland() const override; 0088 0089 protected: 0090 void performStartup() override; 0091 0092 private: 0093 void continueStartupWithScene(); 0094 void finalizeStartup(); 0095 0096 void createVirtualInputDevices(); 0097 void destroyVirtualInputDevices(); 0098 0099 std::unique_ptr<Xwl::Xwayland> m_xwayland; 0100 QString m_inputMethodServerToStart; 0101 0102 std::unique_ptr<Test::VirtualInputDevice> m_virtualPointer; 0103 std::unique_ptr<Test::VirtualInputDevice> m_virtualKeyboard; 0104 std::unique_ptr<Test::VirtualInputDevice> m_virtualTouch; 0105 }; 0106 0107 namespace Test 0108 { 0109 0110 class MockInputMethod; 0111 0112 class TextInputManagerV3 : public QtWayland::zwp_text_input_manager_v3 0113 { 0114 public: 0115 ~TextInputManagerV3() override 0116 { 0117 destroy(); 0118 } 0119 }; 0120 0121 class TextInputV3 : public QObject, public QtWayland::zwp_text_input_v3 0122 { 0123 Q_OBJECT 0124 public: 0125 ~TextInputV3() override 0126 { 0127 destroy(); 0128 } 0129 0130 Q_SIGNALS: 0131 void preeditString(const QString &text, int cursor_begin, int cursor_end); 0132 0133 protected: 0134 void zwp_text_input_v3_preedit_string(const QString &text, int32_t cursor_begin, int32_t cursor_end) override 0135 { 0136 Q_EMIT preeditString(text, cursor_begin, cursor_end); 0137 } 0138 }; 0139 0140 class LayerShellV1 : public QtWayland::zwlr_layer_shell_v1 0141 { 0142 public: 0143 ~LayerShellV1() override; 0144 }; 0145 0146 class LayerSurfaceV1 : public QObject, public QtWayland::zwlr_layer_surface_v1 0147 { 0148 Q_OBJECT 0149 0150 public: 0151 ~LayerSurfaceV1() override; 0152 0153 protected: 0154 void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override; 0155 void zwlr_layer_surface_v1_closed() override; 0156 0157 Q_SIGNALS: 0158 void closeRequested(); 0159 void configureRequested(quint32 serial, const QSize &size); 0160 }; 0161 0162 /** 0163 * The XdgShell class represents the @c xdg_wm_base global. 0164 */ 0165 class XdgShell : public QtWayland::xdg_wm_base 0166 { 0167 public: 0168 ~XdgShell() override; 0169 void xdg_wm_base_ping(uint32_t serial) override 0170 { 0171 pong(serial); 0172 } 0173 }; 0174 0175 /** 0176 * The XdgSurface class represents an xdg_surface object. 0177 */ 0178 class XdgSurface : public QObject, public QtWayland::xdg_surface 0179 { 0180 Q_OBJECT 0181 0182 public: 0183 explicit XdgSurface(XdgShell *shell, KWayland::Client::Surface *surface, QObject *parent = nullptr); 0184 ~XdgSurface() override; 0185 0186 KWayland::Client::Surface *surface() const; 0187 0188 Q_SIGNALS: 0189 void configureRequested(quint32 serial); 0190 0191 protected: 0192 void xdg_surface_configure(uint32_t serial) override; 0193 0194 private: 0195 KWayland::Client::Surface *m_surface; 0196 }; 0197 0198 /** 0199 * The XdgToplevel class represents an xdg_toplevel surface. Note that the XdgToplevel surface 0200 * takes the ownership of the underlying XdgSurface object. 0201 */ 0202 class XdgToplevel : public QObject, public QtWayland::xdg_toplevel 0203 { 0204 Q_OBJECT 0205 0206 public: 0207 enum class State { 0208 Maximized = 1 << 0, 0209 Fullscreen = 1 << 1, 0210 Resizing = 1 << 2, 0211 Activated = 1 << 3 0212 }; 0213 Q_DECLARE_FLAGS(States, State) 0214 0215 explicit XdgToplevel(XdgSurface *surface, QObject *parent = nullptr); 0216 ~XdgToplevel() override; 0217 0218 XdgSurface *xdgSurface() const; 0219 0220 Q_SIGNALS: 0221 void configureRequested(const QSize &size, KWin::Test::XdgToplevel::States states); 0222 void closeRequested(); 0223 0224 protected: 0225 void xdg_toplevel_configure(int32_t width, int32_t height, wl_array *states) override; 0226 void xdg_toplevel_close() override; 0227 0228 private: 0229 std::unique_ptr<XdgSurface> m_xdgSurface; 0230 }; 0231 0232 /** 0233 * The XdgPositioner class represents an xdg_positioner object. 0234 */ 0235 class XdgPositioner : public QtWayland::xdg_positioner 0236 { 0237 public: 0238 explicit XdgPositioner(XdgShell *shell); 0239 ~XdgPositioner() override; 0240 }; 0241 0242 /** 0243 * The XdgPopup class represents an xdg_popup surface. Note that the XdgPopup surface takes 0244 * the ownership of the underlying XdgSurface object. 0245 */ 0246 class XdgPopup : public QObject, public QtWayland::xdg_popup 0247 { 0248 Q_OBJECT 0249 0250 public: 0251 XdgPopup(XdgSurface *surface, XdgSurface *parentSurface, XdgPositioner *positioner, QObject *parent = nullptr); 0252 ~XdgPopup() override; 0253 0254 XdgSurface *xdgSurface() const; 0255 0256 Q_SIGNALS: 0257 void configureRequested(const QRect &rect); 0258 void doneReceived(); 0259 0260 protected: 0261 void xdg_popup_configure(int32_t x, int32_t y, int32_t width, int32_t height) override; 0262 void xdg_popup_popup_done() override; 0263 0264 private: 0265 std::unique_ptr<XdgSurface> m_xdgSurface; 0266 }; 0267 0268 class XdgDecorationManagerV1 : public QtWayland::zxdg_decoration_manager_v1 0269 { 0270 public: 0271 ~XdgDecorationManagerV1() override; 0272 }; 0273 0274 class XdgToplevelDecorationV1 : public QObject, public QtWayland::zxdg_toplevel_decoration_v1 0275 { 0276 Q_OBJECT 0277 0278 public: 0279 XdgToplevelDecorationV1(XdgDecorationManagerV1 *manager, XdgToplevel *toplevel, QObject *parent = nullptr); 0280 ~XdgToplevelDecorationV1() override; 0281 0282 Q_SIGNALS: 0283 void configureRequested(QtWayland::zxdg_toplevel_decoration_v1::mode mode); 0284 0285 protected: 0286 void zxdg_toplevel_decoration_v1_configure(uint32_t mode) override; 0287 }; 0288 0289 class IdleInhibitManagerV1 : public QtWayland::zwp_idle_inhibit_manager_v1 0290 { 0291 public: 0292 ~IdleInhibitManagerV1() override; 0293 }; 0294 0295 class IdleInhibitorV1 : public QtWayland::zwp_idle_inhibitor_v1 0296 { 0297 public: 0298 IdleInhibitorV1(IdleInhibitManagerV1 *manager, KWayland::Client::Surface *surface); 0299 ~IdleInhibitorV1() override; 0300 }; 0301 0302 class WaylandOutputConfigurationV2 : public QObject, public QtWayland::kde_output_configuration_v2 0303 { 0304 Q_OBJECT 0305 public: 0306 WaylandOutputConfigurationV2(struct ::kde_output_configuration_v2 *object); 0307 0308 Q_SIGNALS: 0309 void applied(); 0310 void failed(); 0311 0312 protected: 0313 void kde_output_configuration_v2_applied() override; 0314 void kde_output_configuration_v2_failed() override; 0315 }; 0316 0317 class WaylandOutputManagementV2 : public QObject, public QtWayland::kde_output_management_v2 0318 { 0319 Q_OBJECT 0320 public: 0321 WaylandOutputManagementV2(struct ::wl_registry *registry, int id, int version); 0322 0323 WaylandOutputConfigurationV2 *createConfiguration(); 0324 }; 0325 0326 class WaylandOutputDeviceV2Mode : public QObject, public QtWayland::kde_output_device_mode_v2 0327 { 0328 Q_OBJECT 0329 0330 public: 0331 WaylandOutputDeviceV2Mode(struct ::kde_output_device_mode_v2 *object); 0332 ~WaylandOutputDeviceV2Mode() override; 0333 0334 int refreshRate() const; 0335 QSize size() const; 0336 bool preferred() const; 0337 0338 bool operator==(const WaylandOutputDeviceV2Mode &other); 0339 0340 static WaylandOutputDeviceV2Mode *get(struct ::kde_output_device_mode_v2 *object); 0341 0342 Q_SIGNALS: 0343 void removed(); 0344 0345 protected: 0346 void kde_output_device_mode_v2_size(int32_t width, int32_t height) override; 0347 void kde_output_device_mode_v2_refresh(int32_t refresh) override; 0348 void kde_output_device_mode_v2_preferred() override; 0349 void kde_output_device_mode_v2_removed() override; 0350 0351 private: 0352 int m_refreshRate = 60000; 0353 QSize m_size; 0354 bool m_preferred = false; 0355 }; 0356 0357 class WaylandOutputDeviceV2 : public QObject, public QtWayland::kde_output_device_v2 0358 { 0359 Q_OBJECT 0360 0361 public: 0362 WaylandOutputDeviceV2(int id); 0363 ~WaylandOutputDeviceV2() override; 0364 0365 QByteArray edid() const; 0366 bool enabled() const; 0367 int id() const; 0368 QString name() const; 0369 QString model() const; 0370 QString manufacturer() const; 0371 qreal scale() const; 0372 QPoint globalPosition() const; 0373 QSize pixelSize() const; 0374 int refreshRate() const; 0375 uint32_t vrrPolicy() const; 0376 uint32_t overscan() const; 0377 uint32_t capabilities() const; 0378 uint32_t rgbRange() const; 0379 0380 QString modeId() const; 0381 0382 Q_SIGNALS: 0383 void enabledChanged(); 0384 void done(); 0385 0386 protected: 0387 void kde_output_device_v2_geometry(int32_t x, 0388 int32_t y, 0389 int32_t physical_width, 0390 int32_t physical_height, 0391 int32_t subpixel, 0392 const QString &make, 0393 const QString &model, 0394 int32_t transform) override; 0395 void kde_output_device_v2_current_mode(struct ::kde_output_device_mode_v2 *mode) override; 0396 void kde_output_device_v2_mode(struct ::kde_output_device_mode_v2 *mode) override; 0397 void kde_output_device_v2_done() override; 0398 void kde_output_device_v2_scale(wl_fixed_t factor) override; 0399 void kde_output_device_v2_edid(const QString &raw) override; 0400 void kde_output_device_v2_enabled(int32_t enabled) override; 0401 void kde_output_device_v2_uuid(const QString &uuid) override; 0402 void kde_output_device_v2_serial_number(const QString &serialNumber) override; 0403 void kde_output_device_v2_eisa_id(const QString &eisaId) override; 0404 void kde_output_device_v2_capabilities(uint32_t flags) override; 0405 void kde_output_device_v2_overscan(uint32_t overscan) override; 0406 void kde_output_device_v2_vrr_policy(uint32_t vrr_policy) override; 0407 void kde_output_device_v2_rgb_range(uint32_t rgb_range) override; 0408 0409 private: 0410 QString modeName(const WaylandOutputDeviceV2Mode *m) const; 0411 WaylandOutputDeviceV2Mode *deviceModeFromId(const int modeId) const; 0412 0413 WaylandOutputDeviceV2Mode *m_mode; 0414 QList<WaylandOutputDeviceV2Mode *> m_modes; 0415 0416 int m_id; 0417 QPoint m_pos; 0418 QSize m_physicalSize; 0419 int32_t m_subpixel; 0420 QString m_manufacturer; 0421 QString m_model; 0422 int32_t m_transform; 0423 qreal m_factor; 0424 QByteArray m_edid; 0425 int32_t m_enabled; 0426 QString m_uuid; 0427 QString m_serialNumber; 0428 QString m_eisaId; 0429 uint32_t m_flags; 0430 uint32_t m_overscan; 0431 uint32_t m_vrr_policy; 0432 uint32_t m_rgbRange; 0433 }; 0434 0435 class MockInputMethod : public QObject, QtWayland::zwp_input_method_v1 0436 { 0437 Q_OBJECT 0438 public: 0439 MockInputMethod(struct wl_registry *registry, int id, int version); 0440 ~MockInputMethod(); 0441 0442 KWayland::Client::Surface *inputPanelSurface() const 0443 { 0444 return m_inputSurface.get(); 0445 } 0446 auto *context() const 0447 { 0448 return m_context; 0449 } 0450 0451 Q_SIGNALS: 0452 void activate(); 0453 0454 protected: 0455 void zwp_input_method_v1_activate(struct ::zwp_input_method_context_v1 *context) override; 0456 void zwp_input_method_v1_deactivate(struct ::zwp_input_method_context_v1 *context) override; 0457 0458 private: 0459 std::unique_ptr<KWayland::Client::Surface> m_inputSurface; 0460 QtWayland::zwp_input_panel_surface_v1 *m_inputMethodSurface = nullptr; 0461 struct ::zwp_input_method_context_v1 *m_context = nullptr; 0462 }; 0463 0464 class FractionalScaleManagerV1 : public QObject, public QtWayland::wp_fractional_scale_manager_v1 0465 { 0466 Q_OBJECT 0467 public: 0468 ~FractionalScaleManagerV1() override; 0469 }; 0470 0471 class FractionalScaleV1 : public QObject, public QtWayland::wp_fractional_scale_v1 0472 { 0473 Q_OBJECT 0474 public: 0475 ~FractionalScaleV1() override; 0476 int preferredScale(); 0477 0478 protected: 0479 void wp_fractional_scale_v1_preferred_scale(uint32_t scale) override; 0480 0481 private: 0482 int m_preferredScale = 120; 0483 }; 0484 0485 enum class AdditionalWaylandInterface { 0486 Seat = 1 << 0, 0487 Decoration = 1 << 1, 0488 PlasmaShell = 1 << 2, 0489 WindowManagement = 1 << 3, 0490 PointerConstraints = 1 << 4, 0491 IdleInhibitV1 = 1 << 5, 0492 AppMenu = 1 << 6, 0493 ShadowManager = 1 << 7, 0494 XdgDecorationV1 = 1 << 8, 0495 OutputManagementV2 = 1 << 9, 0496 TextInputManagerV2 = 1 << 10, 0497 InputMethodV1 = 1 << 11, 0498 LayerShellV1 = 1 << 12, 0499 TextInputManagerV3 = 1 << 13, 0500 OutputDeviceV2 = 1 << 14, 0501 FractionalScaleManagerV1 = 1 << 15, 0502 }; 0503 Q_DECLARE_FLAGS(AdditionalWaylandInterfaces, AdditionalWaylandInterface) 0504 0505 class VirtualInputDevice : public InputDevice 0506 { 0507 Q_OBJECT 0508 0509 public: 0510 explicit VirtualInputDevice(QObject *parent = nullptr); 0511 0512 void setPointer(bool set); 0513 void setKeyboard(bool set); 0514 void setTouch(bool set); 0515 void setName(const QString &name); 0516 0517 QString sysName() const override; 0518 QString name() const override; 0519 0520 bool isEnabled() const override; 0521 void setEnabled(bool enabled) override; 0522 0523 LEDs leds() const override; 0524 void setLeds(LEDs leds) override; 0525 0526 bool isKeyboard() const override; 0527 bool isAlphaNumericKeyboard() const override; 0528 bool isPointer() const override; 0529 bool isTouchpad() const override; 0530 bool isTouch() const override; 0531 bool isTabletTool() const override; 0532 bool isTabletPad() const override; 0533 bool isTabletModeSwitch() const override; 0534 bool isLidSwitch() const override; 0535 0536 private: 0537 QString m_name; 0538 bool m_pointer = false; 0539 bool m_keyboard = false; 0540 bool m_touch = false; 0541 }; 0542 0543 void keyboardKeyPressed(quint32 key, quint32 time); 0544 void keyboardKeyReleased(quint32 key, quint32 time); 0545 void pointerAxisHorizontal(qreal delta, 0546 quint32 time, 0547 qint32 discreteDelta = 0, 0548 InputRedirection::PointerAxisSource source = InputRedirection::PointerAxisSourceUnknown); 0549 void pointerAxisVertical(qreal delta, 0550 quint32 time, 0551 qint32 discreteDelta = 0, 0552 InputRedirection::PointerAxisSource source = InputRedirection::PointerAxisSourceUnknown); 0553 void pointerButtonPressed(quint32 button, quint32 time); 0554 void pointerButtonReleased(quint32 button, quint32 time); 0555 void pointerMotion(const QPointF &position, quint32 time); 0556 void pointerMotionRelative(const QPointF &delta, quint32 time); 0557 void touchCancel(); 0558 void touchDown(qint32 id, const QPointF &pos, quint32 time); 0559 void touchMotion(qint32 id, const QPointF &pos, quint32 time); 0560 void touchUp(qint32 id, quint32 time); 0561 0562 /** 0563 * Creates a Wayland Connection in a dedicated thread and creates various 0564 * client side objects which can be used to create windows. 0565 * @returns @c true if created successfully, @c false if there was an error 0566 * @see destroyWaylandConnection 0567 */ 0568 bool setupWaylandConnection(AdditionalWaylandInterfaces flags = AdditionalWaylandInterfaces()); 0569 0570 /** 0571 * Destroys the Wayland Connection created with @link{setupWaylandConnection}. 0572 * This can be called from cleanup in order to ensure that no Wayland Connection 0573 * leaks into the next test method. 0574 * @see setupWaylandConnection 0575 */ 0576 void destroyWaylandConnection(); 0577 0578 KWayland::Client::ConnectionThread *waylandConnection(); 0579 KWayland::Client::Compositor *waylandCompositor(); 0580 KWayland::Client::SubCompositor *waylandSubCompositor(); 0581 KWayland::Client::ShadowManager *waylandShadowManager(); 0582 KWayland::Client::ShmPool *waylandShmPool(); 0583 KWayland::Client::Seat *waylandSeat(); 0584 KWayland::Client::ServerSideDecorationManager *waylandServerSideDecoration(); 0585 KWayland::Client::PlasmaShell *waylandPlasmaShell(); 0586 KWayland::Client::PlasmaWindowManagement *waylandWindowManagement(); 0587 KWayland::Client::PointerConstraints *waylandPointerConstraints(); 0588 KWayland::Client::AppMenuManager *waylandAppMenuManager(); 0589 WaylandOutputManagementV2 *waylandOutputManagementV2(); 0590 KWayland::Client::TextInputManager *waylandTextInputManager(); 0591 QVector<KWayland::Client::Output *> waylandOutputs(); 0592 KWayland::Client::Output *waylandOutput(const QString &name); 0593 QVector<WaylandOutputDeviceV2 *> waylandOutputDevicesV2(); 0594 0595 bool waitForWaylandSurface(Window *window); 0596 0597 bool waitForWaylandPointer(); 0598 bool waitForWaylandTouch(); 0599 bool waitForWaylandKeyboard(); 0600 0601 void flushWaylandConnection(); 0602 0603 std::unique_ptr<KWayland::Client::Surface> createSurface(); 0604 KWayland::Client::SubSurface *createSubSurface(KWayland::Client::Surface *surface, 0605 KWayland::Client::Surface *parentSurface, QObject *parent = nullptr); 0606 0607 LayerSurfaceV1 *createLayerSurfaceV1(KWayland::Client::Surface *surface, 0608 const QString &scope, 0609 KWayland::Client::Output *output = nullptr, 0610 LayerShellV1::layer layer = LayerShellV1::layer_top); 0611 0612 TextInputManagerV3 *waylandTextInputManagerV3(); 0613 0614 enum class CreationSetup { 0615 CreateOnly, 0616 CreateAndConfigure, /// commit and wait for the configure event, making this surface ready to commit buffers 0617 }; 0618 0619 QtWayland::zwp_input_panel_surface_v1 *createInputPanelSurfaceV1(KWayland::Client::Surface *surface, 0620 KWayland::Client::Output *output); 0621 0622 FractionalScaleV1 *createFractionalScaleV1(KWayland::Client::Surface *surface); 0623 0624 XdgToplevel *createXdgToplevelSurface(KWayland::Client::Surface *surface, QObject *parent = nullptr); 0625 XdgToplevel *createXdgToplevelSurface(KWayland::Client::Surface *surface, 0626 CreationSetup configureMode, 0627 QObject *parent = nullptr); 0628 0629 XdgPositioner *createXdgPositioner(); 0630 0631 XdgPopup *createXdgPopupSurface(KWayland::Client::Surface *surface, XdgSurface *parentSurface, 0632 XdgPositioner *positioner, 0633 CreationSetup configureMode = CreationSetup::CreateAndConfigure, 0634 QObject *parent = nullptr); 0635 0636 XdgToplevelDecorationV1 *createXdgToplevelDecorationV1(XdgToplevel *toplevel, QObject *parent = nullptr); 0637 IdleInhibitorV1 *createIdleInhibitorV1(KWayland::Client::Surface *surface); 0638 0639 /** 0640 * Creates a shared memory buffer of @p size in @p color and attaches it to the @p surface. 0641 * The @p surface gets damaged and committed, thus it's rendered. 0642 */ 0643 void render(KWayland::Client::Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format = QImage::Format_ARGB32_Premultiplied); 0644 0645 /** 0646 * Creates a shared memory buffer using the supplied image @p img and attaches it to the @p surface 0647 */ 0648 void render(KWayland::Client::Surface *surface, const QImage &img); 0649 0650 /** 0651 * Waits till a new Window is shown and returns the created Window. 0652 * If no Window gets shown during @p timeout @c null is returned. 0653 */ 0654 Window *waitForWaylandWindowShown(int timeout = 5000); 0655 0656 /** 0657 * Combination of @link{render} and @link{waitForWaylandWindowShown}. 0658 */ 0659 Window *renderAndWaitForShown(KWayland::Client::Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format = QImage::Format_ARGB32, int timeout = 5000); 0660 0661 /** 0662 * Waits for the @p window to be destroyed. 0663 */ 0664 bool waitForWindowDestroyed(Window *window); 0665 0666 /** 0667 * Locks the screen and waits till the screen is locked. 0668 * @returns @c true if the screen could be locked, @c false otherwise 0669 */ 0670 bool lockScreen(); 0671 0672 /** 0673 * Unlocks the screen and waits till the screen is unlocked. 0674 * @returns @c true if the screen could be unlocked, @c false otherwise 0675 */ 0676 bool unlockScreen(); 0677 0678 MockInputMethod *inputMethod(); 0679 KWayland::Client::Surface *inputPanelSurface(); 0680 0681 } 0682 0683 } 0684 0685 Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Test::AdditionalWaylandInterfaces) 0686 Q_DECLARE_METATYPE(KWin::Test::XdgToplevel::States) 0687 Q_DECLARE_METATYPE(QtWayland::zxdg_toplevel_decoration_v1::mode) 0688 0689 #define WAYLANDTEST_MAIN_HELPER(TestObject, DPI, OperationMode) \ 0690 int main(int argc, char *argv[]) \ 0691 { \ 0692 setenv("QT_QPA_PLATFORM", "wayland-org.kde.kwin.qpa", true); \ 0693 setenv("QT_QPA_PLATFORM_PLUGIN_PATH", QFileInfo(QString::fromLocal8Bit(argv[0])).absolutePath().toLocal8Bit().constData(), true); \ 0694 setenv("KWIN_FORCE_OWN_QPA", "1", true); \ 0695 qunsetenv("KDE_FULL_SESSION"); \ 0696 qunsetenv("KDE_SESSION_VERSION"); \ 0697 qunsetenv("XDG_SESSION_DESKTOP"); \ 0698 qunsetenv("XDG_CURRENT_DESKTOP"); \ 0699 DPI; \ 0700 KWin::WaylandTestApplication app(OperationMode, argc, argv); \ 0701 app.setAttribute(Qt::AA_Use96Dpi, true); \ 0702 TestObject tc; \ 0703 return QTest::qExec(&tc, argc, argv); \ 0704 } 0705 0706 #ifdef NO_XWAYLAND 0707 #define WAYLANDTEST_MAIN(TestObject) WAYLANDTEST_MAIN_HELPER(TestObject, QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps), KWin::Application::OperationModeWaylandOnly) 0708 #else 0709 #define WAYLANDTEST_MAIN(TestObject) WAYLANDTEST_MAIN_HELPER(TestObject, QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps), KWin::Application::OperationModeXwayland) 0710 #endif 0711 0712 #endif