From ab9f07344399f70e4079644d9876536472178795 Mon Sep 17 00:00:00 2001 From: K Simmons Date: Thu, 11 Aug 2022 12:24:48 -0700 Subject: [PATCH] fixed merge errors --- crates/gpui/src/presenter.rs | 58 +++++---------- crates/terminal/src/connected_el.rs | 111 ++++++++++++---------------- crates/workspace/src/pane.rs | 15 ++-- 3 files changed, 74 insertions(+), 110 deletions(-) diff --git a/crates/gpui/src/presenter.rs b/crates/gpui/src/presenter.rs index 87dc6377c7..92665dcaba 100644 --- a/crates/gpui/src/presenter.rs +++ b/crates/gpui/src/presenter.rs @@ -284,15 +284,11 @@ impl Presenter { { events_to_send.push(( clicked_region.clone(), -<<<<<<< HEAD - MouseRegionEvent::Drag(*prev_drag_position, *e), -======= MouseRegionEvent::Drag(DragRegionEvent { region: clicked_region.bounds, prev_drag_position: *prev_drag_position, platform_event: e.clone(), }), ->>>>>>> 4bd8a4b0 (wip tab drag and drop) )); } @@ -313,7 +309,7 @@ impl Presenter { _ => {} } - let (invalidated_views, dispatch_directives, handled) = { + let (invalidated_views, handled) = { let mut event_cx = self.handle_hover_events(&event, cx); event_cx.process_region_events(events_to_send); @@ -321,25 +317,9 @@ impl Presenter { event_cx.handled = event_cx.dispatch_event(root_view_id, &event); } - if let Some(callback) = region.handlers.get(&event.handler_key()) { - event_cx.with_current_view(region.view_id, |event_cx| { - callback(event, event_cx); - }) - } - - ( - event_cx.invalidated_views, - event_cx.dispatched_actions, - event_cx.handled, - ) + (event_cx.invalidated_views, event_cx.handled) }; - if !handled { - handled = event_cx.dispatch_event(root_view_id, &event); - } - - invalidated_views.extend(event_cx.invalidated_views); - for view_id in invalidated_views { cx.notify_view(self.window_id, view_id); } @@ -400,23 +380,23 @@ impl Presenter { } } } else if let Some(region_id) = region.id() { - if self.hovered_region_ids.contains(®ion_id) { - let region_event = if pressed_button.is_some() { - MouseRegionEvent::DragOver(DragOverRegionEvent { - region: region.bounds, - started: false, - platform_event: e.clone(), - }) - } else { - MouseRegionEvent::Hover(HoverRegionEvent { - region: region.bounds, - started: false, - platform_event: e.clone(), - }) - }; - events_to_send.push((region.clone(), region_event)); - self.hovered_region_ids.remove(®ion_id); - } + if self.hovered_region_ids.contains(®ion_id) { + let region_event = if pressed_button.is_some() { + MouseRegionEvent::DragOver(DragOverRegionEvent { + region: region.bounds, + started: false, + platform_event: e.clone(), + }) + } else { + MouseRegionEvent::Hover(HoverRegionEvent { + region: region.bounds, + started: false, + platform_event: e.clone(), + }) + }; + events_to_send.push((region.clone(), region_event)); + self.hovered_region_ids.remove(®ion_id); + } } } } diff --git a/crates/terminal/src/connected_el.rs b/crates/terminal/src/connected_el.rs index f138173a0b..b27d8795cb 100644 --- a/crates/terminal/src/connected_el.rs +++ b/crates/terminal/src/connected_el.rs @@ -421,75 +421,60 @@ impl TerminalEl { let drag_connection = self.terminal; cx.scene.push_mouse_region( MouseRegion::new(view_id, None, visible_bounds) - .on_down( - MouseButton::Left, - move |MouseButtonEvent { position, .. }, cx| { - if let Some(conn_handle) = mouse_down_connection.upgrade(cx.app) { - conn_handle.update(cx.app, |terminal, cx| { - let (point, side) = TerminalEl::mouse_to_cell_data( - position, - origin, - cur_size, - display_offset, - ); + .on_down(MouseButton::Left, move |e, cx| { + if let Some(conn_handle) = mouse_down_connection.upgrade(cx.app) { + conn_handle.update(cx.app, |terminal, cx| { + let (point, side) = TerminalEl::mouse_to_cell_data( + e.position, + origin, + cur_size, + display_offset, + ); - terminal.mouse_down(point, side); + terminal.mouse_down(point, side); - cx.notify(); - }) - } - }, - ) - .on_click( - MouseButton::Left, - move |MouseButtonEvent { - position, - click_count, - .. - }, - cx| { - cx.focus_parent_view(); - if let Some(conn_handle) = click_connection.upgrade(cx.app) { - conn_handle.update(cx.app, |terminal, cx| { - let (point, side) = TerminalEl::mouse_to_cell_data( - position, - origin, - cur_size, - display_offset, - ); + cx.notify(); + }) + } + }) + .on_click(MouseButton::Left, move |e, cx| { + cx.focus_parent_view(); + if let Some(conn_handle) = click_connection.upgrade(cx.app) { + conn_handle.update(cx.app, |terminal, cx| { + let (point, side) = TerminalEl::mouse_to_cell_data( + e.position, + origin, + cur_size, + display_offset, + ); - terminal.click(point, side, click_count); + terminal.click(point, side, e.click_count); - cx.notify(); - }); - } - }, - ) - .on_click( - MouseButton::Right, - move |MouseButtonEvent { position, .. }, cx| { - cx.dispatch_action(DeployContextMenu { position }); - }, - ) - .on_drag( - MouseButton::Left, - move |_, MouseMovedEvent { position, .. }, cx| { - if let Some(conn_handle) = drag_connection.upgrade(cx.app) { - conn_handle.update(cx.app, |terminal, cx| { - let (point, side) = TerminalEl::mouse_to_cell_data( - position, - origin, - cur_size, - display_offset, - ); + cx.notify(); + }); + } + }) + .on_click(MouseButton::Right, move |e, cx| { + cx.dispatch_action(DeployContextMenu { + position: e.position, + }); + }) + .on_drag(MouseButton::Left, move |e, cx| { + if let Some(conn_handle) = drag_connection.upgrade(cx.app) { + conn_handle.update(cx.app, |terminal, cx| { + let (point, side) = TerminalEl::mouse_to_cell_data( + e.position, + origin, + cur_size, + display_offset, + ); - terminal.drag(point, side); + terminal.drag(point, side); - cx.notify() - }); - } - }, - ), + cx.notify() + }); + } + }), ); } diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 68878dc6a4..145ba0f851 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -14,8 +14,8 @@ use gpui::{ impl_actions, impl_internal_actions, platform::{CursorStyle, NavigationDirection}, AnyViewHandle, AnyWeakViewHandle, AppContext, AsyncAppContext, Entity, EventContext, - ModelHandle, MouseButton, MouseButtonEvent, MutableAppContext, PromptLevel, Quad, - RenderContext, Task, View, ViewContext, ViewHandle, WeakViewHandle, + ModelHandle, MouseButton, MutableAppContext, PromptLevel, Quad, RenderContext, Task, View, + ViewContext, ViewHandle, WeakViewHandle, }; use project::{Project, ProjectEntryId, ProjectPath}; use serde::Deserialize; @@ -1143,12 +1143,11 @@ impl View for Pane { }, ) .with_cursor_style(CursorStyle::PointingHand) - .on_down( - MouseButton::Left, - |MouseButtonEvent { position, .. }, cx| { - cx.dispatch_action(DeployNewMenu { position }); - }, - ) + .on_down(MouseButton::Left, |e, cx| { + cx.dispatch_action(DeployNewMenu { + position: e.position, + }); + }) .boxed(), MouseEventHandler::new::( 1,