Fix input focus for KDM's dialogs when GrabInput is not active
Review Request #121755 - Created July 29, 2015 and submitted
Commit d03df616 made input grabbing optional in KDM. But without it, input dialogs do not correctly get focus and keyboard shortcuts don't work.
KDM does call activateWindow() on opened dialogs, but this doesn't seem to have the desired effect without a window manager running. And if you hover the mouse over a widget, it visually looks like it has focus, but often it doesn't accept input anyway.
This patch sets the input focus via XSetInputFocus() instead, this also has the positive side-effect that a widget retains the focus if you move the mouse away.
Tried all things mentioned in the bug reports, keyboard input and shortcuts work now in all cases.
I also tested with onboard keyboards (xvkbd and kvkbd), both work fine. Before, kvkbd didn't work at all (the text input widget lost focus as soon as you moved the mouse to the OSK) and xvkbd only works if you forced the focus to the text input widget via its "Focus" button (from which this patch was inspired actually ;-) ).
Other openSUSE users have tested this as well, and the patch is even part of openSUSE's official package since January.
See also https://bugzilla.opensuse.org/show_bug.cgi?id=772344
This is Qt4, right?
::activateWindow() should be equivalent to "XSetInputFocus(display, winId(), XRevertToParent, X11->time);" unless
a) _NET_ACTIVE_WINDOW is listed in _NET_SUPPORTED on the root window (supposed to be set and withdrawn by window managers, crash on exit?)
b) Qt::X11BypassWindowManagerHint is NOT set on the toplevel window
c) the window is not mapped/waiting for a mapping notification
=> If the problem occurs, login aside (VT1 or ssh) and
xprop -root | grep _NET_ACTIVE_WINDOW
If that's emtpy, focus setting fails on either "qt_widget_private(tlw)->topData()->waitingForMapNotify" (qt bug in event handling? missing "XSync(dpy, false)"? events are being processed after show) or "X11->time" being superseded by a more recent/future XSetInputFocus call ("fixed" by passing CurrentTime)
If the feature /is/ listed, that's a bug caused by a crashing WM => setting Qt::X11BypassWindowManagerHint will likely be sufficient.