Module smithay::wayland::output[][src]

Expand description

Output advertising capabilities

This module provides a type helping you to handle the advertising of your compositor’s output and their capabilities to your client, as well as mapping your clients output request to your physical outputs.

How to use it

You need to instantiate an Output for each output global you want to advertise to clients.

Just add it to your Display using the Output::new(..) method. You can use the returned Output to change the properties of your output (if the current resolution mode changes for example), it’ll automatically forward any changes to the clients.

use smithay::wayland::output::{Output, PhysicalProperties, Mode};
use wayland_server::protocol::wl_output;

// Create the Output with given name and physical properties
let (output, _output_global) = Output::new(
    &mut display,      // the display
    "output-0".into(), // the name of this output,
    PhysicalProperties {
        size: (200, 150).into(),        // dimensions (width, height) in mm
        subpixel: wl_output::Subpixel::HorizontalRgb,  // subpixel information
        make: "Screens Inc".into(),     // make of the monitor
        model: "Monitor Ultra".into(),  // model of the monitor
    },
    None // insert a logger here
);
// Now you can configure it
output.change_current_state(
    Some(Mode { size: (1920, 1080).into(), refresh: 60000 }), // the resolution mode,
    Some(wl_output::Transform::Normal), // global screen transformation
    Some(1), // global screen scaling factor
    Some((0,0).into()) // output position
);
// set the preferred mode
output.set_preferred(Mode { size: (1920, 1080).into(), refresh: 60000 });
// add other supported modes
output.add_mode(Mode { size: (800, 600).into(), refresh: 60000 });
output.add_mode(Mode { size: (1024, 768).into(), refresh: 60000 });

Modules

XDG Output advertising capabilities

Structs

An output mode

An output as seen by the clients

The physical properties of an output