Skip to content

Commit

Permalink
Sub windows (#1254)
Browse files Browse the repository at this point in the history
* Sub windows (squashed from previous branch)

* Update druid version. Address review comments

* Fix to mac window close handling.
Add WindowDisconnected event.
Close sub windows when their owning WidgetPod gets a WindowDisconnected event.

* Add WindowCloseRequested event and make window close cancellation work on mac.

* Update druid/src/event.rs

Co-authored-by: Colin Rofls <[email protected]>

* Update druid/src/event.rs

Co-authored-by: Colin Rofls <[email protected]>

* Changes to allow env updates to flow down to sub windows

* Doc fix

* Review fixes

Co-authored-by: Colin Rofls <[email protected]>
  • Loading branch information
rjwittams and cmyr authored Jan 7, 2021
1 parent 97716a1 commit 2ff6318
Show file tree
Hide file tree
Showing 12 changed files with 724 additions and 14 deletions.
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

0 comments on commit 2ff6318

Please sign in to comment.