Skip to content

Commit

Permalink
Close tab on middle mouse click.
Browse files Browse the repository at this point in the history
  • Loading branch information
William Calliari committed Oct 10, 2024
1 parent a4d875e commit ed0e678
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/shell/element/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,10 @@ impl TabMessage for Message {
fn scrolled() -> Self {
Message::Scrolled
}

fn close(idx: usize) -> Self {
Message::Close(idx)
}
}

impl Program for CosmicStackInternal {
Expand Down
10 changes: 10 additions & 0 deletions src/shell/element/stack/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl From<TabBackgroundTheme> for theme::Container {

pub trait TabMessage: Clone {
fn activate(idx: usize) -> Self;
fn close(idx: usize) -> Self;

fn scroll_further() -> Self;
fn scroll_back() -> Self;
Expand Down Expand Up @@ -418,6 +419,15 @@ where
shell.publish(Message::activate(self.idx));
return event::Status::Captured;
}

if matches!(
event,
event::Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Middle))
) {
shell.publish(Message::close(self.idx));
return event::Status::Captured;
}

}

status
Expand Down

0 comments on commit ed0e678

Please sign in to comment.