mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-24 02:46:33 +11:00
Merge pull request #286 from mitchmindtree/master
Updated to latest nightly - RingBuf -> VecDeque, removed unnecessary as_slice_with_nul
This commit is contained in:
commit
06eab6f6c0
10 changed files with 30 additions and 30 deletions
|
@ -9,7 +9,7 @@ use events::ElementState::{Pressed, Released};
|
||||||
use events::Event::{MouseInput, MouseMoved};
|
use events::Event::{MouseInput, MouseMoved};
|
||||||
use events::MouseButton;
|
use events::MouseButton;
|
||||||
|
|
||||||
use std::collections::RingBuf;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
use Api;
|
use Api;
|
||||||
use BuilderAttribs;
|
use BuilderAttribs;
|
||||||
|
@ -26,8 +26,8 @@ pub struct MonitorID;
|
||||||
|
|
||||||
mod ffi;
|
mod ffi;
|
||||||
|
|
||||||
pub fn get_available_monitors() -> RingBuf <MonitorID> {
|
pub fn get_available_monitors() -> VecDeque <MonitorID> {
|
||||||
let mut rb = RingBuf::new();
|
let mut rb = VecDeque::new();
|
||||||
rb.push_back(MonitorID);
|
rb.push_back(MonitorID);
|
||||||
rb
|
rb
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ impl Window {
|
||||||
|
|
||||||
pub fn get_proc_address(&self, addr: &str) -> *const () {
|
pub fn get_proc_address(&self, addr: &str) -> *const () {
|
||||||
let addr = CString::from_slice(addr.as_bytes());
|
let addr = CString::from_slice(addr.as_bytes());
|
||||||
let addr = addr.as_slice_with_nul().as_ptr();
|
let addr = addr.as_ptr();
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::egl::GetProcAddress(addr) as *const ()
|
ffi::egl::GetProcAddress(addr) as *const ()
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ use std::cell::Cell;
|
||||||
use std::ffi::{CString, c_str_to_bytes};
|
use std::ffi::{CString, c_str_to_bytes};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::collections::RingBuf;
|
use std::collections::VecDeque;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
@ -48,7 +48,7 @@ static mut ctrl_pressed: bool = false;
|
||||||
static mut win_pressed: bool = false;
|
static mut win_pressed: bool = false;
|
||||||
static mut alt_pressed: bool = false;
|
static mut alt_pressed: bool = false;
|
||||||
|
|
||||||
struct DelegateState<'a> {
|
struct DelegateState {
|
||||||
is_closed: bool,
|
is_closed: bool,
|
||||||
context: id,
|
context: id,
|
||||||
view: id,
|
view: id,
|
||||||
|
@ -169,7 +169,7 @@ pub struct Window {
|
||||||
is_closed: Cell<bool>,
|
is_closed: Cell<bool>,
|
||||||
|
|
||||||
/// Events that have been retreived with XLib but not dispatched with iterators yet
|
/// Events that have been retreived with XLib but not dispatched with iterators yet
|
||||||
pending_events: Mutex<RingBuf<Event>>,
|
pending_events: Mutex<VecDeque<Event>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
|
@ -252,7 +252,7 @@ impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
(scale_factor * (view_rect.size.height - view_point.y) as f32) as i32)))
|
(scale_factor * (view_rect.size.height - view_point.y) as f32) as i32)))
|
||||||
},
|
},
|
||||||
NSKeyDown => {
|
NSKeyDown => {
|
||||||
let mut events = RingBuf::new();
|
let mut events = VecDeque::new();
|
||||||
let received_c_str = event.characters().UTF8String();
|
let received_c_str = event.characters().UTF8String();
|
||||||
let received_str = CString::from_slice(c_str_to_bytes(&received_c_str));
|
let received_str = CString::from_slice(c_str_to_bytes(&received_c_str));
|
||||||
for received_char in from_utf8(received_str.as_bytes()).unwrap().chars() {
|
for received_char in from_utf8(received_str.as_bytes()).unwrap().chars() {
|
||||||
|
@ -272,7 +272,7 @@ impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
Some(KeyboardInput(Released, NSEvent::keyCode(event) as u8, vkey))
|
Some(KeyboardInput(Released, NSEvent::keyCode(event) as u8, vkey))
|
||||||
},
|
},
|
||||||
NSFlagsChanged => {
|
NSFlagsChanged => {
|
||||||
let mut events = RingBuf::new();
|
let mut events = VecDeque::new();
|
||||||
let shift_modifier = Window::modifier_event(event, appkit::NSShiftKeyMask, events::VirtualKeyCode::LShift, shift_pressed);
|
let shift_modifier = Window::modifier_event(event, appkit::NSShiftKeyMask, events::VirtualKeyCode::LShift, shift_pressed);
|
||||||
if shift_modifier.is_some() {
|
if shift_modifier.is_some() {
|
||||||
shift_pressed = !shift_pressed;
|
shift_pressed = !shift_pressed;
|
||||||
|
@ -380,7 +380,7 @@ impl Window {
|
||||||
resize: None,
|
resize: None,
|
||||||
|
|
||||||
is_closed: Cell::new(false),
|
is_closed: Cell::new(false),
|
||||||
pending_events: Mutex::new(RingBuf::new()),
|
pending_events: Mutex::new(VecDeque::new()),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(window)
|
Ok(window)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use core_graphics::display;
|
use core_graphics::display;
|
||||||
use std::collections::RingBuf;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
pub struct MonitorID(u32);
|
pub struct MonitorID(u32);
|
||||||
|
|
||||||
pub fn get_available_monitors() -> RingBuf<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
let mut monitors = RingBuf::new();
|
let mut monitors = VecDeque::new();
|
||||||
unsafe {
|
unsafe {
|
||||||
let max_displays = 10u32;
|
let max_displays = 10u32;
|
||||||
let mut active_displays = [0u32; 10];
|
let mut active_displays = [0u32; 10];
|
||||||
|
@ -12,7 +12,7 @@ pub fn get_available_monitors() -> RingBuf<MonitorID> {
|
||||||
display::CGGetActiveDisplayList(max_displays,
|
display::CGGetActiveDisplayList(max_displays,
|
||||||
&mut active_displays[0],
|
&mut active_displays[0],
|
||||||
&mut display_count);
|
&mut display_count);
|
||||||
for i in range(0us, display_count as usize) {
|
for i in range(0, display_count as usize) {
|
||||||
monitors.push_back(MonitorID(active_displays[i]));
|
monitors.push_back(MonitorID(active_displays[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ fn init(title: Vec<u16>, builder: BuilderAttribs<'static>, builder_sharelists: O
|
||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
let addr = CString::from_slice(addr.as_bytes());
|
let addr = CString::from_slice(addr.as_bytes());
|
||||||
let addr = addr.as_slice_with_nul().as_ptr();
|
let addr = addr.as_ptr();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
gl::wgl::GetProcAddress(addr) as *const libc::c_void
|
gl::wgl::GetProcAddress(addr) as *const libc::c_void
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::collections::RingBuf;
|
use std::collections::VecDeque;
|
||||||
use std::sync::mpsc::Receiver;
|
use std::sync::mpsc::Receiver;
|
||||||
use libc;
|
use libc;
|
||||||
use {CreationError, Event, MouseCursor};
|
use {CreationError, Event, MouseCursor};
|
||||||
|
@ -192,7 +192,7 @@ impl Window {
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
pub fn get_proc_address(&self, addr: &str) -> *const () {
|
pub fn get_proc_address(&self, addr: &str) -> *const () {
|
||||||
let addr = CString::from_slice(addr.as_bytes());
|
let addr = CString::from_slice(addr.as_bytes());
|
||||||
let addr = addr.as_slice_with_nul().as_ptr();
|
let addr = addr.as_ptr();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let p = gl::wgl::GetProcAddress(addr) as *const ();
|
let p = gl::wgl::GetProcAddress(addr) as *const ();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use winapi;
|
use winapi;
|
||||||
use user32;
|
use user32;
|
||||||
|
|
||||||
use std::collections::RingBuf;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
/// Win32 implementation of the main `MonitorID` object.
|
/// Win32 implementation of the main `MonitorID` object.
|
||||||
pub struct MonitorID {
|
pub struct MonitorID {
|
||||||
|
@ -25,11 +25,11 @@ pub struct MonitorID {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Win32 implementation of the main `get_available_monitors` function.
|
/// Win32 implementation of the main `get_available_monitors` function.
|
||||||
pub fn get_available_monitors() -> RingBuf<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
use std::{iter, mem, ptr};
|
use std::{iter, mem, ptr};
|
||||||
|
|
||||||
// return value
|
// return value
|
||||||
let mut result = RingBuf::new();
|
let mut result = VecDeque::new();
|
||||||
|
|
||||||
// enumerating the devices is done by querying device 0, then device 1, then device 2, etc.
|
// enumerating the devices is done by querying device 0, then device 1, then device 2, etc.
|
||||||
// until the query function returns null
|
// until the query function returns null
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::collections::ring_buf::IntoIter as RingBufIter;
|
use std::collections::vec_deque::IntoIter as VecDequeIter;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
|
||||||
use Api;
|
use Api;
|
||||||
|
@ -452,7 +452,7 @@ impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||||
// Implementation note: we retreive the list once, then serve each element by one by one.
|
// Implementation note: we retreive the list once, then serve each element by one by one.
|
||||||
// This may change in the future.
|
// This may change in the future.
|
||||||
pub struct AvailableMonitorsIter {
|
pub struct AvailableMonitorsIter {
|
||||||
data: RingBufIter<winimpl::MonitorID>,
|
data: VecDequeIter<winimpl::MonitorID>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Iterator for AvailableMonitorsIter {
|
impl Iterator for AvailableMonitorsIter {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use super::ffi;
|
||||||
fn with_c_str<F, T>(s: &str, f: F) -> T where F: FnOnce(*const libc::c_char) -> T {
|
fn with_c_str<F, T>(s: &str, f: F) -> T where F: FnOnce(*const libc::c_char) -> T {
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
let c_str = CString::from_slice(s.as_bytes());
|
let c_str = CString::from_slice(s.as_bytes());
|
||||||
f(c_str.as_slice_with_nul().as_ptr())
|
f(c_str.as_ptr())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct HeadlessContext {
|
pub struct HeadlessContext {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use libc;
|
||||||
use std::{mem, ptr};
|
use std::{mem, ptr};
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
use std::collections::RingBuf;
|
use std::collections::VecDeque;
|
||||||
use super::ffi;
|
use super::ffi;
|
||||||
use std::sync::{Arc, Mutex, Once, ONCE_INIT, Weak};
|
use std::sync::{Arc, Mutex, Once, ONCE_INIT, Weak};
|
||||||
use std::sync::{StaticMutex, MUTEX_INIT};
|
use std::sync::{StaticMutex, MUTEX_INIT};
|
||||||
|
@ -39,7 +39,7 @@ fn ensure_thread_init() {
|
||||||
fn with_c_str<F, T>(s: &str, f: F) -> T where F: FnOnce(*const libc::c_char) -> T {
|
fn with_c_str<F, T>(s: &str, f: F) -> T where F: FnOnce(*const libc::c_char) -> T {
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
let c_str = CString::from_slice(s.as_bytes());
|
let c_str = CString::from_slice(s.as_bytes());
|
||||||
f(c_str.as_slice_with_nul().as_ptr())
|
f(c_str.as_ptr())
|
||||||
}
|
}
|
||||||
|
|
||||||
struct XWindow {
|
struct XWindow {
|
||||||
|
@ -281,7 +281,7 @@ pub struct Window {
|
||||||
wm_delete_window: ffi::Atom,
|
wm_delete_window: ffi::Atom,
|
||||||
current_size: Cell<(libc::c_int, libc::c_int)>,
|
current_size: Cell<(libc::c_int, libc::c_int)>,
|
||||||
/// Events that have been retreived with XLib but not dispatched with iterators yet
|
/// Events that have been retreived with XLib but not dispatched with iterators yet
|
||||||
pending_events: Mutex<RingBuf<Event>>,
|
pending_events: Mutex<VecDeque<Event>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
|
@ -600,7 +600,7 @@ impl Window {
|
||||||
is_closed: AtomicBool::new(false),
|
is_closed: AtomicBool::new(false),
|
||||||
wm_delete_window: wm_delete_window,
|
wm_delete_window: wm_delete_window,
|
||||||
current_size: Cell::new((0, 0)),
|
current_size: Cell::new((0, 0)),
|
||||||
pending_events: Mutex::new(RingBuf::new()),
|
pending_events: Mutex::new(VecDeque::new()),
|
||||||
};
|
};
|
||||||
|
|
||||||
// returning
|
// returning
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::collections::RingBuf;
|
use std::collections::VecDeque;
|
||||||
use super::super::ffi;
|
use super::super::ffi;
|
||||||
use super::ensure_thread_init;
|
use super::ensure_thread_init;
|
||||||
|
|
||||||
pub struct MonitorID(pub u32);
|
pub struct MonitorID(pub u32);
|
||||||
|
|
||||||
pub fn get_available_monitors() -> RingBuf<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
ensure_thread_init();
|
ensure_thread_init();
|
||||||
let nb_monitors = unsafe {
|
let nb_monitors = unsafe {
|
||||||
let display = ffi::XOpenDisplay(ptr::null());
|
let display = ffi::XOpenDisplay(ptr::null());
|
||||||
|
@ -17,7 +17,7 @@ pub fn get_available_monitors() -> RingBuf<MonitorID> {
|
||||||
nb_monitors
|
nb_monitors
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut monitors = RingBuf::new();
|
let mut monitors = VecDeque::new();
|
||||||
monitors.extend(range(0, nb_monitors).map(|i| MonitorID(i as u32)));
|
monitors.extend(range(0, nb_monitors).map(|i| MonitorID(i as u32)));
|
||||||
monitors
|
monitors
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue