wayland_frontend only.Expand description
Utilities for manipulating the primary selection
The primary selection is an additional protocol modeled after the data device to represent and additional selection (copy/paste), a concept taken from the X11 Server. This primary selection is a shortcut to the common clipboard selection, where text just needs to be selected in order to allow copying it elsewhere The de facto way to perform this action is the middle mouse button, although it is not limited to this one.
This module provides the freestanding set_primary_focus function:
This function sets the data device focus for a given seat; you’d typically call it
whenever the keyboard focus changes, to follow it (for example in the focus hook of your keyboards).
The module also provides an additional mechanism allowing your compositor to see and interact with the contents of the primary selection:
- the freestanding function
set_primary_selectionallows you to set the contents of the selection for your clients - the
PrimarySelectionHandlegives you the option to inspect new selections by overridingSelectionHandler::new_selection.
§Initialization
To initialize this implementation, create the PrimarySelectionState, store it inside your State struct
and implement the PrimarySelectionHandler and SelectionHandler, as shown in this example:
use smithay::delegate_primary_selection;
use smithay::wayland::selection::SelectionHandler;
use smithay::wayland::selection::primary_selection::{PrimarySelectionState, PrimarySelectionHandler};
// Create the primary_selection state
let primary_selection_state = PrimarySelectionState::new::<State>(
&display.handle(),
);
// insert the PrimarySelectionState into your state
// ..
// implement the necessary traits
impl SelectionHandler for State {
type SelectionUserData = ();
}
impl PrimarySelectionHandler for State {
fn primary_selection_state(&mut self) -> &mut PrimarySelectionState { &mut self.primary_selection_state }
// ... override default implementations here to customize handling ...
}
delegate_primary_selection!(State);
// You're now ready to go!Structs§
- Primary
Selection State - State of the primary selection.
- Source
Metadata - The metadata describing a data source
Enums§
- Selection
Request Error - Errors happening when requesting selection contents
Traits§
- Primary
Selection Handler - Access the primary selection state.
Functions§
- clear_
primary_ selection - Clear the current selection for this seat
- current_
primary_ selection_ userdata - Gets the user_data for the currently active selection, if set by the compositor
- request_
primary_ client_ selection - Request the current primary selection of the given seat to be written to the provided file descriptor with the given mime type.
- set_
primary_ focus - Set the primary selection focus to a certain client for a given seat
- set_
primary_ selection - Set a compositor-provided primary selection for this seat