mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-05 10:20:51 +00:00
parent
5361a4d72d
commit
569a7234fd
9 changed files with 33 additions and 11 deletions
|
@ -5891,6 +5891,7 @@ async fn test_right_click_menu_behind_collab_panel(cx: &mut TestAppContext) {
|
||||||
position: new_tab_button_bounds.center(),
|
position: new_tab_button_bounds.center(),
|
||||||
modifiers: Modifiers::default(),
|
modifiers: Modifiers::default(),
|
||||||
click_count: 1,
|
click_count: 1,
|
||||||
|
first_mouse: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
// regression test that the right click menu for tabs does not open.
|
// regression test that the right click menu for tabs does not open.
|
||||||
|
@ -5902,6 +5903,7 @@ async fn test_right_click_menu_behind_collab_panel(cx: &mut TestAppContext) {
|
||||||
position: tab_bounds.center(),
|
position: tab_bounds.center(),
|
||||||
modifiers: Modifiers::default(),
|
modifiers: Modifiers::default(),
|
||||||
click_count: 1,
|
click_count: 1,
|
||||||
|
first_mouse: false,
|
||||||
});
|
});
|
||||||
assert!(cx.debug_bounds("MENU_ITEM-Close").is_some());
|
assert!(cx.debug_bounds("MENU_ITEM-Close").is_some());
|
||||||
}
|
}
|
||||||
|
|
|
@ -665,6 +665,7 @@ impl VisualTestContext {
|
||||||
modifiers,
|
modifiers,
|
||||||
button: MouseButton::Left,
|
button: MouseButton::Left,
|
||||||
click_count: 1,
|
click_count: 1,
|
||||||
|
first_mouse: false,
|
||||||
});
|
});
|
||||||
self.simulate_event(MouseUpEvent {
|
self.simulate_event(MouseUpEvent {
|
||||||
position,
|
position,
|
||||||
|
|
|
@ -100,6 +100,9 @@ pub struct MouseDownEvent {
|
||||||
|
|
||||||
/// The number of times the button has been clicked.
|
/// The number of times the button has been clicked.
|
||||||
pub click_count: usize,
|
pub click_count: usize,
|
||||||
|
|
||||||
|
/// Whether this is the first, focusing click.
|
||||||
|
pub first_mouse: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Sealed for MouseDownEvent {}
|
impl Sealed for MouseDownEvent {}
|
||||||
|
|
|
@ -933,6 +933,7 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientState {
|
||||||
position: state.mouse_location,
|
position: state.mouse_location,
|
||||||
modifiers: state.modifiers,
|
modifiers: state.modifiers,
|
||||||
click_count: state.click_state.current_count,
|
click_count: state.click_state.current_count,
|
||||||
|
first_mouse: false,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,6 +218,7 @@ impl X11Client {
|
||||||
position,
|
position,
|
||||||
modifiers,
|
modifiers,
|
||||||
click_count: 1,
|
click_count: 1,
|
||||||
|
first_mouse: false,
|
||||||
}));
|
}));
|
||||||
} else if event.detail >= 4 && event.detail <= 5 {
|
} else if event.detail >= 4 && event.detail <= 5 {
|
||||||
// https://stackoverflow.com/questions/15510472/scrollwheel-event-in-x11
|
// https://stackoverflow.com/questions/15510472/scrollwheel-event-in-x11
|
||||||
|
|
|
@ -131,6 +131,7 @@ impl PlatformInput {
|
||||||
),
|
),
|
||||||
modifiers: read_modifiers(native_event),
|
modifiers: read_modifiers(native_event),
|
||||||
click_count: native_event.clickCount() as usize,
|
click_count: native_event.clickCount() as usize,
|
||||||
|
first_mouse: false,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,6 +350,8 @@ struct MacWindowState {
|
||||||
input_during_keydown: Option<SmallVec<[ImeInput; 1]>>,
|
input_during_keydown: Option<SmallVec<[ImeInput; 1]>>,
|
||||||
previous_keydown_inserted_text: Option<String>,
|
previous_keydown_inserted_text: Option<String>,
|
||||||
external_files_dragged: bool,
|
external_files_dragged: bool,
|
||||||
|
// Whether the next left-mouse click is also the focusing click.
|
||||||
|
first_mouse: bool,
|
||||||
minimized: bool,
|
minimized: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -607,6 +609,7 @@ impl MacWindow {
|
||||||
input_during_keydown: None,
|
input_during_keydown: None,
|
||||||
previous_keydown_inserted_text: None,
|
previous_keydown_inserted_text: None,
|
||||||
external_files_dragged: false,
|
external_files_dragged: false,
|
||||||
|
first_mouse: false,
|
||||||
minimized: false,
|
minimized: false,
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
@ -1262,7 +1265,6 @@ extern "C" fn handle_view_event(this: &Object, _: Sel, native_event: id) {
|
||||||
let weak_window_state = Arc::downgrade(&window_state);
|
let weak_window_state = Arc::downgrade(&window_state);
|
||||||
let mut lock = window_state.as_ref().lock();
|
let mut lock = window_state.as_ref().lock();
|
||||||
let is_active = unsafe { lock.native_window.isKeyWindow() == YES };
|
let is_active = unsafe { lock.native_window.isKeyWindow() == YES };
|
||||||
|
|
||||||
let window_height = lock.content_size().height;
|
let window_height = lock.content_size().height;
|
||||||
let event = unsafe { PlatformInput::from_native(native_event, Some(window_height)) };
|
let event = unsafe { PlatformInput::from_native(native_event, Some(window_height)) };
|
||||||
|
|
||||||
|
@ -1287,6 +1289,20 @@ extern "C" fn handle_view_event(this: &Object, _: Sel, native_event: id) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handles focusing click.
|
||||||
|
PlatformInput::MouseDown(
|
||||||
|
event @ MouseDownEvent {
|
||||||
|
button: MouseButton::Left,
|
||||||
|
..
|
||||||
|
},
|
||||||
|
) if (lock.first_mouse) => {
|
||||||
|
*event = MouseDownEvent {
|
||||||
|
first_mouse: true,
|
||||||
|
..*event
|
||||||
|
};
|
||||||
|
lock.first_mouse = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Because we map a ctrl-left_down to a right_down -> right_up let's ignore
|
// Because we map a ctrl-left_down to a right_down -> right_up let's ignore
|
||||||
// the ctrl-left_up to avoid having a mismatch in button down/up events if the
|
// the ctrl-left_up to avoid having a mismatch in button down/up events if the
|
||||||
// user is still holding ctrl when releasing the left mouse button
|
// user is still holding ctrl when releasing the left mouse button
|
||||||
|
@ -1745,15 +1761,10 @@ extern "C" fn view_did_change_effective_appearance(this: &Object, _: Sel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn accepts_first_mouse(this: &Object, _: Sel, _: id) -> BOOL {
|
extern "C" fn accepts_first_mouse(this: &Object, _: Sel, _: id) -> BOOL {
|
||||||
unsafe {
|
let window_state = unsafe { get_window_state(this) };
|
||||||
let state = get_window_state(this);
|
let mut lock = window_state.as_ref().lock();
|
||||||
let lock = state.as_ref().lock();
|
lock.first_mouse = true;
|
||||||
if lock.kind == WindowKind::PopUp {
|
YES
|
||||||
YES
|
|
||||||
} else {
|
|
||||||
NO
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn dragging_entered(this: &Object, _: Sel, dragging_info: id) -> NSDragOperation {
|
extern "C" fn dragging_entered(this: &Object, _: Sel, dragging_info: id) -> NSDragOperation {
|
||||||
|
|
|
@ -594,6 +594,7 @@ impl WindowsWindowInner {
|
||||||
position: logical_point(x, y, scale_factor),
|
position: logical_point(x, y, scale_factor),
|
||||||
modifiers: self.current_modifiers(),
|
modifiers: self.current_modifiers(),
|
||||||
click_count: 1,
|
click_count: 1,
|
||||||
|
first_mouse: false,
|
||||||
};
|
};
|
||||||
if callback(PlatformInput::MouseDown(event)).default_prevented {
|
if callback(PlatformInput::MouseDown(event)).default_prevented {
|
||||||
return Some(0);
|
return Some(0);
|
||||||
|
@ -1009,6 +1010,7 @@ impl WindowsWindowInner {
|
||||||
position: logical_point(cursor_point.x as f32, cursor_point.y as f32, scale_factor),
|
position: logical_point(cursor_point.x as f32, cursor_point.y as f32, scale_factor),
|
||||||
modifiers: self.current_modifiers(),
|
modifiers: self.current_modifiers(),
|
||||||
click_count: 1,
|
click_count: 1,
|
||||||
|
first_mouse: false,
|
||||||
};
|
};
|
||||||
if callback(PlatformInput::MouseDown(event)).default_prevented {
|
if callback(PlatformInput::MouseDown(event)).default_prevented {
|
||||||
return Some(0);
|
return Some(0);
|
||||||
|
|
|
@ -1450,7 +1450,7 @@ impl ProjectPanel {
|
||||||
.ml_1(),
|
.ml_1(),
|
||||||
)
|
)
|
||||||
.on_click(cx.listener(move |this, event: &gpui::ClickEvent, cx| {
|
.on_click(cx.listener(move |this, event: &gpui::ClickEvent, cx| {
|
||||||
if event.down.button == MouseButton::Right {
|
if event.down.button == MouseButton::Right || event.down.first_mouse {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if !show_editor {
|
if !show_editor {
|
||||||
|
|
Loading…
Reference in a new issue