Skip to content

Commit 9e66bed

Browse files
ids1024Drakulix
authored andcommitted
focus: Split off an x11_surface() method from is_xwm()
1 parent 3c70263 commit 9e66bed

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/shell/focus/target.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use smithay::{
3333
},
3434
utils::{IsAlive, Logical, Point, Serial, Transform},
3535
wayland::{seat::WaylandFocus, session_lock::LockSurface},
36-
xwayland::xwm::XwmId,
36+
xwayland::{xwm::XwmId, X11Surface},
3737
};
3838

3939
#[derive(Debug, Clone, PartialEq)]
@@ -220,22 +220,20 @@ impl KeyboardFocusTarget {
220220
}
221221
}
222222

223-
pub fn is_xwm(&self, xwm: XwmId) -> bool {
223+
fn x11_surface(&self) -> Option<X11Surface> {
224224
match self {
225-
KeyboardFocusTarget::Element(mapped) => {
226-
if let Some(surface) = mapped.active_window().x11_surface() {
227-
return surface.xwm_id().unwrap() == xwm;
228-
}
229-
}
230-
KeyboardFocusTarget::Fullscreen(surface) => {
231-
if let Some(surface) = surface.x11_surface() {
232-
return surface.xwm_id().unwrap() == xwm;
233-
}
234-
}
235-
_ => {}
225+
KeyboardFocusTarget::Element(mapped) => mapped.active_window().x11_surface().cloned(),
226+
KeyboardFocusTarget::Fullscreen(surface) => surface.x11_surface().cloned(),
227+
_ => None,
236228
}
229+
}
237230

238-
false
231+
pub fn is_xwm(&self, xwm: XwmId) -> bool {
232+
if let Some(surface) = self.x11_surface() {
233+
surface.xwm_id().unwrap() == xwm
234+
} else {
235+
false
236+
}
239237
}
240238
}
241239

0 commit comments

Comments
 (0)