tiling: Throttle resizes
This commit is contained in:
parent
cf26fe1c07
commit
560d234036
2 changed files with 45 additions and 12 deletions
|
|
@ -217,8 +217,14 @@ impl ResizeForkGrab {
|
||||||
|
|
||||||
impl ResizeForkGrab {
|
impl ResizeForkGrab {
|
||||||
// Returns `true` if grab should be unset
|
// Returns `true` if grab should be unset
|
||||||
fn update_location(&mut self, data: &mut State, location: Point<f64, Logical>) -> bool {
|
fn update_location(
|
||||||
|
&mut self,
|
||||||
|
data: &mut State,
|
||||||
|
location: Point<f64, Logical>,
|
||||||
|
force: bool,
|
||||||
|
) -> bool {
|
||||||
let delta = location - self.last_loc.as_logical();
|
let delta = location - self.last_loc.as_logical();
|
||||||
|
self.last_loc = location.as_global();
|
||||||
|
|
||||||
if let Some(output) = self.output.upgrade() {
|
if let Some(output) = self.output.upgrade() {
|
||||||
let mut shell = data.common.shell.write().unwrap();
|
let mut shell = data.common.shell.write().unwrap();
|
||||||
|
|
@ -228,7 +234,7 @@ impl ResizeForkGrab {
|
||||||
let tiling_layer = &mut workspace.tiling_layer;
|
let tiling_layer = &mut workspace.tiling_layer;
|
||||||
let gaps = tiling_layer.gaps();
|
let gaps = tiling_layer.gaps();
|
||||||
|
|
||||||
let tree = &mut tiling_layer.queue.trees.back_mut().unwrap().0;
|
let mut tree = tiling_layer.queue.trees.back().unwrap().0.copy_clone();
|
||||||
match &mut self.old_tree {
|
match &mut self.old_tree {
|
||||||
Some(old_tree) => {
|
Some(old_tree) => {
|
||||||
// it would be so nice to just `zip` here, but `zip` just returns `None` once either returns `None`.
|
// it would be so nice to just `zip` here, but `zip` just returns `None` once either returns `None`.
|
||||||
|
|
@ -258,7 +264,7 @@ impl ResizeForkGrab {
|
||||||
*old_tree = tree.copy_clone();
|
*old_tree = tree.copy_clone();
|
||||||
self.accumulated_delta = 0.0;
|
self.accumulated_delta = 0.0;
|
||||||
} else {
|
} else {
|
||||||
*tree = old_tree.copy_clone();
|
tree = old_tree.copy_clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x @ None => {
|
x @ None => {
|
||||||
|
|
@ -284,6 +290,10 @@ impl ResizeForkGrab {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if self.accumulated_delta.round() as i32 == 0 {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
match tree.get_mut(&self.node).unwrap().data_mut() {
|
match tree.get_mut(&self.node).unwrap().data_mut() {
|
||||||
Data::Group {
|
Data::Group {
|
||||||
sizes, orientation, ..
|
sizes, orientation, ..
|
||||||
|
|
@ -319,9 +329,18 @@ impl ResizeForkGrab {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
self.last_loc = location.as_global();
|
let should_configure = force
|
||||||
let blocker = TilingLayout::update_positions(&output, tree, gaps);
|
|| tree
|
||||||
tiling_layer.pending_blockers.extend(blocker);
|
.traverse_pre_order(&self.node)
|
||||||
|
.unwrap()
|
||||||
|
.all(|node| match node.data() {
|
||||||
|
Data::Mapped { mapped, .. } => mapped.latest_size_committed(),
|
||||||
|
_ => true,
|
||||||
|
});
|
||||||
|
if should_configure {
|
||||||
|
let blocker = TilingLayout::update_positions(&output, &mut tree, gaps);
|
||||||
|
tiling_layer.queue.push_tree(tree, None, blocker);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -348,7 +367,7 @@ impl PointerGrab<State> for ResizeForkGrab {
|
||||||
// While the grab is active, no client has pointer focus
|
// While the grab is active, no client has pointer focus
|
||||||
handle.motion(data, None, event);
|
handle.motion(data, None, event);
|
||||||
|
|
||||||
if self.update_location(data, event.location) {
|
if self.update_location(data, event.location, false) {
|
||||||
handle.unset_grab(self, data, event.serial, event.time, true);
|
handle.unset_grab(self, data, event.serial, event.time, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -477,7 +496,9 @@ impl PointerGrab<State> for ResizeForkGrab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unset(&mut self, _data: &mut State) {}
|
fn unset(&mut self, data: &mut State) {
|
||||||
|
self.update_location(data, self.last_loc.as_logical(), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TouchGrab<State> for ResizeForkGrab {
|
impl TouchGrab<State> for ResizeForkGrab {
|
||||||
|
|
@ -515,7 +536,7 @@ impl TouchGrab<State> for ResizeForkGrab {
|
||||||
seq: Serial,
|
seq: Serial,
|
||||||
) {
|
) {
|
||||||
if event.slot == <Self as TouchGrab<State>>::start_data(self).slot {
|
if event.slot == <Self as TouchGrab<State>>::start_data(self).slot {
|
||||||
if self.update_location(data, event.location) {
|
if self.update_location(data, event.location, false) {
|
||||||
handle.unset_grab(self, data);
|
handle.unset_grab(self, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -558,5 +579,7 @@ impl TouchGrab<State> for ResizeForkGrab {
|
||||||
handle.orientation(data, event, seq)
|
handle.orientation(data, event, seq)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unset(&mut self, _data: &mut State) {}
|
fn unset(&mut self, data: &mut State) {
|
||||||
|
self.update_location(data, self.last_loc.as_logical(), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2589,8 +2589,18 @@ impl TilingLayout {
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
|
||||||
self.queue.push_tree(tree, None, blocker);
|
let should_configure =
|
||||||
|
tree.traverse_pre_order(&group_id)
|
||||||
|
.unwrap()
|
||||||
|
.all(|node| match node.data() {
|
||||||
|
Data::Mapped { mapped, .. } => mapped.latest_size_committed(),
|
||||||
|
_ => true,
|
||||||
|
});
|
||||||
|
if should_configure {
|
||||||
|
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||||
|
self.queue.push_tree(tree, None, blocker);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue