[PATCH 2/2 v3] Add keyboard shortcuts inhibitor

Jonas Ådahl jadahl at gmail.com
Wed Apr 12 09:04:01 UTC 2017


On Wed, Apr 05, 2017 at 02:30:15PM +0200, Olivier Fourdan wrote:
> This adds a new protocol to let Wayland clients specify that they want
> all keyboard events to be send to the client, regardless of the
> compositor own shortcuts.
> 
> This is for use by virtual machine and remote connections viewers.

Look out for style nits (especially now that Yong has cleaned up
inconsistencies in the other protocol XML files!), but there are some
other comments below too.

> 
> Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
> ---
>  v2: Clarify that that the compositor is under no obligation to ignore
>      every shortcut (ajax)
>      Add "inhibit_active" and "inhibit_inactive" events to notify clients
>      Add "already_inhibited" error
>  v3: Rename "inhibit_active" and "inhibit_inactive" events to simply
>      "active" and "inactive" and fix some Tab in the middle of the text.
> 
>  Makefile.am                                        |   1 +
>  unstable/keyboard-shortcuts-inhibit/README         |   4 +
>  .../keyboard-shortcuts-inhibit-unstable-v1.xml     | 132 +++++++++++++++++++++
>  3 files changed, 137 insertions(+)
>  create mode 100644 unstable/keyboard-shortcuts-inhibit/README
>  create mode 100644 unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml
> 
> diff --git a/Makefile.am b/Makefile.am
> index 12465e6..d100c13 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -13,6 +13,7 @@ unstable_protocols =								\
>  	unstable/xdg-foreign/xdg-foreign-unstable-v1.xml			\
>  	unstable/idle-inhibit/idle-inhibit-unstable-v1.xml			\
>  	unstable/xwayland-keyboard-grab/xwayland-keyboard-grab-unstable-v1.xml	\
> +	unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml \
>  	$(NULL)
>  
>  stable_protocols =								\
> diff --git a/unstable/keyboard-shortcuts-inhibit/README b/unstable/keyboard-shortcuts-inhibit/README
> new file mode 100644
> index 0000000..63ff335
> --- /dev/null
> +++ b/unstable/keyboard-shortcuts-inhibit/README
> @@ -0,0 +1,4 @@
> +Compositor shortcuts inhibit protocol
> +
> +Maintainers:
> +Olivier Fourdan <ofourdan at redhat.com>
> diff --git a/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml b/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml
> new file mode 100644
> index 0000000..bb35de1
> --- /dev/null
> +++ b/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml
> @@ -0,0 +1,132 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<protocol name="keyboard_shortcuts_inhibit_unstable_v1">
> +
> +  <copyright>
> +	Copyright © 2017 Red Hat Inc.
> +
> +	Permission is hereby granted, free of charge, to any person obtaining a
> +	copy of this software and associated documentation files (the "Software"),
> +	to deal in the Software without restriction, including without limitation
> +	the rights to use, copy, modify, merge, publish, distribute, sublicense,
> +	and/or sell copies of the Software, and to permit persons to whom the
> +	Software is furnished to do so, subject to the following conditions:
> +
> +	The above copyright notice and this permission notice (including the next
> +	paragraph) shall be included in all copies or substantial portions of the
> +	Software.
> +
> +	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> +	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> +	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> +	THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> +	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> +	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> +	DEALINGS IN THE SOFTWARE.

Indentation issue.

> +  </copyright>
> +
> +  <description summary="Protocol for inhibitting the compositor keyboard shortcuts">
> +	This protocol specifies a way for a client to request the compositor
> +	to ignore its own keyboard shortcuts, so that all keyboard events
> +	get forwarded to a surface.
> +
> +	Warning! The protocol described in this file is experimental and
> +	backward incompatible changes may be made. Backward compatible
> +	changes may be added together with the corresponding interface
> +	version bump.
> +	Backward incompatible changes are done by bumping the version
> +	number in the protocol and interface names and resetting the
> +	interface version. Once the protocol is to be declared stable,
> +	the 'z' prefix and the version number in the protocol and
> +	interface names are removed and the interface version number is
> +	reset.

Indentation issue

> +  </description>
> +
> +  <interface name="zwp_keyboard_shortcuts_inhibit_manager_v1" version="1">
> +

Stray newline, and missing <description>.

> +    <request name="destroy" type="destructor">
> +      <description summary="destroy the keyboard shortcuts inhibitor object">
> +	Destroy the keyboard shortcuts inhibitor manager.
> +      </description>
> +    </request>
> +
> +    <request name="inhibit_shortcuts">
> +      <description summary="create a new keyboard shortcuts inhibitor object">
> +	Create a new keyboard shortcuts inhibitor object associated with the given surface.
> +
> +	If shortcuts are already inhibited for the given surface, a protocol error
> +	"already_inhibited" is raised by the compositor.
> +      </description>
> +      <arg name="id" type="new_id" interface="zwp_keyboard_shortcuts_inhibitor_v1"/>
> +      <arg name="surface" type="object" interface="wl_surface"
> +	   summary="the surface that inhibits the keyboard shortcuts behavior"/>
> +    </request>
> +
> +  </interface>
> +
> +  <interface name="zwp_keyboard_shortcuts_inhibitor_v1" version="1">
> +    <description summary="context object for keyboard shortcuts inhibitor">

Wrong indentation below.

> +	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.

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?

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.

> +    </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.

> +       </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
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list