diff --git a/crates/terminal/src/connected_el.rs b/crates/terminal/src/connected_el.rs index 7e4cbd1e82..20a97b53d3 100644 --- a/crates/terminal/src/connected_el.rs +++ b/crates/terminal/src/connected_el.rs @@ -439,9 +439,9 @@ impl TerminalEl { let mut region = MouseRegion::new(view_id, None, visible_bounds); - //Terminal Emulator controlled behavior: + // Terminal Emulator controlled behavior: region = region - //Start selections + // Start selections .on_down( MouseButton::Left, TerminalEl::generic_button_handler( @@ -452,7 +452,7 @@ impl TerminalEl { }, ), ) - //Update drag selections + // Update drag selections .on_drag(MouseButton::Left, move |_prev, event, cx| { if cx.is_parent_view_focused() { if let Some(conn_handle) = connection.upgrade(cx.app) { @@ -463,7 +463,7 @@ impl TerminalEl { } } }) - //Copy on up behavior + // Copy on up behavior .on_up( MouseButton::Left, TerminalEl::generic_button_handler( @@ -474,7 +474,7 @@ impl TerminalEl { }, ), ) - //Handle click based selections + // Handle click based selections .on_click( MouseButton::Left, TerminalEl::generic_button_handler( @@ -485,37 +485,25 @@ impl TerminalEl { }, ), ) - //Context menu + // Context menu .on_click( MouseButton::Right, move |e @ MouseButtonEvent { position, .. }, cx| { let mouse_mode = if let Some(conn_handle) = connection.upgrade(cx.app) { conn_handle.update(cx.app, |terminal, _cx| terminal.mouse_mode(e.shift)) } else { - //If we can't get the model handle, probably can't deploy the context menu + // If we can't get the model handle, probably can't deploy the context menu true }; if !mouse_mode { cx.dispatch_action(DeployContextMenu { position }); } }, - ) - //This handles both drag mode and mouse motion mode - //Mouse Move TODO - //This cannot be done conditionally for unknown reasons. Pending drag and drop rework. - //This also does not fire on right-mouse-down-move events wild. - .on_move(move |event, cx| { - if cx.is_parent_view_focused() { - if let Some(conn_handle) = connection.upgrade(cx.app) { - conn_handle.update(cx.app, |terminal, cx| { - terminal.mouse_move(&event, origin); - cx.notify(); - }) - } - } - }); + ); - if mode.contains(TermMode::MOUSE_MODE) { + // Mouse mode handlers: + // All mouse modes need the extra click handlers + if mode.intersects(TermMode::MOUSE_MODE) { region = region .on_down( MouseButton::Right, @@ -558,9 +546,22 @@ impl TerminalEl { ), ) } + //Mouse move manages both dragging and motion events + if mode.intersects(TermMode::MOUSE_DRAG | TermMode::MOUSE_MOTION) { + region = region + //TODO: This does not fire on right-mouse-down-move events. + .on_move(move |event, cx| { + if cx.is_parent_view_focused() { + if let Some(conn_handle) = connection.upgrade(cx.app) { + conn_handle.update(cx.app, |terminal, cx| { + terminal.mouse_move(&event, origin); + cx.notify(); + }) + } + } + }) + } - //TODO: Mouse drag isn't correct - //TODO: Nor is mouse motion. Move events aren't happening?? cx.scene.push_mouse_region(region); }