qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] ui/cocoa: Clear modifiers whenever possible


From: Gerd Hoffmann
Subject: Re: [PATCH] ui/cocoa: Clear modifiers whenever possible
Date: Tue, 9 Mar 2021 12:24:22 +0100

On Fri, Mar 05, 2021 at 09:19:09PM +0900, Akihiko Odaki wrote:
> ui/cocoa does not receive NSEventTypeFlagsChanged when it is not active,
> and the modifier state can be desynchronized in such a situation.
> 
> [NSEvent -modifierFlags] tells whether a modifier is *not* pressed, so
> check it whenever receiving an event and clear the modifier if it is not
> pressed.
> 
> Note that [NSEvent -modifierFlags] does not tell if a certain modifier
> *is* pressed because the documented mask for [NSEvent -modifierFlags]
> generalizes left shift and right shift, for example. CapsLock is the
> only exception. The pressed state is synchronized only with
> NSEventTypeFlagsChanged.
> 
> This change also removes modifier keys from keycode map. If they
> are input with NSEventTypeKeyDown or NSEventTypeKeyUp, it leads to
> desynchronization. Although such a situation is not observed, they are
> removed just in case.

Have you noticed / looked at ui/kbd-state.c?

This provides a bunch of helper functions to track key and modifier
state.  The other UIs used to have their own keystate tracking too,
but most switched over meanwhile.  Nobody did it for cocoa yet, but
looking at your changes I suspect at the end it might be easier to
switch over cocoa to the shared too instead of trying to fix the
private implementation ...

take care,
  Gerd




reply via email to

[Prev in Thread] Current Thread [Next in Thread]