gtk-session: do not sync modifiers when focused

Spice gtk-session would try to synchronize the modifiers state whenever
the keymap changes, but doing so is inherently racy.

While the there is a keyboard grab in effect, all key events are
forwarded to the guest, hence all modifiers key press get processed by
the kernel on the guest.

Trying to synchronize the modifiers will generate additional key press/
release events which will result in the opposite effect and effectively
desynchronize the modifier states in the guest.

Synchronizing modifiers from the host should therefore be limited to
focus change, as actual press/release events might have occurred without
the guest knowing. Otherwise, no need to synchronize the modifiers.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
4 jobs for modifiers-sync in 1 minute and 43 seconds (queued for 1 second)
latest
Status Job ID Name Coverage
  Test
failed #221733
fedora-autotools

00:01:43

failed #221734
fedora-meson

00:01:39

failed #221735
windows-autotools

00:01:39

failed #221736
windows-meson

00:01:42

 
Name Stage Failure
failed
fedora-autotools Test
Complete!
$ git clone ${CI_REPOSITORY_URL/spice-gtk/spice-protocol}
Cloning into 'spice-protocol'...
remote: The project you were looking for could not be found.
fatal: repository 'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.freedesktop.org/ofourdan/spice-protocol.git/' not found
Uploading artifacts...
WARNING: tests/*.log: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1
failed
windows-meson Test
$ git clone ${CI_REPOSITORY_URL/spice-gtk/spice-protocol}
Cloning into 'spice-protocol'...
remote: The project you were looking for could not be found.
fatal: repository 'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.freedesktop.org/ofourdan/spice-protocol.git/' not found
Uploading artifacts...
WARNING: build-win64/meson-logs/*.txt: no matching files
WARNING: spice-protocol/build-spice-protocol/meson-logs/*.txt: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1
failed
windows-autotools Test
  xz-5.2.4-3.fc29.x86_64                                                        
zip-3.0-23.fc29.x86_64

Complete!
$ git clone ${CI_REPOSITORY_URL/spice-gtk/spice-protocol}
Cloning into 'spice-protocol'...
remote: The project you were looking for could not be found.
fatal: repository 'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.freedesktop.org/ofourdan/spice-protocol.git/' not found
ERROR: Job failed: exit code 1
failed
fedora-meson Test
Complete!
$ git clone ${CI_REPOSITORY_URL/spice-gtk/spice-protocol}
Cloning into 'spice-protocol'...
remote: The project you were looking for could not be found.
fatal: repository 'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.freedesktop.org/ofourdan/spice-protocol.git/' not found
Uploading artifacts...
WARNING: build-*/meson-logs/*.txt: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1