mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Switched from active hover to NSViews acceptsFirstMouse API
This commit is contained in:
parent
4eeb1aec50
commit
88170df7f0
@ -417,13 +417,9 @@ impl CollabTitlebarItem {
|
|||||||
theme: &Theme,
|
theme: &Theme,
|
||||||
cx: &mut RenderContext<Self>,
|
cx: &mut RenderContext<Self>,
|
||||||
) -> ElementBox {
|
) -> ElementBox {
|
||||||
let (is_followed, is_following) = peer.map_or((false, false), |(peer_id, _, _)| {
|
let is_followed = peer.map_or(false, |(peer_id, _, _)| {
|
||||||
(
|
workspace.read(cx).is_following(peer_id)
|
||||||
workspace.read(cx).is_following(peer_id),
|
|
||||||
workspace.read(cx).is_followed(peer_id),
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
// my color, around their avatar.
|
|
||||||
|
|
||||||
let mut avatar_style;
|
let mut avatar_style;
|
||||||
if let Some((_, _, location)) = peer.as_ref() {
|
if let Some((_, _, location)) = peer.as_ref() {
|
||||||
@ -446,10 +442,6 @@ impl CollabTitlebarItem {
|
|||||||
replica_color = Some(color);
|
replica_color = Some(color);
|
||||||
if is_followed {
|
if is_followed {
|
||||||
avatar_style.border = Border::all(1.0, color);
|
avatar_style.border = Border::all(1.0, color);
|
||||||
} else if is_following {
|
|
||||||
let our_id = workspace.read(cx).project().read(cx).replica_id();
|
|
||||||
let our_color = theme.editor.replica_selection_style(our_id).cursor;
|
|
||||||
avatar_style.border = Border::all(1.0, our_color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,10 +45,11 @@ pub fn init(cx: &mut MutableAppContext) {
|
|||||||
kind: WindowKind::PopUp,
|
kind: WindowKind::PopUp,
|
||||||
is_movable: false,
|
is_movable: false,
|
||||||
screen: Some(screen),
|
screen: Some(screen),
|
||||||
|
accepts_first_mouse: true,
|
||||||
},
|
},
|
||||||
|_| IncomingCallNotification::new(incoming_call.clone()),
|
|_| IncomingCallNotification::new(incoming_call.clone()),
|
||||||
);
|
);
|
||||||
cx.activate_window(window_id);
|
|
||||||
notification_windows.push(window_id);
|
notification_windows.push(window_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -226,6 +227,7 @@ impl View for IncomingCallNotification {
|
|||||||
.theme
|
.theme
|
||||||
.incoming_call_notification
|
.incoming_call_notification
|
||||||
.background;
|
.background;
|
||||||
|
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_child(self.render_caller(cx))
|
.with_child(self.render_caller(cx))
|
||||||
.with_child(self.render_buttons(cx))
|
.with_child(self.render_buttons(cx))
|
||||||
|
@ -44,6 +44,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
|||||||
kind: WindowKind::PopUp,
|
kind: WindowKind::PopUp,
|
||||||
is_movable: false,
|
is_movable: false,
|
||||||
screen: Some(screen),
|
screen: Some(screen),
|
||||||
|
accepts_first_mouse: true,
|
||||||
},
|
},
|
||||||
|_| {
|
|_| {
|
||||||
ProjectSharedNotification::new(
|
ProjectSharedNotification::new(
|
||||||
|
@ -156,6 +156,7 @@ pub struct WindowOptions<'a> {
|
|||||||
pub kind: WindowKind,
|
pub kind: WindowKind,
|
||||||
pub is_movable: bool,
|
pub is_movable: bool,
|
||||||
pub screen: Option<Rc<dyn Screen>>,
|
pub screen: Option<Rc<dyn Screen>>,
|
||||||
|
pub accepts_first_mouse: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -301,6 +302,7 @@ impl<'a> Default for WindowOptions<'a> {
|
|||||||
kind: WindowKind::Normal,
|
kind: WindowKind::Normal,
|
||||||
is_movable: true,
|
is_movable: true,
|
||||||
screen: None,
|
screen: None,
|
||||||
|
accepts_first_mouse: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,6 +252,11 @@ unsafe fn build_classes() {
|
|||||||
do_command_by_selector as extern "C" fn(&Object, Sel, Sel),
|
do_command_by_selector as extern "C" fn(&Object, Sel, Sel),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
decl.add_method(
|
||||||
|
sel!(acceptsFirstMouse:),
|
||||||
|
accepts_first_mouse as extern "C" fn(&Object, Sel, id) -> BOOL,
|
||||||
|
);
|
||||||
|
|
||||||
decl.register()
|
decl.register()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -338,6 +343,7 @@ struct WindowState {
|
|||||||
ime_state: ImeState,
|
ime_state: ImeState,
|
||||||
//Retains the last IME Text
|
//Retains the last IME Text
|
||||||
ime_text: Option<String>,
|
ime_text: Option<String>,
|
||||||
|
accepts_first_mouse: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct InsertText {
|
struct InsertText {
|
||||||
@ -444,6 +450,7 @@ impl Window {
|
|||||||
previous_modifiers_changed_event: None,
|
previous_modifiers_changed_event: None,
|
||||||
ime_state: ImeState::None,
|
ime_state: ImeState::None,
|
||||||
ime_text: None,
|
ime_text: None,
|
||||||
|
accepts_first_mouse: options.accepts_first_mouse,
|
||||||
})));
|
})));
|
||||||
|
|
||||||
(*native_window).set_ivar(
|
(*native_window).set_ivar(
|
||||||
@ -1404,6 +1411,14 @@ extern "C" fn view_did_change_effective_appearance(this: &Object, _: Sel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" fn accepts_first_mouse(this: &Object, _: Sel, _: id) -> BOOL {
|
||||||
|
unsafe {
|
||||||
|
let state = get_window_state(this);
|
||||||
|
let state_borrow = state.as_ref().borrow();
|
||||||
|
return state_borrow.accepts_first_mouse as BOOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn synthetic_drag(
|
async fn synthetic_drag(
|
||||||
window_state: Weak<RefCell<WindowState>>,
|
window_state: Weak<RefCell<WindowState>>,
|
||||||
drag_id: usize,
|
drag_id: usize,
|
||||||
|
@ -408,6 +408,7 @@ pub fn build_window_options() -> WindowOptions<'static> {
|
|||||||
kind: WindowKind::Normal,
|
kind: WindowKind::Normal,
|
||||||
is_movable: true,
|
is_movable: true,
|
||||||
screen: None,
|
screen: None,
|
||||||
|
accepts_first_mouse: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user