Add method for resizing display

This commit is contained in:
Jeremy Soller
2017-08-21 20:19:58 -06:00
parent 770a23ef94
commit 4e40c1c8af
4 changed files with 19 additions and 3 deletions
Generated
+1
View File
@@ -63,6 +63,7 @@ dependencies = [
name = "bgad"
version = "0.1.0"
dependencies = [
"orbclient 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
+1
View File
@@ -3,4 +3,5 @@ name = "bgad"
version = "0.1.0"
[dependencies]
orbclient = "0.3"
redox_syscall = "0.1"
+5 -1
View File
@@ -1,5 +1,6 @@
#![deny(warnings)]
extern crate orbclient;
extern crate syscall;
use std::env;
@@ -35,7 +36,10 @@ fn main() {
let mut bga = Bga::new();
print!("{}", format!(" - BGA {}x{}\n", bga.width(), bga.height()));
let mut scheme = BgaScheme { bga: bga };
let mut scheme = BgaScheme {
bga: bga,
display: File::open("display:input").ok()
};
loop {
let mut packet = Packet::default();
socket.read(&mut packet).expect("bgad: failed to read events from bga scheme");
+12 -2
View File
@@ -1,12 +1,15 @@
use orbclient;
use std::fs::File;
use std::io::Write;
use std::str;
use syscall::{Error, Result, SchemeMut, EACCES, EINVAL, MODE_CHR};
use syscall::data::Stat;
use bga::Bga;
pub struct BgaScheme {
pub bga: Bga
pub bga: Bga,
pub display: Option<File>,
}
impl SchemeMut for BgaScheme {
@@ -56,6 +59,13 @@ impl SchemeMut for BgaScheme {
self.bga.set_size(width, height);
if let Some(ref mut display) = self.display {
let _ = display.write(&orbclient::ResizeEvent {
width: width as u32,
height: height as u32,
}.to_event());
}
Ok(buf.len())
}