Wayland: Switched to using a reference to relative_pointer_manager_proxy when creating SeatData (#1179)

* 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

* Improved CHANGELOG

* 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
This commit is contained in:
andersrein 2019-09-23 20:50:06 +02:00 committed by Osspial
parent 472eddcc1b
commit 7df040f451
2 changed files with 28 additions and 22 deletions

View file

@ -20,6 +20,7 @@
- On X11, return dummy monitor data to avoid panicking when no monitors exist.
- On X11, prevent stealing input focus when creating a new window.
Only steal input focus when entering fullscreen mode.
- On Wayland, fixed DeviceEvents for relative mouse movement is not always produced
# 0.20.0 Alpha 3 (2019-08-14)

View file

@ -148,7 +148,7 @@ impl<T: 'static> EventLoop<T> {
let mut seat_manager = SeatManager {
sink: sink.clone(),
relative_pointer_manager_proxy: None,
relative_pointer_manager_proxy: Rc::new(RefCell::new(None)),
store: store.clone(),
seats: seats.clone(),
kbd_sender,
@ -164,13 +164,16 @@ impl<T: 'static> EventLoop<T> {
version,
} => {
if interface == "zwp_relative_pointer_manager_v1" {
seat_manager.relative_pointer_manager_proxy = Some(
registry
let relative_pointer_manager_proxy = registry
.bind(version, id, move |pointer_manager| {
pointer_manager.implement_closure(|_, _| (), ())
})
.unwrap(),
)
.unwrap();
*seat_manager
.relative_pointer_manager_proxy
.try_borrow_mut()
.unwrap() = Some(relative_pointer_manager_proxy);
}
if interface == "wl_seat" {
seat_manager.add_seat(id, version, registry)
@ -493,7 +496,7 @@ struct SeatManager<T: 'static> {
store: Arc<Mutex<WindowStore>>,
seats: Arc<Mutex<Vec<(u32, wl_seat::WlSeat)>>>,
kbd_sender: ::calloop::channel::Sender<(crate::event::WindowEvent, super::WindowId)>,
relative_pointer_manager_proxy: Option<ZwpRelativePointerManagerV1>,
relative_pointer_manager_proxy: Rc<RefCell<Option<ZwpRelativePointerManagerV1>>>,
}
impl<T: 'static> SeatManager<T> {
@ -505,7 +508,7 @@ impl<T: 'static> SeatManager<T> {
store: self.store.clone(),
pointer: None,
relative_pointer: None,
relative_pointer_manager_proxy: self.relative_pointer_manager_proxy.as_ref().cloned(),
relative_pointer_manager_proxy: self.relative_pointer_manager_proxy.clone(),
keyboard: None,
touch: None,
kbd_sender: self.kbd_sender.clone(),
@ -537,7 +540,7 @@ struct SeatData<T> {
kbd_sender: ::calloop::channel::Sender<(crate::event::WindowEvent, super::WindowId)>,
pointer: Option<wl_pointer::WlPointer>,
relative_pointer: Option<ZwpRelativePointerV1>,
relative_pointer_manager_proxy: Option<ZwpRelativePointerManagerV1>,
relative_pointer_manager_proxy: Rc<RefCell<Option<ZwpRelativePointerManagerV1>>>,
keyboard: Option<wl_keyboard::WlKeyboard>,
touch: Option<wl_touch::WlTouch>,
modifiers_tracker: Arc<Mutex<ModifiersState>>,
@ -557,8 +560,10 @@ impl<T: 'static> SeatData<T> {
self.modifiers_tracker.clone(),
));
self.relative_pointer =
self.relative_pointer_manager_proxy
self.relative_pointer = self
.relative_pointer_manager_proxy
.try_borrow()
.unwrap()
.as_ref()
.and_then(|manager| {
super::pointer::implement_relative_pointer(