Remove resource_sceme, Fix syscall crate name, add fmap
This commit is contained in:
parent
db4acfbe8c
commit
e3317f05f7
39 changed files with 130 additions and 221 deletions
|
@ -4,9 +4,9 @@ version = "0.1.0"
|
|||
|
||||
[dependencies]
|
||||
orbclient = "0.1"
|
||||
ransid = { git = "https://github.com/redox-os/ransid.git" }
|
||||
ransid = "0.2"
|
||||
rusttype = { git = "https://github.com/dylanede/rusttype.git", optional = true }
|
||||
syscall = { path = "../../syscall/" }
|
||||
redox_syscall = "0.1"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
|
|
@ -72,6 +72,14 @@ impl SchemeMut for DisplayScheme {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmap(&mut self, id: usize, offset: usize, size: usize) -> Result<usize> {
|
||||
if let Some(screen) = self.screens.get(&id) {
|
||||
screen.map(offset, size)
|
||||
} else {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
}
|
||||
|
||||
fn fpath(&mut self, id: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
let path_str = if id == 0 {
|
||||
format!("display:input")
|
||||
|
|
|
@ -45,6 +45,14 @@ impl Screen for GraphicScreen {
|
|||
Ok(0)
|
||||
}
|
||||
|
||||
fn map(&self, offset: usize, size: usize) -> Result<usize> {
|
||||
if offset + size <= self.display.offscreen.len() * 4 {
|
||||
Ok(self.display.offscreen.as_ptr() as usize + offset)
|
||||
} else {
|
||||
Err(Error::new(EINVAL))
|
||||
}
|
||||
}
|
||||
|
||||
fn input(&mut self, event: &Event) {
|
||||
if let EventOption::Mouse(mut mouse_event) = event.to_option() {
|
||||
let x = cmp::max(0, cmp::min(self.display.width as i32, self.mouse_x + mouse_event.x));
|
||||
|
|
|
@ -14,6 +14,8 @@ pub trait Screen {
|
|||
|
||||
fn event(&mut self, flags: usize) -> Result<usize>;
|
||||
|
||||
fn map(&self, offset: usize, size: usize) -> Result<usize>;
|
||||
|
||||
fn input(&mut self, event: &Event);
|
||||
|
||||
fn read(&mut self, buf: &mut [u8]) -> Result<usize>;
|
||||
|
|
|
@ -3,7 +3,7 @@ extern crate ransid;
|
|||
use std::collections::{BTreeSet, VecDeque};
|
||||
|
||||
use orbclient::{Event, EventOption};
|
||||
use syscall::Result;
|
||||
use syscall::error::*;
|
||||
|
||||
use display::Display;
|
||||
use screen::Screen;
|
||||
|
@ -48,6 +48,10 @@ impl Screen for TextScreen {
|
|||
Ok(0)
|
||||
}
|
||||
|
||||
fn map(&self, offset: usize, size: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
fn input(&mut self, event: &Event) {
|
||||
let mut buf = vec![];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue