Skip to content

Commit 262c46b

Browse files
committed
Use dispatch crate
1 parent 63152c2 commit 262c46b

File tree

5 files changed

+20
-44
lines changed

5 files changed

+20
-44
lines changed

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ version = "0.2"
3333
objc = "0.2.3"
3434

3535
[target.'cfg(target_os = "macos")'.dependencies]
36-
objc = "0.2.3"
3736
cocoa = "0.18.4"
3837
core-foundation = "0.6"
3938
core-graphics = "0.17.3"
39+
dispatch = "0.1.4"
40+
objc = "0.2.3"
4041

4142
[target.'cfg(target_os = "windows")'.dependencies.winapi]
4243
version = "0.3.6"

src/lib.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,19 @@ extern crate serde;
8989

9090
#[cfg(target_os = "windows")]
9191
extern crate winapi;
92-
#[cfg(any(target_os = "macos", target_os = "ios"))]
93-
#[macro_use]
94-
extern crate objc;
92+
9593
#[cfg(target_os = "macos")]
9694
extern crate cocoa;
9795
#[cfg(target_os = "macos")]
9896
extern crate core_foundation;
9997
#[cfg(target_os = "macos")]
10098
extern crate core_graphics;
99+
#[cfg(target_os = "macos")]
100+
extern crate dispatch;
101+
#[cfg(any(target_os = "macos", target_os = "ios"))]
102+
#[macro_use]
103+
extern crate objc;
104+
101105
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))]
102106
extern crate x11_dl;
103107
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", target_os = "windows"))]

src/platform_impl/macos/dispatch.rs

-29
This file was deleted.

src/platform_impl/macos/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
mod app;
44
mod app_delegate;
55
mod app_state;
6-
mod dispatch;
76
mod event;
87
mod event_loop;
98
mod ffi;

src/platform_impl/macos/util.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ use cocoa::{
99
},
1010
};
1111
use core_graphics::display::CGDisplay;
12+
use dispatch::ffi::{dispatch_async_f, dispatch_get_main_queue, dispatch_sync_f};
1213
use objc::runtime::{BOOL, Class, Object, Sel, YES};
1314

1415
pub use util::*;
1516
use {dpi::LogicalSize, window::MouseCursor};
16-
use platform_impl::platform::{dispatch::*, ffi, window::SharedState};
17+
use platform_impl::platform::{ffi, window::SharedState};
1718

1819
pub const EMPTY_RANGE: ffi::NSRange = ffi::NSRange {
1920
location: ffi::NSNotFound as NSUInteger,
@@ -115,15 +116,15 @@ pub unsafe fn set_style_mask_async(nswindow: id, nsview: id, mask: NSWindowStyle
115116
dispatch_async_f(
116117
dispatch_get_main_queue(),
117118
context as *mut _,
118-
Some(set_style_mask_callback),
119+
set_style_mask_callback,
119120
);
120121
}
121122
pub unsafe fn set_style_mask_sync(nswindow: id, nsview: id, mask: NSWindowStyleMask) {
122123
let context = SetStyleMaskData::new_ptr(nswindow, nsview, mask);
123124
dispatch_sync_f(
124125
dispatch_get_main_queue(),
125126
context as *mut _,
126-
Some(set_style_mask_callback),
127+
set_style_mask_callback,
127128
);
128129
}
129130

@@ -162,7 +163,7 @@ pub unsafe fn set_content_size_async(nswindow: id, size: LogicalSize) {
162163
dispatch_async_f(
163164
dispatch_get_main_queue(),
164165
context as *mut _,
165-
Some(set_content_size_callback),
166+
set_content_size_callback,
166167
);
167168
}
168169

@@ -195,7 +196,7 @@ pub unsafe fn set_frame_top_left_point_async(nswindow: id, point: NSPoint) {
195196
dispatch_async_f(
196197
dispatch_get_main_queue(),
197198
context as *mut _,
198-
Some(set_frame_top_left_point_callback),
199+
set_frame_top_left_point_callback,
199200
);
200201
}
201202

@@ -227,7 +228,7 @@ pub unsafe fn set_level_async(nswindow: id, level: ffi::NSWindowLevel) {
227228
dispatch_async_f(
228229
dispatch_get_main_queue(),
229230
context as *mut _,
230-
Some(set_level_callback),
231+
set_level_callback,
231232
);
232233
}
233234

@@ -298,7 +299,7 @@ pub unsafe fn toggle_full_screen_async(
298299
dispatch_async_f(
299300
dispatch_get_main_queue(),
300301
context as *mut _,
301-
Some(toggle_full_screen_callback),
302+
toggle_full_screen_callback,
302303
);
303304
}
304305

@@ -327,7 +328,7 @@ pub unsafe fn order_out_async(nswindow: id) {
327328
dispatch_async_f(
328329
dispatch_get_main_queue(),
329330
context as *mut _,
330-
Some(order_out_callback),
331+
order_out_callback,
331332
);
332333
}
333334

@@ -356,7 +357,7 @@ pub unsafe fn make_key_and_order_front_async(nswindow: id) {
356357
dispatch_async_f(
357358
dispatch_get_main_queue(),
358359
context as *mut _,
359-
Some(make_key_and_order_front_callback),
360+
make_key_and_order_front_callback,
360361
);
361362
}
362363

@@ -387,7 +388,7 @@ pub unsafe fn close_async(nswindow: id) {
387388
dispatch_async_f(
388389
dispatch_get_main_queue(),
389390
context as *mut _,
390-
Some(close_callback),
391+
close_callback,
391392
);
392393
}
393394

0 commit comments

Comments
 (0)