[PATCH 2/2 v3] Add keyboard shortcuts inhibitor

Olivier Fourdan ofourdan at redhat.com
Thu Apr 27 12:52:43 UTC 2017


Hi Jonas,

> > [...]
> > +	A keyboard shortcuts inhibitor instructs the compositor to ignore
> > +	its own keyboard shortcuts when the associated surface has keyboard
> > +	focus. As a result, when the surface is focused, it will receive all
> > +	keyboard events, even those which would normally be caught by the
> > +	compositor for its own shortcuts.
> > +
> > +	The Wayland compositor is however under no obligation to disable
> > +	all of its shortcuts, and may keep some special key combo for its own
> > +	use, including but not limited to one allowing the user to forcibly
> > +	restore normal keyboard events routing in the case of an unwilling
> > +	client.
> > +
> > +	If the surface is destroyed, unmapped, or loses keyboard focus, the
> > +	the compositor will restore its own keyboard shortcuts.
> > +
> > +	When the compositor restores its own keyboard shortcuts, an
> > +	"inactive" event is emitted to notify the client that the keyboard
> > +	shortcuts inhibitor is not effectively active for the surface any
> > +	more, and the client should not expect to receive all keyboard events.
> > +
> > +	When the keyboard shortcuts inhibitor is inactive, either because
> > +	the user has requested it using any mechanism the compositor may offer
> > +	or because the surface doesn't have keyboard focus, the client has
> > +	no way to forcibly reactivate the keyboard shortcuts inhibitor.
> > +
> > +	When the surface regains keyboard focus, the inhibitor will take effect
> > +	again and an "active" event emitted to notify the client.
> 
> I think we should loosen up the details for when an "active" event may
> be sent again. For example, if a user presses the magic combination
> deactivating the inhibitation, but never leaves the surface in question,
> it might want to do that without switching focus back and forth.

Right, I don't have strong opinions about that myself, do we really need to send a "deactivate" on focus lost and an "activate" event when focus is regained? 

The client itself should not expect any key event delivery from the compositor when the surface doesn't have keyboard focus, even less the compositor own shortcuts.

That would leave the activate/deactivate events to what they really mean, i.e. activate or deactivate an existing shortcut-inhibitor requested by the client, like for example when using a compositor specific key combo.
 
> Also, what happens if there multiple seats active? Do we need to make
> this protocol seat aware or do we assume that all seats want their
> shortcuts inhibited, and if so, what seats keyboard focus takes
> precedence, or is it any seats keyboard focus?

Well, initially, I reckoned it would be easier to apply the shortcut inhibitor to all seats, but on a second thought, making the protocol seat aware makes sense.

That raises another question then, do we need to pass the seat serial as well there? I guess we ought to, don't we?

> A third thing, is, do we care about letting the client know about the
> magic combination? The client could help with displaying how to
> uninhibit, and we could possibly avoid ending up with multiple ways to
> uninhibit, as the client will most likely have one way, and the
> compositor another.
> 
> The client and compositor "sharing" the magic combination would also
> enable more predictable enabling/disabling interaction. For example, if
> a client destroys the inhibitation on deactivation, in order to update
> the user interface to explicitly require re-enabling, one can only use
> the compositor side magic combo to *disable* the inhibitation, but never
> enable. This is a bit awkward, as it's AFAIK often the same combination
> that is used for both enabling and disabling. Without this, we'd end up
> with the application side magic combo used most often, and the
> compositor side magic combo, mostly unused due to inconvenience thus
> forgotten.

If the compositor has to "tell" the client what key combo is used to enable/disable an existing shortcut inhibitor, we also need to add an event to notify if the key combo is modified as the compositor may even have that configurable (i.e. a client requests shortcuts to be inhibited, the user disable the shortcut inhibitor, then changes the compositor settings to use another key combo, the compositor needs to send an event telling the new key combo so the client can update its own shortcut).

> > +    </description>
> > +
> > +    <request name="destroy" type="destructor">
> > +      <description summary="destroy the keyboard shortcuts inhibitor
> > object">
> > +	Remove the keyboard shortcuts inhibitor from the associated wl_surface.
> > +      </description>
> > +    </request>
> > +
> > +    <event name="active">
> > +      <description summary="shortcuts are inhibited">
> > +	This event indicates that the shortcut inhibitor is active.
> > +
> > +	The compositor will send this event every time it deactivates its
> > +	shortcuts for the given surface, this occurs typically when the
> > +	surface which requested keyboard shortcuts inhibit regains focus
> > +	or when the initial request "inhibit_shortcuts" becomes active.
> > +      </description>
> > +    </event>
> > +
> > +    <event name="inactive">
> > +      <description summary="shortcuts are restored">
> > +	This event indicates that the shortcuts inhibitor is inactive,
> > +	regular shortcuts processing is restored by the compositor.
> > +
> > +	The compositor will send this event when the surface loses keyboard
> > +	focus or when the user restores the keyboard shortcuts using any
> > +	mechanism offered by the compositor.
> 
> Or some other reason, that doesn't really need to be listed her. Screen
> lock enabling, for example, does not fall under anything here. So
> changing the wording to allow *anything* to trigger this would be good.

I reckon screen locking involves a loss of keyboard focus. But anyhow, as said above, I think activate/deactivate events should be left for user activation of existing inhibitor, so I would even remove that entirely and leave just explicit activation and deactivation events, if that makes sense.

> > +       </description>
> > +    </event>
> > +
> > +    <enum name="error">
> > +      <entry name="already_inhibited"
> > +	     value="0"
> > +	     summary="the shortcuts are already inhibited for this surface"/>
> > +    </enum>
> > +
> > +  </interface>
> > +</protocol>
> > --
> > 2.9.3

Cheers,
Olivier


More information about the xorg-devel mailing list