Commit 7558fc24 authored by Robert Hoffmann's avatar Robert Hoffmann
Browse files

Unpress modifiers on focusOutEvent in VncView

Key combinations like Alt-Tab, Alt-F2, Alt-F3, Alt-F4 or Ctrl-Alt-Delete are
not effective on the remote desktop but local. The remote desktop looses its
focus but pressed modifier keys like Alt, Ctrl, Shift, Meta,... stay pressed,
rendering the remote desktop unusable.

This patch releases the modifier keys on focus loss.

Test: Press key combinations with modifier keys and check that the remote desktop
stays usable, e.g. while connected to a remote desktop, type some text into a
terminal or text application, then press Alt-Tab to change focus to a different
local window. Press Alt-Tab again to switch back to krdc and type some text again.

Without this patch, the Alt modifier is still active on the remote side and typing
text will fail. With the patch applied typing is successful.

Try other modifiers, too, e.g press the Ctrl-key, hold it and mouseclick some other
local window to get focus. Release the Ctrl-key and mouseclick krdc again. Do the
typing test.

Enable KRDC.debug logging and check the "VncView::unpressModifiers key=" message.

BUG: 329951
parent e88fd1c5
......@@ -686,7 +686,8 @@ void VncView::keyEventHandler(QKeyEvent *e)
const bool pressed = (e->type() == QEvent::KeyPress);
// handle modifiers
if (k == XK_Shift_L || k == XK_Control_L || k == XK_Meta_L || k == XK_Alt_L) {
if (k == XK_Shift_L || k == XK_Control_L || k == XK_Meta_L || k == XK_Alt_L || XK_Super_L || XK_Hyper_L ||
k == XK_Shift_R || k == XK_Control_R || k == XK_Meta_R || k == XK_Alt_R || XK_Super_R || XK_Hyper_R) {
if (pressed) {
m_mods[k] = true;
} else if (m_mods.contains(k)) {
......@@ -706,6 +707,7 @@ void VncView::unpressModifiers()
const QList<unsigned int> keys = m_mods.keys();
QList<unsigned int>::const_iterator it = keys.constBegin();
while (it != keys.end()) {
qCDebug(KRDC) << "VncView::unpressModifiers key=" << (*it);
vncThread.keyEvent(*it, false);
......@@ -725,4 +727,12 @@ void VncView::clipboardDataChanged()
void VncView::focusOutEvent(QFocusEvent *event)
qCDebug(KRDC) << "VncView::focusOutEvent";
#include "moc_vncview.cpp"
......@@ -81,6 +81,7 @@ protected:
bool event(QEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
bool eventFilter(QObject *obj, QEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
VncClientThread vncThread;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment