mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
intermediate commit to try and lock in a bug
This commit is contained in:
parent
ae418f5718
commit
d2ef03b7e2
6 changed files with 41 additions and 17 deletions
17
Cargo.lock
generated
17
Cargo.lock
generated
|
|
@ -261,6 +261,15 @@ dependencies = [
|
||||||
"com_rs",
|
"com_rs",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "compiler_builtins"
|
||||||
|
version = "0.1.39"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3748f82c7d366a0b4950257d19db685d4958d2fa27c6d164a3f069fec42b748b"
|
||||||
|
dependencies = [
|
||||||
|
"rustc-std-workspace-core",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "content-plugin-api"
|
name = "content-plugin-api"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
@ -1028,6 +1037,12 @@ version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc-std-workspace-core"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1956f5517128a2b6f23ab2dadf1a976f4f5b27962e7724c2bf3d45e539ec098c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.5"
|
version = "1.0.5"
|
||||||
|
|
@ -1539,10 +1554,12 @@ name = "xous"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
|
"compiler_builtins",
|
||||||
"hex",
|
"hex",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"rkyv",
|
"rkyv",
|
||||||
|
"rustc-std-workspace-core",
|
||||||
"xous-macros",
|
"xous-macros",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,21 +22,21 @@ pub enum CanvasState {
|
||||||
/// A rectangular region that defines a top-left zero relative offset for graphical items
|
/// A rectangular region that defines a top-left zero relative offset for graphical items
|
||||||
/// and a bottom-right point that defines a clipping area for things drawn inside.
|
/// and a bottom-right point that defines a clipping area for things drawn inside.
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
#[repr(C)]
|
|
||||||
pub struct Canvas {
|
pub struct Canvas {
|
||||||
|
// unique, random identifier for the Canvas
|
||||||
|
gid: Gid,
|
||||||
|
|
||||||
// screen coordinates of the clipping region
|
// screen coordinates of the clipping region
|
||||||
clip_rect: Rectangle,
|
clip_rect: Rectangle,
|
||||||
|
|
||||||
// trust level, 255 is most trusted
|
// trust level, 255 is most trusted
|
||||||
trust_level: u8,
|
trust_level: u8,
|
||||||
|
|
||||||
state: CanvasState,
|
|
||||||
|
|
||||||
// unique, random identifier for the Canvas
|
|
||||||
gid: Gid,
|
|
||||||
|
|
||||||
// enables scroll/pan of objects within a region
|
// enables scroll/pan of objects within a region
|
||||||
pan_offset: Point,
|
pan_offset: Point,
|
||||||
|
|
||||||
|
// track the drawing state of the canvas
|
||||||
|
state: CanvasState,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ use heapless::consts::*;
|
||||||
use rkyv::{Unarchive, archived_value, archived_value_mut};
|
use rkyv::{Unarchive, archived_value, archived_value_mut};
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
// GIDs of canvases that are used the "Chat" layout.
|
// GIDs of canvases that are used the "Chat" layout.
|
||||||
struct ChatLayout {
|
struct ChatLayout {
|
||||||
// a set of GIDs to track the elements of the chat layout
|
// a set of GIDs to track the elements of the chat layout
|
||||||
|
|
@ -178,6 +179,7 @@ impl ModalCanvases {
|
||||||
#[xous::xous_main]
|
#[xous::xous_main]
|
||||||
fn xmain() -> ! {
|
fn xmain() -> ! {
|
||||||
let debug1 = false; // debug level 1 - most general level
|
let debug1 = false; // debug level 1 - most general level
|
||||||
|
let debugc = false;
|
||||||
log_server::init_wait().unwrap();
|
log_server::init_wait().unwrap();
|
||||||
info!("GAM: my PID is {}", xous::process::id());
|
info!("GAM: my PID is {}", xous::process::id());
|
||||||
|
|
||||||
|
|
@ -194,7 +196,7 @@ fn xmain() -> ! {
|
||||||
|
|
||||||
// a map of canvases accessable by Gid
|
// a map of canvases accessable by Gid
|
||||||
let mut canvases: FnvIndexMap<Gid, Canvas, U32> = FnvIndexMap::new();
|
let mut canvases: FnvIndexMap<Gid, Canvas, U32> = FnvIndexMap::new();
|
||||||
let modallayout = ModalCanvases::init(trng_conn, &mut canvases).expect("GAM: can't add modal layouts");
|
// let modallayout = ModalCanvases::init(trng_conn, &mut canvases).expect("GAM: can't add modal layouts");
|
||||||
let mut chatlayout = ChatLayout::init(gfx_conn, trng_conn, &mut canvases).expect("GAM: couldn't create chat layout");
|
let mut chatlayout = ChatLayout::init(gfx_conn, trng_conn, &mut canvases).expect("GAM: couldn't create chat layout");
|
||||||
chatlayout.clear(&mut canvases).expect("GAM: couldn't clear initial chatlayout");
|
chatlayout.clear(&mut canvases).expect("GAM: couldn't clear initial chatlayout");
|
||||||
|
|
||||||
|
|
@ -217,6 +219,7 @@ fn xmain() -> ! {
|
||||||
// no content canvas initially, but keep a placeholder for one
|
// no content canvas initially, but keep a placeholder for one
|
||||||
let mut ccc: ContentCanvasConnection = ContentCanvasConnection{connection: None};
|
let mut ccc: ContentCanvasConnection = ContentCanvasConnection{connection: None};
|
||||||
|
|
||||||
|
if debugc{info!("GAM: chatlayout made st {:?} co {:?} pr {:?} in {:?}", chatlayout.status, chatlayout.content, chatlayout.predictive, chatlayout.input);}
|
||||||
// make a thread to manage the status bar -- this needs to start after the IMEF is initialized
|
// make a thread to manage the status bar -- this needs to start after the IMEF is initialized
|
||||||
// the status bar is a trusted element managed by the OS, and we are chosing to domicile this in the GAM process for now
|
// the status bar is a trusted element managed by the OS, and we are chosing to domicile this in the GAM process for now
|
||||||
xous::create_thread_simple(status_thread, chatlayout.status.gid()).expect("GAM: couldn't create status thread");
|
xous::create_thread_simple(status_thread, chatlayout.status.gid()).expect("GAM: couldn't create status thread");
|
||||||
|
|
@ -327,7 +330,7 @@ fn xmain() -> ! {
|
||||||
info!("GAM: attempt to draw TextView on non-drawable canvas. Not fatal, but request ignored.");
|
info!("GAM: attempt to draw TextView on non-drawable canvas. Not fatal, but request ignored.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info!("GAM: bogus GID in TextView, not doing anything in response to draw request.");
|
info!("GAM: bogus GID {:?} in TextView {}, not doing anything in response to draw request.", tv.get_canvas_gid(), tv.text);
|
||||||
// silently fail if a bogus Gid is given???
|
// silently fail if a bogus Gid is given???
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ pub fn status_thread(canvas_gid: [u32; 4]) {
|
||||||
if debug1{info!("GAM|status: registering GAM|status thread");}
|
if debug1{info!("GAM|status: registering GAM|status thread");}
|
||||||
let status_sid = xous_names::register_name(xous::names::SERVER_NAME_STATUS).expect("GAM|status: can't register server");
|
let status_sid = xous_names::register_name(xous::names::SERVER_NAME_STATUS).expect("GAM|status: can't register server");
|
||||||
|
|
||||||
|
let gam_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_GAM).expect("GAM|status: can't connect to GAM");
|
||||||
let ticktimer_conn = xous::connect(xous::SID::from_bytes(b"ticktimer-server").unwrap()).unwrap();
|
let ticktimer_conn = xous::connect(xous::SID::from_bytes(b"ticktimer-server").unwrap()).unwrap();
|
||||||
let com_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_COM).expect("GAM|status: can't connect to COM");
|
let com_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_COM).expect("GAM|status: can't connect to COM");
|
||||||
let gam_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_GAM).expect("GAM|status: can't connect to GAM");
|
|
||||||
|
|
||||||
if debug1{info!("GAM|status: getting screen size");}
|
if debug1{info!("GAM|status: getting screen size");}
|
||||||
let screensize = gam::get_canvas_bounds(gam_conn, status_gid).expect("GAM|status: Couldn't get canvas size");
|
let screensize = gam::get_canvas_bounds(gam_conn, status_gid).expect("GAM|status: Couldn't get canvas size");
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,9 @@ const TEXTVIEW_LEN: usize = 3072;
|
||||||
|
|
||||||
#[derive(Copy, Clone, rkyv::Archive, rkyv::Unarchive)]
|
#[derive(Copy, Clone, rkyv::Archive, rkyv::Unarchive)]
|
||||||
pub struct TextView {
|
pub struct TextView {
|
||||||
|
canvas: Gid, // GID of the canvas to draw on
|
||||||
|
pub clip_rect: Option<Rectangle>, // this is set by the GAM to the canvas' clip_rect; needed by gfx for drawing. Note this is in screen coordinates.
|
||||||
|
|
||||||
// this is the operation as specified for the GAM. Note this is different from the "op" when sent to graphics-server
|
// this is the operation as specified for the GAM. Note this is different from the "op" when sent to graphics-server
|
||||||
// only the GAM should be sending TextViews to the graphics-server, and a different coding scheme is used for that link.
|
// only the GAM should be sending TextViews to the graphics-server, and a different coding scheme is used for that link.
|
||||||
operation: TextOp,
|
operation: TextOp,
|
||||||
|
|
@ -62,7 +65,6 @@ pub struct TextView {
|
||||||
pub dry_run: bool, // set to true if no drawing is desired and we just want to compute the bounds
|
pub dry_run: bool, // set to true if no drawing is desired and we just want to compute the bounds
|
||||||
|
|
||||||
pub style: GlyphStyle,
|
pub style: GlyphStyle,
|
||||||
pub text: xous::String::<3072>,
|
|
||||||
pub cursor: Cursor,
|
pub cursor: Cursor,
|
||||||
pub insertion: Option<i32>, // this is the insertion point offset, if it's to be drawn, on the string
|
pub insertion: Option<i32>, // this is the insertion point offset, if it's to be drawn, on the string
|
||||||
pub ellipsis: bool,
|
pub ellipsis: bool,
|
||||||
|
|
@ -76,12 +78,12 @@ pub struct TextView {
|
||||||
// this field specifies the beginning and end of a "selected" region of text
|
// this field specifies the beginning and end of a "selected" region of text
|
||||||
pub selected: Option<[u32; 2]>,
|
pub selected: Option<[u32; 2]>,
|
||||||
|
|
||||||
canvas: Gid, // GID of the canvas to draw on
|
pub text: xous::String::<3072>,
|
||||||
pub clip_rect: Option<Rectangle>, // this is set by the GAM to the canvas' clip_rect; needed by gfx for drawing. Note this is in screen coordinates.
|
|
||||||
}
|
}
|
||||||
impl TextView {
|
impl TextView {
|
||||||
pub fn new(canvas: Gid, bounds_hint: TextBounds) -> Self {
|
pub fn new(canvas: Gid, bounds_hint: TextBounds) -> Self {
|
||||||
TextView {
|
TextView {
|
||||||
|
canvas,
|
||||||
operation: TextOp::Nop,
|
operation: TextOp::Nop,
|
||||||
untrusted: true,
|
untrusted: true,
|
||||||
token: None,
|
token: None,
|
||||||
|
|
@ -99,7 +101,6 @@ impl TextView {
|
||||||
rounded_border: None,
|
rounded_border: None,
|
||||||
margin: Point { x: 4, y: 4 },
|
margin: Point { x: 4, y: 4 },
|
||||||
selected: None,
|
selected: None,
|
||||||
canvas,
|
|
||||||
clear_area: true,
|
clear_area: true,
|
||||||
overflow: None,
|
overflow: None,
|
||||||
dry_run: false,
|
dry_run: false,
|
||||||
|
|
@ -116,6 +117,7 @@ impl TextView {
|
||||||
pub fn clear_str(&mut self) { self.text.clear() }
|
pub fn clear_str(&mut self) { self.text.clear() }
|
||||||
|
|
||||||
pub fn populate_from(&mut self, t: &TextView) {
|
pub fn populate_from(&mut self, t: &TextView) {
|
||||||
|
self.canvas = t.canvas;
|
||||||
self.operation = t.operation;
|
self.operation = t.operation;
|
||||||
self.untrusted = t.untrusted;
|
self.untrusted = t.untrusted;
|
||||||
self.token = t.token;
|
self.token = t.token;
|
||||||
|
|
@ -131,7 +133,6 @@ impl TextView {
|
||||||
self.rounded_border = t.rounded_border;
|
self.rounded_border = t.rounded_border;
|
||||||
self.margin = t.margin;
|
self.margin = t.margin;
|
||||||
self.selected = t.selected;
|
self.selected = t.selected;
|
||||||
self.canvas = t.canvas;
|
|
||||||
self.overflow = t.overflow;
|
self.overflow = t.overflow;
|
||||||
self.clip_rect = t.clip_rect;
|
self.clip_rect = t.clip_rect;
|
||||||
self.dry_run = t.dry_run;
|
self.dry_run = t.dry_run;
|
||||||
|
|
|
||||||
|
|
@ -523,6 +523,7 @@ impl InputTracker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let debug_canvas = false;
|
||||||
if valid_predictions == 0 {
|
if valid_predictions == 0 {
|
||||||
let mut empty_tv = TextView::new(pc,
|
let mut empty_tv = TextView::new(pc,
|
||||||
TextBounds::BoundingBox(Rectangle::new(Point::new(0, 1), pc_bounds)));
|
TextBounds::BoundingBox(Rectangle::new(Point::new(0, 1), pc_bounds)));
|
||||||
|
|
@ -530,6 +531,7 @@ impl InputTracker {
|
||||||
empty_tv.border_width = 1;
|
empty_tv.border_width = 1;
|
||||||
empty_tv.clear_area = true;
|
empty_tv.clear_area = true;
|
||||||
write!(empty_tv.text, "Ready for input...").expect("IMEF: couldn't set up empty TextView");
|
write!(empty_tv.text, "Ready for input...").expect("IMEF: couldn't set up empty TextView");
|
||||||
|
if debug_canvas { info!("IMEF: pc canvas {:?}", pc) }
|
||||||
gam::post_textview(self.gam_conn, &mut empty_tv).expect("IMEF: can't draw prediction TextView");
|
gam::post_textview(self.gam_conn, &mut empty_tv).expect("IMEF: can't draw prediction TextView");
|
||||||
} else if update_predictor {
|
} else if update_predictor {
|
||||||
// alright, first, let's clear the area
|
// alright, first, let's clear the area
|
||||||
|
|
@ -578,7 +580,8 @@ impl InputTracker {
|
||||||
#[xous::xous_main]
|
#[xous::xous_main]
|
||||||
fn xmain() -> ! {
|
fn xmain() -> ! {
|
||||||
let debug1 = false;
|
let debug1 = false;
|
||||||
let dbglistener = true;
|
let dbglistener = false;
|
||||||
|
let dbgcanvas = false;
|
||||||
log_server::init_wait().unwrap();
|
log_server::init_wait().unwrap();
|
||||||
info!("IMEF: my PID is {}", xous::process::id());
|
info!("IMEF: my PID is {}", xous::process::id());
|
||||||
|
|
||||||
|
|
@ -601,11 +604,11 @@ fn xmain() -> ! {
|
||||||
if let Ok(opcode) = ImefOpcode::try_from(&envelope.body) {
|
if let Ok(opcode) = ImefOpcode::try_from(&envelope.body) {
|
||||||
match opcode {
|
match opcode {
|
||||||
ImefOpcode::SetInputCanvas(g) => {
|
ImefOpcode::SetInputCanvas(g) => {
|
||||||
if debug1{info!("IMEF: got input canvas {:?}", g);}
|
if debug1 || dbgcanvas {info!("IMEF: got input canvas {:?}", g);}
|
||||||
tracker.set_input_canvas(g);
|
tracker.set_input_canvas(g);
|
||||||
},
|
},
|
||||||
ImefOpcode::SetPredictionCanvas(g) => {
|
ImefOpcode::SetPredictionCanvas(g) => {
|
||||||
if debug1{info!("IMEF: got prediction canvas {:?}", g);}
|
if debug1 || dbgcanvas {info!("IMEF: got prediction canvas {:?}", g);}
|
||||||
tracker.set_pred_canvas(g);
|
tracker.set_pred_canvas(g);
|
||||||
},
|
},
|
||||||
_ => info!("IMEF: expected canvas Gid, but got {:?}", opcode)
|
_ => info!("IMEF: expected canvas Gid, but got {:?}", opcode)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue