aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/cocoa')
-rw-r--r--src/api/cocoa/headless.rs7
-rw-r--r--src/api/cocoa/mod.rs21
2 files changed, 19 insertions, 9 deletions
diff --git a/src/api/cocoa/headless.rs b/src/api/cocoa/headless.rs
index 7fe2046..ac6c4e0 100644
--- a/src/api/cocoa/headless.rs
+++ b/src/api/cocoa/headless.rs
@@ -13,6 +13,9 @@ use cocoa::appkit::*;
use PixelFormat;
use api::cocoa::helpers;
+#[derive(Default)]
+pub struct PlatformSpecificHeadlessBuilderAttributes;
+
pub struct HeadlessContext {
width: u32,
height: u32,
@@ -21,7 +24,9 @@ pub struct HeadlessContext {
impl HeadlessContext {
pub fn new((width, height): (u32, u32), pf_reqs: &PixelFormatRequirements,
- opengl: &GlAttributes<&HeadlessContext>) -> Result<HeadlessContext, CreationError>
+ opengl: &GlAttributes<&HeadlessContext>,
+ _: &PlatformSpecificHeadlessBuilderAttributes)
+ -> Result<HeadlessContext, CreationError>
{
let context = unsafe {
diff --git a/src/api/cocoa/mod.rs b/src/api/cocoa/mod.rs
index 138a448..4502405 100644
--- a/src/api/cocoa/mod.rs
+++ b/src/api/cocoa/mod.rs
@@ -1,7 +1,5 @@
#![cfg(target_os = "macos")]
-pub use self::headless::HeadlessContext;
-
use {CreationError, Event, MouseCursor, CursorState};
use CreationError::OsError;
use libc;
@@ -50,6 +48,8 @@ use events::MouseButton;
use events;
pub use self::monitor::{MonitorId, get_available_monitors, get_primary_monitor};
+pub use self::headless::HeadlessContext;
+pub use self::headless::PlatformSpecificHeadlessBuilderAttributes;
mod monitor;
mod event;
@@ -179,6 +179,9 @@ impl Drop for WindowDelegate {
}
}
+#[derive(Default)]
+pub struct PlatformSpecificWindowBuilderAttributes;
+
pub struct Window {
view: IdRef,
window: IdRef,
@@ -264,7 +267,8 @@ impl<'a> Iterator for WaitEventsIterator<'a> {
impl Window {
pub fn new(win_attribs: &WindowAttributes, pf_reqs: &PixelFormatRequirements,
- opengl: &GlAttributes<&Window>) -> Result<Window, CreationError>
+ opengl: &GlAttributes<&Window>, _: &PlatformSpecificWindowBuilderAttributes)
+ -> Result<Window, CreationError>
{
if opengl.sharing.is_some() {
unimplemented!()
@@ -837,9 +841,7 @@ unsafe fn NSEventToEvent(window: &Window, nsevent: id) -> Option<Event> {
let received_c_str = nsevent.characters().UTF8String();
let received_str = CStr::from_ptr(received_c_str);
for received_char in from_utf8(received_str.to_bytes()).unwrap().chars() {
- if received_char.is_ascii() {
- events.push_back(ReceivedCharacter(received_char));
- }
+ events.push_back(ReceivedCharacter(received_char));
}
let vkey = event::vkeycode_to_element(NSEvent::keyCode(nsevent));
@@ -881,10 +883,13 @@ unsafe fn NSEventToEvent(window: &Window, nsevent: id) -> Option<Event> {
},
NSScrollWheel => {
use events::MouseScrollDelta::{LineDelta, PixelDelta};
+ let scale_factor = window.hidpi_factor();
let delta = if nsevent.hasPreciseScrollingDeltas() == YES {
- PixelDelta(nsevent.scrollingDeltaX() as f32, nsevent.scrollingDeltaY() as f32)
+ PixelDelta(scale_factor * nsevent.scrollingDeltaX() as f32,
+ scale_factor * nsevent.scrollingDeltaY() as f32)
} else {
- LineDelta(nsevent.scrollingDeltaX() as f32, nsevent.scrollingDeltaY() as f32)
+ LineDelta(scale_factor * nsevent.scrollingDeltaX() as f32,
+ scale_factor * nsevent.scrollingDeltaY() as f32)
};
Some(MouseWheel(delta))
},