config: allow retrieving the modes
This commit is contained in:
parent
2ab7b43f74
commit
558bea47b7
8 changed files with 73 additions and 3 deletions
|
|
@ -2,7 +2,12 @@ pub mod client;
|
||||||
pub mod ipc;
|
pub mod ipc;
|
||||||
mod logging;
|
mod logging;
|
||||||
|
|
||||||
use {bincode::Options, std::marker::PhantomData};
|
use {
|
||||||
|
crate::video::Mode,
|
||||||
|
bincode::Options,
|
||||||
|
serde::{Deserialize, Serialize},
|
||||||
|
std::marker::PhantomData,
|
||||||
|
};
|
||||||
|
|
||||||
pub const VERSION: u32 = 1;
|
pub const VERSION: u32 = 1;
|
||||||
|
|
||||||
|
|
@ -36,3 +41,20 @@ pub fn bincode_ops() -> impl Options {
|
||||||
pub trait Config {
|
pub trait Config {
|
||||||
extern "C" fn configure();
|
extern "C" fn configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct WireMode {
|
||||||
|
pub width: i32,
|
||||||
|
pub height: i32,
|
||||||
|
pub refresh_millihz: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WireMode {
|
||||||
|
pub fn to_mode(self) -> Mode {
|
||||||
|
Mode {
|
||||||
|
width: self.width,
|
||||||
|
height: self.height,
|
||||||
|
refresh_millihz: self.refresh_millihz,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use {
|
||||||
_private::{
|
_private::{
|
||||||
bincode_ops,
|
bincode_ops,
|
||||||
ipc::{ClientMessage, InitMessage, Response, ServerMessage},
|
ipc::{ClientMessage, InitMessage, Response, ServerMessage},
|
||||||
logging, Config, ConfigEntry, ConfigEntryGen, VERSION,
|
logging, Config, ConfigEntry, ConfigEntryGen, WireMode, VERSION,
|
||||||
},
|
},
|
||||||
exec::Command,
|
exec::Command,
|
||||||
input::{acceleration::AccelProfile, capability::Capability, InputDevice, Seat},
|
input::{acceleration::AccelProfile, capability::Capability, InputDevice, Seat},
|
||||||
|
|
@ -570,6 +570,12 @@ impl Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn connector_modes(&self, connector: Connector) -> Vec<Mode> {
|
||||||
|
let res = self.send_with_response(&ClientMessage::ConnectorModes { connector });
|
||||||
|
get_response!(res, Vec::new(), ConnectorModes { modes });
|
||||||
|
modes.into_iter().map(WireMode::to_mode).collect()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn connector_size(&self, connector: Connector) -> (i32, i32) {
|
pub fn connector_size(&self, connector: Connector) -> (i32, i32) {
|
||||||
let res = self.send_with_response(&ClientMessage::ConnectorSize { connector });
|
let res = self.send_with_response(&ClientMessage::ConnectorSize { connector });
|
||||||
get_response!(res, (0, 0), ConnectorSize { width, height });
|
get_response!(res, (0, 0), ConnectorSize { width, height });
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ use {
|
||||||
timer::Timer,
|
timer::Timer,
|
||||||
video::{connector_type::ConnectorType, Connector, DrmDevice, GfxApi, Transform},
|
video::{connector_type::ConnectorType, Connector, DrmDevice, GfxApi, Transform},
|
||||||
Axis, Direction, PciId, Workspace,
|
Axis, Direction, PciId, Workspace,
|
||||||
|
_private::WireMode,
|
||||||
},
|
},
|
||||||
serde::{Deserialize, Serialize},
|
serde::{Deserialize, Serialize},
|
||||||
std::time::Duration,
|
std::time::Duration,
|
||||||
|
|
@ -352,6 +353,9 @@ pub enum ClientMessage<'a> {
|
||||||
SetDoubleClickDistance {
|
SetDoubleClickDistance {
|
||||||
dist: i32,
|
dist: i32,
|
||||||
},
|
},
|
||||||
|
ConnectorModes {
|
||||||
|
connector: Connector,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
|
@ -454,6 +458,9 @@ pub enum Response {
|
||||||
GetWorkspaceCapture {
|
GetWorkspaceCapture {
|
||||||
capture: bool,
|
capture: bool,
|
||||||
},
|
},
|
||||||
|
ConnectorModes {
|
||||||
|
modes: Vec<WireMode>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ use {
|
||||||
/// - width in pixels
|
/// - width in pixels
|
||||||
/// - height in pixels
|
/// - height in pixels
|
||||||
/// - refresh rate in mhz.
|
/// - refresh rate in mhz.
|
||||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||||
pub struct Mode {
|
pub struct Mode {
|
||||||
pub(crate) width: i32,
|
pub(crate) width: i32,
|
||||||
pub(crate) height: i32,
|
pub(crate) height: i32,
|
||||||
|
|
@ -112,6 +112,14 @@ impl Connector {
|
||||||
get!(Mode::zeroed()).connector_mode(self)
|
get!(Mode::zeroed()).connector_mode(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the available modes of the connector.
|
||||||
|
pub fn modes(self) -> Vec<Mode> {
|
||||||
|
if !self.exists() {
|
||||||
|
return Vec::new();
|
||||||
|
}
|
||||||
|
get!(Vec::new()).connector_modes(self)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the logical width of the connector.
|
/// Returns the logical width of the connector.
|
||||||
///
|
///
|
||||||
/// The returned value will be different from `mode().width()` if the scale is not 1.
|
/// The returned value will be different from `mode().width()` if the scale is not 1.
|
||||||
|
|
|
||||||
|
|
@ -375,6 +375,7 @@ fn create_dummy_output(state: &Rc<State>) {
|
||||||
async_event: Default::default(),
|
async_event: Default::default(),
|
||||||
}),
|
}),
|
||||||
0,
|
0,
|
||||||
|
Vec::new(),
|
||||||
&backend::Mode {
|
&backend::Mode {
|
||||||
width: 0,
|
width: 0,
|
||||||
height: 0,
|
height: 0,
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ use {
|
||||||
_private::{
|
_private::{
|
||||||
bincode_ops,
|
bincode_ops,
|
||||||
ipc::{ClientMessage, Response, ServerMessage},
|
ipc::{ClientMessage, Response, ServerMessage},
|
||||||
|
WireMode,
|
||||||
},
|
},
|
||||||
input::{
|
input::{
|
||||||
acceleration::{AccelProfile, ACCEL_PROFILE_ADAPTIVE, ACCEL_PROFILE_FLAT},
|
acceleration::{AccelProfile, ACCEL_PROFILE_ADAPTIVE, ACCEL_PROFILE_FLAT},
|
||||||
|
|
@ -694,6 +695,24 @@ impl ConfigProxyHandler {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_connector_modes(&self, connector: Connector) -> Result<(), CphError> {
|
||||||
|
let connector = self.get_output(connector)?;
|
||||||
|
self.respond(Response::ConnectorModes {
|
||||||
|
modes: connector
|
||||||
|
.node
|
||||||
|
.global
|
||||||
|
.modes
|
||||||
|
.iter()
|
||||||
|
.map(|m| WireMode {
|
||||||
|
width: m.width,
|
||||||
|
height: m.height,
|
||||||
|
refresh_millihz: m.refresh_rate_millihz,
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
});
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn handle_set_cursor_size(&self, seat: Seat, size: i32) -> Result<(), CphError> {
|
fn handle_set_cursor_size(&self, seat: Seat, size: i32) -> Result<(), CphError> {
|
||||||
let seat = self.get_seat(seat)?;
|
let seat = self.get_seat(seat)?;
|
||||||
if size < 0 {
|
if size < 0 {
|
||||||
|
|
@ -1369,6 +1388,9 @@ impl ConfigProxyHandler {
|
||||||
ClientMessage::SetDoubleClickDistance { dist } => {
|
ClientMessage::SetDoubleClickDistance { dist } => {
|
||||||
self.handle_set_double_click_distance(dist)
|
self.handle_set_double_click_distance(dist)
|
||||||
}
|
}
|
||||||
|
ClientMessage::ConnectorModes { connector } => self
|
||||||
|
.handle_connector_modes(connector)
|
||||||
|
.wrn("connector_modes")?,
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ pub struct WlOutputGlobal {
|
||||||
pub pos: Cell<Rect>,
|
pub pos: Cell<Rect>,
|
||||||
pub output_id: Rc<OutputId>,
|
pub output_id: Rc<OutputId>,
|
||||||
pub mode: Cell<backend::Mode>,
|
pub mode: Cell<backend::Mode>,
|
||||||
|
pub modes: Vec<backend::Mode>,
|
||||||
pub node: CloneCell<Option<Rc<OutputNode>>>,
|
pub node: CloneCell<Option<Rc<OutputNode>>>,
|
||||||
pub width_mm: i32,
|
pub width_mm: i32,
|
||||||
pub height_mm: i32,
|
pub height_mm: i32,
|
||||||
|
|
@ -96,6 +97,7 @@ impl WlOutputGlobal {
|
||||||
state: &Rc<State>,
|
state: &Rc<State>,
|
||||||
connector: &Rc<ConnectorData>,
|
connector: &Rc<ConnectorData>,
|
||||||
x1: i32,
|
x1: i32,
|
||||||
|
modes: Vec<backend::Mode>,
|
||||||
mode: &backend::Mode,
|
mode: &backend::Mode,
|
||||||
manufacturer: &str,
|
manufacturer: &str,
|
||||||
product: &str,
|
product: &str,
|
||||||
|
|
@ -122,6 +124,7 @@ impl WlOutputGlobal {
|
||||||
pos: Cell::new(Rect::new_sized(x1, 0, width, height).unwrap()),
|
pos: Cell::new(Rect::new_sized(x1, 0, width, height).unwrap()),
|
||||||
output_id,
|
output_id,
|
||||||
mode: Cell::new(*mode),
|
mode: Cell::new(*mode),
|
||||||
|
modes,
|
||||||
node: Default::default(),
|
node: Default::default(),
|
||||||
width_mm,
|
width_mm,
|
||||||
height_mm,
|
height_mm,
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ impl ConnectorHandler {
|
||||||
&self.state,
|
&self.state,
|
||||||
&self.data,
|
&self.data,
|
||||||
x1,
|
x1,
|
||||||
|
info.modes.clone(),
|
||||||
&info.initial_mode,
|
&info.initial_mode,
|
||||||
&info.manufacturer,
|
&info.manufacturer,
|
||||||
&info.product,
|
&info.product,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue