Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions src/shell/element/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ impl CosmicStack {
let old_idx = p.active.swap(idx, Ordering::SeqCst);
if old_idx == idx {
p.reenter.store(true, Ordering::SeqCst);
p.previous_keyboard.store(old_idx, Ordering::SeqCst);
}
} else {
let mut windows = p.windows.lock().unwrap();
Expand Down Expand Up @@ -261,13 +260,10 @@ impl CosmicStack {
let result = self.0.with_program(|p| match direction {
FocusDirection::Left => {
if !p.group_focused.load(Ordering::SeqCst) {
if let Ok(old) =
p.active
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |val| {
val.checked_sub(1)
})
if p.active
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |val| val.checked_sub(1))
.is_ok()
{
p.previous_keyboard.store(old, Ordering::SeqCst);
p.scroll_to_focus.store(true, Ordering::SeqCst);
true
} else {
Expand All @@ -280,17 +276,16 @@ impl CosmicStack {
FocusDirection::Right => {
if !p.group_focused.load(Ordering::SeqCst) {
let max = p.windows.lock().unwrap().len();
if let Ok(old) =
p.active
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |val| {
if val < max - 1 {
Some(val + 1)
} else {
None
}
})
if p.active
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |val| {
if val < max - 1 {
Some(val + 1)
} else {
None
}
})
.is_ok()
{
p.previous_keyboard.store(old, Ordering::SeqCst);
p.scroll_to_focus.store(true, Ordering::SeqCst);
true
} else {
Expand Down Expand Up @@ -353,7 +348,6 @@ impl CosmicStack {
if let Some(val) = next {
let old = p.active.swap(val, Ordering::SeqCst);
windows.swap(old, val);
p.previous_keyboard.store(old, Ordering::SeqCst);
p.scroll_to_focus.store(true, Ordering::SeqCst);
MoveResult::Handled
} else {
Expand Down Expand Up @@ -399,8 +393,7 @@ impl CosmicStack {
pub fn set_active(&self, window: &CosmicSurface) {
self.0.with_program(|p| {
if let Some(val) = p.windows.lock().unwrap().iter().position(|w| w == window) {
let old = p.active.swap(val, Ordering::SeqCst);
p.previous_keyboard.store(old, Ordering::SeqCst);
p.active.store(val, Ordering::SeqCst);
}
});
self.0
Expand Down
Loading