tree: switch workspace by scrolling
This commit is contained in:
parent
a310329c42
commit
b970965ed9
5 changed files with 82 additions and 2 deletions
|
|
@ -369,6 +369,7 @@ fn create_dummy_output(state: &Rc<State>) {
|
||||||
state: state.clone(),
|
state: state.clone(),
|
||||||
is_dummy: true,
|
is_dummy: true,
|
||||||
status: Default::default(),
|
status: Default::default(),
|
||||||
|
scroll: Default::default(),
|
||||||
});
|
});
|
||||||
let dummy_workspace = Rc::new(WorkspaceNode {
|
let dummy_workspace = Rc::new(WorkspaceNode {
|
||||||
id: state.node_ids.next(),
|
id: state.node_ids.next(),
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ mod t0012_subsurface_focus;
|
||||||
mod t0013_graphics_initialized;
|
mod t0013_graphics_initialized;
|
||||||
mod t0014_container_scroll_focus;
|
mod t0014_container_scroll_focus;
|
||||||
mod t0015_scroll_partial;
|
mod t0015_scroll_partial;
|
||||||
|
mod t0016_scroll_ws;
|
||||||
|
|
||||||
pub trait TestCase: Sync {
|
pub trait TestCase: Sync {
|
||||||
fn name(&self) -> &'static str;
|
fn name(&self) -> &'static str;
|
||||||
|
|
@ -74,5 +75,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> {
|
||||||
t0013_graphics_initialized,
|
t0013_graphics_initialized,
|
||||||
t0014_container_scroll_focus,
|
t0014_container_scroll_focus,
|
||||||
t0015_scroll_partial,
|
t0015_scroll_partial,
|
||||||
|
t0016_scroll_ws,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
37
src/it/tests/t0016_scroll_ws.rs
Normal file
37
src/it/tests/t0016_scroll_ws.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
use {
|
||||||
|
crate::it::{
|
||||||
|
test_error::{TestErrorExt, TestResult},
|
||||||
|
testrun::TestRun,
|
||||||
|
},
|
||||||
|
std::rc::Rc,
|
||||||
|
};
|
||||||
|
|
||||||
|
testcase!();
|
||||||
|
|
||||||
|
async fn test(run: Rc<TestRun>) -> TestResult {
|
||||||
|
let ds = run.create_default_setup().await?;
|
||||||
|
run.cfg.show_workspace(ds.seat.id(), "1")?;
|
||||||
|
|
||||||
|
let client = run.create_client().await?;
|
||||||
|
let dss = client.get_default_seat().await?;
|
||||||
|
|
||||||
|
let w1 = client.create_window().await?;
|
||||||
|
w1.map().await?;
|
||||||
|
|
||||||
|
run.cfg.show_workspace(ds.seat.id(), "2")?;
|
||||||
|
|
||||||
|
let w2 = client.create_window().await?;
|
||||||
|
w2.map().await?;
|
||||||
|
|
||||||
|
let enters = dss.kb.enter.expect()?;
|
||||||
|
|
||||||
|
ds.mouse.abs(&ds.connector, 0.0, 0.0);
|
||||||
|
ds.mouse.scroll(-1);
|
||||||
|
|
||||||
|
client.sync().await;
|
||||||
|
|
||||||
|
let enter = enters.next().with_context(|| "no enter")?;
|
||||||
|
tassert_eq!(enter.surface, w1.surface.id);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
@ -106,6 +106,7 @@ impl ConnectorHandler {
|
||||||
state: self.state.clone(),
|
state: self.state.clone(),
|
||||||
is_dummy: false,
|
is_dummy: false,
|
||||||
status: self.state.status.clone(),
|
status: self.state.status.clone(),
|
||||||
|
scroll: Default::default(),
|
||||||
});
|
});
|
||||||
let mode = info.initial_mode;
|
let mode = info.initial_mode;
|
||||||
let output_data = Rc::new(OutputData {
|
let output_data = Rc::new(OutputData {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use {
|
||||||
cursor::KnownCursor,
|
cursor::KnownCursor,
|
||||||
ifs::{
|
ifs::{
|
||||||
wl_output::WlOutputGlobal,
|
wl_output::WlOutputGlobal,
|
||||||
wl_seat::{collect_kb_foci2, NodeSeatState, WlSeatGlobal},
|
wl_seat::{collect_kb_foci2, wl_pointer::PendingScroll, NodeSeatState, WlSeatGlobal},
|
||||||
wl_surface::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1,
|
wl_surface::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1,
|
||||||
zwlr_layer_shell_v1::{BACKGROUND, BOTTOM, OVERLAY, TOP},
|
zwlr_layer_shell_v1::{BACKGROUND, BOTTOM, OVERLAY, TOP},
|
||||||
},
|
},
|
||||||
|
|
@ -14,7 +14,9 @@ use {
|
||||||
text,
|
text,
|
||||||
theme::Color,
|
theme::Color,
|
||||||
tree::{walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode},
|
tree::{walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode},
|
||||||
utils::{clonecell::CloneCell, errorfmt::ErrorFmt, linkedlist::LinkedList},
|
utils::{
|
||||||
|
clonecell::CloneCell, errorfmt::ErrorFmt, linkedlist::LinkedList, scroller::Scroller,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
jay_config::Direction,
|
jay_config::Direction,
|
||||||
smallvec::SmallVec,
|
smallvec::SmallVec,
|
||||||
|
|
@ -38,6 +40,7 @@ pub struct OutputNode {
|
||||||
pub state: Rc<State>,
|
pub state: Rc<State>,
|
||||||
pub is_dummy: bool,
|
pub is_dummy: bool,
|
||||||
pub status: CloneCell<Rc<String>>,
|
pub status: CloneCell<Rc<String>>,
|
||||||
|
pub scroll: Scroller,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OutputNode {
|
impl OutputNode {
|
||||||
|
|
@ -404,6 +407,42 @@ impl Node for OutputNode {
|
||||||
renderer.render_output(self, x, y);
|
renderer.render_output(self, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn node_on_axis_event(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, event: &PendingScroll) {
|
||||||
|
let steps = match self.scroll.handle(event) {
|
||||||
|
Some(e) => e,
|
||||||
|
_ => return,
|
||||||
|
};
|
||||||
|
if steps == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let ws = match self.workspace.get() {
|
||||||
|
Some(ws) => ws,
|
||||||
|
_ => return,
|
||||||
|
};
|
||||||
|
let mut ws = 'ws: {
|
||||||
|
for r in self.workspaces.iter() {
|
||||||
|
if r.id == ws.id {
|
||||||
|
break 'ws r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
for _ in 0..steps.abs() {
|
||||||
|
let new = if steps < 0 { ws.prev() } else { ws.next() };
|
||||||
|
ws = match new {
|
||||||
|
Some(n) => n,
|
||||||
|
None => break,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if !self.show_workspace(&ws) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ws.deref()
|
||||||
|
.clone()
|
||||||
|
.node_do_focus(seat, Direction::Unspecified);
|
||||||
|
self.update_render_data();
|
||||||
|
}
|
||||||
|
|
||||||
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||||
// log::info!("output focus");
|
// log::info!("output focus");
|
||||||
seat.set_known_cursor(KnownCursor::Default);
|
seat.set_known_cursor(KnownCursor::Default);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue