Skip to content

Commit

Permalink
layout: Correct view offset when swapping columns
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Sep 13, 2023
1 parent 219ca08 commit 46403bd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,19 @@ impl<W: LayoutElement> Workspace<W> {
return;
}

let current_x = self.view_pos();

self.columns.swap(self.active_column_idx, new_idx);

let new_x = self.column_x(self.active_column_idx) - PADDING;
let new_view_offset = compute_new_view_offset(
current_x,
self.view_size.w,
new_x,
self.columns[self.active_column_idx].size().w,
);
self.view_offset = new_view_offset;

self.activate_column(new_idx);
}

Expand All @@ -1537,7 +1549,19 @@ impl<W: LayoutElement> Workspace<W> {
return;
}

let current_x = self.view_pos();

self.columns.swap(self.active_column_idx, new_idx);

let new_x = self.column_x(self.active_column_idx) - PADDING;
let new_view_offset = compute_new_view_offset(
current_x,
self.view_size.w,
new_x,
self.columns[self.active_column_idx].size().w,
);
self.view_offset = new_view_offset;

self.activate_column(new_idx);
}

Expand Down

0 comments on commit 46403bd

Please sign in to comment.