Skip to content

Commit

Permalink
fixing cranky
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhbooth committed Jan 7, 2025
1 parent 0a7d697 commit 8d6d521
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion benches/image_compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ fn compression_benchmark(c: &mut Criterion) {
let files = fs::read_dir("/home/rasputin/qoi_benchmark_images/screenshot_web/")
.unwrap()
.map(|dirent| dirent.unwrap().path())
.filter(|path| path.extension().map_or(false, |ext| ext == "png"));
.filter(|path| path.extension().is_some_and(|ext| ext == "png"));
let mut compression_ratios = Vec::new();
let mut filter_compression_ratios = Vec::new();
for file in files {
Expand Down
5 changes: 3 additions & 2 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ pub trait OptionalConfig<Conf: Config>:
return None;
}

let config_str = fs::read_to_string(&config_file)
.expect("config file at path {config_file} exists but there was an error reading it");
let config_str = fs::read_to_string(&config_file).unwrap_or_else(|_| {
panic!("config file at path {config_file:?} exists but there was an error reading it")
});
let config: Self = Options::default()
.with_default_extension(Extensions::IMPLICIT_SOME)
.from_str(&config_str)
Expand Down
4 changes: 3 additions & 1 deletion src/client/smithay_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@ impl SeatHandler for WprsClientState {
if let Some(seat_obj) = self.seat_objects.iter_mut().find(|s| s.seat == seat) {
match capability {
Capability::Keyboard => {
seat_obj.keyboard.take().map(|k| k.release());
if let Some(k) = seat_obj.keyboard.take() {
k.release()
}
},
Capability::Pointer => {
seat_obj.pointer.take();
Expand Down
8 changes: 6 additions & 2 deletions src/xwayland_xdg_shell/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,14 @@ impl SeatHandler for WprsState {
{
match capability {
Capability::Keyboard => {
seat_obj.keyboard.take().map(|k| k.release());
if let Some(k) = seat_obj.keyboard.take() {
k.release()
}
},
Capability::Pointer => {
seat_obj.pointer.take().map(|p| p.pointer().release());
if let Some(p) = seat_obj.pointer.take() {
p.pointer().release()
}
},
_ => {},
}
Expand Down
2 changes: 1 addition & 1 deletion src/xwayland_xdg_shell/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ pub(crate) fn find_x11_parent(
.find(|(_, xwls)| {
xwls.x11_surface
.as_ref()
.map_or(false, |s| s.window_id() == parent_id)
.is_some_and(|s| s.window_id() == parent_id)
})
.unwrap();

Expand Down
11 changes: 5 additions & 6 deletions src/xwayland_xdg_shell/xwayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ impl XwmHandler for WprsState {
// Without this, xwayland still thinks the key that triggered the
// window close is still held down and sends key repeat events.
if let Some(keyboard) = self.compositor_state.seat.get_keyboard() {
if keyboard
.current_focus()
.map_or(false, |focus| focus == window)
{
let serial = SERIAL_COUNTER.next_serial();
keyboard.set_focus(self, None, serial);
if let Some(focus) = keyboard.current_focus() {
if focus == window {
let serial = SERIAL_COUNTER.next_serial();
keyboard.set_focus(self, None, serial);
}
}
}
}
Expand Down

0 comments on commit 8d6d521

Please sign in to comment.