mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
Provide current modifiers state with pointer events on wayland (#676)
This commit is contained in:
parent
ea07ec1fda
commit
7baa96c5c7
|
@ -1,5 +1,6 @@
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
- On Wayland, pointer events will now provide the current modifiers state.
|
||||||
- On Wayland, titles will now be displayed in the window header decoration.
|
- On Wayland, titles will now be displayed in the window header decoration.
|
||||||
- On Wayland, key repetition is now ended when keyboard loses focus.
|
- On Wayland, key repetition is now ended when keyboard loses focus.
|
||||||
- On Wayland, windows will now use more stylish and modern client side decorations.
|
- On Wayland, windows will now use more stylish and modern client side decorations.
|
||||||
|
|
|
@ -19,6 +19,8 @@ use sctk::Environment;
|
||||||
use sctk::reexports::client::protocol::wl_display::RequestsTrait as DisplayRequests;
|
use sctk::reexports::client::protocol::wl_display::RequestsTrait as DisplayRequests;
|
||||||
use sctk::reexports::client::protocol::wl_surface::RequestsTrait;
|
use sctk::reexports::client::protocol::wl_surface::RequestsTrait;
|
||||||
|
|
||||||
|
use ModifiersState;
|
||||||
|
|
||||||
pub struct EventsLoopSink {
|
pub struct EventsLoopSink {
|
||||||
buffer: VecDeque<::Event>,
|
buffer: VecDeque<::Event>,
|
||||||
}
|
}
|
||||||
|
@ -303,6 +305,7 @@ impl SeatManager {
|
||||||
keyboard: None,
|
keyboard: None,
|
||||||
touch: None,
|
touch: None,
|
||||||
events_loop_proxy: self.events_loop_proxy.clone(),
|
events_loop_proxy: self.events_loop_proxy.clone(),
|
||||||
|
modifiers_tracker: Arc::new(Mutex::new(ModifiersState::default())),
|
||||||
};
|
};
|
||||||
let seat = registry
|
let seat = registry
|
||||||
.bind(min(version, 5), id, move |seat| {
|
.bind(min(version, 5), id, move |seat| {
|
||||||
|
@ -335,6 +338,7 @@ struct SeatData {
|
||||||
keyboard: Option<Proxy<wl_keyboard::WlKeyboard>>,
|
keyboard: Option<Proxy<wl_keyboard::WlKeyboard>>,
|
||||||
touch: Option<Proxy<wl_touch::WlTouch>>,
|
touch: Option<Proxy<wl_touch::WlTouch>>,
|
||||||
events_loop_proxy: EventsLoopProxy,
|
events_loop_proxy: EventsLoopProxy,
|
||||||
|
modifiers_tracker: Arc<Mutex<ModifiersState>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SeatData {
|
impl SeatData {
|
||||||
|
@ -348,6 +352,7 @@ impl SeatData {
|
||||||
&seat,
|
&seat,
|
||||||
self.sink.clone(),
|
self.sink.clone(),
|
||||||
self.store.clone(),
|
self.store.clone(),
|
||||||
|
self.modifiers_tracker.clone(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
// destroy pointer if applicable
|
// destroy pointer if applicable
|
||||||
|
@ -365,6 +370,7 @@ impl SeatData {
|
||||||
&seat,
|
&seat,
|
||||||
self.sink.clone(),
|
self.sink.clone(),
|
||||||
self.events_loop_proxy.clone(),
|
self.events_loop_proxy.clone(),
|
||||||
|
self.modifiers_tracker.clone(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
// destroy keyboard if applicable
|
// destroy keyboard if applicable
|
||||||
|
|
|
@ -15,14 +15,14 @@ pub fn init_keyboard(
|
||||||
seat: &Proxy<wl_seat::WlSeat>,
|
seat: &Proxy<wl_seat::WlSeat>,
|
||||||
sink: Arc<Mutex<EventsLoopSink>>,
|
sink: Arc<Mutex<EventsLoopSink>>,
|
||||||
events_loop_proxy: EventsLoopProxy,
|
events_loop_proxy: EventsLoopProxy,
|
||||||
|
modifiers_tracker: Arc<Mutex<ModifiersState>>,
|
||||||
) -> Proxy<wl_keyboard::WlKeyboard> {
|
) -> Proxy<wl_keyboard::WlKeyboard> {
|
||||||
// { variables to be captured by the closures
|
// { variables to be captured by the closures
|
||||||
let target = Arc::new(Mutex::new(None));
|
let target = Arc::new(Mutex::new(None));
|
||||||
let my_sink = sink.clone();
|
let my_sink = sink.clone();
|
||||||
let repeat_sink = sink.clone();
|
let repeat_sink = sink.clone();
|
||||||
let repeat_target = target.clone();
|
let repeat_target = target.clone();
|
||||||
let modifiers = Arc::new(Mutex::new(ModifiersState::default()));
|
let my_modifiers = modifiers_tracker.clone();
|
||||||
let my_modifiers = modifiers.clone();
|
|
||||||
// }
|
// }
|
||||||
let ret = map_keyboard_auto_with_repeat(
|
let ret = map_keyboard_auto_with_repeat(
|
||||||
seat,
|
seat,
|
||||||
|
@ -65,7 +65,7 @@ pub fn init_keyboard(
|
||||||
state: state,
|
state: state,
|
||||||
scancode: rawkey,
|
scancode: rawkey,
|
||||||
virtual_keycode: vkcode,
|
virtual_keycode: vkcode,
|
||||||
modifiers: modifiers.lock().unwrap().clone(),
|
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wid,
|
wid,
|
||||||
|
@ -83,7 +83,7 @@ pub fn init_keyboard(
|
||||||
}
|
}
|
||||||
KbEvent::RepeatInfo { .. } => { /* Handled by smithay client toolkit */ }
|
KbEvent::RepeatInfo { .. } => { /* Handled by smithay client toolkit */ }
|
||||||
KbEvent::Modifiers { modifiers: event_modifiers } => {
|
KbEvent::Modifiers { modifiers: event_modifiers } => {
|
||||||
*modifiers.lock().unwrap() = event_modifiers.into()
|
*modifiers_tracker.lock().unwrap() = event_modifiers.into()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
move |repeat_event: KeyRepeatEvent, _| {
|
move |repeat_event: KeyRepeatEvent, _| {
|
||||||
|
|
|
@ -16,6 +16,7 @@ pub fn implement_pointer(
|
||||||
seat: &Proxy<wl_seat::WlSeat>,
|
seat: &Proxy<wl_seat::WlSeat>,
|
||||||
sink: Arc<Mutex<EventsLoopSink>>,
|
sink: Arc<Mutex<EventsLoopSink>>,
|
||||||
store: Arc<Mutex<WindowStore>>,
|
store: Arc<Mutex<WindowStore>>,
|
||||||
|
modifiers_tracker: Arc<Mutex<ModifiersState>>,
|
||||||
) -> Proxy<WlPointer> {
|
) -> Proxy<WlPointer> {
|
||||||
let mut mouse_focus = None;
|
let mut mouse_focus = None;
|
||||||
let mut axis_buffer = None;
|
let mut axis_buffer = None;
|
||||||
|
@ -46,8 +47,7 @@ pub fn implement_pointer(
|
||||||
WindowEvent::CursorMoved {
|
WindowEvent::CursorMoved {
|
||||||
device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)),
|
device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)),
|
||||||
position: (surface_x, surface_y).into(),
|
position: (surface_x, surface_y).into(),
|
||||||
// TODO: replace dummy value with actual modifier state
|
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||||
modifiers: ModifiersState::default(),
|
|
||||||
},
|
},
|
||||||
wid,
|
wid,
|
||||||
);
|
);
|
||||||
|
@ -75,8 +75,7 @@ pub fn implement_pointer(
|
||||||
WindowEvent::CursorMoved {
|
WindowEvent::CursorMoved {
|
||||||
device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)),
|
device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)),
|
||||||
position: (surface_x, surface_y).into(),
|
position: (surface_x, surface_y).into(),
|
||||||
// TODO: replace dummy value with actual modifier state
|
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||||
modifiers: ModifiersState::default(),
|
|
||||||
},
|
},
|
||||||
wid,
|
wid,
|
||||||
);
|
);
|
||||||
|
@ -100,8 +99,7 @@ pub fn implement_pointer(
|
||||||
device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)),
|
device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)),
|
||||||
state: state,
|
state: state,
|
||||||
button: button,
|
button: button,
|
||||||
// TODO: replace dummy value with actual modifier state
|
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||||
modifiers: ModifiersState::default(),
|
|
||||||
},
|
},
|
||||||
wid,
|
wid,
|
||||||
);
|
);
|
||||||
|
@ -122,8 +120,7 @@ pub fn implement_pointer(
|
||||||
device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)),
|
device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)),
|
||||||
delta: MouseScrollDelta::PixelDelta((x as f64, y as f64).into()),
|
delta: MouseScrollDelta::PixelDelta((x as f64, y as f64).into()),
|
||||||
phase: TouchPhase::Moved,
|
phase: TouchPhase::Moved,
|
||||||
// TODO: replace dummy value with actual modifier state
|
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||||
modifiers: ModifiersState::default(),
|
|
||||||
},
|
},
|
||||||
wid,
|
wid,
|
||||||
);
|
);
|
||||||
|
@ -152,8 +149,7 @@ pub fn implement_pointer(
|
||||||
device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)),
|
device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)),
|
||||||
delta: MouseScrollDelta::LineDelta(x as f32, y as f32),
|
delta: MouseScrollDelta::LineDelta(x as f32, y as f32),
|
||||||
phase: axis_state,
|
phase: axis_state,
|
||||||
// TODO: replace dummy value with actual modifier state
|
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||||
modifiers: ModifiersState::default(),
|
|
||||||
},
|
},
|
||||||
wid,
|
wid,
|
||||||
);
|
);
|
||||||
|
@ -163,8 +159,7 @@ pub fn implement_pointer(
|
||||||
device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)),
|
device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)),
|
||||||
delta: MouseScrollDelta::PixelDelta((x as f64, y as f64).into()),
|
delta: MouseScrollDelta::PixelDelta((x as f64, y as f64).into()),
|
||||||
phase: axis_state,
|
phase: axis_state,
|
||||||
// TODO: replace dummy value with actual modifier state
|
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||||
modifiers: ModifiersState::default(),
|
|
||||||
},
|
},
|
||||||
wid,
|
wid,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue