[wayland] Change keyboard focus window when active window changes
We used to change it only on keypresses. This resulted in the strange situation that e.g. the input method virtual keyboard doesn't show up until one presses a real key, because e.g. maliit only activates the keyboard if there is an active focus object in the Qt application.
This commit is contained in:
parent
98bcdbe70a
commit
01ac0abfd7
2 changed files with 39 additions and 16 deletions
53
input.cpp
53
input.cpp
|
@ -256,6 +256,7 @@ InputRedirection::InputRedirection(QObject *parent)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
connect(kwinApp(), &Application::workspaceCreated, this, &InputRedirection::setupWorkspace);
|
||||
}
|
||||
|
||||
InputRedirection::~InputRedirection()
|
||||
|
@ -263,6 +264,15 @@ InputRedirection::~InputRedirection()
|
|||
s_self = NULL;
|
||||
}
|
||||
|
||||
void InputRedirection::setupWorkspace()
|
||||
{
|
||||
#if HAVE_WAYLAND
|
||||
if (waylandServer()) {
|
||||
connect(workspace(), &Workspace::clientActivated, this, &InputRedirection::updateKeyboardWindow);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HAVE_WAYLAND
|
||||
static KWayland::Server::SeatInterface *findSeat()
|
||||
{
|
||||
|
@ -732,6 +742,32 @@ void InputRedirection::processPointerAxis(InputRedirection::PointerAxis axis, qr
|
|||
#endif
|
||||
}
|
||||
|
||||
void InputRedirection::updateKeyboardWindow()
|
||||
{
|
||||
#if HAVE_WAYLAND
|
||||
if (!workspace()) {
|
||||
return;
|
||||
}
|
||||
if (auto seat = findSeat()) {
|
||||
// TODO: this needs better integration
|
||||
// check unmanaged
|
||||
Toplevel *t = nullptr;
|
||||
if (!workspace()->unmanagedList().isEmpty()) {
|
||||
// TODO: better check whether this unmanaged should get the key event
|
||||
t = workspace()->unmanagedList().first();
|
||||
}
|
||||
if (!t) {
|
||||
t = workspace()->activeClient();
|
||||
}
|
||||
if (t && t->surface()) {
|
||||
if (t->surface() != seat->focusedKeyboardSurface()) {
|
||||
seat->setFocusedKeyboardSurface(t->surface());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void InputRedirection::processKeyboardKey(uint32_t key, InputRedirection::KeyboardKeyState state, uint32_t time)
|
||||
{
|
||||
#if HAVE_XKB
|
||||
|
@ -786,22 +822,7 @@ void InputRedirection::processKeyboardKey(uint32_t key, InputRedirection::Keyboa
|
|||
#if HAVE_WAYLAND
|
||||
if (auto seat = findSeat()) {
|
||||
seat->setTimestamp(time);
|
||||
// TODO: this needs better integration
|
||||
// check unmanaged
|
||||
Toplevel *t = nullptr;
|
||||
if (!workspace()->unmanagedList().isEmpty()) {
|
||||
// TODO: better check whether this unmanaged should get the key event
|
||||
t = workspace()->unmanagedList().first();
|
||||
}
|
||||
if (!t) {
|
||||
t = workspace()->activeClient();
|
||||
}
|
||||
if (t && t->surface()) {
|
||||
if (t->surface() != seat->focusedKeyboardSurface()) {
|
||||
seat->setFocusedKeyboardSurface(t->surface());
|
||||
}
|
||||
state == InputRedirection::KeyboardKeyPressed ? seat->keyPressed(key) : seat->keyReleased(key);
|
||||
}
|
||||
state == InputRedirection::KeyboardKeyPressed ? seat->keyPressed(key) : seat->keyReleased(key);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
2
input.h
2
input.h
|
@ -197,6 +197,8 @@ private:
|
|||
void pointerInternalWindowVisibilityChanged(bool visible);
|
||||
void installCursorFromDecoration();
|
||||
bool areButtonsPressed() const;
|
||||
void updateKeyboardWindow();
|
||||
void setupWorkspace();
|
||||
QPointF m_globalPointer;
|
||||
QHash<uint32_t, PointerButtonState> m_pointerButtons;
|
||||
#if HAVE_XKB
|
||||
|
|
Loading…
Reference in a new issue