Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub windows (squashed from previous branch) #1254

Merged
merged 11 commits into from
Jan 7, 2021
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ You can find its changes [documented below](#070---2021-01-01).
### Highlights

### Added
- Sub windows: Allow opening windows that share state with arbitrary parts of the widget hierarchy ([#1254] by [@rjwittams])
- WindowCloseRequested/WindowDisconnected event when a window is closing ([#1254] by [@rjwittams])

### Changed

Expand Down
Empty file modified druid-shell/Cargo.toml
100644 → 100755
Empty file.
15 changes: 14 additions & 1 deletion druid-shell/src/platform/mac/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ lazy_static! {
sel!(showContextMenu:),
show_context_menu as extern "C" fn(&mut Object, Sel, id),
);
decl.add_method(
sel!(windowShouldClose:),
window_should_close as extern "C" fn(&mut Object, Sel, id)->BOOL,
);
decl.add_method(
sel!(windowWillClose:),
window_will_close as extern "C" fn(&mut Object, Sel, id),
Expand Down Expand Up @@ -827,7 +831,16 @@ extern "C" fn window_did_resign_key(this: &mut Object, _: Sel, _notification: id
}
}

extern "C" fn window_will_close(this: &mut Object, _: Sel, _window: id) {
extern "C" fn window_should_close(this: &mut Object, _: Sel, _window: id) -> BOOL {
unsafe {
let view_state: *mut c_void = *this.get_ivar("viewState");
let view_state = &mut *(view_state as *mut ViewState);
(*view_state).handler.request_close();
NO
}
}

extern "C" fn window_will_close(this: &mut Object, _: Sel, _notification: id) {
unsafe {
let view_state: *mut c_void = *this.get_ivar("viewState");
let view_state = &mut *(view_state as *mut ViewState);
Expand Down
Loading