Grab keyboard based on focus in windows client
Grab keyboard based on focus in windows client

Currently the client grabs keyboard based on session focus, on windows
environment gtk sends grab_broken if wm_killfocus is received (when
focus is changed) while the application has the grab. It means that
when grab is based on the session, clicking inside focusless window
will cause wm_killfocus to be sent towards the focused window, this
will generate grab_broken event which follows by no grab at all.

This patch expands the solution presented in 143ebfd to work also on
windows client without causing grab_broken event.
This is implemented a bit differently from linux, if on mouse entrance
session already has focus, focus will be set to the current window,
this will generate focus events that will release and take grab again
without grab_broken event.

Resolves: rhbz#1429611
Related: rhbz#1275231

Acked-by: Victor Toso <39b7599ff73bbf5db531748ba5250f21fa7120ff@redhat.com>

flexVDI/spice-gtk,flexVDI/spice-gtk