Switched from active hover to NSViews acceptsFirstMouse API

This commit is contained in:
Mikayla Maki 2023-01-19 15:21:26 -08:00
parent 4eeb1aec50
commit 88170df7f0
6 changed files with 24 additions and 11 deletions

View file

@ -252,6 +252,11 @@ unsafe fn build_classes() {
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()
};
}
@ -338,6 +343,7 @@ struct WindowState {
ime_state: ImeState,
//Retains the last IME Text
ime_text: Option<String>,
accepts_first_mouse: bool,
}
struct InsertText {
@ -444,6 +450,7 @@ impl Window {
previous_modifiers_changed_event: None,
ime_state: ImeState::None,
ime_text: None,
accepts_first_mouse: options.accepts_first_mouse,
})));
(*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(
window_state: Weak<RefCell<WindowState>>,
drag_id: usize,