Skip to content

Commit

Permalink
cli: add randr subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
mahkoh committed Mar 5, 2024
1 parent 5b2bfb8 commit 20ac21e
Show file tree
Hide file tree
Showing 14 changed files with 1,053 additions and 17 deletions.
8 changes: 7 additions & 1 deletion src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ pub trait Connector {
fn on_change(&self, cb: Rc<dyn Fn()>);
fn damage(&self);
fn drm_dev(&self) -> Option<DrmDeviceId>;
fn set_enabled(&self, enabled: bool);
fn enabled(&self) -> bool {
true
}
fn set_enabled(&self, enabled: bool) {
let _ = enabled;
}
fn drm_feedback(&self) -> Option<Rc<DrmFeedback>> {
None
}
Expand Down Expand Up @@ -232,4 +237,5 @@ pub trait BackendDrmDevice {
fn gtx_api(&self) -> GfxApi;
fn version(&self) -> Result<DrmVersion, DrmError>;
fn set_direct_scanout_enabled(&self, enabled: bool);
fn is_render_device(&self) -> bool;
}
4 changes: 0 additions & 4 deletions src/backends/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ impl Connector for DummyOutput {
None
}

fn set_enabled(&self, _enabled: bool) {
// nothing
}

fn set_mode(&self, _mode: Mode) {
// nothing
}
Expand Down
8 changes: 8 additions & 0 deletions src/backends/metal/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ impl BackendDrmDevice for MetalDrmDevice {
fn set_direct_scanout_enabled(&self, enabled: bool) {
self.direct_scanout_enabled.set(Some(enabled));
}

fn is_render_device(&self) -> bool {
Some(self.id) == self.backend.ctx.get().map(|c| c.dev_id)
}
}

pub struct HandleEvents {
Expand Down Expand Up @@ -846,6 +850,10 @@ impl Connector for MetalConnector {
Some(self.dev.id)
}

fn enabled(&self) -> bool {
self.enabled.get()
}

fn set_enabled(&self, enabled: bool) {
if self.enabled.replace(enabled) != enabled {
if self.display.borrow_mut().connection == ConnectorStatus::Connected {
Expand Down
8 changes: 4 additions & 4 deletions src/backends/x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,10 @@ impl BackendDrmDevice for XDrmDevice {
fn set_direct_scanout_enabled(&self, enabled: bool) {
let _ = enabled;
}

fn is_render_device(&self) -> bool {
true
}
}

struct XOutput {
Expand Down Expand Up @@ -1055,10 +1059,6 @@ impl Connector for XOutput {
Some(self.backend.drm_device_id)
}

fn set_enabled(&self, _enabled: bool) {
// nothing
}

fn set_mode(&self, _mode: Mode) {
log::warn!("X backend doesn't support changing the connector mode");
}
Expand Down
6 changes: 5 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ mod generate;
mod idle;
mod log;
mod quit;
mod randr;
mod run_privileged;
pub mod screenshot;
mod seat_test;
mod set_log_level;
mod unlock;

use {
crate::{compositor::start_compositor, portal},
crate::{cli::randr::RandrArgs, compositor::start_compositor, portal},
::log::Level,
clap::{Args, Parser, Subcommand, ValueEnum},
clap_complete::Shell,
Expand Down Expand Up @@ -55,6 +56,8 @@ pub enum Cmd {
SeatTest(SeatTestArgs),
/// Run the desktop portal.
Portal,
/// Inspect/modify graphics card and connector settings.
Randr(RandrArgs),
#[cfg(feature = "it")]
RunTests,
}
Expand Down Expand Up @@ -217,6 +220,7 @@ pub fn main() {
Cmd::RunPrivileged(a) => run_privileged::main(cli.global, a),
Cmd::SeatTest(a) => seat_test::main(cli.global, a),
Cmd::Portal => portal::run(cli.global),
Cmd::Randr(a) => randr::main(cli.global, a),
#[cfg(feature = "it")]
Cmd::RunTests => crate::it::run_tests(),
}
Expand Down
Loading

0 comments on commit 20ac21e

Please sign in to comment.