diff --git a/autotests/integration/CMakeLists.txt b/autotests/integration/CMakeLists.txt index 8eb2135441..80255f6ef4 100644 --- a/autotests/integration/CMakeLists.txt +++ b/autotests/integration/CMakeLists.txt @@ -131,6 +131,7 @@ integrationTest(NAME testXwaylandServerRestart SRCS xwaylandserver_restart_test. integrationTest(NAME testFakeInput SRCS fakeinput_test.cpp) integrationTest(NAME testSecurityContext SRCS security_context_test.cpp) integrationTest(NAME testStickyKeys SRCS sticky_keys_test.cpp) +integrationTest(NAME testXinerama SRCS xinerama_test.cpp) qt_add_dbus_interfaces(DBUS_SRCS ${CMAKE_BINARY_DIR}/src/org.kde.kwin.VirtualKeyboard.xml) integrationTest(NAME testVirtualKeyboardDBus SRCS test_virtualkeyboard_dbus.cpp ${DBUS_SRCS}) diff --git a/autotests/integration/xinerama_test.cpp b/autotests/integration/xinerama_test.cpp new file mode 100644 index 0000000000..2ad3b30791 --- /dev/null +++ b/autotests/integration/xinerama_test.cpp @@ -0,0 +1,65 @@ +/* + SPDX-FileCopyrightText: 2024 Vlad Zahorodnii + + SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "kwin_wayland_test.h" + +#include "core/output.h" +#include "wayland_server.h" +#include "workspace.h" + +namespace KWin +{ + +static const QString s_socketName = QStringLiteral("wayland_test_kwin_xinerama-0"); + +class XineramaTest : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void initTestCase(); + void indexToOutput(); +}; + +void XineramaTest::initTestCase() +{ + QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); + QVERIFY(waylandServer()->init(s_socketName)); + kwinApp()->start(); + QVERIFY(applicationStartedSpy.wait()); +} + +void XineramaTest::indexToOutput() +{ + Test::setOutputConfig({ + Test::OutputInfo{ + .geometry = QRect(0, 0, 1280, 1024), + .scale = 1.5, + }, + Test::OutputInfo{ + .geometry = QRect(1280, 0, 1280, 1024), + .scale = 1.5, + }, + }); + kwinApp()->setXwaylandScale(1.5); + + // Start Xwayland + Test::XcbConnectionPtr c = Test::createX11Connection(); + QVERIFY(!xcb_connection_has_error(c.get())); + + const auto outputs = workspace()->outputs(); + QCOMPARE(workspace()->xineramaIndexToOutput(0), outputs.at(0)); + QCOMPARE(workspace()->xineramaIndexToOutput(1), outputs.at(1)); + + workspace()->setOutputOrder({outputs[1], outputs[0]}); + QCOMPARE(workspace()->xineramaIndexToOutput(0), outputs.at(1)); + QCOMPARE(workspace()->xineramaIndexToOutput(1), outputs.at(0)); +} + +} // namespace KWin + +WAYLANDTEST_MAIN(KWin::XineramaTest) +#include "xinerama_test.moc" diff --git a/src/wayland/xdgoutput_v1.cpp b/src/wayland/xdgoutput_v1.cpp index 78a98425d1..56a83f5e1a 100644 --- a/src/wayland/xdgoutput_v1.cpp +++ b/src/wayland/xdgoutput_v1.cpp @@ -108,8 +108,8 @@ XdgOutputV1Interface::XdgOutputV1Interface(OutputInterface *output) name = handle->name(); description = handle->description(); - pos = handle->geometry().topLeft(); - size = handle->geometry().size(); + pos = handle->fractionalGeometry().topLeft(); + size = handle->fractionalGeometry().size(); connect(handle, &Output::geometryChanged, this, &XdgOutputV1Interface::update); } diff --git a/src/workspace.cpp b/src/workspace.cpp index 09c3a388c2..bbd8c3b2e4 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -2518,7 +2518,7 @@ Output *Workspace::xineramaIndexToOutput(int index) const const QRect needle(infos[index].x_org, infos[index].y_org, infos[index].width, infos[index].height); for (Output *output : std::as_const(m_outputs)) { - if (Xcb::toXNative(output->geometry()) == needle) { + if (Xcb::toXNative(output->fractionalGeometry()) == needle) { return output; } }