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

Fix macOS timer not firing during modal loop. #1028

Merged
merged 2 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ You can find its changes [documented below](#060---2020-06-01).

### Fixed

- macOS: Timers not firing during modal loop. ([#1028] by [@xStrom])
- GTK: Directory selection now properly ignores file filters. ([#957] by [@xStrom])

### Visual
Expand Down Expand Up @@ -322,6 +323,7 @@ Last release without a changelog :(
[#1008]: https://github.com/xi-editor/druid/pull/1008
[#1011]: https://github.com/xi-editor/druid/pull/1011
[#1013]: https://github.com/xi-editor/druid/pull/1013
[#1028]: https://github.com/xi-editor/druid/pull/1028

[Unreleased]: https://github.com/xi-editor/druid/compare/v0.6.0...master
[0.6.0]: https://github.com/xi-editor/druid/compare/v0.5.0...v0.6.0
Expand Down
5 changes: 5 additions & 0 deletions druid-shell/src/platform/mac/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ use cocoa::base::id;
use cocoa::foundation::NSRect;
use objc::{class, msg_send, sel, sel_impl};

#[link(name = "AppKit", kind = "framework")]
extern "C" {
pub static NSRunLoopCommonModes: id;
}

bitflags! {
pub struct NSTrackingAreaOptions: i32 {
const MouseEnteredAndExited = 1;
Expand Down
8 changes: 6 additions & 2 deletions druid-shell/src/platform/mac/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ use objc::{class, msg_send, sel, sel_impl};
use crate::kurbo::{Point, Rect, Size, Vec2};
use crate::piet::{Piet, RenderContext};

use super::appkit::{NSTrackingArea, NSTrackingAreaOptions, NSView as NSViewExt};
use super::appkit::{
NSRunLoopCommonModes, NSTrackingArea, NSTrackingAreaOptions, NSView as NSViewExt,
};
use super::application::Application;
use super::dialog;
use super::menu::Menu;
Expand Down Expand Up @@ -804,7 +806,9 @@ impl WindowHandle {
let user_info: id = msg_send![nsnumber, numberWithUnsignedInteger: token.into_raw()];
let selector = sel!(handleTimer:);
let view = self.nsview.load();
let _: id = msg_send![nstimer, scheduledTimerWithTimeInterval: ti target: view selector: selector userInfo: user_info repeats: NO];
let timer: id = msg_send![nstimer, timerWithTimeInterval: ti target: view selector: selector userInfo: user_info repeats: NO];
let runloop: id = msg_send![class!(NSRunLoop), currentRunLoop];
let () = msg_send![runloop, addTimer: timer forMode: NSRunLoopCommonModes];
}
token
}
Expand Down