From c42bf1c50b13022b81472b8a7370d06f4d03bd56 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 19 Aug 2022 17:19:35 -0700 Subject: [PATCH 1/2] Fixed bug in mouse handler attaching --- crates/terminal/src/connected_el.rs | 34 +++++++++++++++-------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/crates/terminal/src/connected_el.rs b/crates/terminal/src/connected_el.rs index 7e4cbd1e82..e0117192fd 100644 --- a/crates/terminal/src/connected_el.rs +++ b/crates/terminal/src/connected_el.rs @@ -499,23 +499,10 @@ impl TerminalEl { 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) { + //All mouse modes need the extra click handlers + if mode.intersects(TermMode::MOUSE_MODE) { region = region .on_down( MouseButton::Right, @@ -558,6 +545,21 @@ impl TerminalEl { ), ) } + //Mouse move manages both dragging and motion events + if mode.intersects(TermMode::MOUSE_DRAG | TermMode::MOUSE_MOTION) { + region = region + //This 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(); + }) + } + } + }) + } //TODO: Mouse drag isn't correct //TODO: Nor is mouse motion. Move events aren't happening?? From 3ffe760ed344ef6ba02bb648f6d6bef61577c312 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 19 Aug 2022 17:20:54 -0700 Subject: [PATCH 2/2] Removed extra todos --- crates/terminal/src/connected_el.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/crates/terminal/src/connected_el.rs b/crates/terminal/src/connected_el.rs index e0117192fd..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,14 +485,14 @@ 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 { @@ -501,7 +501,8 @@ impl TerminalEl { }, ); - //All mouse modes need the extra click handlers + // Mouse mode handlers: + // All mouse modes need the extra click handlers if mode.intersects(TermMode::MOUSE_MODE) { region = region .on_down( @@ -548,7 +549,7 @@ impl TerminalEl { //Mouse move manages both dragging and motion events if mode.intersects(TermMode::MOUSE_DRAG | TermMode::MOUSE_MOTION) { region = region - //This does not fire on right-mouse-down-move events wild. + //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) { @@ -561,8 +562,6 @@ impl TerminalEl { }) } - //TODO: Mouse drag isn't correct - //TODO: Nor is mouse motion. Move events aren't happening?? cx.scene.push_mouse_region(region); }