1
0
Fork 0
forked from wry/wry

all: use let chains

This commit is contained in:
Julian Orth 2025-07-01 11:20:48 +02:00
parent 3d5d146d65
commit 286857971a
89 changed files with 1516 additions and 1574 deletions

View file

@ -102,13 +102,12 @@ impl ExtImageCopyCaptureFrameV1 {
let mut shm_staging = self.session.shm_staging.take();
match storage {
WlBufferStorage::Shm { mem, stride } => {
if let Some(b) = &shm_bridge {
if b.physical_size() != buffer.rect.size()
if let Some(b) = &shm_bridge
&& (b.physical_size() != buffer.rect.size()
|| b.format() != buffer.format
|| b.stride() != *stride
{
shm_bridge = None;
}
|| b.stride() != *stride)
{
shm_bridge = None;
}
let bridge = match shm_bridge {
Some(b) => b,
@ -129,10 +128,10 @@ impl ExtImageCopyCaptureFrameV1 {
}
}
};
if let Some(s) = &shm_staging {
if s.size() != bridge.staging_size() {
shm_staging = None;
}
if let Some(s) = &shm_staging
&& s.size() != bridge.staging_size()
{
shm_staging = None;
}
let staging = match shm_staging {
Some(s) => s,

View file

@ -125,10 +125,10 @@ impl ExtImageCopyCaptureSessionV1 {
}
fn stop_pending_frame(&self) {
if let Some(frame) = self.frame.get() {
if let FrameStatus::Capturing | FrameStatus::Captured = self.status.get() {
frame.fail(FrameFailureReason::Stopped);
}
if let Some(frame) = self.frame.get()
&& let FrameStatus::Capturing | FrameStatus::Captured = self.status.get()
{
frame.fail(FrameFailureReason::Stopped);
}
}
@ -223,22 +223,22 @@ impl ExtImageCopyCaptureSessionV1 {
y_off: i32,
size: Option<(i32, i32)>,
) {
if self.status.get() == FrameStatus::Capturing {
if let Some(frame) = self.frame.get() {
frame.copy_texture(
on,
texture,
cd,
resv,
acquire_sync,
release_sync,
render_hardware_cursors,
x_off,
y_off,
size,
);
return;
}
if self.status.get() == FrameStatus::Capturing
&& let Some(frame) = self.frame.get()
{
frame.copy_texture(
on,
texture,
cd,
resv,
acquire_sync,
release_sync,
render_hardware_cursors,
x_off,
y_off,
size,
);
return;
}
self.force_capture.set(true);
}

View file

@ -64,17 +64,17 @@ impl ExtSessionLockV1RequestHandler for ExtSessionLockV1 {
track!(new.client, new);
new.install()?;
self.client.add_client_obj(&new)?;
if !self.finished.get() {
if let Some(node) = output.global.node() {
if node.lock_surface.is_some() {
return Err(ExtSessionLockV1Error::OutputAlreadyLocked);
}
node.set_lock_surface(Some(new.clone()));
let pos = node.global.pos.get();
new.change_extents(pos);
new.surface.set_output(&node);
self.client.state.tree_changed();
if !self.finished.get()
&& let Some(node) = output.global.node()
{
if node.lock_surface.is_some() {
return Err(ExtSessionLockV1Error::OutputAlreadyLocked);
}
node.set_lock_surface(Some(new.clone()));
let pos = node.global.pos.get();
new.change_extents(pos);
new.surface.set_output(&node);
self.client.state.tree_changed();
}
Ok(())
}

View file

@ -414,10 +414,9 @@ pub fn destroy_data_offer<T: IpcVtable>(offer: &T::Offer) {
if src_data.offers.is_empty()
&& src_data.role.get() == Role::Dnd
&& data.shared.state.get().contains(OFFER_STATE_DROPPED)
&& let Some(seat) = src_data.seat.take()
{
if let Some(seat) = src_data.seat.take() {
T::unset(&seat, data.shared.role.get());
}
T::unset(&seat, data.shared.role.get());
}
}
}

View file

@ -90,13 +90,13 @@ impl WlDataOffer {
}
pub fn send_source_actions(&self) {
if let Some(src) = self.data.source.get() {
if let Some(source_actions) = src.source_data().actions.get() {
self.client.event(SourceActions {
self_id: self.id,
source_actions,
})
}
if let Some(src) = self.data.source.get()
&& let Some(source_actions) = src.source_data().actions.get()
{
self.client.event(SourceActions {
self_id: self.id,
source_actions,
})
}
}

View file

@ -136,51 +136,51 @@ impl JayInput {
.map(uapi::as_bytes)
.unwrap_or_default(),
});
if let Some(output) = data.data.output.get() {
if let Some(output) = output.get() {
self.client.event(InputDeviceOutput {
self_id: self.id,
id: data.id.raw(),
output: &output.connector.name,
});
}
if let Some(output) = data.data.output.get()
&& let Some(output) = output.get()
{
self.client.event(InputDeviceOutput {
self_id: self.id,
id: data.id.raw(),
output: &output.connector.name,
});
}
if self.version >= CALIBRATION_MATRIX_SINCE {
if let Some(m) = dev.calibration_matrix() {
self.client.event(CalibrationMatrix {
self_id: self.id,
m00: m[0][0],
m01: m[0][1],
m02: m[0][2],
m10: m[1][0],
m11: m[1][1],
m12: m[1][2],
});
}
if self.version >= CALIBRATION_MATRIX_SINCE
&& let Some(m) = dev.calibration_matrix()
{
self.client.event(CalibrationMatrix {
self_id: self.id,
m00: m[0][0],
m01: m[0][1],
m02: m[0][2],
m10: m[1][0],
m11: m[1][1],
m12: m[1][2],
});
}
if self.version >= CLICK_METHOD_SINCE {
if let Some(click_method) = dev.click_method() {
self.client.event(ClickMethod {
self_id: self.id,
click_method: match click_method {
InputDeviceClickMethod::None => LIBINPUT_CONFIG_CLICK_METHOD_NONE.0,
InputDeviceClickMethod::Clickfinger => {
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER.0
}
InputDeviceClickMethod::ButtonAreas => {
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS.0
}
},
});
}
if self.version >= CLICK_METHOD_SINCE
&& let Some(click_method) = dev.click_method()
{
self.client.event(ClickMethod {
self_id: self.id,
click_method: match click_method {
InputDeviceClickMethod::None => LIBINPUT_CONFIG_CLICK_METHOD_NONE.0,
InputDeviceClickMethod::Clickfinger => {
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER.0
}
InputDeviceClickMethod::ButtonAreas => {
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS.0
}
},
});
}
if self.version >= MIDDLE_BUTTON_EMULATION_SINCE {
if let Some(middle_button_emulation) = dev.middle_button_emulation_enabled() {
self.client.event(MiddleButtonEmulation {
self_id: self.id,
middle_button_emulation_enabled: middle_button_emulation as _,
});
}
if self.version >= MIDDLE_BUTTON_EMULATION_SINCE
&& let Some(middle_button_emulation) = dev.middle_button_emulation_enabled()
{
self.client.event(MiddleButtonEmulation {
self_id: self.id,
middle_button_emulation_enabled: middle_button_emulation as _,
});
}
}
@ -404,10 +404,10 @@ impl JayInputRequestHandler for JayInput {
let seat = self.seat(req.name)?;
self.send_seat(&seat);
for dev in self.client.state.input_device_handlers.borrow().values() {
if let Some(attached) = dev.data.seat.get() {
if attached.id() == seat.id() {
self.send_input_device(dev);
}
if let Some(attached) = dev.data.seat.get()
&& attached.id() == seat.id()
{
self.send_input_device(dev);
}
}
Ok(())

View file

@ -216,10 +216,10 @@ impl JayRandr {
fn get_device(&self, name: &str) -> Option<Rc<DrmDevData>> {
let mut candidates = vec![];
for dev in self.client.state.drm_devs.lock().values() {
if let Some(node) = &dev.devnode {
if node.ends_with(name) {
candidates.push(dev.clone());
}
if let Some(node) = &dev.devnode
&& node.ends_with(name)
{
candidates.push(dev.clone());
}
}
if candidates.len() == 1 {

View file

@ -56,27 +56,27 @@ impl JayReexec {
let _ = waitpid(pid, 0);
}
Forked::Child { .. } => {
if let Ok(f) = fork_with_pidfd(false) {
if let Forked::Child { .. } = f {
drop(p2);
fds.sort_by_key(|fd| fd.raw());
let c2_dup = fds.last().unwrap().raw() + 1;
let c1_dup = c2_dup + 1;
let _ = dup2(c1.raw(), c1_dup);
let _ = dup2(c2.raw(), c2_dup);
for (idx, fd) in fds.iter().enumerate() {
let _ = dup2(fd.raw(), idx as _);
}
let c2_dup_dup = fds.len() as _;
let _ = dup2(c2_dup, c2_dup_dup);
let _ = close_range(c2_dup_dup as c::c_uint + 1, !0, 0);
let mut pollfd = c::pollfd {
fd: c2_dup_dup,
events: 0,
revents: 0,
};
let _ = uapi::poll(from_mut(&mut pollfd), -1);
if let Ok(f) = fork_with_pidfd(false)
&& let Forked::Child { .. } = f
{
drop(p2);
fds.sort_by_key(|fd| fd.raw());
let c2_dup = fds.last().unwrap().raw() + 1;
let c1_dup = c2_dup + 1;
let _ = dup2(c1.raw(), c1_dup);
let _ = dup2(c2.raw(), c2_dup);
for (idx, fd) in fds.iter().enumerate() {
let _ = dup2(fd.raw(), idx as _);
}
let c2_dup_dup = fds.len() as _;
let _ = dup2(c2_dup, c2_dup_dup);
let _ = close_range(c2_dup_dup as c::c_uint + 1, !0, 0);
let mut pollfd = c::pollfd {
fd: c2_dup_dup,
events: 0,
revents: 0,
};
let _ = uapi::poll(from_mut(&mut pollfd), -1);
}
unsafe {
c::_exit(0);

View file

@ -655,10 +655,8 @@ impl JayScreencastRequestHandler for JayScreencast {
slf.schedule_realloc_or_reconfigure();
}
if capture_rules_changed {
if let Some(Target::Output(o)) = self.target.get() {
o.screencast_changed();
}
if capture_rules_changed && let Some(Target::Output(o)) = self.target.get() {
o.screencast_changed();
}
if self.running.get() {

View file

@ -158,10 +158,8 @@ impl WlBuffer {
return;
}
let had_texture = self.reset_gfx_objects(surface);
if had_texture {
if let Some(surface) = surface {
self.update_texture_or_log(surface, true);
}
if had_texture && let Some(surface) = surface {
self.update_texture_or_log(surface, true);
}
}
@ -234,19 +232,17 @@ impl WlBuffer {
};
match storage {
WlBufferStorage::Shm { mem, stride } => {
if sync_shm {
if let Some(ctx) = self.client.state.render_ctx.get() {
let tex = ctx.async_shmem_texture(
self.format,
self.width,
self.height,
*stride,
&self.client.state.cpu_worker,
)?;
mem.access(|mem| tex.clone().sync_upload(mem, Region::new2(self.rect)))??;
surface.shm_textures.front().tex.set(Some(tex));
surface.shm_textures.front().damage.clear();
}
if sync_shm && let Some(ctx) = self.client.state.render_ctx.get() {
let tex = ctx.async_shmem_texture(
self.format,
self.width,
self.height,
*stride,
&self.client.state.cpu_worker,
)?;
mem.access(|mem| tex.clone().sync_upload(mem, Region::new2(self.rect)))??;
surface.shm_textures.front().tex.set(Some(tex));
surface.shm_textures.front().damage.clear();
}
}
WlBufferStorage::Dmabuf { img, tex, .. } => {

View file

@ -442,14 +442,14 @@ impl WlSeatGlobal {
}
fn maybe_constrain_pointer_node(&self) {
if let Some(pn) = self.pointer_node() {
if let Some(surface) = pn.node_into_surface() {
let (mut x, mut y) = self.pointer_cursor.position();
let (sx, sy) = surface.buffer_abs_pos.get().position();
x -= Fixed::from_int(sx);
y -= Fixed::from_int(sy);
self.maybe_constrain(&surface, x, y);
}
if let Some(pn) = self.pointer_node()
&& let Some(surface) = pn.node_into_surface()
{
let (mut x, mut y) = self.pointer_cursor.position();
let (sx, sy) = surface.buffer_abs_pos.get().position();
x -= Fixed::from_int(sx);
y -= Fixed::from_int(sy);
self.maybe_constrain(&surface, x, y);
}
}
@ -513,10 +513,10 @@ impl WlSeatGlobal {
}
pub fn get_kb_state(&self, keymap: &Rc<KbvmMap>) -> Rc<RefCell<KbvmState>> {
if let Some(weak) = self.kb_states.get(&keymap.id) {
if let Some(state) = weak.upgrade() {
return state;
}
if let Some(weak) = self.kb_states.get(&keymap.id)
&& let Some(state) = weak.upgrade()
{
return state;
}
self.kb_states
.lock()
@ -548,13 +548,12 @@ impl WlSeatGlobal {
}
pub fn set_mono(&self, mono: bool) {
if let Some(tl) = self.keyboard_node.get().node_toplevel() {
if let Some(parent) = tl.tl_data().parent.get() {
if let Some(container) = parent.node_into_container() {
let node = if mono { Some(tl.deref()) } else { None };
container.set_mono(node);
}
}
if let Some(tl) = self.keyboard_node.get().node_toplevel()
&& let Some(parent) = tl.tl_data().parent.get()
&& let Some(container) = parent.node_into_container()
{
let node = if mono { Some(tl.deref()) } else { None };
container.set_mono(node);
}
}
@ -573,12 +572,11 @@ impl WlSeatGlobal {
}
pub fn focus_parent(self: &Rc<Self>) {
if let Some(tl) = self.keyboard_node.get().node_toplevel() {
if let Some(parent) = tl.tl_data().parent.get() {
if let Some(tl) = parent.node_toplevel() {
self.focus_node(tl);
}
}
if let Some(tl) = self.keyboard_node.get().node_toplevel()
&& let Some(parent) = tl.tl_data().parent.get()
&& let Some(tl) = parent.node_toplevel()
{
self.focus_node(tl);
}
}
@ -642,12 +640,11 @@ impl WlSeatGlobal {
pub fn move_focused(self: &Rc<Self>, direction: Direction) {
let kb_node = self.keyboard_node.get();
if let Some(tl) = kb_node.node_toplevel() {
if let Some(parent) = tl.tl_data().parent.get() {
if let Some(c) = parent.node_into_container() {
c.move_child(tl, direction);
}
}
if let Some(tl) = kb_node.node_toplevel()
&& let Some(parent) = tl.tl_data().parent.get()
&& let Some(c) = parent.node_into_container()
{
c.move_child(tl, direction);
}
}
@ -662,10 +659,10 @@ impl WlSeatGlobal {
X: ipc::IpcVtable<Device = XIpcDevice>,
S: DynDataSource,
{
if let (Some(new), Some(old)) = (&src, &field.get()) {
if new.source_data().id == old.source_data().id {
return Ok(());
}
if let (Some(new), Some(old)) = (&src, &field.get())
&& new.source_data().id == old.source_data().id
{
return Ok(());
}
if let Some(new) = &src {
ipc::attach_seat(&**new, self, ipc::Role::Selection)?;
@ -753,10 +750,10 @@ impl WlSeatGlobal {
if let Some(serial) = serial {
self.selection_serial.set(serial);
}
if let Some(selection) = &selection {
if selection.toplevel_drag.is_some() {
return Err(WlSeatError::OfferHasDrag);
}
if let Some(selection) = &selection
&& selection.toplevel_drag.is_some()
{
return Err(WlSeatError::OfferHasDrag);
}
self.set_selection(selection)
}
@ -784,10 +781,10 @@ impl WlSeatGlobal {
}
pub fn may_modify_primary_selection(&self, client: &Rc<Client>, serial: Option<u64>) -> bool {
if let Some(serial) = serial {
if serial < self.primary_selection_serial.get() {
return false;
}
if let Some(serial) = serial
&& serial < self.primary_selection_serial.get()
{
return false;
}
self.keyboard_node.get().node_client_id() == Some(client.id)
|| self.pointer_node().and_then(|n| n.node_client_id()) == Some(client.id)
@ -935,10 +932,10 @@ impl WlSeatGlobal {
if let Some(icon) = self.dnd_icon() {
icon.surface().set_visible(visible);
}
if let Some(tl_drag) = self.toplevel_drag() {
if let Some(tl) = tl_drag.toplevel.get() {
tl.tl_set_visible(visible);
}
if let Some(tl_drag) = self.toplevel_drag()
&& let Some(tl) = tl_drag.toplevel.get()
{
tl.tl_set_visible(visible);
}
if let Some(im) = self.input_method.get() {
for (_, popup) in &im.popups {
@ -1086,10 +1083,10 @@ impl CursorUserOwner for WlSeatGlobal {
if let Some(dnd) = self.pointer_owner.dnd_icon() {
dnd.surface().set_output(output);
}
if let Some(drag) = self.pointer_owner.toplevel_drag() {
if let Some(tl) = drag.toplevel.get() {
tl.xdg.set_output(output);
}
if let Some(drag) = self.pointer_owner.toplevel_drag()
&& let Some(tl) = drag.toplevel.get()
{
tl.xdg.set_output(output);
}
}
}
@ -1161,20 +1158,20 @@ impl WlSeatRequestHandler for WlSeat {
.global
.pointer_node()
.and_then(|n| n.node_into_surface());
if let Some(surface) = surface {
if surface.client.id == self.client.id {
let (x, y) = self.global.pointer_cursor.position();
let (x_int, y_int) = surface
.buffer_abs_pos
.get()
.translate(x.round_down(), y.round_down());
p.send_enter(
self.client.next_serial(),
surface.id,
x.apply_fract(x_int),
y.apply_fract(y_int),
);
}
if let Some(surface) = surface
&& surface.client.id == self.client.id
{
let (x, y) = self.global.pointer_cursor.position();
let (x_int, y_int) = surface
.buffer_abs_pos
.get()
.translate(x.round_down(), y.round_down());
p.send_enter(
self.client.next_serial(),
surface.id,
x.apply_fract(x_int),
y.apply_fract(y_int),
);
}
Ok(())
}
@ -1184,14 +1181,14 @@ impl WlSeatRequestHandler for WlSeat {
track!(self.client, p);
self.client.add_client_obj(&p)?;
self.keyboards.set(req.id, p.clone());
if let Some(surface) = self.global.keyboard_node.get().node_into_surface() {
if surface.client.id == self.client.id {
p.enter(
self.client.next_serial(),
surface.id,
&self.global.seat_kb_state.get().borrow().kb_state,
);
}
if let Some(surface) = self.global.keyboard_node.get().node_into_surface()
&& surface.client.id == self.client.id
{
p.enter(
self.client.next_serial(),
surface.id,
&self.global.seat_kb_state.get().borrow().kb_state,
);
}
if self.version >= REPEAT_INFO_SINCE {
let (rate, delay) = self.global.repeat_rate.get();
@ -1277,10 +1274,10 @@ pub fn collect_kb_foci(node: Rc<dyn Node>) -> SmallVec<[Rc<WlSeatGlobal>; 3]> {
impl DeviceHandlerData {
pub fn set_seat(&self, seat: Option<Rc<WlSeatGlobal>>) {
if let Some(new) = &seat {
if let Some(old) = self.seat.get() {
if old.id() == new.id() {
return;
}
if let Some(old) = self.seat.get()
&& old.id() == new.id()
{
return;
}
} else {
if self.seat.is_none() {
@ -1340,10 +1337,10 @@ impl DeviceHandlerData {
}
pub fn get_rect(&self, state: &State) -> Rect {
if let Some(output) = self.output.get() {
if let Some(output) = output.get() {
return output.pos.get();
}
if let Some(output) = self.output.get()
&& let Some(output) = output.get()
{
return output.pos.get();
}
state.root.extents.get()
}

View file

@ -524,10 +524,10 @@ impl WlSeatGlobal {
ei_seat.handle_motion_abs(time_usec, x, y);
});
let (x, y) = self.set_pointer_cursor_position(x, y);
if let Some(c) = self.constraint.get() {
if c.ty == ConstraintType::Lock || !c.contains(x.round_down(), y.round_down()) {
c.deactivate(false);
}
if let Some(c) = self.constraint.get()
&& (c.ty == ConstraintType::Lock || !c.contains(x.round_down(), y.round_down()))
{
c.deactivate(false);
}
self.state.for_each_seat_tester(|t| {
t.send_pointer_abs(self.id, time_usec, x, y);
@ -839,16 +839,16 @@ impl WlSeatGlobal {
if sym == self.revert_key.get().0 && mods == 0 {
revert_pointer_to_default = true;
}
if !self.state.lock.locked.get() {
if let Some(key_mods) = scs.get(&sym) {
for (key_mods, mask) in key_mods {
if mods & mask == key_mods {
shortcuts.push(InvokedShortcut {
unmasked_mods: Modifiers(mods),
effective_mods: Modifiers(key_mods),
sym: KeySym(sym),
});
}
if !self.state.lock.locked.get()
&& let Some(key_mods) = scs.get(&sym)
{
for (key_mods, mask) in key_mods {
if mods & mask == key_mods {
shortcuts.push(InvokedShortcut {
unmasked_mods: Modifiers(mods),
effective_mods: Modifiers(key_mods),
sym: KeySym(sym),
});
}
}
}
@ -1169,10 +1169,8 @@ impl WlSeatGlobal {
p.send_button(serial, time, button, state)
});
self.surface_pointer_frame(surface);
if pressed {
if let Some(node) = surface.get_focus_node() {
self.focus_node_with_serial(node, serial);
}
if pressed && let Some(node) = surface.get_focus_node() {
self.focus_node_with_serial(node, serial);
}
}
}
@ -1225,10 +1223,10 @@ impl WlSeatGlobal {
impl WlSeatGlobal {
pub fn motion_surface(&self, n: &WlSurface, x: Fixed, y: Fixed) {
'send_motion: {
if let Some(constraint) = self.constraint.get() {
if constraint.ty == ConstraintType::Lock {
break 'send_motion;
}
if let Some(constraint) = self.constraint.get()
&& constraint.ty == ConstraintType::Lock
{
break 'send_motion;
}
let time = (self.pos_time_usec.get() / 1000) as u32;
self.surface_pointer_event(Version::ALL, n, |p| p.send_motion(time, x, y));
@ -1299,10 +1297,10 @@ impl WlSeatGlobal {
// Unfocus callbacks
impl WlSeatGlobal {
pub fn unfocus_surface(&self, surface: &WlSurface) {
if let Some(ti) = self.text_input.take() {
if let Some(con) = ti.connection.get() {
con.disconnect(TextDisconnectReason::FocusLost);
}
if let Some(ti) = self.text_input.take()
&& let Some(con) = ti.connection.get()
{
con.disconnect(TextDisconnectReason::FocusLost);
}
if let Some(tis) = self.text_inputs.borrow().get(&surface.client.id) {
for ti in tis.lock().values() {

View file

@ -530,10 +530,8 @@ impl PointerOwner for DndPointerOwner {
}
target.node_on_dnd_leave(&self.dnd);
target.node_seat_state().remove_dnd_target(seat);
if !should_drop {
if let Some(src) = &self.dnd.src {
ipc::detach_seat(&**src, seat);
}
if !should_drop && let Some(src) = &self.dnd.src {
ipc::detach_seat(&**src, seat);
}
if let Some(icon) = self.icon.get() {
icon.disable();

View file

@ -97,17 +97,16 @@ impl WlSeatGlobal {
group_idx: u32,
mode: u32,
) {
if let Some(pad) = self.tablet.pads.get(&pad) {
if let Some(group) = pad.groups.get(group_idx as usize) {
if group.mode.replace(mode) != mode {
self.state.for_each_seat_tester(|t| {
t.send_tablet_pad_mode_switch(self.id, pad.dev, time_usec, group_idx, mode)
});
if pad.tablet.is_some() {
let node = pad.node.get();
node.node_on_tablet_pad_mode_switch(&pad, group, time_usec, mode);
}
}
if let Some(pad) = self.tablet.pads.get(&pad)
&& let Some(group) = pad.groups.get(group_idx as usize)
&& group.mode.replace(mode) != mode
{
self.state.for_each_seat_tester(|t| {
t.send_tablet_pad_mode_switch(self.id, pad.dev, time_usec, group_idx, mode)
});
if pad.tablet.is_some() {
let node = pad.node.get();
node.node_on_tablet_pad_mode_switch(&pad, group, time_usec, mode);
}
}
}
@ -141,11 +140,11 @@ impl WlSeatGlobal {
self.state.for_each_seat_tester(|t| {
t.send_tablet_pad_ring(self.id, pad.dev, time_usec, ring, source, angle)
});
if pad.tablet.is_some() {
if let Some(ring) = pad.rings.get(ring as usize) {
let node = self.keyboard_node.get();
node.node_on_tablet_pad_ring(&pad, ring, source, angle, time_usec);
}
if pad.tablet.is_some()
&& let Some(ring) = pad.rings.get(ring as usize)
{
let node = self.keyboard_node.get();
node.node_on_tablet_pad_ring(&pad, ring, source, angle, time_usec);
}
}
}
@ -162,11 +161,11 @@ impl WlSeatGlobal {
self.state.for_each_seat_tester(|t| {
t.send_tablet_pad_strip(self.id, pad.dev, time_usec, strip, source, position)
});
if pad.tablet.is_some() {
if let Some(strip) = pad.strips.get(strip as usize) {
let node = pad.node.get();
node.node_on_tablet_pad_strip(&pad, strip, source, position, time_usec);
}
if pad.tablet.is_some()
&& let Some(strip) = pad.strips.get(strip as usize)
{
let node = pad.node.get();
node.node_on_tablet_pad_strip(&pad, strip, source, position, time_usec);
}
}
}
@ -182,11 +181,11 @@ impl WlSeatGlobal {
self.state.for_each_seat_tester(|t| {
t.send_tablet_pad_dial(self.id, pad.dev, time_usec, value120, dial)
});
if pad.tablet.is_some() {
if let Some(dial) = pad.dials.get(dial as usize) {
let node = self.keyboard_node.get();
node.node_on_tablet_pad_dial(&pad, dial, value120, time_usec);
}
if pad.tablet.is_some()
&& let Some(dial) = pad.dials.get(dial as usize)
{
let node = self.keyboard_node.get();
node.node_on_tablet_pad_dial(&pad, dial, value120, time_usec);
}
}
}

View file

@ -258,12 +258,12 @@ impl TabletTool {
tool.send_motion(x, y);
tool.send_frame(time);
});
if let Some(changes) = changes {
if changes.down == Some(true) {
n.client.focus_stealing_serial.set(Some(serial.get()));
if let Some(node) = n.get_focus_node() {
self.tablet.seat.focus_node_with_serial(node, serial.get());
}
if let Some(changes) = changes
&& changes.down == Some(true)
{
n.client.focus_stealing_serial.set(Some(serial.get()));
if let Some(node) = n.get_focus_node() {
self.tablet.seat.focus_node_with_serial(node, serial.get());
}
}
}

View file

@ -57,10 +57,10 @@ impl ZwpTabletSeatV2 {
obj.send_name(&tablet.name);
obj.send_id(tablet.vid, tablet.pid);
obj.send_path(&tablet.path);
if obj.version >= BUSTYPE_SINCE {
if let Some(bustype) = tablet.bustype {
obj.send_bustype(bustype);
}
if obj.version >= BUSTYPE_SINCE
&& let Some(bustype) = tablet.bustype
{
obj.send_bustype(bustype);
}
obj.send_done();
tablet.bindings.add(self, &obj);

View file

@ -87,11 +87,11 @@ impl ZwpTextInputManagerV3RequestHandler for ZwpTextInputManagerV3 {
.entry(self.client.id)
.or_default()
.set(req.id, ti.clone());
if let Some(surface) = seat.global.keyboard_node.get().node_into_surface() {
if surface.client.id == self.client.id {
ti.send_enter(&surface);
ti.send_done();
}
if let Some(surface) = seat.global.keyboard_node.get().node_into_surface()
&& surface.client.id == self.client.id
{
ti.send_enter(&surface);
ti.send_done();
}
Ok(())
}

View file

@ -252,11 +252,11 @@ impl ZwpTextInputV3RequestHandler for ZwpTextInputV3 {
}
let con = self.connection.get();
if let Some(val) = pending.cursor_rect {
if state.cursor_rectangle != val {
if let Some(con) = &con {
for (_, popup) in &con.input_method.popups {
popup.schedule_positioning();
}
if state.cursor_rectangle != val
&& let Some(con) = &con
{
for (_, popup) in &con.input_method.popups {
popup.schedule_positioning();
}
}
state.cursor_rectangle = val;
@ -282,10 +282,8 @@ impl ZwpTextInputV3RequestHandler for ZwpTextInputV3 {
}
state.surrounding_text = val;
}
if sent_any {
if let Some(con) = &con {
con.input_method.send_done();
}
if sent_any && let Some(con) = &con {
con.input_method.send_done();
}
Ok(())
}

View file

@ -854,10 +854,10 @@ impl WlSurface {
ss.surface.set_toplevel(tl.clone());
}
}
if self.seat_state.is_active() {
if let Some(tl) = &tl {
tl.tl_surface_active_changed(true);
}
if self.seat_state.is_active()
&& let Some(tl) = &tl
{
tl.tl_surface_active_changed(true);
}
self.toplevel.set(tl);
}
@ -977,14 +977,14 @@ impl WlSurface {
if let Some(fs) = self.fractional_scale.get() {
fs.send_preferred_scale();
}
if let Some(xsurface) = self.ext.get().into_xsurface() {
if let Some(window) = xsurface.xwindow.get() {
self.client
.state
.xwayland
.queue
.push(XWaylandEvent::Configure(window));
}
if let Some(xsurface) = self.ext.get().into_xsurface()
&& let Some(window) = xsurface.xwindow.get()
{
self.client
.state
.xwayland
.queue
.push(XWaylandEvent::Configure(window));
}
}
}
@ -1152,14 +1152,12 @@ impl WlSurface {
viewport_changed = true;
self.src_rect.set(src_rect);
}
if viewport_changed {
if let Some(rect) = self.src_rect.get() {
if self.dst_size.is_none() {
if !rect[2].is_integer() || !rect[3].is_integer() {
return Err(WlSurfaceError::NonIntegerViewportSize);
}
}
}
if viewport_changed
&& let Some(rect) = self.src_rect.get()
&& self.dst_size.is_none()
&& (!rect[2].is_integer() || !rect[3].is_integer())
{
return Err(WlSurfaceError::NonIntegerViewportSize);
}
let mut color_description_changed = false;
if let Some(desc) = pending.color_description.take() {
@ -1360,10 +1358,10 @@ impl WlSurface {
self.is_opaque.set(is_opaque);
}
let mut tearing_changed = false;
if let Some(tearing) = pending.tearing.take() {
if self.tearing.replace(tearing) != tearing {
tearing_changed = true;
}
if let Some(tearing) = pending.tearing.take()
&& self.tearing.replace(tearing) != tearing
{
tearing_changed = true;
}
if let Some(content_type) = pending.content_type.take() {
self.content_type.set(content_type);
@ -1437,12 +1435,11 @@ impl WlSurface {
pending.surface_damage.clear();
pending.damage_full = false;
pending.fifo_barrier_wait = false;
if tearing_changed {
if let Some(tl) = self.toplevel.get() {
if tl.tl_data().is_fullscreen.get() {
self.output.get().update_presentation_type();
}
}
if tearing_changed
&& let Some(tl) = self.toplevel.get()
&& tl.tl_data().is_fullscreen.get()
{
self.output.get().update_presentation_type();
}
self.commit_version.fetch_add(1);
Ok(())
@ -1878,14 +1875,14 @@ impl Node for WlSurface {
}
fn node_on_focus(self: Rc<Self>, seat: &WlSeatGlobal) {
if let Some(xsurface) = self.ext.get().into_xsurface() {
if let Some(window) = xsurface.xwindow.get() {
self.client
.state
.xwayland
.queue
.push(XWaylandEvent::Activate(window.data.clone()));
}
if let Some(xsurface) = self.ext.get().into_xsurface()
&& let Some(window) = xsurface.xwindow.get()
{
self.client
.state
.xwayland
.queue
.push(XWaylandEvent::Activate(window.data.clone()));
}
seat.focus_surface(&self);
}

View file

@ -604,10 +604,10 @@ fn schedule_async_upload(
};
let back = surface.shm_textures.back();
let mut back_tex_opt = back.tex.get();
if let Some(back_tex) = &back_tex_opt {
if !back_tex.compatible_with(buf.format, buf.rect.width(), buf.rect.height(), *stride) {
back_tex_opt = None;
}
if let Some(back_tex) = &back_tex_opt
&& !back_tex.compatible_with(buf.format, buf.rect.width(), buf.rect.height(), *stride)
{
back_tex_opt = None;
}
let damage_full = || {
back.damage.clear();
@ -643,10 +643,10 @@ fn schedule_async_upload(
}
};
let mut staging_opt = surface.shm_staging.get();
if let Some(staging) = &staging_opt {
if staging.size() != back_tex.staging_size() {
staging_opt = None;
}
if let Some(staging) = &staging_opt
&& staging.size() != back_tex.staging_size()
{
staging_opt = None;
}
let staging = match staging_opt {
Some(s) => s,
@ -682,11 +682,11 @@ impl CommitDataCollector {
if buffer.is_shm() {
self.shm_uploads += 1;
}
if !pending.explicit_sync {
if let Some(dmabuf) = &buffer.dmabuf {
for plane in &dmabuf.planes {
self.implicit_dmabufs.push(plane.fd.clone());
}
if !pending.explicit_sync
&& let Some(dmabuf) = &buffer.dmabuf
{
for plane in &dmabuf.planes {
self.implicit_dmabufs.push(plane.fd.clone());
}
}
}

View file

@ -79,13 +79,12 @@ impl ExtSessionLockSurfaceV1RequestHandler for ExtSessionLockSurfaceV1 {
impl ExtSessionLockSurfaceV1 {
pub fn destroy_node(&self) {
if let Some(output) = &self.output.node() {
if let Some(ls) = output.lock_surface.get() {
if ls.node_id == self.node_id {
output.set_lock_surface(None);
self.client.state.tree_changed();
}
}
if let Some(output) = &self.output.node()
&& let Some(ls) = output.lock_surface.get()
&& ls.node_id == self.node_id
{
output.set_lock_surface(None);
self.client.state.tree_changed();
}
self.surface.destroy_node();
self.seat_state.destroy_node(self);

View file

@ -248,12 +248,12 @@ impl<T: TrayItem> SurfaceExt for T {
}
if data.surface.buffer.is_some() {
data.surface.set_visible(data.visible.get());
if let Some(node) = data.output.node() {
if !data.attached.replace(true) {
let link = node.tray_items.add_last(self.clone());
data.linked_node.set(Some(link));
node.update_tray_positions();
}
if let Some(node) = data.output.node()
&& !data.attached.replace(true)
{
let link = node.tray_items.add_last(self.clone());
data.linked_node.set(Some(link));
node.update_tray_positions();
}
}
}

View file

@ -260,10 +260,10 @@ impl WlSubsurface {
fn on_desync(&self) -> Result<(), WlSurfaceError> {
let committed = &mut *self.parent.pending.borrow_mut();
let committed = committed.subsurfaces.get_mut(&self.unique_id);
if let Some(ps) = committed {
if let Some(mut state) = ps.pending.state.take() {
self.surface.apply_state(&mut state)?;
}
if let Some(ps) = committed
&& let Some(mut state) = ps.pending.state.take()
{
self.surface.apply_state(&mut state)?;
}
Ok(())
}

View file

@ -59,10 +59,10 @@ impl SurfaceExt for XSurface {
}
fn focus_node(&self) -> Option<Rc<dyn Node>> {
if let Some(xwindow) = self.xwindow.get() {
if xwindow.tl_accepts_keyboard_focus() {
return Some(xwindow.x.surface.clone());
}
if let Some(xwindow) = self.xwindow.get()
&& xwindow.tl_accepts_keyboard_focus()
{
return Some(xwindow.x.surface.clone());
}
None
}

View file

@ -183,10 +183,10 @@ impl XwindowData {
pub fn title_changed(&self) {
let title = self.info.title.borrow_mut();
if let Some(w) = self.window.get() {
if let Some(p) = w.toplevel_data.parent.get() {
p.node_child_title_changed(w.deref(), title.as_deref().unwrap_or(""));
}
if let Some(w) = self.window.get()
&& let Some(p) = w.toplevel_data.parent.get()
{
p.node_child_title_changed(w.deref(), title.as_deref().unwrap_or(""));
}
}
}

View file

@ -110,12 +110,12 @@ impl XdgPopupParent for Popup {
let state = &surface.client.state;
if surface.buffer.is_some() {
let mut any_set = false;
if wl.is_none() {
if let Some(ws) = self.parent.workspace.get() {
self.popup.xdg.set_workspace(&ws);
*wl = Some(ws.stacked.add_last(self.popup.clone()));
any_set = true;
}
if wl.is_none()
&& let Some(ws) = self.parent.workspace.get()
{
self.popup.xdg.set_workspace(&ws);
*wl = Some(ws.stacked.add_last(self.popup.clone()));
any_set = true;
}
if dl.is_none() {
*dl = Some(
@ -453,10 +453,10 @@ impl XdgSurface {
new_extents = new_extents.intersect(geometry);
}
self.extents.set(new_extents);
if old_extents != new_extents {
if let Some(ext) = self.ext.get() {
ext.extents_changed();
}
if old_extents != new_extents
&& let Some(ext) = self.ext.get()
{
ext.extents_changed();
}
}
@ -518,22 +518,22 @@ impl SurfaceExt for XdgSurface {
self: Rc<Self>,
pending: &mut PendingState,
) -> Result<(), WlSurfaceError> {
if !self.have_initial_commit.get() {
if let Some(ext) = self.ext.get() {
ext.initial_configure()?;
self.do_send_configure();
self.have_initial_commit.set(true);
}
if !self.have_initial_commit.get()
&& let Some(ext) = self.ext.get()
{
ext.initial_configure()?;
self.do_send_configure();
self.have_initial_commit.set(true);
}
if let Some(pending) = &mut pending.xdg_surface {
if let Some(geometry) = pending.geometry.take() {
let prev = self.geometry.replace(Some(geometry));
if prev != Some(geometry) {
self.update_extents();
self.update_surface_position();
if let Some(ext) = self.ext.get() {
ext.geometry_changed();
}
if let Some(pending) = &mut pending.xdg_surface
&& let Some(geometry) = pending.geometry.take()
{
let prev = self.geometry.replace(Some(geometry));
if prev != Some(geometry) {
self.update_extents();
self.update_surface_position();
if let Some(ext) = self.ext.get() {
ext.geometry_changed();
}
}
}

View file

@ -371,10 +371,10 @@ impl StackedNode for XdgPopup {
fn stacked_set_visible(&self, visible: bool) {
if visible {
if let Some(parent) = self.parent.get() {
if !parent.visible() {
return;
}
if let Some(parent) = self.parent.get()
&& !parent.visible()
{
return;
}
}
self.set_visible(visible);

View file

@ -433,11 +433,9 @@ impl XdgToplevel {
fn map_tiled(self: &Rc<Self>) {
self.state.map_tiled(self.clone());
let fullscreen = self.states.borrow().contains(&STATE_FULLSCREEN);
if fullscreen {
if let Some(ws) = self.xdg.workspace.get() {
self.toplevel_data
.set_fullscreen2(&self.state, self.clone(), &ws);
}
if fullscreen && let Some(ws) = self.xdg.workspace.get() {
self.toplevel_data
.set_fullscreen2(&self.state, self.clone(), &ws);
}
}
@ -470,26 +468,26 @@ impl XdgToplevel {
}
let surface = &self.xdg.surface;
let should_be_mapped = surface.buffer.is_some();
if let Some(drag) = self.drag.get() {
if drag.is_ongoing() {
if should_be_mapped {
if !self.is_mapped.replace(true) {
if let Some(seat) = drag.source.data.seat.get() {
self.xdg.set_output(&seat.get_output());
}
self.toplevel_data.broadcast(self.clone());
self.tl_set_visible(self.state.root_visible());
self.xdg.damage();
}
self.extents_changed();
} else {
if self.is_mapped.replace(false) {
self.tl_set_visible(false);
self.xdg.damage();
if let Some(drag) = self.drag.get()
&& drag.is_ongoing()
{
if should_be_mapped {
if !self.is_mapped.replace(true) {
if let Some(seat) = drag.source.data.seat.get() {
self.xdg.set_output(&seat.get_output());
}
self.toplevel_data.broadcast(self.clone());
self.tl_set_visible(self.state.root_visible());
self.xdg.damage();
}
self.extents_changed();
} else {
if self.is_mapped.replace(false) {
self.tl_set_visible(false);
self.xdg.damage();
}
return;
}
return;
}
if self.is_mapped.replace(should_be_mapped) == should_be_mapped {
return;

View file

@ -384,10 +384,10 @@ impl ZwlrLayerSurfaceV1 {
_ => {}
}
}
if self.exclusive_size.replace(exclusive_size) != exclusive_size {
if let Some(output) = self.output.node.get() {
output.update_exclusive_zones();
}
if self.exclusive_size.replace(exclusive_size) != exclusive_size
&& let Some(output) = self.output.node.get()
{
output.update_exclusive_zones();
}
}
@ -422,10 +422,10 @@ impl ZwlrLayerSurfaceV1 {
if height == 0 && !anchor.contains(TOP | BOTTOM) {
return Err(ZwlrLayerSurfaceV1Error::HeightZero);
}
if let Some(ee) = self.exclusive_edge.get() {
if !self.anchor.get().contains(ee) {
return Err(ZwlrLayerSurfaceV1Error::ExclusiveEdgeNotAnchored);
}
if let Some(ee) = self.exclusive_edge.get()
&& !self.anchor.get().contains(ee)
{
return Err(ZwlrLayerSurfaceV1Error::ExclusiveEdgeNotAnchored);
}
self.configure();
Ok(())
@ -539,10 +539,10 @@ impl ZwlrLayerSurfaceV1 {
self.seat_state.destroy_node(self);
self.client.state.tree_changed();
self.last_configure.take();
if self.exclusive_size.take().is_not_empty() {
if let Some(node) = self.output.node() {
node.update_exclusive_zones();
}
if self.exclusive_size.take().is_not_empty()
&& let Some(node) = self.output.node()
{
node.update_exclusive_zones();
}
for popup in self.popups.lock().drain_values() {
popup.popup.destroy_node();

View file

@ -136,19 +136,19 @@ impl ExtWorkspaceGroupHandleV1RequestHandler for ExtWorkspaceGroupHandleV1 {
}
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
if let Some(manager) = self.manager.get() {
if let Some(node) = self.output.node() {
let mut sent_any = false;
for ws in node.workspaces.iter() {
if let Some(ws) = ws.ext_workspaces.get(&self.manager_id) {
self.send_workspace_leave(&ws);
sent_any = true;
}
}
if sent_any {
manager.schedule_done();
if let Some(manager) = self.manager.get()
&& let Some(node) = self.output.node()
{
let mut sent_any = false;
for ws in node.workspaces.iter() {
if let Some(ws) = ws.ext_workspaces.get(&self.manager_id) {
self.send_workspace_leave(&ws);
sent_any = true;
}
}
if sent_any {
manager.schedule_done();
}
}
self.detach();
self.client.remove_obj(self)?;

View file

@ -77,10 +77,10 @@ impl ExtWorkspaceHandleV1 {
};
let mut state = 0;
let output = ws.output.get();
if let Some(active) = output.workspace.get() {
if active.id == ws.id {
state |= STATE_ACTIVE;
}
if let Some(active) = output.workspace.get()
&& active.id == ws.id
{
state |= STATE_ACTIVE;
}
if ws.attention_requests.active() {
state |= STATE_URGENT;

View file

@ -55,10 +55,10 @@ impl WpDrmLeaseDeviceV1Global {
}
}
for c in dev.connectors.lock().keys() {
if let Some(o) = client.state.outputs.get(c) {
if o.monitor_info.non_desktop {
obj.create_connector(&o);
}
if let Some(o) = client.state.outputs.get(c)
&& o.monitor_info.non_desktop
{
obj.create_connector(&o);
}
}
}

View file

@ -55,10 +55,10 @@ impl XdgActivationTokenV1RequestHandler for XdgActivationTokenV1 {
let token = activation_token();
self.client.state.activation_tokens.set(token, ());
let mut tokens = self.client.activation_tokens.borrow_mut();
if tokens.len() >= MAX_TOKENS_PER_CLIENT {
if let Some(oldest) = tokens.pop_front() {
self.client.state.activation_tokens.remove(&oldest);
}
if tokens.len() >= MAX_TOKENS_PER_CLIENT
&& let Some(oldest) = tokens.pop_front()
{
self.client.state.activation_tokens.remove(&oldest);
}
tokens.push_back(token);
self.send_done(token);

View file

@ -72,11 +72,11 @@ impl XdgToplevelDragV1 {
}
pub fn render(&self, renderer: &mut Renderer<'_>, cursor_rect: &Rect, x: i32, y: i32) {
if let Some(tl) = self.toplevel.get() {
if tl.xdg.surface.buffer.get().is_some() {
let (x, y) = cursor_rect.translate(x - self.x_off.get(), y - self.y_off.get());
renderer.render_xdg_surface(&tl.xdg, x, y, None)
}
if let Some(tl) = self.toplevel.get()
&& tl.xdg.surface.buffer.get().is_some()
{
let (x, y) = cursor_rect.translate(x - self.x_off.get(), y - self.y_off.get());
renderer.render_xdg_surface(&tl.xdg, x, y, None)
}
}
}
@ -133,17 +133,17 @@ impl XdgToplevelDragV1 {
}
pub fn finish_drag(&self, seat: &Rc<WlSeatGlobal>) {
if self.source.data.was_used() {
if let Some(tl) = self.toplevel.get() {
let output = seat.get_output();
let (x, y) = seat.pointer_cursor().position();
tl.drag.take();
tl.after_toplevel_drag(
&output,
x.round_down() - self.x_off.get(),
y.round_down() - self.y_off.get(),
);
}
if self.source.data.was_used()
&& let Some(tl) = self.toplevel.get()
{
let output = seat.get_output();
let (x, y) = seat.pointer_cursor().position();
tl.drag.take();
tl.after_toplevel_drag(
&output,
x.round_down() - self.x_off.get(),
y.round_down() - self.y_off.get(),
);
}
self.detach();
}

View file

@ -111,16 +111,14 @@ impl ZwlrScreencopyFrameV1 {
return Err(ZwlrScreencopyFrameV1Error::InvalidBufferFormat);
}
buffer.update_framebuffer()?;
if let Some(WlBufferStorage::Shm { stride, .. }) = buffer.storage.borrow_mut().deref() {
if *stride != self.rect.width() * 4 {
return Err(ZwlrScreencopyFrameV1Error::InvalidBufferStride);
}
if let Some(WlBufferStorage::Shm { stride, .. }) = buffer.storage.borrow_mut().deref()
&& *stride != self.rect.width() * 4
{
return Err(ZwlrScreencopyFrameV1Error::InvalidBufferStride);
}
self.buffer.set(Some(buffer));
if !with_damage {
if let Some(global) = self.output.get() {
global.connector.damage();
}
if !with_damage && let Some(global) = self.output.get() {
global.connector.damage();
}
self.with_damage.set(with_damage);
node.screencopies

View file

@ -37,15 +37,15 @@ impl ZwpLinuxDmabufV1Global {
});
track!(client, obj);
client.add_client_obj(&obj)?;
if version < FEEDBACK_SINCE_VERSION {
if let Some(ctx) = client.state.render_ctx.get() {
let formats = ctx.formats();
for format in formats.values() {
obj.send_format(format.format.drm);
if version >= MODIFIERS_SINCE_VERSION {
for &modifier in &format.read_modifiers {
obj.send_modifier(format.format.drm, modifier);
}
if version < FEEDBACK_SINCE_VERSION
&& let Some(ctx) = client.state.render_ctx.get()
{
let formats = ctx.formats();
for format in formats.values() {
obj.send_format(format.format.drm);
if version >= MODIFIERS_SINCE_VERSION {
for &modifier in &format.read_modifiers {
obj.send_modifier(format.format.drm, modifier);
}
}
}