1
0
Fork 0
forked from wry/wry

tree: support toggling floating with double clicks

This commit is contained in:
Julian Orth 2024-03-03 14:18:46 +01:00
parent a588b9044d
commit d425768760
11 changed files with 137 additions and 14 deletions

View file

@ -18,6 +18,7 @@ use {
},
utils::{
clonecell::CloneCell,
double_click_state::DoubleClickState,
errorfmt::ErrorFmt,
linkedlist::{LinkedList, LinkedNode, NodeRef},
numcell::NumCell,
@ -146,6 +147,7 @@ struct SeatState {
x: i32,
y: i32,
op: Option<SeatOp>,
double_click_state: DoubleClickState,
}
impl ContainerChild {
@ -521,6 +523,7 @@ impl ContainerNode {
x,
y,
op: None,
double_click_state: Default::default(),
});
let mut changed = false;
changed |= mem::replace(&mut seat_state.x, x) != x;
@ -1176,7 +1179,7 @@ impl Node for ContainerNode {
fn node_on_button(
self: Rc<Self>,
seat: &Rc<WlSeatGlobal>,
_time_usec: u64,
time_usec: u64,
button: u32,
state: KeyState,
_serial: u32,
@ -1232,6 +1235,15 @@ impl Node for ContainerNode {
}
return;
};
if seat_data
.double_click_state
.click(&self.state, time_usec, seat_data.x, seat_data.y)
&& kind == SeatOpKind::Move
{
drop(seat_datas);
seat.set_tl_floating(child.node.clone(), true);
return;
}
seat_data.op = Some(SeatOp { child, kind })
} else if state == KeyState::Released {
let op = seat_data.op.take().unwrap();

View file

@ -14,8 +14,8 @@ use {
StackedNode, ToplevelNode, WorkspaceNode,
},
utils::{
clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt,
linkedlist::LinkedNode,
clonecell::CloneCell, copyhashmap::CopyHashMap, double_click_state::DoubleClickState,
errorfmt::ErrorFmt, linkedlist::LinkedNode,
},
},
ahash::AHashMap,
@ -57,6 +57,7 @@ struct SeatState {
op_active: bool,
dist_hor: i32,
dist_ver: i32,
double_click_state: DoubleClickState,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
@ -228,6 +229,7 @@ impl FloatNode {
op_active: false,
dist_hor: 0,
dist_ver: 0,
double_click_state: Default::default(),
});
seat_state.x = x;
seat_state.y = y;
@ -462,7 +464,7 @@ impl Node for FloatNode {
fn node_on_button(
self: Rc<Self>,
seat: &Rc<WlSeatGlobal>,
_time_usec: u64,
time_usec: u64,
button: u32,
state: KeyState,
_serial: u32,
@ -479,6 +481,17 @@ impl Node for FloatNode {
if state != KeyState::Pressed {
return;
}
if seat_data
.double_click_state
.click(&self.state, time_usec, seat_data.x, seat_data.y)
&& seat_data.op_type == OpType::Move
{
if let Some(tl) = self.child.get() {
drop(seat_datas);
seat.set_tl_floating(tl, false);
return;
}
}
seat_data.op_active = true;
let pos = self.position.get();
match seat_data.op_type {