Wayland support for set_cursor_grab and set_cursor_visible (#1180)
* Fixed relative_pointer not being set up when the "zwp_relative_pointer_manager_v1" callback comes after the "wl_seat" callback * Ran cargo fmt * Updated changelog * Added wayland support for set_grab_cursor and set_cursor_visible * Updated changelog * Ran cargo fmt * Fixed set_cursor_visible and set_cursor_grab so they can be called from any thread. * Ran cargo_fmt * Improved CHANGELOG * Added workaround so that when cursor is hidden it takes effect before the cursor enters the surface. Making the cursor visible again still only happens once the cursor re-enters the surface * Switched to using Rc<RefCell> instead of Arc<Mutex> since all accesses to the relative_pointer_manager_proxy will happen on the same thread. * Forgot to run cargo fmt * Switched to using Rc and RefCell instead of Arc and Mutex where applicable. * Improved comments and documentation relating to changing a hidden cursor back to visible on wayland. * Wayland: Fixed cursor not appearing immendiately when setting the cursor to visible. * Forgot to run cargo fmt * Switched to only storing the pointers in CursorManager as AutoPointer. * Fixed typo and removed println * Update CHANGELOG.md Co-Authored-By: Kirill Chibisov <wchibisovkirill@gmail.com>
This commit is contained in:
parent
18a0119b06
commit
237e7ee2e6
5 changed files with 207 additions and 5 deletions
|
|
@ -38,6 +38,8 @@ pub struct Window {
|
|||
need_frame_refresh: Arc<Mutex<bool>>,
|
||||
need_refresh: Arc<Mutex<bool>>,
|
||||
fullscreen: Arc<Mutex<bool>>,
|
||||
cursor_grab_changed: Arc<Mutex<Option<bool>>>,
|
||||
cursor_visible_changed: Arc<Mutex<Option<bool>>>,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
|
@ -140,6 +142,8 @@ impl Window {
|
|||
let need_frame_refresh = Arc::new(Mutex::new(true));
|
||||
let frame = Arc::new(Mutex::new(frame));
|
||||
let need_refresh = Arc::new(Mutex::new(true));
|
||||
let cursor_grab_changed = Arc::new(Mutex::new(None));
|
||||
let cursor_visible_changed = Arc::new(Mutex::new(None));
|
||||
|
||||
evlp.store.lock().unwrap().windows.push(InternalWindow {
|
||||
closed: false,
|
||||
|
|
@ -148,6 +152,8 @@ impl Window {
|
|||
need_refresh: need_refresh.clone(),
|
||||
fullscreen: fullscreen.clone(),
|
||||
need_frame_refresh: need_frame_refresh.clone(),
|
||||
cursor_grab_changed: cursor_grab_changed.clone(),
|
||||
cursor_visible_changed: cursor_visible_changed.clone(),
|
||||
surface: surface.clone(),
|
||||
kill_switch: kill_switch.clone(),
|
||||
frame: Arc::downgrade(&frame),
|
||||
|
|
@ -166,6 +172,8 @@ impl Window {
|
|||
need_frame_refresh,
|
||||
need_refresh,
|
||||
fullscreen,
|
||||
cursor_grab_changed,
|
||||
cursor_visible_changed,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -297,13 +305,14 @@ impl Window {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_cursor_visible(&self, _visible: bool) {
|
||||
// TODO: This isn't possible on Wayland yet
|
||||
pub fn set_cursor_visible(&self, visible: bool) {
|
||||
*self.cursor_visible_changed.lock().unwrap() = Some(visible);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_cursor_grab(&self, _grab: bool) -> Result<(), ExternalError> {
|
||||
Err(ExternalError::NotSupported(NotSupportedError::new()))
|
||||
pub fn set_cursor_grab(&self, grab: bool) -> Result<(), ExternalError> {
|
||||
*self.cursor_grab_changed.lock().unwrap() = Some(grab);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -362,6 +371,8 @@ struct InternalWindow {
|
|||
need_refresh: Arc<Mutex<bool>>,
|
||||
fullscreen: Arc<Mutex<bool>>,
|
||||
need_frame_refresh: Arc<Mutex<bool>>,
|
||||
cursor_grab_changed: Arc<Mutex<Option<bool>>>,
|
||||
cursor_visible_changed: Arc<Mutex<Option<bool>>>,
|
||||
closed: bool,
|
||||
kill_switch: Arc<Mutex<bool>>,
|
||||
frame: Weak<Mutex<SWindow<ConceptFrame>>>,
|
||||
|
|
@ -429,6 +440,9 @@ impl WindowStore {
|
|||
bool,
|
||||
bool,
|
||||
bool,
|
||||
Option<bool>,
|
||||
Option<bool>,
|
||||
&wl_surface::WlSurface,
|
||||
WindowId,
|
||||
Option<&mut SWindow<ConceptFrame>>,
|
||||
),
|
||||
|
|
@ -443,6 +457,9 @@ impl WindowStore {
|
|||
::std::mem::replace(&mut *window.need_refresh.lock().unwrap(), false),
|
||||
::std::mem::replace(&mut *window.need_frame_refresh.lock().unwrap(), false),
|
||||
window.closed,
|
||||
window.cursor_visible_changed.lock().unwrap().take(),
|
||||
window.cursor_grab_changed.lock().unwrap().take(),
|
||||
&window.surface,
|
||||
make_wid(&window.surface),
|
||||
opt_mutex_lock.as_mut().map(|m| &mut **m),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue