Introduce KeyboardInteractivity enum
This commit is contained in:
		
							parent
							
								
									549f5ad682
								
							
						
					
					
						commit
						11a811061f
					
				
					 6 changed files with 95 additions and 20 deletions
				
			
		| 
						 | 
					@ -24,7 +24,7 @@ public:
 | 
				
			||||||
    QString scope = QStringLiteral("window");
 | 
					    QString scope = QStringLiteral("window");
 | 
				
			||||||
    Window::Anchors anchors = {Window::AnchorTop | Window::AnchorBottom | Window::AnchorLeft | Window::AnchorRight};
 | 
					    Window::Anchors anchors = {Window::AnchorTop | Window::AnchorBottom | Window::AnchorLeft | Window::AnchorRight};
 | 
				
			||||||
    int32_t exclusionZone = 0;
 | 
					    int32_t exclusionZone = 0;
 | 
				
			||||||
    bool keyboardInteractivity = true;
 | 
					    Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityExclusive;
 | 
				
			||||||
    Window::Layer layer = Window::LayerTop;
 | 
					    Window::Layer layer = Window::LayerTop;
 | 
				
			||||||
    QMargins margins;
 | 
					    QMargins margins;
 | 
				
			||||||
    QWaylandLayerSurface *getSurface() const;
 | 
					    QWaylandLayerSurface *getSurface() const;
 | 
				
			||||||
| 
						 | 
					@ -76,15 +76,15 @@ QMargins Window::margins() const
 | 
				
			||||||
    return d->margins;
 | 
					    return d->margins;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Window::setKeyboardInteractivity(bool enabled)
 | 
					void Window::setKeyboardInteractivity(KeyboardInteractivity interactivity)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    d->keyboardInteractivity = enabled;
 | 
					    d->keyboardInteractivity = interactivity;
 | 
				
			||||||
    if (auto surface = d->getSurface()) {
 | 
					    if (auto surface = d->getSurface()) {
 | 
				
			||||||
        surface->setKeyboardInteractivity(enabled);
 | 
					        surface->setKeyboardInteractivity(interactivity);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool Window::keyboardInteractivity() const
 | 
					Window::KeyboardInteractivity Window::keyboardInteractivity() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return d->keyboardInteractivity;
 | 
					    return d->keyboardInteractivity;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,6 +43,16 @@ public:
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    Q_ENUM(Layer)
 | 
					    Q_ENUM(Layer)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * This enum type is used to specify how the layer surface handles keyboard focus.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    enum KeyboardInteractivity {
 | 
				
			||||||
 | 
					        KeyboardInteractivityNone = 0,
 | 
				
			||||||
 | 
					        KeyboardInteractivityExclusive = 1,
 | 
				
			||||||
 | 
					        KeyboardInteractivityOnDemand = 2,
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    Q_ENUM(KeyboardInteractivity)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void setAnchors(Anchors anchor);
 | 
					    void setAnchors(Anchors anchor);
 | 
				
			||||||
    Anchors anchors() const;
 | 
					    Anchors anchors() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,8 +62,8 @@ public:
 | 
				
			||||||
    void setMargins(const QMargins &margins);
 | 
					    void setMargins(const QMargins &margins);
 | 
				
			||||||
    QMargins margins() const;
 | 
					    QMargins margins() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void setKeyboardInteractivity(bool enabled);
 | 
					    void setKeyboardInteractivity(KeyboardInteractivity interactivity);
 | 
				
			||||||
    bool keyboardInteractivity() const;
 | 
					    KeyboardInteractivity keyboardInteractivity() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void setLayer(Layer layer);
 | 
					    void setLayer(Layer layer);
 | 
				
			||||||
    Layer layer() const;
 | 
					    Layer layer() const;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,7 @@ void QWaylandLayerShellIntegration::registryLayer(void *data, struct wl_registry
 | 
				
			||||||
    QWaylandLayerShellIntegration *shell = static_cast<QWaylandLayerShellIntegration *>(data);
 | 
					    QWaylandLayerShellIntegration *shell = static_cast<QWaylandLayerShellIntegration *>(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (interface == zwlr_layer_shell_v1_interface.name)
 | 
					    if (interface == zwlr_layer_shell_v1_interface.name)
 | 
				
			||||||
        shell->m_layerShell = new QWaylandLayerShell(new QtWayland::zwlr_layer_shell_v1(registry, id, std::min(version, 3u)));
 | 
					        shell->m_layerShell = new QWaylandLayerShell(new QtWayland::zwlr_layer_shell_v1(registry, id, std::min(version, 4u)));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -89,9 +89,9 @@ void QWaylandLayerSurface::setMargins(const QMargins &margins)
 | 
				
			||||||
    set_margin(margins.top(), margins.right(), margins.bottom(), margins.left());
 | 
					    set_margin(margins.top(), margins.right(), margins.bottom(), margins.left());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void QWaylandLayerSurface::setKeyboardInteractivity(bool enabled)
 | 
					void QWaylandLayerSurface::setKeyboardInteractivity(uint32_t interactivity)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    set_keyboard_interactivity(enabled);
 | 
					    set_keyboard_interactivity(interactivity);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void QWaylandLayerSurface::setLayer(uint32_t layer)
 | 
					void QWaylandLayerSurface::setLayer(uint32_t layer)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,7 +33,7 @@ public:
 | 
				
			||||||
    void setAnchor(uint32_t anchor);
 | 
					    void setAnchor(uint32_t anchor);
 | 
				
			||||||
    void setExclusiveZone(int32_t zone);
 | 
					    void setExclusiveZone(int32_t zone);
 | 
				
			||||||
    void setMargins(const QMargins &margins);
 | 
					    void setMargins(const QMargins &margins);
 | 
				
			||||||
    void setKeyboardInteractivity(bool enabled);
 | 
					    void setKeyboardInteractivity(uint32_t interactivity);
 | 
				
			||||||
    void setLayer(uint32_t layer);
 | 
					    void setLayer(uint32_t layer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void applyConfigure() override;
 | 
					    void applyConfigure() override;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,7 @@
 | 
				
			||||||
    THIS SOFTWARE.
 | 
					    THIS SOFTWARE.
 | 
				
			||||||
  </copyright>
 | 
					  </copyright>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <interface name="zwlr_layer_shell_v1" version="3">
 | 
					  <interface name="zwlr_layer_shell_v1" version="4">
 | 
				
			||||||
    <description summary="create surfaces that are layers of the desktop">
 | 
					    <description summary="create surfaces that are layers of the desktop">
 | 
				
			||||||
      Clients can use this interface to assign the surface_layer role to
 | 
					      Clients can use this interface to assign the surface_layer role to
 | 
				
			||||||
      wl_surfaces. Such surfaces are assigned to a "layer" of the output and
 | 
					      wl_surfaces. Such surfaces are assigned to a "layer" of the output and
 | 
				
			||||||
| 
						 | 
					@ -100,7 +100,7 @@
 | 
				
			||||||
    </request>
 | 
					    </request>
 | 
				
			||||||
  </interface>
 | 
					  </interface>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <interface name="zwlr_layer_surface_v1" version="3">
 | 
					  <interface name="zwlr_layer_surface_v1" version="4">
 | 
				
			||||||
    <description summary="layer metadata interface">
 | 
					    <description summary="layer metadata interface">
 | 
				
			||||||
      An interface that may be implemented by a wl_surface, for surfaces that
 | 
					      An interface that may be implemented by a wl_surface, for surfaces that
 | 
				
			||||||
      are designed to be rendered as a layer of a stacked desktop-like
 | 
					      are designed to be rendered as a layer of a stacked desktop-like
 | 
				
			||||||
| 
						 | 
					@ -203,21 +203,85 @@
 | 
				
			||||||
      <arg name="left" type="int"/>
 | 
					      <arg name="left" type="int"/>
 | 
				
			||||||
    </request>
 | 
					    </request>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <enum name="keyboard_interactivity">
 | 
				
			||||||
 | 
					      <description summary="types of keyboard interaction possible for a layer shell surface">
 | 
				
			||||||
 | 
					        Types of keyboard interaction possible for layer shell surfaces. The
 | 
				
			||||||
 | 
					        rationale for this is twofold: (1) some applications are not interested
 | 
				
			||||||
 | 
					        in keyboard events and not allowing them to be focused can improve the
 | 
				
			||||||
 | 
					        desktop experience; (2) some applications will want to take exclusive
 | 
				
			||||||
 | 
					        keyboard focus.
 | 
				
			||||||
 | 
					      </description>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      <entry name="none" value="0">
 | 
				
			||||||
 | 
					        <description summary="no keyboard focus is possible">
 | 
				
			||||||
 | 
					          This value indicates that this surface is not interested in keyboard
 | 
				
			||||||
 | 
					          events and the compositor should never assign it the keyboard focus.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          This is the default value, set for newly created layer shell surfaces.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          This is useful for e.g. desktop widgets that display information or
 | 
				
			||||||
 | 
					          only have interaction with non-keyboard input devices.
 | 
				
			||||||
 | 
					        </description>
 | 
				
			||||||
 | 
					      </entry>
 | 
				
			||||||
 | 
					      <entry name="exclusive" value="1">
 | 
				
			||||||
 | 
					        <description summary="request exclusive keyboard focus">
 | 
				
			||||||
 | 
					          Request exclusive keyboard focus if this surface is above the shell surface layer.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          For the top and overlay layers, the seat will always give
 | 
				
			||||||
 | 
					          exclusive keyboard focus to the top-most layer which has keyboard
 | 
				
			||||||
 | 
					          interactivity set to exclusive. If this layer contains multiple
 | 
				
			||||||
 | 
					          surfaces with keyboard interactivity set to exclusive, the compositor
 | 
				
			||||||
 | 
					          determines the one receiving keyboard events in an implementation-
 | 
				
			||||||
 | 
					          defined manner. In this case, no guarantee is made when this surface
 | 
				
			||||||
 | 
					          will receive keyboard focus (if ever).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          For the bottom and background layers, the compositor is allowed to use
 | 
				
			||||||
 | 
					          normal focus semantics.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          This setting is mainly intended for applications that need to ensure
 | 
				
			||||||
 | 
					          they receive all keyboard events, such as a lock screen or a password
 | 
				
			||||||
 | 
					          prompt.
 | 
				
			||||||
 | 
					        </description>
 | 
				
			||||||
 | 
					      </entry>
 | 
				
			||||||
 | 
					      <entry name="on_demand" value="2" since="4">
 | 
				
			||||||
 | 
					        <description summary="request regular keyboard focus semantics">
 | 
				
			||||||
 | 
					          This requests the compositor to allow this surface to be focused and
 | 
				
			||||||
 | 
					          unfocused by the user in an implementation-defined manner. The user
 | 
				
			||||||
 | 
					          should be able to unfocus this surface even regardless of the layer
 | 
				
			||||||
 | 
					          it is on.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          Typically, the compositor will want to use its normal mechanism to
 | 
				
			||||||
 | 
					          manage keyboard focus between layer shell surfaces with this setting
 | 
				
			||||||
 | 
					          and regular toplevels on the desktop layer (e.g. click to focus).
 | 
				
			||||||
 | 
					          Nevertheless, it is possible for a compositor to require a special
 | 
				
			||||||
 | 
					          interaction to focus or unfocus layer shell surfaces (e.g. requiring
 | 
				
			||||||
 | 
					          a click even if focus follows the mouse normally, or providing a
 | 
				
			||||||
 | 
					          keybinding to switch focus between layers).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          This setting is mainly intended for desktop shell components (e.g.
 | 
				
			||||||
 | 
					          panels) that allow keyboard interaction. Using this option can allow
 | 
				
			||||||
 | 
					          implementing a desktop shell that can be fully usable without the
 | 
				
			||||||
 | 
					          mouse.
 | 
				
			||||||
 | 
					        </description>
 | 
				
			||||||
 | 
					      </entry>
 | 
				
			||||||
 | 
					    </enum>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <request name="set_keyboard_interactivity">
 | 
					    <request name="set_keyboard_interactivity">
 | 
				
			||||||
      <description summary="requests keyboard events">
 | 
					      <description summary="requests keyboard events">
 | 
				
			||||||
        Set to 1 to request that the seat send keyboard events to this layer
 | 
					        Set how keyboard events are delivered to this surface. By default,
 | 
				
			||||||
        surface. For layers below the shell surface layer, the seat will use
 | 
					        layer shell surfaces do not receive keyboard events; this request can
 | 
				
			||||||
        normal focus semantics. For layers above the shell surface layers, the
 | 
					        be used to change this.
 | 
				
			||||||
        seat will always give exclusive keyboard focus to the top-most layer
 | 
					
 | 
				
			||||||
        which has keyboard interactivity set to true.
 | 
					        This setting is inherited by child surfaces set by the get_popup
 | 
				
			||||||
 | 
					        request.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Layer surfaces receive pointer, touch, and tablet events normally. If
 | 
					        Layer surfaces receive pointer, touch, and tablet events normally. If
 | 
				
			||||||
        you do not want to receive them, set the input region on your surface
 | 
					        you do not want to receive them, set the input region on your surface
 | 
				
			||||||
        to an empty region.
 | 
					        to an empty region.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Events is double-buffered, see wl_surface.commit.
 | 
					        Keyboard interactivity is double-buffered, see wl_surface.commit.
 | 
				
			||||||
      </description>
 | 
					      </description>
 | 
				
			||||||
      <arg name="keyboard_interactivity" type="uint"/>
 | 
					      <arg name="keyboard_interactivity" type="uint" enum="keyboard_interactivity"/>
 | 
				
			||||||
    </request>
 | 
					    </request>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <request name="get_popup">
 | 
					    <request name="get_popup">
 | 
				
			||||||
| 
						 | 
					@ -302,6 +366,7 @@
 | 
				
			||||||
      <entry name="invalid_surface_state" value="0" summary="provided surface state is invalid"/>
 | 
					      <entry name="invalid_surface_state" value="0" summary="provided surface state is invalid"/>
 | 
				
			||||||
      <entry name="invalid_size" value="1" summary="size is invalid"/>
 | 
					      <entry name="invalid_size" value="1" summary="size is invalid"/>
 | 
				
			||||||
      <entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/>
 | 
					      <entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/>
 | 
				
			||||||
 | 
					      <entry name="invalid_keyboard_interactivity" value="3" summary="keyboard interactivity is invalid"/>
 | 
				
			||||||
    </enum>
 | 
					    </enum>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <enum name="anchor" bitfield="true">
 | 
					    <enum name="anchor" bitfield="true">
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue