mirror of
https://github.com/YaLTeR/niri.git
synced 2025-12-23 05:36:51 +00:00
Use is_none_or()
This commit is contained in:
parent
80469abc20
commit
f913219f94
8 changed files with 13 additions and 17 deletions
|
|
@ -387,12 +387,10 @@ impl XdgShellHandler for State {
|
|||
|
||||
let keyboard_grab_mismatches = keyboard.is_grabbed()
|
||||
&& !(keyboard.has_grab(serial)
|
||||
|| grab
|
||||
.previous_serial()
|
||||
.map_or(true, |s| keyboard.has_grab(s)));
|
||||
|| grab.previous_serial().is_none_or(|s| keyboard.has_grab(s)));
|
||||
let pointer_grab_mismatches = pointer.is_grabbed()
|
||||
&& !(pointer.has_grab(serial)
|
||||
|| grab.previous_serial().map_or(true, |s| pointer.has_grab(s)));
|
||||
|| grab.previous_serial().is_none_or(|s| pointer.has_grab(s)));
|
||||
if (can_receive_keyboard_focus && keyboard_grab_mismatches) || pointer_grab_mismatches {
|
||||
trace!("ignoring popup grab because of current grab mismatch");
|
||||
grab.ungrab(PopupUngrabStrategy::All);
|
||||
|
|
|
|||
|
|
@ -3049,7 +3049,7 @@ impl State {
|
|||
pointer
|
||||
.current_focus()
|
||||
.map(|surface| self.niri.find_root_shell_surface(&surface))
|
||||
.map_or(true, |root| {
|
||||
.is_none_or(|root| {
|
||||
!self
|
||||
.niri
|
||||
.mapped_layer_surfaces
|
||||
|
|
|
|||
|
|
@ -2674,13 +2674,13 @@ impl<W: LayoutElement> Layout<W> {
|
|||
pub fn are_animations_ongoing(&self, output: Option<&Output>) -> bool {
|
||||
// Keep advancing animations if we might need to scroll the view.
|
||||
if let Some(dnd) = &self.dnd {
|
||||
if output.map_or(true, |output| *output == dnd.output) {
|
||||
if output.is_none_or(|output| *output == dnd.output) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move {
|
||||
if output.map_or(true, |output| *output == move_.output) {
|
||||
if output.is_none_or(|output| *output == move_.output) {
|
||||
if move_.tile.are_animations_ongoing() {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2720,7 +2720,7 @@ impl<W: LayoutElement> Layout<W> {
|
|||
|
||||
let zoom = self.overview_zoom();
|
||||
if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move {
|
||||
if output.map_or(true, |output| move_.output == *output) {
|
||||
if output.is_none_or(|output| move_.output == *output) {
|
||||
let pos_within_output = move_.tile_render_location(zoom);
|
||||
let view_rect =
|
||||
Rectangle::new(pos_within_output.upscale(-1.), output_size(&move_.output));
|
||||
|
|
@ -2741,7 +2741,7 @@ impl<W: LayoutElement> Layout<W> {
|
|||
};
|
||||
|
||||
for (idx, mon) in monitors.iter_mut().enumerate() {
|
||||
if output.map_or(true, |output| mon.output == *output) {
|
||||
if output.is_none_or(|output| mon.output == *output) {
|
||||
let is_active = self.is_active
|
||||
&& idx == *active_monitor_idx
|
||||
&& !matches!(self.interactive_move, Some(InteractiveMoveState::Moving(_)));
|
||||
|
|
@ -3271,7 +3271,7 @@ impl<W: LayoutElement> Layout<W> {
|
|||
|
||||
let mon = &mut monitors[mon_idx];
|
||||
let activate = activate.map_smart(|| {
|
||||
window.map_or(true, |win| {
|
||||
window.is_none_or(|win| {
|
||||
mon_idx == *active_monitor_idx
|
||||
&& mon.active_window().map(|win| win.id()) == Some(win)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -870,9 +870,7 @@ impl<W: LayoutElement> Monitor<W> {
|
|||
let new_id = self.workspaces[new_idx].id();
|
||||
|
||||
let activate = activate.map_smart(|| {
|
||||
window.map_or(true, |win| {
|
||||
self.active_window().map(|win| win.id()) == Some(win)
|
||||
})
|
||||
window.is_none_or(|win| self.active_window().map(|win| win.id()) == Some(win))
|
||||
});
|
||||
|
||||
let workspace = &mut self.workspaces[source_workspace_idx];
|
||||
|
|
|
|||
|
|
@ -1386,7 +1386,7 @@ impl<W: LayoutElement> Workspace<W> {
|
|||
|
||||
pub fn toggle_window_floating(&mut self, id: Option<&W::Id>) {
|
||||
let active_id = self.active_window().map(|win| win.id().clone());
|
||||
let target_is_active = id.map_or(true, |id| Some(id) == active_id.as_ref());
|
||||
let target_is_active = id.is_none_or(|id| Some(id) == active_id.as_ref());
|
||||
let Some(id) = id.cloned().or(active_id) else {
|
||||
return;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
state.niri.a11y.start();
|
||||
}
|
||||
|
||||
if env::var_os("NIRI_DISABLE_SYSTEM_MANAGER_NOTIFY").map_or(true, |x| x != "1") {
|
||||
if env::var_os("NIRI_DISABLE_SYSTEM_MANAGER_NOTIFY").is_none_or(|x| x != "1") {
|
||||
// Notify systemd we're ready.
|
||||
if let Err(err) = sd_notify::notify(true, &[NotifyState::Ready]) {
|
||||
warn!("error notifying systemd: {err:?}");
|
||||
|
|
|
|||
|
|
@ -4278,7 +4278,7 @@ impl Niri {
|
|||
self.layout.update_render_elements(output);
|
||||
|
||||
for (out, state) in self.output_state.iter_mut() {
|
||||
if output.map_or(true, |output| out == output) {
|
||||
if output.is_none_or(|output| out == output) {
|
||||
let scale = Scale::from(out.current_scale().fractional_scale());
|
||||
let transform = out.current_transform();
|
||||
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ impl TransactionBlocker {
|
|||
|
||||
impl Blocker for TransactionBlocker {
|
||||
fn state(&self) -> BlockerState {
|
||||
if self.0.upgrade().map_or(true, |x| x.is_completed()) {
|
||||
if self.0.upgrade().is_none_or(|x| x.is_completed()) {
|
||||
BlockerState::Released
|
||||
} else {
|
||||
BlockerState::Pending
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue