From a85c57c8e7fcb6c5ff5485d582a30cb9fec293e0 Mon Sep 17 00:00:00 2001 From: squid Date: Tue, 17 Nov 2026 20:44:05 +0100 Subject: [PATCH] Better mouse cursors selection on tabs and tab close areas --- src/main.rs | 61 ++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9013f3f..45fd657 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8049,24 +8049,20 @@ fn tab_view( let inactive_bg = colors[ColorOption::SidebarBackground.index()]; let outline = colors[ColorOption::ActiveTabOutline.index()]; - let title_button = button( - container(text(fit_title(&title)).size(15)) + let title_color = if active { + text_color + } else { + text_color.scale_alpha(0.6) + }; + + let title_button = mouse_area( + container(text(fit_title(&title)).size(15).color(title_color)) .width(Length::Fill) + .padding(padding) + .clip(true) .align_x(Alignment::Center), ) - .on_press(Message::SelectTab(window, tab)) - .padding(padding) - .width(Length::Fill) - .clip(true) - .style(move |theme, status| { - let mut style = button::text(theme, status); - style.text_color = if active { - text_color - } else { - text_color.scale_alpha(0.6) - }; - style - }); + .on_press(Message::SelectTab(window, tab)); let close_icon = |padding: Padding| { button(text("×").size(15)) @@ -8198,18 +8194,21 @@ fn drag_ghost( }); Some( - container(ghost) - .width(Length::Fill) - .height(Length::Fill) - .align_x(Alignment::Start) - .align_y(Alignment::Start) - .padding(Padding { - top: y, - left: x, - right: 0.0, - bottom: 0.0, - }) - .into(), + mouse_area( + container(ghost) + .width(Length::Fill) + .height(Length::Fill) + .align_x(Alignment::Start) + .align_y(Alignment::Start) + .padding(Padding { + top: y, + left: x, + right: 0.0, + bottom: 0.0, + }), + ) + .interaction(mouse::Interaction::Grabbing) + .into(), ) } @@ -11900,9 +11899,13 @@ impl canvas::Program for TerminalCanvas<'_> { fn mouse_interaction( &self, dragging: &Self::State, - _bounds: Rectangle, - _cursor: mouse::Cursor, + bounds: Rectangle, + cursor: mouse::Cursor, ) -> mouse::Interaction { + if !cursor.is_over(bounds) { + return mouse::Interaction::None; + } + if *dragging { mouse::Interaction::Grabbing } else {