xwayland: Make xinerama index -> Output mapping more robust with fractional scaling

xdg-output-v1 uses the fractional geometry, so also use it when mapping
a xinerama screen index to an Output.
This commit is contained in:
Vlad Zahorodnii 2024-01-10 14:08:40 +02:00
parent 61699e9ed3
commit 66b1462cf8
4 changed files with 69 additions and 3 deletions

View file

@ -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})

View file

@ -0,0 +1,65 @@
/*
SPDX-FileCopyrightText: 2024 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
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"

View file

@ -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);
}

View file

@ -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;
}
}