Skip to content

Commit

Permalink
Merge branch 'master' into window-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
micahrj authored Dec 17, 2023
2 parents 7ca4214 + 937ef96 commit b565d17
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 25 deletions.
13 changes: 6 additions & 7 deletions src/macos/window.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::cell::{Cell, RefCell};
use std::ffi::c_void;
use std::marker::PhantomData;
use std::ptr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
Expand All @@ -24,8 +23,8 @@ use raw_window_handle::{
};

use crate::{
Event, EventStatus, Size, WindowEvent, WindowHandler, WindowInfo, WindowOpenOptions,
WindowScalePolicy,
Event, EventStatus, MouseCursor, Size, WindowEvent, WindowHandler, WindowInfo,
WindowOpenOptions, WindowScalePolicy,
};

use super::keyboard::KeyboardState;
Expand All @@ -38,9 +37,6 @@ pub struct WindowHandle {
raw_window_handle: Option<RawWindowHandle>,
close_requested: Arc<AtomicBool>,
is_open: Arc<AtomicBool>,

// Ensure handle is !Send
_phantom: PhantomData<*mut ()>,
}

impl WindowHandle {
Expand Down Expand Up @@ -81,7 +77,6 @@ impl ParentHandle {
raw_window_handle: Some(raw_window_handle),
close_requested: Arc::clone(&close_requested),
is_open: Arc::clone(&is_open),
_phantom: PhantomData::default(),
};

(Self { _close_requested: close_requested, is_open }, handle)
Expand Down Expand Up @@ -308,6 +303,10 @@ impl<'a> Window<'a> {
}
}

pub fn set_mouse_cursor(&mut self, _mouse_cursor: MouseCursor) {
todo!()
}

#[cfg(feature = "opengl")]
pub fn gl_context(&self) -> Option<&GlContext> {
self.inner.gl_context.as_ref()
Expand Down
16 changes: 6 additions & 10 deletions src/win/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use winapi::um::winuser::{
use std::cell::{Cell, Ref, RefCell, RefMut};
use std::collections::VecDeque;
use std::ffi::{c_void, OsStr};
use std::marker::PhantomData;
use std::os::windows::ffi::OsStrExt;
use std::ptr::null_mut;
use std::rc::Rc;
Expand All @@ -34,7 +33,7 @@ use raw_window_handle::{
const BV_WINDOW_MUST_CLOSE: UINT = WM_USER + 1;

use crate::{
Event, MouseButton, MouseEvent, PhyPoint, PhySize, ScrollDelta, Size, WindowEvent,
Event, MouseButton, MouseCursor, MouseEvent, PhyPoint, PhySize, ScrollDelta, Size, WindowEvent,
WindowHandler, WindowInfo, WindowOpenOptions, WindowScalePolicy,
};

Expand Down Expand Up @@ -68,9 +67,6 @@ const WIN_FRAME_TIMER: usize = 4242;
pub struct WindowHandle {
hwnd: Option<HWND>,
is_open: Rc<Cell<bool>>,

// Ensure handle is !Send
_phantom: PhantomData<*mut ()>,
}

impl WindowHandle {
Expand Down Expand Up @@ -108,11 +104,7 @@ impl ParentHandle {
pub fn new(hwnd: HWND) -> (Self, WindowHandle) {
let is_open = Rc::new(Cell::new(true));

let handle = WindowHandle {
hwnd: Some(hwnd),
is_open: Rc::clone(&is_open),
_phantom: PhantomData::default(),
};
let handle = WindowHandle { hwnd: Some(hwnd), is_open: Rc::clone(&is_open) };

(Self { is_open }, handle)
}
Expand Down Expand Up @@ -757,6 +749,10 @@ impl Window<'_> {
self.state.deferred_tasks.borrow_mut().push_back(task);
}

pub fn set_mouse_cursor(&mut self, _mouse_cursor: MouseCursor) {
todo!()
}

#[cfg(feature = "opengl")]
pub fn gl_context(&self) -> Option<&GlContext> {
self.state.gl_context.as_ref()
Expand Down
6 changes: 5 additions & 1 deletion src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use raw_window_handle::{

use crate::event::{Event, EventStatus};
use crate::window_open_options::WindowOpenOptions;
use crate::Size;
use crate::{MouseCursor, Size};

#[cfg(target_os = "macos")]
use crate::macos as platform;
Expand Down Expand Up @@ -98,6 +98,10 @@ impl<'a> Window<'a> {
self.window.resize(size);
}

pub fn set_mouse_cursor(&mut self, cursor: MouseCursor) {
self.window.set_mouse_cursor(cursor);
}

/// If provided, then an OpenGL context will be created for this window. You'll be able to
/// access this context through [crate::Window::gl_context].
#[cfg(feature = "opengl")]
Expand Down
6 changes: 0 additions & 6 deletions src/x11/window.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::ffi::c_void;
use std::marker::PhantomData;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc;
use std::sync::Arc;
Expand Down Expand Up @@ -28,9 +27,6 @@ pub struct WindowHandle {
raw_window_handle: Option<RawWindowHandle>,
close_requested: Arc<AtomicBool>,
is_open: Arc<AtomicBool>,

// Ensure handle is !Send
_phantom: PhantomData<*mut ()>,
}

impl WindowHandle {
Expand Down Expand Up @@ -75,7 +71,6 @@ impl ParentHandle {
raw_window_handle: None,
close_requested: Arc::clone(&close_requested),
is_open: Arc::clone(&is_open),
_phantom: PhantomData::default(),
};

(Self { close_requested, is_open }, handle)
Expand All @@ -97,7 +92,6 @@ struct WindowInner {
window_id: u32,
window_info: WindowInfo,
visual_id: u32,
// FIXME: There's all this mouse cursor logic but it's never actually used, is this correct?
mouse_cursor: MouseCursor,

frame_interval: Duration,
Expand Down
1 change: 0 additions & 1 deletion src/x11/xcb_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub struct XcbConnection {

pub(crate) atoms: Atoms,

// FIXME: Same here, there's a ton of unused cursor machinery in here
pub(super) cursor_cache: HashMap<MouseCursor, u32>,
}

Expand Down

0 comments on commit b565d17

Please sign in to comment.