mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 21:31:29 +11:00
Remove all features for 1.0 beta
This commit is contained in:
parent
1c74614c4a
commit
0f7bd9071e
|
@ -17,6 +17,7 @@ headless = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gl_common = "*"
|
gl_common = "*"
|
||||||
|
lazy_static = "0.1"
|
||||||
libc = "*"
|
libc = "*"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
|
@ -385,7 +385,6 @@ impl WindowProxy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unsafe_destructor]
|
|
||||||
impl Drop for Window {
|
impl Drop for Window {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#![feature(collections, unsafe_destructor, core, std_misc, alloc)]
|
|
||||||
#![unstable]
|
|
||||||
|
|
||||||
//! The purpose of this library is to provide an OpenGL context on as many
|
//! The purpose of this library is to provide an OpenGL context on as many
|
||||||
//! platforms as possible.
|
//! platforms as possible.
|
||||||
//!
|
//!
|
||||||
|
@ -26,6 +23,9 @@
|
||||||
//!
|
//!
|
||||||
//! By default only `window` is enabled.
|
//! By default only `window` is enabled.
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate lazy_static;
|
||||||
|
|
||||||
extern crate gl_common;
|
extern crate gl_common;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,8 @@ use CursorState;
|
||||||
use GlRequest;
|
use GlRequest;
|
||||||
use PixelFormat;
|
use PixelFormat;
|
||||||
|
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString, OsStr};
|
||||||
|
use std::os::windows::ffi::OsStrExt;
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
|
|
||||||
use libc;
|
use libc;
|
||||||
|
@ -38,8 +39,9 @@ pub fn new_window(builder: BuilderAttribs<'static>, builder_sharelists: Option<C
|
||||||
-> Result<Window, CreationError>
|
-> Result<Window, CreationError>
|
||||||
{
|
{
|
||||||
// initializing variables to be sent to the task
|
// initializing variables to be sent to the task
|
||||||
let title = builder.title.utf16_units()
|
|
||||||
.chain(Some(0).into_iter()).collect::<Vec<u16>>(); // title to utf16
|
let title = OsStr::from_str(&builder.title).encode_wide().chain(Some(0).into_iter())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
|
|
||||||
|
@ -265,8 +267,8 @@ unsafe fn init(title: Vec<u16>, builder: BuilderAttribs<'static>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn register_window_class() -> Vec<u16> {
|
unsafe fn register_window_class() -> Vec<u16> {
|
||||||
let class_name: Vec<u16> = "Window Class".utf16_units().chain(Some(0).into_iter())
|
let class_name = OsStr::from_str("Window Class").encode_wide().chain(Some(0).into_iter())
|
||||||
.collect::<Vec<u16>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let class = winapi::WNDCLASSEXW {
|
let class = winapi::WNDCLASSEXW {
|
||||||
cbSize: mem::size_of::<winapi::WNDCLASSEXW>() as winapi::UINT,
|
cbSize: mem::size_of::<winapi::WNDCLASSEXW>() as winapi::UINT,
|
||||||
|
@ -515,10 +517,10 @@ unsafe fn set_pixel_format(hdc: &WindowWrapper, id: libc::c_int) -> Result<(), C
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn load_opengl32_dll() -> Result<winapi::HMODULE, CreationError> {
|
unsafe fn load_opengl32_dll() -> Result<winapi::HMODULE, CreationError> {
|
||||||
let name = "opengl32.dll".utf16_units().chain(Some(0).into_iter())
|
let name = OsStr::from_str("opengl32.dll").encode_wide().chain(Some(0).into_iter())
|
||||||
.collect::<Vec<u16>>().as_ptr();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let lib = kernel32::LoadLibraryW(name);
|
let lib = kernel32::LoadLibraryW(name.as_ptr());
|
||||||
|
|
||||||
if lib.is_null() {
|
if lib.is_null() {
|
||||||
return Err(OsError(format!("LoadLibrary function failed: {}",
|
return Err(OsError(format!("LoadLibrary function failed: {}",
|
||||||
|
|
|
@ -42,7 +42,6 @@ impl<'a, 'b> CurrentContextGuard<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unsafe_destructor]
|
|
||||||
impl<'a, 'b> Drop for CurrentContextGuard<'a, 'b> {
|
impl<'a, 'b> Drop for CurrentContextGuard<'a, 'b> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -2,6 +2,8 @@ use std::sync::atomic::AtomicBool;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
|
use std::ffi::OsStr;
|
||||||
|
use std::os::windows::ffi::OsStrExt;
|
||||||
use std::sync::{
|
use std::sync::{
|
||||||
Arc,
|
Arc,
|
||||||
Mutex
|
Mutex
|
||||||
|
@ -109,10 +111,11 @@ impl Window {
|
||||||
///
|
///
|
||||||
/// Calls SetWindowText on the HWND.
|
/// Calls SetWindowText on the HWND.
|
||||||
pub fn set_title(&self, text: &str) {
|
pub fn set_title(&self, text: &str) {
|
||||||
|
let text = OsStr::from_str(text).encode_wide().chain(Some(0).into_iter())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
user32::SetWindowTextW(self.window.0,
|
user32::SetWindowTextW(self.window.0, text.as_ptr() as winapi::LPCWSTR);
|
||||||
text.utf16_units().chain(Some(0).into_iter())
|
|
||||||
.collect::<Vec<u16>>().as_ptr() as winapi::LPCWSTR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +398,6 @@ impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unsafe_destructor]
|
|
||||||
impl Drop for Window {
|
impl Drop for Window {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -8,7 +8,6 @@ use std::sync::atomic::AtomicBool;
|
||||||
use std::collections::VecDeque;
|
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 Api;
|
use Api;
|
||||||
use CursorState;
|
use CursorState;
|
||||||
|
@ -21,6 +20,11 @@ mod monitor;
|
||||||
|
|
||||||
static THREAD_INIT: Once = ONCE_INIT;
|
static THREAD_INIT: Once = ONCE_INIT;
|
||||||
|
|
||||||
|
// XOpenIM doesn't seem to be thread-safe
|
||||||
|
lazy_static! { // TODO: use a static mutex when that's possible, and put me back in my function
|
||||||
|
static ref GLOBAL_XOPENIM_LOCK: Mutex<()> = Mutex::new(());
|
||||||
|
}
|
||||||
|
|
||||||
fn x_error_callback(_: *mut ffi::Display, event: *mut ffi::XErrorEvent) -> libc::c_int {
|
fn x_error_callback(_: *mut ffi::Display, event: *mut ffi::XErrorEvent) -> libc::c_int {
|
||||||
unsafe {
|
unsafe {
|
||||||
println!("[glutin] x error code={} major={} minor={}!", (*event).error_code, (*event).request_code, (*event).minor_code);
|
println!("[glutin] x error code={} major={} minor={}!", (*event).error_code, (*event).request_code, (*event).minor_code);
|
||||||
|
@ -82,30 +86,25 @@ impl Drop for XWindow {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct WindowProxy {
|
pub struct WindowProxy {
|
||||||
x: Weak<XWindow>,
|
x: Arc<XWindow>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowProxy {
|
impl WindowProxy {
|
||||||
pub fn wakeup_event_loop(&self) {
|
pub fn wakeup_event_loop(&self) {
|
||||||
match self.x.upgrade() {
|
let mut xev = ffi::XClientMessageEvent {
|
||||||
Some(x) => {
|
type_: ffi::ClientMessage,
|
||||||
let mut xev = ffi::XClientMessageEvent {
|
window: self.x.window,
|
||||||
type_: ffi::ClientMessage,
|
format: 32,
|
||||||
window: x.window,
|
message_type: 0,
|
||||||
format: 32,
|
serial: 0,
|
||||||
message_type: 0,
|
send_event: 0,
|
||||||
serial: 0,
|
display: self.x.display,
|
||||||
send_event: 0,
|
l: [0, 0, 0, 0, 0],
|
||||||
display: x.display,
|
};
|
||||||
l: [0, 0, 0, 0, 0],
|
|
||||||
};
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::XSendEvent(x.display, x.window, 0, 0, mem::transmute(&mut xev));
|
ffi::XSendEvent(self.x.display, self.x.window, 0, 0, mem::transmute(&mut xev));
|
||||||
ffi::XFlush(x.display);
|
ffi::XFlush(self.x.display);
|
||||||
}
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,15 +117,13 @@ impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
type Item = Event;
|
type Item = Event;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Event> {
|
fn next(&mut self) -> Option<Event> {
|
||||||
use std::num::Int;
|
|
||||||
|
|
||||||
if let Some(ev) = self.window.pending_events.lock().unwrap().pop_front() {
|
if let Some(ev) = self.window.pending_events.lock().unwrap().pop_front() {
|
||||||
return Some(ev);
|
return Some(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let mut xev = unsafe { mem::uninitialized() };
|
let mut xev = unsafe { mem::uninitialized() };
|
||||||
let res = unsafe { ffi::XCheckMaskEvent(self.window.x.display, Int::max_value(), &mut xev) };
|
let res = unsafe { ffi::XCheckMaskEvent(self.window.x.display, -1, &mut xev) };
|
||||||
|
|
||||||
if res == 0 {
|
if res == 0 {
|
||||||
let res = unsafe { ffi::XCheckTypedEvent(self.window.x.display, ffi::ClientMessage, &mut xev) };
|
let res = unsafe { ffi::XCheckTypedEvent(self.window.x.display, ffi::ClientMessage, &mut xev) };
|
||||||
|
@ -192,12 +189,12 @@ impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
mem::transmute(buffer.as_mut_ptr()),
|
mem::transmute(buffer.as_mut_ptr()),
|
||||||
buffer.len() as libc::c_int, ptr::null_mut(), ptr::null_mut());
|
buffer.len() as libc::c_int, ptr::null_mut(), ptr::null_mut());
|
||||||
|
|
||||||
str::from_utf8(&buffer.as_slice()[..count as usize]).unwrap_or("").to_string()
|
str::from_utf8(&buffer[..count as usize]).unwrap_or("").to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut pending = self.window.pending_events.lock().unwrap();
|
let mut pending = self.window.pending_events.lock().unwrap();
|
||||||
for chr in written.as_slice().chars() {
|
for chr in written.chars() {
|
||||||
pending.push_back(ReceivedCharacter(chr));
|
pending.push_back(ReceivedCharacter(chr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -445,8 +442,6 @@ impl Window {
|
||||||
|
|
||||||
// creating IM
|
// creating IM
|
||||||
let im = unsafe {
|
let im = unsafe {
|
||||||
// XOpenIM doesn't seem to be thread-safe
|
|
||||||
static GLOBAL_XOPENIM_LOCK: StaticMutex = MUTEX_INIT;
|
|
||||||
let _lock = GLOBAL_XOPENIM_LOCK.lock().unwrap();
|
let _lock = GLOBAL_XOPENIM_LOCK.lock().unwrap();
|
||||||
|
|
||||||
let im = ffi::XOpenIM(display, ptr::null(), ptr::null_mut(), ptr::null_mut());
|
let im = ffi::XOpenIM(display, ptr::null(), ptr::null_mut(), ptr::null_mut());
|
||||||
|
@ -681,7 +676,7 @@ impl Window {
|
||||||
|
|
||||||
pub fn create_window_proxy(&self) -> WindowProxy {
|
pub fn create_window_proxy(&self) -> WindowProxy {
|
||||||
WindowProxy {
|
WindowProxy {
|
||||||
x: self.x.downgrade()
|
x: self.x.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,7 +823,7 @@ impl Window {
|
||||||
1.0
|
1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
pub fn set_cursor_position(&self, _x: i32, _y: i32) -> Result<(), ()> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue