Remove api_transition macro (#279)
* Remove api_transition macro * Rename Window2 to Window * Try fix X11 code
This commit is contained in:
parent
0ada6c15ea
commit
342d5d8587
13 changed files with 97 additions and 247 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
|
||||
|
||||
pub use self::monitor::{MonitorId, get_available_monitors, get_primary_monitor};
|
||||
pub use self::window::{Window, XWindow};
|
||||
pub use self::window::{Window2, XWindow};
|
||||
pub use self::xdisplay::{XConnection, XNotSupported, XError};
|
||||
|
||||
pub mod ffi;
|
||||
|
|
@ -655,16 +655,16 @@ pub struct WindowId(ffi::Window);
|
|||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct DeviceId(c_int);
|
||||
|
||||
pub struct Window2 {
|
||||
pub window: Arc<Window>,
|
||||
pub struct Window {
|
||||
pub window: Arc<Window2>,
|
||||
display: Weak<XConnection>,
|
||||
windows: Weak<Mutex<HashMap<WindowId, WindowData>>>,
|
||||
}
|
||||
|
||||
impl ::std::ops::Deref for Window2 {
|
||||
type Target = Window;
|
||||
impl ::std::ops::Deref for Window {
|
||||
type Target = Window2;
|
||||
#[inline]
|
||||
fn deref(&self) -> &Window {
|
||||
fn deref(&self) -> &Window2 {
|
||||
&*self.window
|
||||
}
|
||||
}
|
||||
|
|
@ -674,13 +674,13 @@ lazy_static! { // TODO: use a static mutex when that's possible, and put me
|
|||
static ref GLOBAL_XOPENIM_LOCK: Mutex<()> = Mutex::new(());
|
||||
}
|
||||
|
||||
impl Window2 {
|
||||
impl Window {
|
||||
pub fn new(x_events_loop: &EventsLoop,
|
||||
window: &::WindowAttributes,
|
||||
pl_attribs: &PlatformSpecificWindowBuilderAttributes)
|
||||
-> Result<Self, CreationError>
|
||||
{
|
||||
let win = ::std::sync::Arc::new(try!(Window::new(&x_events_loop, window, pl_attribs)));
|
||||
let win = ::std::sync::Arc::new(try!(Window2::new(&x_events_loop, window, pl_attribs)));
|
||||
|
||||
// creating IM
|
||||
let im = unsafe {
|
||||
|
|
@ -716,7 +716,7 @@ impl Window2 {
|
|||
cursor_pos: None,
|
||||
});
|
||||
|
||||
Ok(Window2 {
|
||||
Ok(Window {
|
||||
window: win,
|
||||
windows: Arc::downgrade(&x_events_loop.windows),
|
||||
display: Arc::downgrade(&x_events_loop.display),
|
||||
|
|
@ -749,7 +749,7 @@ impl Window2 {
|
|||
}
|
||||
}
|
||||
|
||||
impl Drop for Window2 {
|
||||
impl Drop for Window {
|
||||
fn drop(&mut self) {
|
||||
if let (Some(windows), Some(display)) = (self.windows.upgrade(), self.display.upgrade()) {
|
||||
let mut windows = windows.lock().unwrap();
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ pub struct XWindow {
|
|||
unsafe impl Send for XWindow {}
|
||||
unsafe impl Sync for XWindow {}
|
||||
|
||||
unsafe impl Send for Window {}
|
||||
unsafe impl Sync for Window {}
|
||||
unsafe impl Send for Window2 {}
|
||||
unsafe impl Sync for Window2 {}
|
||||
|
||||
impl XWindow {
|
||||
fn switch_to_fullscreen_mode(&self, monitor: i32, width: u16, height: u16) {
|
||||
|
|
@ -141,15 +141,15 @@ impl Drop for XWindow {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct Window {
|
||||
pub struct Window2 {
|
||||
pub x: Arc<XWindow>,
|
||||
cursor_state: Mutex<CursorState>,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
impl Window2 {
|
||||
pub fn new(ctx: &EventsLoop, window_attrs: &WindowAttributes,
|
||||
pl_attribs: &PlatformSpecificWindowBuilderAttributes)
|
||||
-> Result<Window, CreationError>
|
||||
-> Result<Window2, CreationError>
|
||||
{
|
||||
let display = &ctx.display;
|
||||
let dimensions = {
|
||||
|
|
@ -306,7 +306,7 @@ impl Window {
|
|||
};
|
||||
}
|
||||
|
||||
let window = Window {
|
||||
let window = Window2 {
|
||||
x: Arc::new(XWindow {
|
||||
display: display.clone(),
|
||||
window: window,
|
||||
|
|
@ -402,16 +402,16 @@ impl Window {
|
|||
match state {
|
||||
FullScreenState::None => {
|
||||
self.x.switch_from_fullscreen_mode();
|
||||
Window::set_netwm(&self.x.display, self.x.window, self.x.root, "_NET_WM_STATE_FULLSCREEN", false);
|
||||
Window2::set_netwm(&self.x.display, self.x.window, self.x.root, "_NET_WM_STATE_FULLSCREEN", false);
|
||||
},
|
||||
FullScreenState::Windowed => {
|
||||
self.x.switch_from_fullscreen_mode();
|
||||
Window::set_netwm(&self.x.display, self.x.window, self.x.root, "_NET_WM_STATE_FULLSCREEN", true);
|
||||
Window2::set_netwm(&self.x.display, self.x.window, self.x.root, "_NET_WM_STATE_FULLSCREEN", true);
|
||||
},
|
||||
FullScreenState::Exclusive(RootMonitorId { inner: PlatformMonitorId::X(X11MonitorId(_, monitor)) }) => {
|
||||
if let Some(dimensions) = self.get_inner_size() {
|
||||
self.x.switch_to_fullscreen_mode(monitor as i32, dimensions.0 as u16, dimensions.1 as u16);
|
||||
Window::set_netwm(&self.x.display, self.x.window, self.x.root, "_NET_WM_STATE_FULLSCREEN", true);
|
||||
Window2::set_netwm(&self.x.display, self.x.window, self.x.root, "_NET_WM_STATE_FULLSCREEN", true);
|
||||
} else {
|
||||
eprintln!("[winit] Couldn't get window dimensions to go fullscreen");
|
||||
}
|
||||
|
|
@ -421,8 +421,8 @@ impl Window {
|
|||
}
|
||||
|
||||
pub fn set_maximized(&self, maximized: bool) {
|
||||
Window::set_netwm(&self.x.display, self.x.window, self.x.root, "_NET_WM_STATE_MAXIMIZED_HORZ", maximized);
|
||||
Window::set_netwm(&self.x.display, self.x.window, self.x.root, "_NET_WM_STATE_MAXIMIZED_VERT", maximized);
|
||||
Window2::set_netwm(&self.x.display, self.x.window, self.x.root, "_NET_WM_STATE_MAXIMIZED_HORZ", maximized);
|
||||
Window2::set_netwm(&self.x.display, self.x.window, self.x.root, "_NET_WM_STATE_MAXIMIZED_VERT", maximized);
|
||||
}
|
||||
|
||||
pub fn set_title(&self, title: &str) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue