Skip to content

Commit

Permalink
update: temporary set display scale manually
Browse files Browse the repository at this point in the history
  • Loading branch information
luftaquila committed May 16, 2024
1 parent 9d4b448 commit 58943b7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/bin/transistor-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() -> Result<(), Error> {
println!("[INF] transistor client startup! server: {}", server);
print_displays();

let mut client = Client::new(server)?;
let mut client = Client::new(server, 1.0)?;
client.start()?;

loop {}
Expand Down
2 changes: 1 addition & 1 deletion src/bin/transistor-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() -> Result<(), Error> {
print_displays();

let client_config = config_dir!("server").join("authorized_clients.json");
let server = Server::new()?;
let server = Server::new(1.0)?;

server.start(client_config);

Expand Down
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Client {
}

impl Client {
pub fn new(server: &str) -> Result<Client, Error> {
pub fn new(server: &str, display_scale: f32) -> Result<Client, Error> {
// mkdir -p
fs::create_dir_all(config_dir!("client"))?;

Expand All @@ -39,7 +39,7 @@ impl Client {
displays: DisplayInfo::all()
.expect("[ERR] failed to get system displays")
.into_iter()
.map(|x| Display::from(x, cid))
.map(|x| Display::from(x, cid, display_scale))
.collect(),
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct Display {
}

impl Display {
pub fn from(item: DisplayInfo, cid: Cid) -> Self {
pub fn from(item: DisplayInfo, cid: Cid, display_scale: f32) -> Self {
Display {
name: item.name,
id: item.id,
Expand All @@ -70,7 +70,7 @@ impl Display {
width: item.width as i32,
height: item.height as i32,
rotation: item.rotation,
scale_factor: item.scale_factor,
scale_factor: display_scale,
frequency: item.frequency,
is_primary: item.is_primary,
warpzones: Vec::new(),
Expand Down
4 changes: 2 additions & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ pub struct Server {
}

impl Server {
pub fn new() -> Result<Server, Error> {
pub fn new(display_scale: f32) -> Result<Server, Error> {
// mkdir -p
fs::create_dir_all(config_dir!("server"))?;

let mut disp: Vec<Display> = DisplayInfo::all()
.expect("[ERR] failed to get system displays")
.into_iter()
.map(|x| Display::from(x, SERVER_CID))
.map(|x| Display::from(x, SERVER_CID, display_scale))
.collect();

if disp.len() == 0 {
Expand Down

0 comments on commit 58943b7

Please sign in to comment.