Merge remote-tracking branch 'origin/main' into cache

# Conflicts:
#	crates/copilot/src/sign_in.rs
#	crates/gpui/src/window.rs
#	crates/workspace/src/pane_group.rs
This commit is contained in:
Antonio Scandurra
2024-01-10 22:58:52 +01:00
216 changed files with 4218 additions and 2389 deletions
+2 -2
View File
@@ -14,12 +14,12 @@ pub struct MacDisplay(pub(crate) CGDirectDisplayID);
unsafe impl Send for MacDisplay {}
impl MacDisplay {
/// Get the screen with the given [DisplayId].
/// Get the screen with the given [`DisplayId`].
pub fn find_by_id(id: DisplayId) -> Option<Self> {
Self::all().find(|screen| screen.id() == id)
}
/// Get the screen with the given persistent [Uuid].
/// Get the screen with the given persistent [`Uuid`].
pub fn find_by_uuid(uuid: Uuid) -> Option<Self> {
Self::all().find(|screen| screen.uuid().ok() == Some(uuid))
}
+18 -9
View File
@@ -337,6 +337,7 @@ struct MacWindowState {
ime_state: ImeState,
// Retains the last IME Text
ime_text: Option<String>,
external_files_dragged: bool,
}
impl MacWindowState {
@@ -565,6 +566,7 @@ impl MacWindow {
previous_modifiers_changed_event: None,
ime_state: ImeState::None,
ime_text: None,
external_files_dragged: false,
})));
(*native_window).set_ivar(
@@ -1230,15 +1232,20 @@ extern "C" fn handle_view_event(this: &Object, _: Sel, native_event: id) {
..
},
) => {
lock.synthetic_drag_counter += 1;
let executor = lock.executor.clone();
executor
.spawn(synthetic_drag(
weak_window_state,
lock.synthetic_drag_counter,
event.clone(),
))
.detach();
// Synthetic drag is used for selecting long buffer contents while buffer is being scrolled.
// External file drag and drop is able to emit its own synthetic mouse events which will conflict
// with these ones.
if !lock.external_files_dragged {
lock.synthetic_drag_counter += 1;
let executor = lock.executor.clone();
executor
.spawn(synthetic_drag(
weak_window_state,
lock.synthetic_drag_counter,
event.clone(),
))
.detach();
}
}
InputEvent::MouseMove(_) if !(is_active || lock.kind == WindowKind::PopUp) => return,
@@ -1679,6 +1686,7 @@ extern "C" fn dragging_entered(this: &Object, _: Sel, dragging_info: id) -> NSDr
let paths = external_paths_from_event(dragging_info);
InputEvent::FileDrop(FileDropEvent::Entered { position, paths })
}) {
window_state.lock().external_files_dragged = true;
NSDragOperationCopy
} else {
NSDragOperationNone
@@ -1701,6 +1709,7 @@ extern "C" fn dragging_updated(this: &Object, _: Sel, dragging_info: id) -> NSDr
extern "C" fn dragging_exited(this: &Object, _: Sel, _: id) {
let window_state = unsafe { get_window_state(this) };
send_new_event(&window_state, InputEvent::FileDrop(FileDropEvent::Exited));
window_state.lock().external_files_dragged = false;
}
extern "C" fn perform_drag_operation(this: &Object, _: Sel, dragging_info: id) -> BOOL {
+1 -1
View File
@@ -32,7 +32,7 @@ impl PlatformDisplay for TestDisplay {
}
fn as_any(&self) -> &dyn std::any::Any {
todo!()
unimplemented!()
}
fn bounds(&self) -> crate::Bounds<crate::GlobalPixels> {
+6 -3
View File
@@ -14,6 +14,7 @@ use std::{
time::Duration,
};
/// TestPlatform implements the Platform trait for use in tests.
pub struct TestPlatform {
background_executor: BackgroundExecutor,
foreground_executor: ForegroundExecutor,
@@ -100,9 +101,12 @@ impl TestPlatform {
})
.detach();
}
pub(crate) fn did_prompt_for_new_path(&self) -> bool {
self.prompts.borrow().new_path.len() > 0
}
}
// todo!("implement out what our tests needed in GPUI 1")
impl Platform for TestPlatform {
fn background_executor(&self) -> BackgroundExecutor {
self.background_executor.clone()
@@ -276,8 +280,7 @@ impl Platform for TestPlatform {
}
fn should_auto_hide_scrollbars(&self) -> bool {
// todo()
true
false
}
fn write_to_clipboard(&self, item: ClipboardItem) {