it: fix integration geometry and tab scrolling
This commit is contained in:
parent
5c2f631fdb
commit
466da3da88
30 changed files with 123 additions and 72 deletions
|
|
@ -32,6 +32,7 @@ use {
|
|||
numcell::NumCell,
|
||||
on_drop_event::OnDropEvent,
|
||||
rc_eq::rc_eq,
|
||||
scroller::Scroller,
|
||||
threshold_counter::ThresholdCounter,
|
||||
},
|
||||
},
|
||||
|
|
@ -150,6 +151,7 @@ pub struct ContainerNode {
|
|||
pub child_removed: Rc<LazyEventSource>,
|
||||
pub all_children_resized: Rc<LazyEventSource>,
|
||||
pub tab_bar: RefCell<Option<TabBar>>,
|
||||
scroll: Scroller,
|
||||
pub update_tab_textures_scheduled: Cell<bool>,
|
||||
pub ephemeral: Cell<Ephemeral>,
|
||||
}
|
||||
|
|
@ -266,6 +268,7 @@ impl ContainerNode {
|
|||
child_removed: state.lazy_event_sources.create_source(),
|
||||
all_children_resized: state.post_layout_event_sources.create_source(),
|
||||
tab_bar: RefCell::new(None),
|
||||
scroll: Default::default(),
|
||||
update_tab_textures_scheduled: Cell::new(false),
|
||||
ephemeral: Cell::new(Ephemeral::Off),
|
||||
});
|
||||
|
|
@ -793,6 +796,18 @@ impl ContainerNode {
|
|||
self.activate_child2(child, false);
|
||||
}
|
||||
|
||||
fn activate_child_from_input(
|
||||
self: &Rc<Self>,
|
||||
child: &NodeRef<ContainerChild>,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
) {
|
||||
self.activate_child(child);
|
||||
child
|
||||
.node
|
||||
.clone()
|
||||
.node_do_focus(seat, Direction::Unspecified);
|
||||
}
|
||||
|
||||
fn activate_child2(self: &Rc<Self>, child: &NodeRef<ContainerChild>, preserve_focus: bool) {
|
||||
if let Some(mc) = self.mono_child.get() {
|
||||
if mc.node.node_id() == child.node.node_id() {
|
||||
|
|
@ -1519,7 +1534,7 @@ impl ContainerNode {
|
|||
fn button(
|
||||
self: Rc<Self>,
|
||||
id: CursorType,
|
||||
_seat: &Rc<WlSeatGlobal>,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
_time_usec: u64,
|
||||
pressed: bool,
|
||||
button: u32,
|
||||
|
|
@ -1549,7 +1564,7 @@ impl ContainerNode {
|
|||
if let Some(child) = children.get(&child_id) {
|
||||
let child_ref = child.to_ref();
|
||||
drop(children);
|
||||
self.activate_child(&child_ref);
|
||||
self.activate_child_from_input(&child_ref, seat);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -2066,31 +2081,33 @@ impl Node for ContainerNode {
|
|||
self.button(id, seat, time_usec, state == ButtonState::Pressed, button);
|
||||
}
|
||||
|
||||
fn node_on_axis_event(self: Rc<Self>, _seat: &Rc<WlSeatGlobal>, event: &PendingScroll) {
|
||||
fn node_on_axis_event(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, event: &PendingScroll) {
|
||||
if self.mono_child.is_none() {
|
||||
return;
|
||||
}
|
||||
// Use vertical scroll (index 1) to switch tabs.
|
||||
let v = match event.v120[1].get() {
|
||||
Some(v) if v != 0 => v,
|
||||
let steps = match self.scroll.handle(event) {
|
||||
Some(steps) => steps,
|
||||
_ => return,
|
||||
};
|
||||
let mono = match self.mono_child.get() {
|
||||
let mut target = match self.mono_child.get() {
|
||||
Some(m) => m,
|
||||
None => return,
|
||||
};
|
||||
let next = if v > 0 {
|
||||
// Scroll down → next tab.
|
||||
mono.next().or_else(|| self.children.first())
|
||||
} else {
|
||||
// Scroll up → previous tab.
|
||||
mono.prev().or_else(|| self.children.last())
|
||||
};
|
||||
if let Some(next) = next {
|
||||
if next.node.node_id() != mono.node.node_id() {
|
||||
self.activate_child(&next);
|
||||
let current_id = target.node.node_id();
|
||||
for _ in 0..steps.abs() {
|
||||
let next = if steps > 0 {
|
||||
target.next().or_else(|| self.children.first())
|
||||
} else {
|
||||
target.prev().or_else(|| self.children.last())
|
||||
};
|
||||
match next {
|
||||
Some(next) => target = next,
|
||||
None => break,
|
||||
}
|
||||
}
|
||||
if target.node.node_id() != current_id {
|
||||
self.activate_child_from_input(&target, seat);
|
||||
}
|
||||
}
|
||||
|
||||
fn node_on_leave(&self, seat: &WlSeatGlobal) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue