@@ -3,7 +3,7 @@ |
| 3 | 3 | use garfield::ui::pane::SplitDirection; |
| 4 | 4 | use garfield::ui::{AddressBar, Breadcrumb, HelpModal, Pane, Sidebar, StatusBar, TabBar, TabInfo, Toolbar, ToolbarAction, ViewMode, TAB_BAR_HEIGHT, TOOLBAR_HEIGHT}; |
| 5 | 5 | use anyhow::Result; |
| 6 | | -use gartk_core::{InputEvent, Key, Point, Rect, Theme}; |
| 6 | +use gartk_core::{InputEvent, Key, MouseButton, Point, Rect, Theme}; |
| 7 | 7 | use gartk_render::{Renderer, Surface, TextStyle}; |
| 8 | 8 | use gartk_x11::{Connection, EventLoop, EventLoopConfig, Window, WindowConfig}; |
| 9 | 9 | use std::path::PathBuf; |
@@ -232,7 +232,7 @@ impl App { |
| 232 | 232 | } |
| 233 | 233 | InputEvent::MousePress(mouse_event) => { |
| 234 | 234 | let pos = Point::new(mouse_event.position.x, mouse_event.position.y); |
| 235 | | - self.handle_mouse_press(pos, &mouse_event.modifiers); |
| 235 | + self.handle_mouse_press(pos, &mouse_event.modifiers, mouse_event.button); |
| 236 | 236 | ev.request_redraw(); |
| 237 | 237 | } |
| 238 | 238 | InputEvent::MouseRelease(mouse_event) => { |
@@ -283,25 +283,35 @@ impl App { |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /// Handle mouse press. |
| 286 | | - fn handle_mouse_press(&mut self, pos: Point, modifiers: &gartk_core::Modifiers) { |
| 286 | + fn handle_mouse_press(&mut self, pos: Point, modifiers: &gartk_core::Modifiers, button: Option<MouseButton>) { |
| 287 | 287 | // Check help modal first (clicking outside closes it) |
| 288 | 288 | if self.help_modal.on_click(pos) { |
| 289 | 289 | return; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | | - // Check tab bar clicks - try to start tab drag first |
| 293 | | - if self.tab_bar.start_drag(pos) { |
| 294 | | - // Started potential tab drag, don't switch yet |
| 295 | | - return; |
| 292 | + // Handle middle-click on tab bar to close tab |
| 293 | + if button == Some(MouseButton::Middle) { |
| 294 | + if let Some(index) = self.tab_bar.tab_at_point(pos) { |
| 295 | + self.close_tab(index); |
| 296 | + return; |
| 297 | + } |
| 296 | 298 | } |
| 297 | 299 | |
| 298 | | - // Handle tab bar close button clicks (non-drag) |
| 299 | | - if let Some((tab_index, is_close)) = self.tab_bar.on_click(pos) { |
| 300 | | - if is_close { |
| 301 | | - self.close_tab(tab_index); |
| 300 | + // Check tab bar clicks - try to start tab drag first (left click only) |
| 301 | + if button == Some(MouseButton::Left) || button.is_none() { |
| 302 | + if self.tab_bar.start_drag(pos) { |
| 303 | + // Started potential tab drag, don't switch yet |
| 304 | + return; |
| 305 | + } |
| 306 | + |
| 307 | + // Handle tab bar close button clicks (non-drag) |
| 308 | + if let Some((tab_index, is_close)) = self.tab_bar.on_click(pos) { |
| 309 | + if is_close { |
| 310 | + self.close_tab(tab_index); |
| 311 | + } |
| 312 | + // Tab selection happens on mouse release if not dragged |
| 313 | + return; |
| 302 | 314 | } |
| 303 | | - // Tab selection happens on mouse release if not dragged |
| 304 | | - return; |
| 305 | 315 | } |
| 306 | 316 | |
| 307 | 317 | // Check toolbar clicks |