pointer_input: position cursor on the primary output after a placeholder

this improves the out of the box behavior which has regressed a bit over
time. since we default to kcfg_ActiveMouseScreen=true the active screen
by default follows the pointer. during early startup we position the
pointer on a Placeholder output, this output does eventually get
replaced by the real output(s). because of the update logic we'd
re-position the pointer on the closest real output, but that isn't
necessarily the intended primary output.

e.g. consider an eDP + HDMI setup depending on the geometries involved
the cursor may end up on the HDMI screen by default rather than the eDP
resulting in plasma-welcome opening on the HDMI output.

to mitigate this problem we now track whether the last output was a
placeholder and if so we instead try to position the pointer on the
current primary output
This commit is contained in:
Harald Sitter 2023-11-09 11:22:41 +01:00
parent 0b8b9b70bb
commit b8fb43db95
2 changed files with 18 additions and 5 deletions

View file

@ -5,6 +5,7 @@
SPDX-FileCopyrightText: 2013, 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-FileCopyrightText: 2023 Harald Sitter <sitter@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
@ -805,12 +806,23 @@ void PointerInputRedirection::updateAfterScreenChange()
if (!inited()) {
return;
}
if (screenContainsPos(m_pos)) {
// pointer still on a screen
return;
Output *output = nullptr;
if (m_lastOutputWasPlaceholder) {
// previously we've positioned our pointer on a placeholder screen, try
// to get us onto the real "primary" screen instead.
output = workspace()->outputOrder().at(0);
} else {
if (screenContainsPos(m_pos)) {
// pointer still on a screen
return;
}
// pointer no longer on a screen, reposition to closes screen
output = workspace()->outputAt(m_pos);
}
// pointer no longer on a screen, reposition to closes screen
const Output *output = workspace()->outputAt(m_pos);
m_lastOutputWasPlaceholder = output->isPlaceholder();
// TODO: better way to get timestamps
processMotionAbsolute(output->geometry().center(), waylandServer()->seat()->timestamp());
}

View file

@ -175,6 +175,7 @@ private:
bool m_confined = false;
bool m_locked = false;
bool m_enableConstraints = true;
bool m_lastOutputWasPlaceholder = true;
friend class PositionUpdateBlocker;
};