all: use let chains
This commit is contained in:
parent
3d5d146d65
commit
286857971a
89 changed files with 1516 additions and 1574 deletions
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue