mirror of
https://github.com/wez/wezterm.git
synced 2024-08-17 02:00:25 +03:00
Fix crash when switching TTYs
This commit is contained in:
parent
b1069576b7
commit
369fcb9928
@ -23,43 +23,50 @@ impl SeatHandler for WaylandState {
|
||||
_conn: &Connection,
|
||||
qh: &QueueHandle<Self>,
|
||||
seat: WlSeat,
|
||||
capability: smithay_client_toolkit::seat::Capability,
|
||||
capability: Capability,
|
||||
) {
|
||||
if capability == Capability::Keyboard && self.keyboard.is_none() {
|
||||
log::trace!("Setting keyboard capability");
|
||||
let keyboard = seat.get_keyboard(qh, KeyboardData {});
|
||||
self.keyboard = Some(keyboard.clone());
|
||||
match capability {
|
||||
Capability::Keyboard if self.keyboard.is_none() => {
|
||||
log::trace!("Setting keyboard capability");
|
||||
let keyboard = seat.get_keyboard(qh, KeyboardData {});
|
||||
self.keyboard = Some(keyboard.clone());
|
||||
|
||||
if let Some(text_input) = &self.text_input {
|
||||
text_input.advise_seat(&seat, &keyboard, qh);
|
||||
if let Some(text_input) = &self.text_input {
|
||||
text_input.advise_seat(&seat, &keyboard, qh);
|
||||
}
|
||||
}
|
||||
Capability::Pointer if self.pointer.is_none() => {
|
||||
log::trace!("Setting pointer capability");
|
||||
let surface = self.compositor.create_surface(qh);
|
||||
let pointer = self
|
||||
.seat
|
||||
.get_pointer_with_theme_and_data::<WaylandState, SurfaceUserData, PointerUserData>(
|
||||
qh,
|
||||
&seat,
|
||||
&self.shm.wl_shm(),
|
||||
surface,
|
||||
ThemeSpec::System,
|
||||
PointerUserData::new(seat.clone()),
|
||||
)
|
||||
.expect("Failed to create pointer");
|
||||
self.pointer = Some(pointer);
|
||||
}
|
||||
Capability::Touch /* if self.touch.is_none() */ => {
|
||||
log::trace!("Setting touch capability");
|
||||
// TODO
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if capability == Capability::Pointer && self.pointer.is_none() {
|
||||
log::trace!("Setting pointer capability");
|
||||
let surface = self.compositor.create_surface(qh);
|
||||
let pointer = self
|
||||
.seat
|
||||
.get_pointer_with_theme_and_data::<WaylandState, SurfaceUserData, PointerUserData>(
|
||||
qh,
|
||||
&seat,
|
||||
&self.shm.wl_shm(),
|
||||
surface,
|
||||
ThemeSpec::System,
|
||||
PointerUserData::new(seat.clone()),
|
||||
)
|
||||
.expect("Failed to create pointer");
|
||||
self.pointer = Some(pointer);
|
||||
|
||||
// TODO: is there a better place to put this? It only needs to be run once. (presumably per-seat)
|
||||
if self.data_device.is_none() {
|
||||
let data_device_manager = &self.data_device_manager_state;
|
||||
let data_device = data_device_manager.get_data_device(qh, &seat);
|
||||
self.data_device.replace(data_device);
|
||||
self.data_device = Some(data_device_manager.get_data_device(qh, &seat));
|
||||
|
||||
let primary_selection_device = self
|
||||
self.primary_selection_device = self
|
||||
.primary_selection_manager
|
||||
.as_ref()
|
||||
.map(|m| m.get_selection_device(qh, &seat));
|
||||
self.primary_selection_device = primary_selection_device;
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,9 +75,23 @@ impl SeatHandler for WaylandState {
|
||||
_conn: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
_seat: WlSeat,
|
||||
_capability: smithay_client_toolkit::seat::Capability,
|
||||
capability: Capability,
|
||||
) {
|
||||
todo!()
|
||||
match capability {
|
||||
Capability::Keyboard => {
|
||||
log::trace!("Lost keyboard capability");
|
||||
self.keyboard.take().unwrap().release();
|
||||
}
|
||||
Capability::Pointer => {
|
||||
log::trace!("Lost pointer capability");
|
||||
self.pointer.take(); // ThemedPointer's drop implementation calls wl_pointer.release() already.
|
||||
}
|
||||
Capability::Touch => {
|
||||
log::trace!("Lost touch capability");
|
||||
// Nothing to do here. (yet)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_seat(&mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _seat: WlSeat) {
|
||||
|
Loading…
Reference in New Issue
Block a user