Use and_then over unwrap for rest of surface.data() use
Continues on the #113 fix by eliminating the remaining places the unwrap could occur on
This commit is contained in:
parent
d4dcee4e8d
commit
5bbc4c507a
1 changed files with 18 additions and 14 deletions
|
|
@ -454,8 +454,12 @@ impl HandleEvent for Pointer {
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
};
|
};
|
||||||
let surface_key: ObjectKey = surface.data().copied().unwrap();
|
if surface
|
||||||
if state.objects.get(surface_key).is_some() {
|
.data()
|
||||||
|
.copied()
|
||||||
|
.and_then(|key| state.objects.get(key))
|
||||||
|
.is_some()
|
||||||
|
{
|
||||||
trace!("resending enter ({serial}) before motion");
|
trace!("resending enter ({serial}) before motion");
|
||||||
let enter_event = client::wl_pointer::Event::Enter {
|
let enter_event = client::wl_pointer::Event::Enter {
|
||||||
serial: *serial,
|
serial: *serial,
|
||||||
|
|
@ -547,12 +551,12 @@ impl HandleEvent for Keyboard {
|
||||||
surface,
|
surface,
|
||||||
keys,
|
keys,
|
||||||
} => {
|
} => {
|
||||||
let key: ObjectKey = surface.data().copied().unwrap();
|
if let Some(data) = surface.data().copied().and_then(|key| {
|
||||||
if let Some(data) = state
|
state
|
||||||
.objects
|
.objects
|
||||||
.get(key)
|
.get(key)
|
||||||
.map(<_ as AsRef<SurfaceData>>::as_ref)
|
.map(<_ as AsRef<SurfaceData>>::as_ref)
|
||||||
{
|
}) {
|
||||||
state.last_kb_serial = Some(serial);
|
state.last_kb_serial = Some(serial);
|
||||||
let output_name = data.get_output_name(state);
|
let output_name = data.get_output_name(state);
|
||||||
state.to_focus = Some(FocusData {
|
state.to_focus = Some(FocusData {
|
||||||
|
|
@ -566,12 +570,12 @@ impl HandleEvent for Keyboard {
|
||||||
if !surface.is_alive() {
|
if !surface.is_alive() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let key: ObjectKey = surface.data().copied().unwrap();
|
if let Some(data) = surface.data().copied().and_then(|key| {
|
||||||
if let Some(data) = state
|
state
|
||||||
.objects
|
.objects
|
||||||
.get(key)
|
.get(key)
|
||||||
.map(<_ as AsRef<SurfaceData>>::as_ref)
|
.map(<_ as AsRef<SurfaceData>>::as_ref)
|
||||||
{
|
}) {
|
||||||
if state.to_focus.as_ref().map(|d| d.window) == Some(data.window.unwrap()) {
|
if state.to_focus.as_ref().map(|d| d.window) == Some(data.window.unwrap()) {
|
||||||
state.to_focus.take();
|
state.to_focus.take();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue