mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-11-16 07:48:11 +01:00
Invalidate snapshots when swapping windows
Hack to make the snapshot location correct
This commit is contained in:
parent
f3d0653e9a
commit
598b7efa74
3 changed files with 14 additions and 10 deletions
|
@ -165,6 +165,14 @@ impl PointerGrab<State> for MoveSurfaceGrab {
|
|||
|
||||
let output = self.window.output(&state.pinnacle);
|
||||
|
||||
// HACK: Snapshots may not be cleared and updated when swapping two windows of the same size;
|
||||
// this causes new snapshots attempts to fizzle and the currently stored snapshot
|
||||
// will have the wrong location. We're just gonna invalidate all window snapshots here
|
||||
// because I'm too lazy to rearchitect stuff to make it more sensible.
|
||||
for window in state.pinnacle.windows.iter() {
|
||||
window.with_state_mut(|state| state.snapshot.take());
|
||||
}
|
||||
|
||||
if let Some(output) = output.as_ref() {
|
||||
state.capture_snapshots_on_output(output, [self.window.clone()]);
|
||||
}
|
||||
|
|
|
@ -128,7 +128,6 @@ impl Pinnacle {
|
|||
pending_wins
|
||||
}
|
||||
|
||||
/// Swaps two windows in the main window vec and updates all windows.
|
||||
pub fn swap_window_positions(&mut self, win1: &WindowElement, win2: &WindowElement) {
|
||||
let win1_index = self.windows.iter().position(|win| win == win1);
|
||||
let win2_index = self.windows.iter().position(|win| win == win2);
|
||||
|
|
|
@ -132,19 +132,16 @@ impl WindowElement {
|
|||
location: Point<i32, Logical>,
|
||||
scale: Scale<f64>,
|
||||
alpha: f32,
|
||||
) -> LayoutSnapshot {
|
||||
) -> Option<LayoutSnapshot> {
|
||||
self.with_state_mut(|state| {
|
||||
if state.snapshot.is_none() || self.is_x11() {
|
||||
let elements = self.texture_render_elements(renderer, location, scale, alpha);
|
||||
|
||||
state.snapshot = Some(RenderSnapshot::new(elements, scale));
|
||||
if !elements.is_empty() {
|
||||
state.snapshot = Some(RenderSnapshot::new(elements, scale));
|
||||
}
|
||||
}
|
||||
|
||||
let Some(ret) = state.snapshot.clone() else {
|
||||
unreachable!()
|
||||
};
|
||||
|
||||
ret
|
||||
state.snapshot.clone()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +209,7 @@ pub fn capture_snapshots_on_output(
|
|||
1.0,
|
||||
);
|
||||
|
||||
Some(SnapshotTarget::Snapshot(snapshot))
|
||||
snapshot.map(SnapshotTarget::Snapshot)
|
||||
} else {
|
||||
Some(SnapshotTarget::Window(win))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue