summaryrefslogtreecommitdiffstats
path: root/rsnix/src
diff options
context:
space:
mode:
Diffstat (limited to 'rsnix/src')
-rw-r--r--rsnix/src/tty.rs16
-rw-r--r--rsnix/src/wm.rs8
2 files changed, 18 insertions, 6 deletions
diff --git a/rsnix/src/tty.rs b/rsnix/src/tty.rs
index 918f6e0..c44dca8 100644
--- a/rsnix/src/tty.rs
+++ b/rsnix/src/tty.rs
@@ -139,7 +139,14 @@ pub fn read_line() -> LineInput {
139/// windowed shells). Same semantics as `read_line` but keys arrive as 139/// windowed shells). Same semantics as `read_line` but keys arrive as
140/// `TaskMsg::Key` instead of from the global PS/2 queue. Returns `None` 140/// `TaskMsg::Key` instead of from the global PS/2 queue. Returns `None`
141/// on `TaskMsg::Close` (window was closed). 141/// on `TaskMsg::Close` (window was closed).
142pub fn read_line_from_queue() -> Option<LineInput> { 142/// Read one line in canonical mode from the task's message queue (for
143/// windowed shells). Same semantics as `read_line` but keys arrive as
144/// `TaskMsg::Key` instead of from the global PS/2 queue. Returns `None`
145/// on `TaskMsg::Close` (window was closed).
146///
147/// Handles `TaskMsg::Focus` to toggle the global `ACTIVE` redirect so
148/// gop_print! goes to the right terminal buffer.
149pub fn read_line_from_queue(term: &mut crate::vt::Terminal) -> Option<LineInput> {
143 crate::vt::sync_scroll(); 150 crate::vt::sync_scroll();
144 let mut buf = strbuf::String::<LINE_BUF_SIZE>::new(); 151 let mut buf = strbuf::String::<LINE_BUF_SIZE>::new();
145 loop { 152 loop {
@@ -191,6 +198,13 @@ pub fn read_line_from_queue() -> Option<LineInput> {
191 } 198 }
192 _ => {} 199 _ => {}
193 }, 200 },
201 crate::sched::TaskMsg::Focus(gained) => {
202 if gained {
203 crate::vt::set_active(term as *mut crate::vt::Terminal);
204 } else {
205 crate::vt::set_active(core::ptr::null_mut());
206 }
207 }
194 crate::sched::TaskMsg::Close => return None, 208 crate::sched::TaskMsg::Close => return None,
195 _ => {} 209 _ => {}
196 } 210 }
diff --git a/rsnix/src/wm.rs b/rsnix/src/wm.rs
index 05781e8..71c310f 100644
--- a/rsnix/src/wm.rs
+++ b/rsnix/src/wm.rs
@@ -617,12 +617,10 @@ pub fn spawn_input_pump() -> Option<usize> {
617 617
618fn pump_main() { 618fn pump_main() {
619 loop { 619 loop {
620 if focused().is_some() { 620 if let Some(id) = focused() {
621 let o = owner(id).unwrap_or(0);
621 while let Some(ev) = crate::ps2::try_poll_key().or_else(crate::uhci::try_poll_key) { 622 while let Some(ev) = crate::ps2::try_poll_key().or_else(crate::uhci::try_poll_key) {
622 if !handle_key(ev) 623 if !handle_key(ev) {
623 && let Some(id) = focused()
624 && let Some(o) = owner(id)
625 {
626 let _ = crate::sched::send(o, TaskMsg::Key(ev)); 624 let _ = crate::sched::send(o, TaskMsg::Key(ev));
627 } 625 }
628 } 626 }