Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: add randr subcommand #123

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading