all: use let chains
This commit is contained in:
parent
3d5d146d65
commit
286857971a
89 changed files with 1516 additions and 1574 deletions
|
|
@ -17,13 +17,12 @@ fn create_bridge() -> anyhow::Result<()> {
|
|||
|
||||
fn create_version() -> anyhow::Result<()> {
|
||||
let mut version_string = env!("CARGO_PKG_VERSION").to_string();
|
||||
if let Ok(output) = Command::new("git").arg("rev-parse").arg("HEAD").output() {
|
||||
if output.status.success() {
|
||||
if let Ok(commit) = std::str::from_utf8(&output.stdout) {
|
||||
if let Ok(output) = Command::new("git").arg("rev-parse").arg("HEAD").output()
|
||||
&& output.status.success()
|
||||
&& let Ok(commit) = std::str::from_utf8(&output.stdout)
|
||||
{
|
||||
write!(version_string, " ({})", commit.trim())?;
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut f = open("version.rs")?;
|
||||
writeln!(f, "pub const VERSION: &str = \"{}\";", version_string)?;
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -595,15 +595,14 @@ fn struct_needs_lt(s: &Struct, protocols: &Protocols) -> Result<bool> {
|
|||
}
|
||||
let mut needs_lt = false;
|
||||
for field in &s.fields {
|
||||
if let Field::Real(f) = field {
|
||||
if f.value.is_none() {
|
||||
if needs_lifetime(&f.ty, protocols)? {
|
||||
if let Field::Real(f) = field
|
||||
&& f.value.is_none()
|
||||
&& needs_lifetime(&f.ty, protocols)?
|
||||
{
|
||||
needs_lt = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
s.needs_lt.set(Some(needs_lt));
|
||||
Ok(needs_lt)
|
||||
}
|
||||
|
|
@ -674,13 +673,13 @@ fn struct_has_fds(s: &Struct, protocols: &Protocols) -> Result<bool> {
|
|||
}
|
||||
let mut has_fds = false;
|
||||
for field in &s.fields {
|
||||
if let Field::Real(f) = field {
|
||||
if type_has_fds(&f.ty, protocols)? {
|
||||
if let Field::Real(f) = field
|
||||
&& type_has_fds(&f.ty, protocols)?
|
||||
{
|
||||
has_fds = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
s.has_fds.set(Some(has_fds));
|
||||
Ok(has_fds)
|
||||
}
|
||||
|
|
@ -1519,12 +1518,12 @@ fn format_struct<F: Write>(
|
|||
}
|
||||
writeln!(f, " Ok(Self {{")?;
|
||||
for field in &s.fields {
|
||||
if let Field::Real(rf) = field {
|
||||
if rf.value.is_none() {
|
||||
if let Field::Real(rf) = field
|
||||
&& rf.value.is_none()
|
||||
{
|
||||
writeln!(f, " {},", rf.name)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
writeln!(f, " }})")?;
|
||||
}
|
||||
writeln!(f, " }}")?;
|
||||
|
|
|
|||
|
|
@ -1857,8 +1857,9 @@ impl ConfigClient {
|
|||
run_cb("shortcut", &handler, ());
|
||||
}
|
||||
self.pressed_keysym.set(None);
|
||||
if was_latched {
|
||||
if let Entry::Occupied(mut oe) = self.key_handlers.borrow_mut().entry((seat, ms)) {
|
||||
if was_latched
|
||||
&& let Entry::Occupied(mut oe) = self.key_handlers.borrow_mut().entry((seat, ms))
|
||||
{
|
||||
let o = oe.get_mut();
|
||||
if o.latched.is_empty() {
|
||||
if o.cb.is_none() {
|
||||
|
|
@ -1876,7 +1877,6 @@ impl ConfigClient {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_msg2(&self, msg: &[u8]) {
|
||||
let res = bincode_ops().deserialize::<ServerMessage>(msg);
|
||||
|
|
|
|||
|
|
@ -441,12 +441,12 @@ impl ToConnectorId for &'_ str {
|
|||
("USB-", CON_USB),
|
||||
];
|
||||
for (prefix, ty) in pairs {
|
||||
if let Some(suffix) = self.strip_prefix(prefix) {
|
||||
if let Ok(idx) = u32::from_str(suffix) {
|
||||
if let Some(suffix) = self.strip_prefix(prefix)
|
||||
&& let Ok(idx) = u32::from_str(suffix)
|
||||
{
|
||||
return Ok((ty, idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(format!("`{}` is not a valid connector identifier", self))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,15 +247,15 @@ impl Backend for MetalBackend {
|
|||
for device in devices.values() {
|
||||
let mut change = device.dev.master.change();
|
||||
for connector in device.connectors.lock().values() {
|
||||
if let Some(crtc) = connector.crtc.get() {
|
||||
if idle == crtc.active.value.get() {
|
||||
if let Some(crtc) = connector.crtc.get()
|
||||
&& idle == crtc.active.value.get()
|
||||
{
|
||||
crtc.active.value.set(!idle);
|
||||
change.change_object(crtc.id, |c| {
|
||||
c.change(crtc.active.id, (!idle) as _);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Err(e) = change.commit(DRM_MODE_ATOMIC_ALLOW_MODESET, 0) {
|
||||
log::error!("Could not set monitors idle/not idle: {}", ErrorFmt(e));
|
||||
return;
|
||||
|
|
@ -283,12 +283,12 @@ impl Backend for MetalBackend {
|
|||
fn get_input_fds(&self) -> Vec<Rc<OwnedFd>> {
|
||||
let mut res = vec![];
|
||||
for dev in &*self.device_holder.input_devices.borrow() {
|
||||
if let Some(dev) = dev {
|
||||
if let Some(fd) = dev.fd.get() {
|
||||
if let Some(dev) = dev
|
||||
&& let Some(fd) = dev.fd.get()
|
||||
{
|
||||
res.push(fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
res
|
||||
}
|
||||
}
|
||||
|
|
@ -428,12 +428,12 @@ impl LibInputAdapter for DeviceHolder {
|
|||
Ok(s) => s,
|
||||
Err(e) => return Err(LibInputError::Stat(e.into())),
|
||||
};
|
||||
if let Some(MetalDevice::Input(d)) = self.devices.get(&stat.st_rdev) {
|
||||
if let Some(fd) = d.fd.get() {
|
||||
if let Some(MetalDevice::Input(d)) = self.devices.get(&stat.st_rdev)
|
||||
&& let Some(fd) = d.fd.get()
|
||||
{
|
||||
return uapi::fcntl_dupfd_cloexec(fd.raw(), 0)
|
||||
.map_err(|e| LibInputError::DupFd(e.into()));
|
||||
}
|
||||
}
|
||||
Err(LibInputError::DeviceUnavailable)
|
||||
}
|
||||
}
|
||||
|
|
@ -537,27 +537,27 @@ impl MetalInputDevice {
|
|||
|
||||
fn set_accel_profile_(&self, profile: AccelProfile) {
|
||||
self.desired.accel_profile.set(Some(profile));
|
||||
if let Some(dev) = self.inputdev.get() {
|
||||
if dev.device().accel_available() {
|
||||
if let Some(dev) = self.inputdev.get()
|
||||
&& dev.device().accel_available()
|
||||
{
|
||||
dev.device().set_accel_profile(profile);
|
||||
self.effective
|
||||
.accel_profile
|
||||
.set(Some(dev.device().accel_profile()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_click_method_(&self, method: ConfigClickMethod) {
|
||||
self.desired.click_method.set(Some(method));
|
||||
if let Some(dev) = self.inputdev.get() {
|
||||
if dev.device().has_click_methods() {
|
||||
if let Some(dev) = self.inputdev.get()
|
||||
&& dev.device().has_click_methods()
|
||||
{
|
||||
dev.device().set_click_method(method);
|
||||
self.effective
|
||||
.click_method
|
||||
.set(Some(dev.device().click_method()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl InputDevice for MetalInputDevice {
|
||||
|
|
@ -595,15 +595,15 @@ impl InputDevice for MetalInputDevice {
|
|||
|
||||
fn set_left_handed(&self, left_handed: bool) {
|
||||
self.desired.left_handed.set(Some(left_handed));
|
||||
if let Some(dev) = self.inputdev.get() {
|
||||
if dev.device().left_handed_available() {
|
||||
if let Some(dev) = self.inputdev.get()
|
||||
&& dev.device().left_handed_available()
|
||||
{
|
||||
dev.device().set_left_handed(left_handed);
|
||||
self.effective
|
||||
.left_handed
|
||||
.set(Some(dev.device().left_handed()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn accel_profile(&self) -> Option<InputDeviceAccelProfile> {
|
||||
let p = self.effective.accel_profile.get()?;
|
||||
|
|
@ -629,15 +629,15 @@ impl InputDevice for MetalInputDevice {
|
|||
|
||||
fn set_accel_speed(&self, speed: f64) {
|
||||
self.desired.accel_speed.set(Some(speed));
|
||||
if let Some(dev) = self.inputdev.get() {
|
||||
if dev.device().accel_available() {
|
||||
if let Some(dev) = self.inputdev.get()
|
||||
&& dev.device().accel_available()
|
||||
{
|
||||
dev.device().set_accel_speed(speed);
|
||||
self.effective
|
||||
.accel_speed
|
||||
.set(Some(dev.device().accel_speed()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn transform_matrix(&self) -> Option<TransformMatrix> {
|
||||
self.transform_matrix.get()
|
||||
|
|
@ -653,15 +653,15 @@ impl InputDevice for MetalInputDevice {
|
|||
|
||||
fn set_calibration_matrix(&self, m: [[f32; 3]; 2]) {
|
||||
self.desired.calibration_matrix.set(Some(m));
|
||||
if let Some(dev) = self.inputdev.get() {
|
||||
if dev.device().has_calibration_matrix() {
|
||||
if let Some(dev) = self.inputdev.get()
|
||||
&& dev.device().has_calibration_matrix()
|
||||
{
|
||||
dev.device().set_calibration_matrix(m);
|
||||
self.effective
|
||||
.calibration_matrix
|
||||
.set(Some(dev.device().get_calibration_matrix()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn name(&self) -> Rc<String> {
|
||||
self.name.get()
|
||||
|
|
@ -677,15 +677,15 @@ impl InputDevice for MetalInputDevice {
|
|||
|
||||
fn set_tap_enabled(&self, enabled: bool) {
|
||||
self.desired.tap_enabled.set(Some(enabled));
|
||||
if let Some(dev) = self.inputdev.get() {
|
||||
if dev.device().tap_available() {
|
||||
if let Some(dev) = self.inputdev.get()
|
||||
&& dev.device().tap_available()
|
||||
{
|
||||
dev.device().set_tap_enabled(enabled);
|
||||
self.effective
|
||||
.tap_enabled
|
||||
.set(Some(dev.device().tap_enabled()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn drag_enabled(&self) -> Option<bool> {
|
||||
self.effective.drag_enabled.get()
|
||||
|
|
@ -693,15 +693,15 @@ impl InputDevice for MetalInputDevice {
|
|||
|
||||
fn set_drag_enabled(&self, enabled: bool) {
|
||||
self.desired.drag_enabled.set(Some(enabled));
|
||||
if let Some(dev) = self.inputdev.get() {
|
||||
if dev.device().tap_available() {
|
||||
if let Some(dev) = self.inputdev.get()
|
||||
&& dev.device().tap_available()
|
||||
{
|
||||
dev.device().set_drag_enabled(enabled);
|
||||
self.effective
|
||||
.drag_enabled
|
||||
.set(Some(dev.device().drag_enabled()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn drag_lock_enabled(&self) -> Option<bool> {
|
||||
self.effective.drag_lock_enabled.get()
|
||||
|
|
@ -709,15 +709,15 @@ impl InputDevice for MetalInputDevice {
|
|||
|
||||
fn set_drag_lock_enabled(&self, enabled: bool) {
|
||||
self.desired.drag_lock_enabled.set(Some(enabled));
|
||||
if let Some(dev) = self.inputdev.get() {
|
||||
if dev.device().tap_available() {
|
||||
if let Some(dev) = self.inputdev.get()
|
||||
&& dev.device().tap_available()
|
||||
{
|
||||
dev.device().set_drag_lock_enabled(enabled);
|
||||
self.effective
|
||||
.drag_lock_enabled
|
||||
.set(Some(dev.device().drag_lock_enabled()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn natural_scrolling_enabled(&self) -> Option<bool> {
|
||||
self.effective.natural_scrolling_enabled.get()
|
||||
|
|
@ -725,15 +725,15 @@ impl InputDevice for MetalInputDevice {
|
|||
|
||||
fn set_natural_scrolling_enabled(&self, enabled: bool) {
|
||||
self.desired.natural_scrolling_enabled.set(Some(enabled));
|
||||
if let Some(dev) = self.inputdev.get() {
|
||||
if dev.device().has_natural_scrolling() {
|
||||
if let Some(dev) = self.inputdev.get()
|
||||
&& dev.device().has_natural_scrolling()
|
||||
{
|
||||
dev.device().set_natural_scrolling_enabled(enabled);
|
||||
self.effective
|
||||
.natural_scrolling_enabled
|
||||
.set(Some(dev.device().natural_scrolling_enabled()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn click_method(&self) -> Option<InputDeviceClickMethod> {
|
||||
let p = self.effective.click_method.get()?;
|
||||
|
|
@ -763,15 +763,15 @@ impl InputDevice for MetalInputDevice {
|
|||
self.desired
|
||||
.middle_button_emulation_enabled
|
||||
.set(Some(enabled));
|
||||
if let Some(dev) = self.inputdev.get() {
|
||||
if dev.device().middle_button_emulation_available() {
|
||||
if let Some(dev) = self.inputdev.get()
|
||||
&& dev.device().middle_button_emulation_available()
|
||||
{
|
||||
dev.device().set_middle_button_emulation_enabled(enabled);
|
||||
self.effective
|
||||
.middle_button_emulation_enabled
|
||||
.set(Some(dev.device().middle_button_emulation_enabled()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn tablet_info(&self) -> Option<Box<TabletInit>> {
|
||||
let dev = self.inputdev.get()?;
|
||||
|
|
|
|||
|
|
@ -345,11 +345,11 @@ impl MetalBackend {
|
|||
let id = &slf.device_holder.devices;
|
||||
let mut slots = slf.device_holder.input_devices.borrow_mut();
|
||||
let dev = 'dev: {
|
||||
if let Some(dev) = slots[slot].clone() {
|
||||
if dev.id == device_id {
|
||||
if let Some(dev) = slots[slot].clone()
|
||||
&& dev.id == device_id
|
||||
{
|
||||
break 'dev dev;
|
||||
}
|
||||
}
|
||||
return;
|
||||
};
|
||||
let res = match res {
|
||||
|
|
|
|||
|
|
@ -200,14 +200,14 @@ impl MetalConnector {
|
|||
present_fb = Some(fb);
|
||||
}
|
||||
self.perform_screencopies(&present_fb, &node, &cd);
|
||||
if let Some(sync_file) = self.cursor_sync_file.take() {
|
||||
if let Err(e) = self.state.ring.readable(&sync_file).await {
|
||||
if let Some(sync_file) = self.cursor_sync_file.take()
|
||||
&& let Err(e) = self.state.ring.readable(&sync_file).await
|
||||
{
|
||||
log::error!(
|
||||
"Could not wait for cursor sync file to complete: {}",
|
||||
ErrorFmt(e)
|
||||
);
|
||||
}
|
||||
}
|
||||
self.await_present_fb(present_fb.as_mut()).await;
|
||||
let mut res = self.program_connector(
|
||||
version,
|
||||
|
|
@ -216,8 +216,9 @@ impl MetalConnector {
|
|||
cursor_programming.as_ref(),
|
||||
present_fb.as_ref(),
|
||||
);
|
||||
if res.is_err() {
|
||||
if let Some(dsd_id) = direct_scanout_id {
|
||||
if res.is_err()
|
||||
&& let Some(dsd_id) = direct_scanout_id
|
||||
{
|
||||
let fb = self.prepare_present_fb(
|
||||
&cd,
|
||||
&linear_cd,
|
||||
|
|
@ -248,7 +249,6 @@ impl MetalConnector {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let reset_damage = || {
|
||||
for buffer in &*buffers {
|
||||
buffer.damage_queue.clear();
|
||||
|
|
@ -369,22 +369,24 @@ impl MetalConnector {
|
|||
change!(c, plane.crtc_y, crtc_y);
|
||||
change!(c, plane.crtc_w, crtc_w);
|
||||
change!(c, plane.crtc_h, crtc_h);
|
||||
if !try_async_flip && !self.dev.is_nvidia {
|
||||
if let Some(sf) = self.backend.signaled_sync_file.get() {
|
||||
if !try_async_flip
|
||||
&& !self.dev.is_nvidia
|
||||
&& let Some(sf) = self.backend.signaled_sync_file.get()
|
||||
{
|
||||
c.change(plane.in_fence_fd, sf.0.raw() as u64);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if self.dev.is_amd && crtc.vrr_enabled.value.get() {
|
||||
// Work around https://gitlab.freedesktop.org/drm/amd/-/issues/2186
|
||||
if let Some(fb) = &*self.active_framebuffer.borrow() {
|
||||
if self.dev.is_amd
|
||||
&& crtc.vrr_enabled.value.get()
|
||||
&& let Some(fb) = &*self.active_framebuffer.borrow()
|
||||
{
|
||||
changes.change_object(plane.id, |c| {
|
||||
c.change(plane.fb_id, fb.fb.id().0 as _);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(cursor) = cursor {
|
||||
try_async_flip = false;
|
||||
match cursor {
|
||||
|
|
@ -408,11 +410,11 @@ impl MetalConnector {
|
|||
c.change(plane.src_y.id, 0);
|
||||
c.change(plane.src_w.id, (*width as u64) << 16);
|
||||
c.change(plane.src_h.id, (*height as u64) << 16);
|
||||
if !self.dev.is_nvidia {
|
||||
if let Some(sf) = self.backend.signaled_sync_file.get() {
|
||||
if !self.dev.is_nvidia
|
||||
&& let Some(sf) = self.backend.signaled_sync_file.get()
|
||||
{
|
||||
c.change(plane.in_fence_fd, sf.0.raw() as u64);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
CursorProgramming::Disable { plane } => {
|
||||
|
|
@ -606,12 +608,12 @@ impl MetalConnector {
|
|||
}
|
||||
}
|
||||
}
|
||||
if let Some(clear) = pass.clear {
|
||||
if clear != Color::SOLID_BLACK {
|
||||
if let Some(clear) = pass.clear
|
||||
&& clear != Color::SOLID_BLACK
|
||||
{
|
||||
// Background could be visible.
|
||||
return None;
|
||||
}
|
||||
}
|
||||
ct
|
||||
};
|
||||
if let AcquireSync::None | AcquireSync::Implicit = ct.acquire_sync {
|
||||
|
|
@ -683,11 +685,11 @@ impl MetalConnector {
|
|||
break 'format f;
|
||||
}
|
||||
// Try opaque format if possible.
|
||||
if let Some(opaque) = dmabuf.format.opaque {
|
||||
if let Some(f) = plane.formats.get(&opaque.drm) {
|
||||
if let Some(opaque) = dmabuf.format.opaque
|
||||
&& let Some(f) = plane.formats.get(&opaque.drm)
|
||||
{
|
||||
break 'format f;
|
||||
}
|
||||
}
|
||||
return None;
|
||||
};
|
||||
if !format.modifiers.contains(&dmabuf.modifier) {
|
||||
|
|
|
|||
|
|
@ -759,14 +759,14 @@ impl MetalConnector {
|
|||
}
|
||||
if let Err(e) = self.master.queue_sequence(crtc.id) {
|
||||
log::error!("Could not queue a CRTC sequence: {}", ErrorFmt(&e));
|
||||
if let DrmError::QueueSequence(OsError(c::EOPNOTSUPP)) = e {
|
||||
if let Some(node) = self.state.root.outputs.get(&self.connector_id) {
|
||||
if let DrmError::QueueSequence(OsError(c::EOPNOTSUPP)) = e
|
||||
&& let Some(node) = self.state.root.outputs.get(&self.connector_id)
|
||||
{
|
||||
log::warn!("{}: Switching to vblank emulation", self.kernel_id());
|
||||
crtc.needs_vblank_emulation.set(true);
|
||||
node.global.connector.needs_vblank_emulation.set(true);
|
||||
node.vblank();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
crtc.have_queued_sequence.set(true);
|
||||
}
|
||||
|
|
@ -856,17 +856,15 @@ impl Connector for MetalConnector {
|
|||
}
|
||||
|
||||
fn set_enabled(&self, enabled: bool) {
|
||||
if self.enabled.replace(enabled) != enabled {
|
||||
if self.display.borrow_mut().connection == ConnectorStatus::Connected {
|
||||
if let Some(dev) = self.backend.device_holder.drm_devices.get(&self.dev.devnum) {
|
||||
if let Err(e) = self.backend.handle_drm_change_(&dev, true) {
|
||||
if self.enabled.replace(enabled) != enabled
|
||||
&& self.display.borrow_mut().connection == ConnectorStatus::Connected
|
||||
&& let Some(dev) = self.backend.device_holder.drm_devices.get(&self.dev.devnum)
|
||||
&& let Err(e) = self.backend.handle_drm_change_(&dev, true)
|
||||
{
|
||||
dev.unprocessed_change.set(true);
|
||||
log::error!("Could not dis/enable connector: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn drm_feedback(&self) -> Option<Rc<DrmFeedback>> {
|
||||
self.drm_feedback.get()
|
||||
|
|
@ -930,13 +928,13 @@ impl Connector for MetalConnector {
|
|||
}
|
||||
dd.non_desktop_effective = non_desktop_effective;
|
||||
drop(dd);
|
||||
if let Some(dev) = self.backend.device_holder.drm_devices.get(&self.dev.devnum) {
|
||||
if let Err(e) = self.backend.handle_drm_change_(&dev, true) {
|
||||
if let Some(dev) = self.backend.device_holder.drm_devices.get(&self.dev.devnum)
|
||||
&& let Err(e) = self.backend.handle_drm_change_(&dev, true)
|
||||
{
|
||||
dev.unprocessed_change.set(true);
|
||||
log::error!("Could not override non-desktop setting: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn drm_object_id(&self) -> Option<DrmConnector> {
|
||||
Some(self.id)
|
||||
|
|
@ -991,13 +989,13 @@ impl Connector for MetalConnector {
|
|||
}
|
||||
self.try_switch_format.set(true);
|
||||
}
|
||||
if let Some(dev) = self.backend.device_holder.drm_devices.get(&self.dev.devnum) {
|
||||
if let Err(e) = self.backend.handle_drm_change_(&dev, true) {
|
||||
if let Some(dev) = self.backend.device_holder.drm_devices.get(&self.dev.devnum)
|
||||
&& let Err(e) = self.backend.handle_drm_change_(&dev, true)
|
||||
{
|
||||
dev.unprocessed_change.set(true);
|
||||
log::error!("Could not change format: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_colors(&self, bcs: BackendColorSpace, btf: BackendTransferFunction) {
|
||||
let prev_bcs = Cell::new(bcs);
|
||||
|
|
@ -1376,12 +1374,12 @@ fn create_connector_display_data(
|
|||
}
|
||||
}
|
||||
for desc in &edid.base_block.descriptors {
|
||||
if let Some(desc) = desc {
|
||||
if let Descriptor::DisplayRangeLimitsAndAdditionalTiming(timings) = desc {
|
||||
if let Some(desc) = desc
|
||||
&& let Descriptor::DisplayRangeLimitsAndAdditionalTiming(timings) = desc
|
||||
{
|
||||
break 'fetch_min_hz timings.vertical_field_rate_min as u64;
|
||||
}
|
||||
}
|
||||
}
|
||||
0
|
||||
};
|
||||
if min_vrr_hz > 0 {
|
||||
|
|
@ -1450,12 +1448,12 @@ fn create_connector_display_data(
|
|||
}
|
||||
};
|
||||
let mut mode_opt = desired_state.mode.borrow_mut();
|
||||
if let Some(mode) = &*mode_opt {
|
||||
if !info.modes.contains(mode) {
|
||||
if let Some(mode) = &*mode_opt
|
||||
&& !info.modes.contains(mode)
|
||||
{
|
||||
log::warn!("Discarding previously desired mode");
|
||||
*mode_opt = None;
|
||||
}
|
||||
}
|
||||
if mode_opt.is_none() {
|
||||
*mode_opt = info.modes.first().cloned();
|
||||
}
|
||||
|
|
@ -1854,13 +1852,12 @@ impl MetalBackend {
|
|||
for c in removed_connectors {
|
||||
dev.futures.remove(&c);
|
||||
if let Some(c) = dev.connectors.remove(&c) {
|
||||
if let Some(lease_id) = c.lease.get() {
|
||||
if let Some(lease) = dev.dev.leases.remove(&lease_id) {
|
||||
if !lease.try_revoke() {
|
||||
if let Some(lease_id) = c.lease.get()
|
||||
&& let Some(lease) = dev.dev.leases.remove(&lease_id)
|
||||
&& !lease.try_revoke()
|
||||
{
|
||||
dev.dev.leases_to_break.set(lease_id, lease);
|
||||
}
|
||||
}
|
||||
}
|
||||
match c.frontend_state.get() {
|
||||
FrontState::Removed | FrontState::Disconnected => {}
|
||||
FrontState::Connected { .. } | FrontState::Unavailable => {
|
||||
|
|
@ -1908,13 +1905,12 @@ impl MetalBackend {
|
|||
}
|
||||
if disconnect {
|
||||
c.tearing_requested.set(false);
|
||||
if let Some(lease_id) = c.lease.get() {
|
||||
if let Some(lease) = dev.dev.leases.remove(&lease_id) {
|
||||
if !lease.try_revoke() {
|
||||
if let Some(lease_id) = c.lease.get()
|
||||
&& let Some(lease) = dev.dev.leases.remove(&lease_id)
|
||||
&& !lease.try_revoke()
|
||||
{
|
||||
dev.dev.leases_to_break.set(lease_id, lease);
|
||||
}
|
||||
}
|
||||
}
|
||||
c.send_event(ConnectorEvent::Disconnected);
|
||||
} else if preserve_any {
|
||||
preserve_connector = true;
|
||||
|
|
@ -2493,14 +2489,14 @@ impl MetalBackend {
|
|||
log::warn!("Cannot preserve connector whose crtc is inactive");
|
||||
fail!(c.id);
|
||||
}
|
||||
if let Some(plane) = c.primary_plane.get() {
|
||||
if plane.crtc_id.value.get() != crtc.id {
|
||||
if let Some(plane) = c.primary_plane.get()
|
||||
&& plane.crtc_id.value.get() != crtc.id
|
||||
{
|
||||
log::warn!(
|
||||
"Cannot preserve connector whose primary plane is attached to a different crtc"
|
||||
);
|
||||
fail!(c.id);
|
||||
}
|
||||
}
|
||||
if let Some(plane) = c.cursor_plane.get() {
|
||||
let crtc_id = plane.crtc_id.value.get();
|
||||
if crtc_id.is_some() && crtc_id != crtc.id {
|
||||
|
|
@ -2510,12 +2506,12 @@ impl MetalBackend {
|
|||
fail!(c.id);
|
||||
}
|
||||
}
|
||||
if let Some(m) = &dd.colorspace {
|
||||
if m.value.get() != dd.persistent.color_space.get().to_drm() {
|
||||
if let Some(m) = &dd.colorspace
|
||||
&& m.value.get() != dd.persistent.color_space.get().to_drm()
|
||||
{
|
||||
log::debug!("Connector has wrong colorspace");
|
||||
fail!(c.id);
|
||||
}
|
||||
}
|
||||
if let Some(diff) = self.compare_hdr_metadata(&dev.dev, &dd) {
|
||||
log::debug!("{}", diff);
|
||||
fail!(c.id);
|
||||
|
|
@ -2541,16 +2537,16 @@ impl MetalBackend {
|
|||
}
|
||||
|
||||
fn make_render_device(&self, dev: &MetalDrmDevice, force: bool) {
|
||||
if !force {
|
||||
if let Some(ctx) = self.ctx.get() {
|
||||
if ctx.dev_id == dev.id {
|
||||
if !force
|
||||
&& let Some(ctx) = self.ctx.get()
|
||||
&& ctx.dev_id == dev.id
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
let ctx = dev.ctx.get();
|
||||
if self.signaled_sync_file.is_none() {
|
||||
if let Some(sync) = ctx.gfx.sync_obj_ctx() {
|
||||
if self.signaled_sync_file.is_none()
|
||||
&& let Some(sync) = ctx.gfx.sync_obj_ctx()
|
||||
{
|
||||
match sync.create_signaled_sync_file() {
|
||||
Ok(sf) => {
|
||||
self.signaled_sync_file.set(Some(sf));
|
||||
|
|
@ -2560,7 +2556,6 @@ impl MetalBackend {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.state.set_render_ctx(Some(ctx.gfx.clone()));
|
||||
let fb = match DrmFeedback::new(&self.state.drm_feedback_ids, &*ctx.gfx) {
|
||||
Ok(fb) => Some(Rc::new(fb)),
|
||||
|
|
@ -2675,33 +2670,32 @@ impl MetalBackend {
|
|||
flags = DRM_MODE_ATOMIC_ALLOW_MODESET;
|
||||
self.reset_connectors_and_crtcs(dev, &mut changes, preserve);
|
||||
for connector in dev.connectors.lock().values() {
|
||||
if !preserve.connectors.contains(&connector.id) {
|
||||
if let Err(e) = self.assign_connector_crtc(connector, &mut changes) {
|
||||
if !preserve.connectors.contains(&connector.id)
|
||||
&& let Err(e) = self.assign_connector_crtc(connector, &mut changes)
|
||||
{
|
||||
log::error!("Could not assign a crtc: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.reset_planes(dev, &mut changes, preserve);
|
||||
let mut old_buffers = vec![];
|
||||
for connector in dev.connectors.lock().values() {
|
||||
if !preserve.connectors.contains(&connector.id) {
|
||||
if let Err(e) =
|
||||
if !preserve.connectors.contains(&connector.id)
|
||||
&& let Err(e) =
|
||||
self.assign_connector_planes(connector, &mut changes, &ctx, &mut old_buffers)
|
||||
{
|
||||
log::error!("Could not assign a plane: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
let res = loop {
|
||||
let res = changes.commit(flags, 0);
|
||||
if let Err(e) = &res {
|
||||
if flags.not_contains(DRM_MODE_ATOMIC_ALLOW_MODESET) {
|
||||
if let Err(e) = &res
|
||||
&& flags.not_contains(DRM_MODE_ATOMIC_ALLOW_MODESET)
|
||||
{
|
||||
log::warn!("Fast commit failed, retrying with modeset: {}", ErrorFmt(e));
|
||||
flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break res;
|
||||
};
|
||||
if let Err(e) = res {
|
||||
|
|
@ -2775,12 +2769,12 @@ impl MetalBackend {
|
|||
if dd.should_enable_vrr() {
|
||||
vrr_crtcs.insert(crtc_id);
|
||||
}
|
||||
if let Some(m) = &dd.colorspace {
|
||||
if m.value.get() != dd.persistent.color_space.get().to_drm() {
|
||||
if let Some(m) = &dd.colorspace
|
||||
&& m.value.get() != dd.persistent.color_space.get().to_drm()
|
||||
{
|
||||
log::debug!("Connector has wrong colorspace");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(diff) = self.compare_hdr_metadata(&dev.dev, &dd) {
|
||||
log::debug!("{}", diff);
|
||||
return false;
|
||||
|
|
@ -3139,12 +3133,11 @@ impl MetalBackend {
|
|||
if plane.ty == PlaneType::Primary
|
||||
&& !plane.assigned.get()
|
||||
&& plane.lease.is_none()
|
||||
&& let Some(format) = plane.formats.get(&format.drm)
|
||||
{
|
||||
if let Some(format) = plane.formats.get(&format.drm) {
|
||||
break 'primary_plane (plane.clone(), &format.modifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Err(MetalError::NoPrimaryPlaneForConnector);
|
||||
};
|
||||
let buffers = Rc::new(self.create_scanout_buffers(
|
||||
|
|
@ -3189,14 +3182,13 @@ impl MetalBackend {
|
|||
&& !plane.assigned.get()
|
||||
&& plane.lease.is_none()
|
||||
&& plane.formats.contains_key(&ARGB8888.drm)
|
||||
&& let Some(format) = plane.formats.get(&ARGB8888.drm)
|
||||
{
|
||||
if let Some(format) = plane.formats.get(&ARGB8888.drm) {
|
||||
cursor_plane = Some(plane.clone());
|
||||
cursor_modifiers = &format.modifiers;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut cursor_buffers = None;
|
||||
if cursor_plane.is_some() {
|
||||
let res = self.create_scanout_buffers(
|
||||
|
|
|
|||
|
|
@ -265,14 +265,13 @@ impl Drop for ClientHolder {
|
|||
self.data.remove_activation_tokens();
|
||||
self.data.commit_timelines.clear();
|
||||
self.data.property_changed(CL_CHANGED_DESTROYED);
|
||||
if self.data.is_xwayland {
|
||||
if let Some(pidfd) = self.data.state.xwayland.pidfd.get() {
|
||||
if let Err(e) = pidfd_send_signal(&pidfd, c::SIGKILL) {
|
||||
if self.data.is_xwayland
|
||||
&& let Some(pidfd) = self.data.state.xwayland.pidfd.get()
|
||||
&& let Err(e) = pidfd_send_signal(&pidfd, c::SIGKILL)
|
||||
{
|
||||
log::error!("Could not kill Xwayland: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait EventFormatter: Debug {
|
||||
|
|
|
|||
|
|
@ -78,12 +78,12 @@ async fn receive(data: Rc<Client>) {
|
|||
// log::trace!("{:x?}", data_buf);
|
||||
let parser = MsgParser::new(&mut buf, &data_buf[..]);
|
||||
if let Err(e) = obj.handle_request(&data, request, parser) {
|
||||
if let ClientError::InvalidMethod = e {
|
||||
if let Ok(obj) = data.objects.get_obj(obj_id) {
|
||||
if let ClientError::InvalidMethod = e
|
||||
&& let Ok(obj) = data.objects.get_obj(obj_id)
|
||||
{
|
||||
data.invalid_request(&*obj, request);
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
return Err(ClientError::RequestError(Box::new(e)));
|
||||
}
|
||||
// data.flush();
|
||||
|
|
|
|||
|
|
@ -76,22 +76,19 @@ impl ClientMem {
|
|||
flags: c::c_int,
|
||||
) -> Result<Self, ClientMemError> {
|
||||
let mut sigbus_impossible = false;
|
||||
if let Ok(seals) = uapi::fcntl_get_seals(fd.raw()) {
|
||||
if seals & c::F_SEAL_SHRINK != 0 {
|
||||
if let Ok(stat) = uapi::fstat(fd.raw()) {
|
||||
if let Ok(seals) = uapi::fcntl_get_seals(fd.raw())
|
||||
&& seals & c::F_SEAL_SHRINK != 0
|
||||
&& let Ok(stat) = uapi::fstat(fd.raw())
|
||||
{
|
||||
sigbus_impossible = stat.st_size as u64 >= len as u64;
|
||||
}
|
||||
}
|
||||
}
|
||||
if !sigbus_impossible {
|
||||
if let Some(client) = client {
|
||||
if !sigbus_impossible && let Some(client) = client {
|
||||
log::debug!(
|
||||
"Client {} ({}) has created a shm buffer that might cause SIGBUS",
|
||||
client.pid_info.comm,
|
||||
client.id,
|
||||
);
|
||||
}
|
||||
}
|
||||
let data = if len == 0 {
|
||||
&mut [][..]
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -200,12 +200,12 @@ impl ConfigProxyHandler {
|
|||
self.window_matcher_leafs.clear();
|
||||
self.window_matchers.clear();
|
||||
|
||||
if let Some(path) = &self.path {
|
||||
if let Err(e) = uapi::unlink(path.as_str()) {
|
||||
if let Some(path) = &self.path
|
||||
&& let Err(e) = uapi::unlink(path.as_str())
|
||||
{
|
||||
log::error!("Could not unlink {}: {}", path, ErrorFmt(OsError(e.0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send(&self, msg: &ServerMessage) {
|
||||
let mut buf = self.bufs.pop().unwrap_or_default();
|
||||
|
|
@ -963,11 +963,11 @@ impl ConfigProxyHandler {
|
|||
let seat = self.get_seat(seat)?;
|
||||
let output = seat.get_output();
|
||||
let mut workspace = Workspace(0);
|
||||
if !output.is_dummy {
|
||||
if let Some(ws) = output.workspace.get() {
|
||||
if !output.is_dummy
|
||||
&& let Some(ws) = output.workspace.get()
|
||||
{
|
||||
workspace = self.get_workspace_by_name(&ws.name);
|
||||
}
|
||||
}
|
||||
self.respond(Response::GetSeatWorkspace { workspace });
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -975,13 +975,12 @@ impl ConfigProxyHandler {
|
|||
fn handle_get_seat_keyboard_workspace(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
let mut workspace = Workspace(0);
|
||||
if let Some(output) = seat.get_keyboard_output() {
|
||||
if !output.is_dummy {
|
||||
if let Some(ws) = output.workspace.get() {
|
||||
if let Some(output) = seat.get_keyboard_output()
|
||||
&& !output.is_dummy
|
||||
&& let Some(ws) = output.workspace.get()
|
||||
{
|
||||
workspace = self.get_workspace_by_name(&ws.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
self.respond(Response::GetSeatKeyboardWorkspace { workspace });
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -1900,13 +1899,13 @@ impl ConfigProxyHandler {
|
|||
}
|
||||
let id = ClientMatcher(self.client_matcher_ids.fetch_add(1));
|
||||
let cache = &self.client_matcher_cache;
|
||||
if let Some(matcher) = cache.get(&criterion) {
|
||||
if let Some(matcher) = matcher.upgrade() {
|
||||
if let Some(matcher) = cache.get(&criterion)
|
||||
&& let Some(matcher) = matcher.upgrade()
|
||||
{
|
||||
self.client_matchers.set(id, matcher);
|
||||
self.respond(Response::CreateClientMatcher { matcher: id });
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
let mgr = &self.state.cl_matcher_manager;
|
||||
let mut upstream = vec![];
|
||||
let matcher = match &criterion {
|
||||
|
|
@ -2000,13 +1999,13 @@ impl ConfigProxyHandler {
|
|||
}
|
||||
let id = WindowMatcher(self.window_matcher_ids.fetch_add(1));
|
||||
let cache = &self.window_matcher_cache;
|
||||
if let Some(matcher) = cache.get(&criterion) {
|
||||
if let Some(matcher) = matcher.upgrade() {
|
||||
if let Some(matcher) = cache.get(&criterion)
|
||||
&& let Some(matcher) = matcher.upgrade()
|
||||
{
|
||||
self.window_matchers.set(id, matcher);
|
||||
self.respond(Response::CreateWindowMatcher { matcher: id });
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
let mgr = &self.state.tl_matcher_manager;
|
||||
let mut upstream = vec![];
|
||||
let matcher = match &criterion {
|
||||
|
|
|
|||
|
|
@ -107,14 +107,14 @@ where
|
|||
pub fn run(self) {
|
||||
let n = self.node;
|
||||
n.needs_event.set(true);
|
||||
if n.new_data != n.data {
|
||||
if let Some(on_unmatch) = n.on_unmatch.take() {
|
||||
if n.new_data != n.data
|
||||
&& let Some(on_unmatch) = n.on_unmatch.take()
|
||||
{
|
||||
if n.leaf.strong_count() == 0 {
|
||||
return;
|
||||
}
|
||||
on_unmatch();
|
||||
}
|
||||
}
|
||||
n.data.set(n.new_data.get());
|
||||
if n.data.is_some() != n.on_unmatch.is_some() {
|
||||
let Some(leaf) = n.leaf.upgrade() else {
|
||||
|
|
|
|||
|
|
@ -79,12 +79,12 @@ where
|
|||
}
|
||||
|
||||
pub fn remove(&self, target_id: Target::Id) {
|
||||
if let Some(node) = self.data.borrow_mut().remove(&target_id) {
|
||||
if let Some(node) = node.node.upgrade() {
|
||||
if let Some(node) = self.data.borrow_mut().remove(&target_id)
|
||||
&& let Some(node) = node.node.upgrade()
|
||||
{
|
||||
node.data().destroyed().remove(&self.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn borrow_mut(&self) -> RefMut<'_, AHashMap<Target::Id, PerTreeNodeData<Target, T>>> {
|
||||
self.data.borrow_mut()
|
||||
|
|
|
|||
|
|
@ -45,13 +45,13 @@ impl TlmMatchClient {
|
|||
}
|
||||
|
||||
pub fn handle(&self, node: &ToplevelData) {
|
||||
if let Some(client) = &node.client {
|
||||
if self.node.get(client) {
|
||||
if let Some(client) = &node.client
|
||||
&& self.node.get(client)
|
||||
{
|
||||
let data = self.downstream.get_or_create(node);
|
||||
self.downstream.update_matched(node, data, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CritUpstreamNodeBase<ToplevelData> for TlmMatchClient {
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ const HOME: &str = "HOME";
|
|||
const HEADER_SIZE: u32 = 16;
|
||||
|
||||
pub static DEFAULT_CURSOR_SIZE: Lazy<u32> = Lazy::new(|| {
|
||||
if let Ok(size) = env::var(XCURSOR_SIZE) {
|
||||
if let Ok(val) = size.parse() {
|
||||
if let Ok(size) = env::var(XCURSOR_SIZE)
|
||||
&& let Ok(val) = size.parse()
|
||||
{
|
||||
return val;
|
||||
}
|
||||
}
|
||||
24
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -78,8 +78,9 @@ impl CursorUserGroup {
|
|||
}
|
||||
|
||||
fn damage_active(&self) {
|
||||
if let Some(active) = self.active.get() {
|
||||
if let Some(cursor) = active.cursor.get() {
|
||||
if let Some(active) = self.active.get()
|
||||
&& let Some(cursor) = active.cursor.get()
|
||||
{
|
||||
let (x, y) = active.pos.get();
|
||||
let x_int = x.round_down();
|
||||
let y_int = y.round_down();
|
||||
|
|
@ -87,7 +88,6 @@ impl CursorUserGroup {
|
|||
self.state.damage2(true, extents.move_(x_int, y_int));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deactivate(&self) {
|
||||
if self.hardware_cursor.get() {
|
||||
|
|
@ -136,12 +136,12 @@ impl CursorUserGroup {
|
|||
}
|
||||
|
||||
pub fn set_visible(&self, visible: bool) {
|
||||
if let Some(user) = self.active.get() {
|
||||
if let Some(cursor) = user.cursor.get() {
|
||||
if let Some(user) = self.active.get()
|
||||
&& let Some(cursor) = user.cursor.get()
|
||||
{
|
||||
cursor.set_visible(visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn active(&self) -> Option<Rc<CursorUser>> {
|
||||
self.active.get()
|
||||
|
|
@ -369,12 +369,12 @@ impl CursorUser {
|
|||
|
||||
fn set_cursor2(&self, cursor: Option<Rc<dyn Cursor>>) {
|
||||
if let Some(old) = self.cursor.get() {
|
||||
if let Some(new) = cursor.as_ref() {
|
||||
if rc_eq(&old, new) {
|
||||
if let Some(new) = cursor.as_ref()
|
||||
&& rc_eq(&old, new)
|
||||
{
|
||||
self.update_hardware_cursor();
|
||||
return;
|
||||
}
|
||||
}
|
||||
old.handle_unset();
|
||||
if self.software_cursor() {
|
||||
self.group.damage_active();
|
||||
|
|
@ -409,8 +409,9 @@ impl CursorUser {
|
|||
x = x.apply_fract(x_tmp);
|
||||
y = y.apply_fract(y_tmp);
|
||||
}
|
||||
if self.software_cursor() {
|
||||
if let Some(cursor) = self.cursor.get() {
|
||||
if self.software_cursor()
|
||||
&& let Some(cursor) = self.cursor.get()
|
||||
{
|
||||
let (old_x, old_y) = self.pos.get();
|
||||
let old_x_int = old_x.round_down();
|
||||
let old_y_int = old_y.round_down();
|
||||
|
|
@ -420,7 +421,6 @@ impl CursorUser {
|
|||
.damage2(true, extents.move_(old_x_int, old_y_int));
|
||||
self.group.state.damage2(true, extents.move_(x_int, y_int));
|
||||
}
|
||||
}
|
||||
self.pos.set((x, y));
|
||||
self.update_hardware_cursor_(false);
|
||||
(x, y)
|
||||
|
|
|
|||
|
|
@ -243,15 +243,15 @@ impl ForkerProxy {
|
|||
true => Ok((io.pop_fd().unwrap(), pid)),
|
||||
_ => Err(ForkerError::PidfdForkFailed),
|
||||
};
|
||||
if let Some(handoff) = self.pending_pidfds.remove(&id) {
|
||||
if let Some(handoff) = handoff.upgrade() {
|
||||
if let Some(handoff) = self.pending_pidfds.remove(&id)
|
||||
&& let Some(handoff) = handoff.upgrade()
|
||||
{
|
||||
handoff.pidfd.set(Some(res));
|
||||
if let Some(w) = handoff.waiter.take() {
|
||||
w.wake();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_log(&self, level: usize, msg: &str) {
|
||||
let level = match level {
|
||||
|
|
|
|||
|
|
@ -937,9 +937,10 @@ pub fn create_render_pass(
|
|||
}
|
||||
if render_cursor {
|
||||
let cursor_user_group = seat.cursor_group();
|
||||
if render_hardware_cursor || !cursor_user_group.hardware_cursor() {
|
||||
if let Some(cursor_user) = cursor_user_group.active() {
|
||||
if let Some(cursor) = cursor_user.get() {
|
||||
if (render_hardware_cursor || !cursor_user_group.hardware_cursor())
|
||||
&& let Some(cursor_user) = cursor_user_group.active()
|
||||
&& let Some(cursor) = cursor_user.get()
|
||||
{
|
||||
cursor.tick();
|
||||
let (mut x, mut y) = cursor_user.position();
|
||||
x -= Fixed::from_int(rect.x1());
|
||||
|
|
@ -949,13 +950,11 @@ pub fn create_render_pass(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(visualizer) = visualizer {
|
||||
if let Some(cursor_rect) = cursor_rect {
|
||||
if let Some(visualizer) = visualizer
|
||||
&& let Some(cursor_rect) = cursor_rect
|
||||
{
|
||||
visualizer.render(&cursor_rect, &mut renderer.base);
|
||||
}
|
||||
}
|
||||
let c = match black_background {
|
||||
true => Color::SOLID_BLACK,
|
||||
false => state.theme.colors.background.get(),
|
||||
|
|
|
|||
|
|
@ -296,14 +296,13 @@ fn run_ops(fb: &Framebuffer, ops: &[GfxApiOpt]) -> Option<SyncFile> {
|
|||
};
|
||||
let user = fb.ctx.buffer_resv_user;
|
||||
for op in ops {
|
||||
if let GfxApiOpt::CopyTexture(ct) = op {
|
||||
if ct.release_sync == ReleaseSync::Explicit {
|
||||
if let Some(resv) = &ct.buffer_resv {
|
||||
if let GfxApiOpt::CopyTexture(ct) = op
|
||||
&& ct.release_sync == ReleaseSync::Explicit
|
||||
&& let Some(resv) = &ct.buffer_resv
|
||||
{
|
||||
resv.set_sync_file(user, &file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Some(file);
|
||||
}
|
||||
None
|
||||
|
|
@ -429,12 +428,12 @@ fn handle_explicit_sync(ctx: &GlRenderContext, img: Option<&Rc<EglImage>>, sync:
|
|||
};
|
||||
sync.wait();
|
||||
} else {
|
||||
if let Some(img) = img {
|
||||
if let Err(e) = img.dmabuf.import_sync_file(DMA_BUF_SYNC_READ, &sync_file) {
|
||||
if let Some(img) = img
|
||||
&& let Err(e) = img.dmabuf.import_sync_file(DMA_BUF_SYNC_READ, &sync_file)
|
||||
{
|
||||
log::error!("Could not import sync file into dmabuf: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl dyn GfxTexture {
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ unsafe fn get_extensions(ext: *const c::c_char) -> Option<AHashSet<String>> {
|
|||
let ext = unsafe { CStr::from_ptr(ext).to_bytes() };
|
||||
for part in ext.split_str(" ") {
|
||||
let name = part.trim_ascii();
|
||||
if name.len() > 0 {
|
||||
if let Ok(s) = str::from_utf8(name) {
|
||||
if name.len() > 0
|
||||
&& let Ok(s) = str::from_utf8(name)
|
||||
{
|
||||
res.insert(s.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(res)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ impl VulkanRenderer {
|
|||
let height = height as u32;
|
||||
let cached = &mut *self.blend_buffers.borrow_mut();
|
||||
let cached = cached.entry((width, height));
|
||||
if let Entry::Occupied(entry) = &cached {
|
||||
if let Some(buffer) = entry.get().upgrade() {
|
||||
if let Entry::Occupied(entry) = &cached
|
||||
&& let Some(buffer) = entry.get().upgrade()
|
||||
{
|
||||
return Ok(buffer);
|
||||
}
|
||||
}
|
||||
let limits = self.device.blend_limits;
|
||||
if width > limits.max_width || height > limits.max_height {
|
||||
return Err(VulkanError::ImageTooLarge);
|
||||
|
|
|
|||
|
|
@ -669,12 +669,12 @@ impl VulkanBoMapping {
|
|||
|
||||
impl Drop for VulkanBoMapping {
|
||||
fn drop(&mut self) {
|
||||
if self.upload {
|
||||
if let Err(e) = self.upload() {
|
||||
if self.upload
|
||||
&& let Err(e) = self.upload()
|
||||
{
|
||||
log::error!("Could not upload to image: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MappedBuffer for VulkanBoMapping {
|
||||
|
|
@ -721,11 +721,11 @@ fn validate_modifier(
|
|||
if disjoint && !modifier.features.contains(FormatFeatureFlags::DISJOINT) {
|
||||
return false;
|
||||
}
|
||||
if let Some(plane_count) = plane_count {
|
||||
if plane_count != modifier.planes {
|
||||
if let Some(plane_count) = plane_count
|
||||
&& plane_count != modifier.planes
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
let Some(limits) = modifier.transfer_limits else {
|
||||
return false;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -558,8 +558,9 @@ impl GfxFramebuffer for VulkanImage {
|
|||
) -> Result<Option<SyncFile>, GfxError> {
|
||||
let mut blend_buffer =
|
||||
blend_buffer.map(|b| b.clone().into_vk(&self.renderer.device.device));
|
||||
if let Some(bb) = &blend_buffer {
|
||||
if bb.size() != self.size() {
|
||||
if let Some(bb) = &blend_buffer
|
||||
&& bb.size() != self.size()
|
||||
{
|
||||
log::error!(
|
||||
"Blend buffer has invalid size: {:?} != {:?}",
|
||||
bb.size(),
|
||||
|
|
@ -567,7 +568,6 @@ impl GfxFramebuffer for VulkanImage {
|
|||
);
|
||||
blend_buffer = None;
|
||||
}
|
||||
}
|
||||
self.renderer
|
||||
.execute(
|
||||
&self,
|
||||
|
|
|
|||
|
|
@ -670,12 +670,13 @@ impl VulkanRenderer {
|
|||
for pos in &memory.fill_targets[f.range.clone()] {
|
||||
memory.data_buffer.extend_from_slice(uapi::as_bytes(pos));
|
||||
}
|
||||
if let Some(VulkanOp::Fill(p)) = mops.last_mut() {
|
||||
if p.color == f.color && idx > 0 {
|
||||
if let Some(VulkanOp::Fill(p)) = mops.last_mut()
|
||||
&& p.color == f.color
|
||||
&& idx > 0
|
||||
{
|
||||
p.instances += f.instances;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
mops.push(VulkanOp::Fill(f));
|
||||
}
|
||||
VulkanOp::Tex(mut c) => {
|
||||
|
|
@ -874,13 +875,13 @@ impl VulkanRenderer {
|
|||
})?;
|
||||
for ops in memory.ops.values_mut() {
|
||||
for op in ops {
|
||||
if let VulkanOp::Tex(c) = op {
|
||||
if let Some(addr) = &mut c.color_management_data_address {
|
||||
if let VulkanOp::Tex(c) = op
|
||||
&& let Some(addr) = &mut c.color_management_data_address
|
||||
{
|
||||
*addr += buffer.buffer.address;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
memory.used_buffers.push(buffer);
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -1037,8 +1038,9 @@ impl VulkanRenderer {
|
|||
let mut load_clear = None;
|
||||
let mut manual_clear = None;
|
||||
let clear_rects = &memory.clear_rects[pass];
|
||||
if let Some(clear) = clear {
|
||||
if clear_rects.is_not_empty() {
|
||||
if let Some(clear) = clear
|
||||
&& clear_rects.is_not_empty()
|
||||
{
|
||||
let color = memory
|
||||
.color_transforms
|
||||
.apply_to_color(clear_cd, target_cd, *clear);
|
||||
|
|
@ -1060,7 +1062,6 @@ impl VulkanRenderer {
|
|||
manual_clear = Some(clear_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut rendering_attachment_info = RenderingAttachmentInfo::default()
|
||||
.image_layout(ImageLayout::COLOR_ATTACHMENT_OPTIMAL)
|
||||
.image_view(target.render_view.unwrap_or(target.texture_view))
|
||||
|
|
@ -1560,13 +1561,13 @@ impl VulkanRenderer {
|
|||
if let Some(resv) = resv {
|
||||
resv.set_sync_file(self.buffer_resv_user, sync_file);
|
||||
} else if sync == ReleaseSync::Implicit {
|
||||
if let VulkanImageMemory::DmaBuf(buf) = &img.ty {
|
||||
if let Err(e) = buf.template.dmabuf.import_sync_file(flag, sync_file) {
|
||||
if let VulkanImageMemory::DmaBuf(buf) = &img.ty
|
||||
&& let Err(e) = buf.template.dmabuf.import_sync_file(flag, sync_file)
|
||||
{
|
||||
log::error!("Could not import sync file into dmabuf: {}", ErrorFmt(e));
|
||||
log::warn!("Relying on implicit sync");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let attach_async_shm_sync_file = self.device.transfer_queue.is_some()
|
||||
&& self.device.distinct_transfer_queue_family_idx.is_none();
|
||||
|
|
@ -1577,21 +1578,19 @@ impl VulkanRenderer {
|
|||
texture.resv.take(),
|
||||
DMA_BUF_SYNC_READ,
|
||||
);
|
||||
if attach_async_shm_sync_file {
|
||||
if let VulkanImageMemory::Internal(shm) = &texture.tex.ty {
|
||||
if let Some(data) = &shm.async_data {
|
||||
if attach_async_shm_sync_file
|
||||
&& let VulkanImageMemory::Internal(shm) = &texture.tex.ty
|
||||
&& let Some(data) = &shm.async_data
|
||||
{
|
||||
data.last_gfx_use.set(Some(sync_file.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if attach_async_shm_sync_file {
|
||||
if let VulkanImageMemory::Internal(shm) = &fb.ty {
|
||||
if let Some(data) = &shm.async_data {
|
||||
if attach_async_shm_sync_file
|
||||
&& let VulkanImageMemory::Internal(shm) = &fb.ty
|
||||
&& let Some(data) = &shm.async_data
|
||||
{
|
||||
data.last_gfx_use.set(Some(sync_file.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
import(fb, fb_release_sync, None, DMA_BUF_SYNC_WRITE);
|
||||
}
|
||||
|
||||
|
|
@ -1750,11 +1749,11 @@ impl VulkanRenderer {
|
|||
GfxApiOpt::FillRect(f) => (f.effective_color().is_opaque(), f.rect),
|
||||
GfxApiOpt::CopyTexture(c) => {
|
||||
let opaque = 'opaque: {
|
||||
if let Some(a) = c.alpha {
|
||||
if a < 1.0 {
|
||||
if let Some(a) = c.alpha
|
||||
&& a < 1.0
|
||||
{
|
||||
break 'opaque false;
|
||||
}
|
||||
}
|
||||
if !c.opaque {
|
||||
let tex = c.tex.as_vk(&self.device.device);
|
||||
if tex.format.has_alpha {
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ impl VulkanShmImage {
|
|||
damage: Option<&[Rect]>,
|
||||
) -> Result<(), VulkanError> {
|
||||
img.renderer.check_defunct()?;
|
||||
if let Some(damage) = damage {
|
||||
if damage.is_empty() {
|
||||
if let Some(damage) = damage
|
||||
&& damage.is_empty()
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
let copy = |full: bool, off, x, y, width, height| {
|
||||
let mut builder = BufferImageCopy2::default()
|
||||
.buffer_offset(off)
|
||||
|
|
@ -169,11 +169,11 @@ impl VulkanShmImage {
|
|||
.dst_stage_mask(dsm)
|
||||
};
|
||||
let mut transfer_queue_family_idx = img.renderer.device.graphics_queue_idx;
|
||||
if use_transfer_queue {
|
||||
if let Some(idx) = img.renderer.device.distinct_transfer_queue_family_idx {
|
||||
if use_transfer_queue
|
||||
&& let Some(idx) = img.renderer.device.distinct_transfer_queue_family_idx
|
||||
{
|
||||
transfer_queue_family_idx = idx;
|
||||
}
|
||||
}
|
||||
let mut initial_image_barrier = image_barrier()
|
||||
.image(img.image)
|
||||
.src_queue_family_index(img.renderer.device.graphics_queue_idx)
|
||||
|
|
|
|||
|
|
@ -102,14 +102,13 @@ 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
|
||||
|| b.stride() != *stride)
|
||||
{
|
||||
shm_bridge = None;
|
||||
}
|
||||
}
|
||||
let bridge = match shm_bridge {
|
||||
Some(b) => b,
|
||||
_ => {
|
||||
|
|
@ -129,11 +128,11 @@ impl ExtImageCopyCaptureFrameV1 {
|
|||
}
|
||||
}
|
||||
};
|
||||
if let Some(s) = &shm_staging {
|
||||
if s.size() != bridge.staging_size() {
|
||||
if let Some(s) = &shm_staging
|
||||
&& s.size() != bridge.staging_size()
|
||||
{
|
||||
shm_staging = None;
|
||||
}
|
||||
}
|
||||
let staging = match shm_staging {
|
||||
Some(s) => s,
|
||||
_ => ctx.create_staging_buffer(bridge.staging_size(), STAGING_DOWNLOAD),
|
||||
|
|
|
|||
|
|
@ -125,12 +125,12 @@ impl ExtImageCopyCaptureSessionV1 {
|
|||
}
|
||||
|
||||
fn stop_pending_frame(&self) {
|
||||
if let Some(frame) = self.frame.get() {
|
||||
if let FrameStatus::Capturing | FrameStatus::Captured = self.status.get() {
|
||||
if let Some(frame) = self.frame.get()
|
||||
&& let FrameStatus::Capturing | FrameStatus::Captured = self.status.get()
|
||||
{
|
||||
frame.fail(FrameFailureReason::Stopped);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn send_stopped(&self) {
|
||||
self.client.event(Stopped { self_id: self.id });
|
||||
|
|
@ -223,8 +223,9 @@ impl ExtImageCopyCaptureSessionV1 {
|
|||
y_off: i32,
|
||||
size: Option<(i32, i32)>,
|
||||
) {
|
||||
if self.status.get() == FrameStatus::Capturing {
|
||||
if let Some(frame) = self.frame.get() {
|
||||
if self.status.get() == FrameStatus::Capturing
|
||||
&& let Some(frame) = self.frame.get()
|
||||
{
|
||||
frame.copy_texture(
|
||||
on,
|
||||
texture,
|
||||
|
|
@ -239,7 +240,6 @@ impl ExtImageCopyCaptureSessionV1 {
|
|||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
self.force_capture.set(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,8 +64,9 @@ 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 !self.finished.get()
|
||||
&& let Some(node) = output.global.node()
|
||||
{
|
||||
if node.lock_surface.is_some() {
|
||||
return Err(ExtSessionLockV1Error::OutputAlreadyLocked);
|
||||
}
|
||||
|
|
@ -75,7 +76,6 @@ impl ExtSessionLockV1RequestHandler for ExtSessionLockV1 {
|
|||
new.surface.set_output(&node);
|
||||
self.client.state.tree_changed();
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -414,12 +414,11 @@ 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn destroy_data_device<T: IpcVtable>(dd: &T::Device) {
|
||||
|
|
|
|||
|
|
@ -90,15 +90,15 @@ 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() {
|
||||
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,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send_action(&self, dnd_action: u32) {
|
||||
self.client.event(Action {
|
||||
|
|
|
|||
|
|
@ -136,17 +136,18 @@ impl JayInput {
|
|||
.map(uapi::as_bytes)
|
||||
.unwrap_or_default(),
|
||||
});
|
||||
if let Some(output) = data.data.output.get() {
|
||||
if let Some(output) = output.get() {
|
||||
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() {
|
||||
if self.version >= CALIBRATION_MATRIX_SINCE
|
||||
&& let Some(m) = dev.calibration_matrix()
|
||||
{
|
||||
self.client.event(CalibrationMatrix {
|
||||
self_id: self.id,
|
||||
m00: m[0][0],
|
||||
|
|
@ -157,9 +158,9 @@ impl JayInput {
|
|||
m12: m[1][2],
|
||||
});
|
||||
}
|
||||
}
|
||||
if self.version >= CLICK_METHOD_SINCE {
|
||||
if let Some(click_method) = dev.click_method() {
|
||||
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 {
|
||||
|
|
@ -173,16 +174,15 @@ impl JayInput {
|
|||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
if self.version >= MIDDLE_BUTTON_EMULATION_SINCE {
|
||||
if let Some(middle_button_emulation) = dev.middle_button_emulation_enabled() {
|
||||
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 _,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn device(&self, id: u32) -> Result<Rc<DeviceHandlerData>, JayInputError> {
|
||||
let idh = self.client.state.input_device_handlers.borrow_mut();
|
||||
|
|
@ -404,12 +404,12 @@ 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() {
|
||||
if let Some(attached) = dev.data.seat.get()
|
||||
&& attached.id() == seat.id()
|
||||
{
|
||||
self.send_input_device(dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,12 +216,12 @@ 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) {
|
||||
if let Some(node) = &dev.devnode
|
||||
&& node.ends_with(name)
|
||||
{
|
||||
candidates.push(dev.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
if candidates.len() == 1 {
|
||||
return Some(candidates[0].clone());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,8 +56,9 @@ impl JayReexec {
|
|||
let _ = waitpid(pid, 0);
|
||||
}
|
||||
Forked::Child { .. } => {
|
||||
if let Ok(f) = fork_with_pidfd(false) {
|
||||
if let Forked::Child { .. } = f {
|
||||
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;
|
||||
|
|
@ -77,7 +78,6 @@ impl JayReexec {
|
|||
};
|
||||
let _ = uapi::poll(from_mut(&mut pollfd), -1);
|
||||
}
|
||||
}
|
||||
unsafe {
|
||||
c::_exit(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -655,11 +655,9 @@ impl JayScreencastRequestHandler for JayScreencast {
|
|||
slf.schedule_realloc_or_reconfigure();
|
||||
}
|
||||
|
||||
if capture_rules_changed {
|
||||
if let Some(Target::Output(o)) = self.target.get() {
|
||||
if capture_rules_changed && let Some(Target::Output(o)) = self.target.get() {
|
||||
o.screencast_changed();
|
||||
}
|
||||
}
|
||||
|
||||
if self.running.get() {
|
||||
self.damage();
|
||||
|
|
|
|||
|
|
@ -158,12 +158,10 @@ impl WlBuffer {
|
|||
return;
|
||||
}
|
||||
let had_texture = self.reset_gfx_objects(surface);
|
||||
if had_texture {
|
||||
if let Some(surface) = surface {
|
||||
if had_texture && let Some(surface) = surface {
|
||||
self.update_texture_or_log(surface, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn reset_gfx_objects(&self, surface: Option<&WlSurface>) -> bool {
|
||||
let mut storage = self.storage.borrow_mut();
|
||||
|
|
@ -234,8 +232,7 @@ impl WlBuffer {
|
|||
};
|
||||
match storage {
|
||||
WlBufferStorage::Shm { mem, stride } => {
|
||||
if sync_shm {
|
||||
if let Some(ctx) = self.client.state.render_ctx.get() {
|
||||
if sync_shm && let Some(ctx) = self.client.state.render_ctx.get() {
|
||||
let tex = ctx.async_shmem_texture(
|
||||
self.format,
|
||||
self.width,
|
||||
|
|
@ -248,7 +245,6 @@ impl WlBuffer {
|
|||
surface.shm_textures.front().damage.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
WlBufferStorage::Dmabuf { img, tex, .. } => {
|
||||
if tex.is_none() {
|
||||
*tex = Some(img.clone().to_texture()?);
|
||||
|
|
|
|||
|
|
@ -442,8 +442,9 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
fn maybe_constrain_pointer_node(&self) {
|
||||
if let Some(pn) = self.pointer_node() {
|
||||
if let Some(surface) = pn.node_into_surface() {
|
||||
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);
|
||||
|
|
@ -451,7 +452,6 @@ impl WlSeatGlobal {
|
|||
self.maybe_constrain(&surface, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn maybe_constrain(&self, surface: &WlSurface, x: Fixed, y: Fixed) {
|
||||
if self.constraint.is_some() {
|
||||
|
|
@ -513,11 +513,11 @@ 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() {
|
||||
if let Some(weak) = self.kb_states.get(&keymap.id)
|
||||
&& let Some(state) = weak.upgrade()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
}
|
||||
self.kb_states
|
||||
.lock()
|
||||
.retain(|_, state| state.strong_count() > 0);
|
||||
|
|
@ -548,15 +548,14 @@ 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() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_split(&self, axis: ContainerSplit) {
|
||||
if let Some(c) = self.kb_parent_container() {
|
||||
|
|
@ -573,14 +572,13 @@ 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() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_floating(self: &Rc<Self>) -> Option<bool> {
|
||||
match self.keyboard_node.get().node_toplevel() {
|
||||
|
|
@ -642,14 +640,13 @@ 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() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_selection_<T, X, S>(
|
||||
self: &Rc<Self>,
|
||||
|
|
@ -662,11 +659,11 @@ 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 {
|
||||
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,11 +750,11 @@ impl WlSeatGlobal {
|
|||
if let Some(serial) = serial {
|
||||
self.selection_serial.set(serial);
|
||||
}
|
||||
if let Some(selection) = &selection {
|
||||
if selection.toplevel_drag.is_some() {
|
||||
if let Some(selection) = &selection
|
||||
&& selection.toplevel_drag.is_some()
|
||||
{
|
||||
return Err(WlSeatError::OfferHasDrag);
|
||||
}
|
||||
}
|
||||
self.set_selection(selection)
|
||||
}
|
||||
|
||||
|
|
@ -784,11 +781,11 @@ 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() {
|
||||
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,11 +932,11 @@ 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() {
|
||||
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 {
|
||||
popup.update_visible();
|
||||
|
|
@ -1086,12 +1083,12 @@ 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() {
|
||||
if let Some(drag) = self.pointer_owner.toplevel_drag()
|
||||
&& let Some(tl) = drag.toplevel.get()
|
||||
{
|
||||
tl.xdg.set_output(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global_base!(WlSeatGlobal, WlSeat, WlSeatError);
|
||||
|
|
@ -1161,8 +1158,9 @@ 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 {
|
||||
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
|
||||
|
|
@ -1175,7 +1173,6 @@ impl WlSeatRequestHandler for WlSeat {
|
|||
y.apply_fract(y_int),
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -1184,15 +1181,15 @@ 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 {
|
||||
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();
|
||||
p.send_repeat_info(rate, delay);
|
||||
|
|
@ -1277,11 +1274,11 @@ 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() {
|
||||
if let Some(old) = self.seat.get()
|
||||
&& old.id() == new.id()
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if self.seat.is_none() {
|
||||
return;
|
||||
|
|
@ -1340,11 +1337,11 @@ impl DeviceHandlerData {
|
|||
}
|
||||
|
||||
pub fn get_rect(&self, state: &State) -> Rect {
|
||||
if let Some(output) = self.output.get() {
|
||||
if let Some(output) = output.get() {
|
||||
if let Some(output) = self.output.get()
|
||||
&& let Some(output) = output.get()
|
||||
{
|
||||
return output.pos.get();
|
||||
}
|
||||
}
|
||||
state.root.extents.get()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -524,11 +524,11 @@ 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()) {
|
||||
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,8 +839,9 @@ 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) {
|
||||
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 {
|
||||
|
|
@ -852,7 +853,6 @@ impl WlSeatGlobal {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if revert_pointer_to_default {
|
||||
drop(kbvm_state);
|
||||
self.pointer_owner.revert_to_default(self);
|
||||
|
|
@ -1169,12 +1169,10 @@ impl WlSeatGlobal {
|
|||
p.send_button(serial, time, button, state)
|
||||
});
|
||||
self.surface_pointer_frame(surface);
|
||||
if pressed {
|
||||
if let Some(node) = surface.get_focus_node() {
|
||||
if pressed && let Some(node) = surface.get_focus_node() {
|
||||
self.focus_node_with_serial(node, serial);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Scroll callbacks
|
||||
|
|
@ -1225,11 +1223,11 @@ 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 {
|
||||
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,11 +1297,11 @@ 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() {
|
||||
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() {
|
||||
ti.send_leave(surface);
|
||||
|
|
|
|||
|
|
@ -530,11 +530,9 @@ 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 {
|
||||
if !should_drop && let Some(src) = &self.dnd.src {
|
||||
ipc::detach_seat(&**src, seat);
|
||||
}
|
||||
}
|
||||
if let Some(icon) = self.icon.get() {
|
||||
icon.disable();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,9 +97,10 @@ 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 {
|
||||
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)
|
||||
});
|
||||
|
|
@ -109,8 +110,6 @@ impl WlSeatGlobal {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tablet_event_pad_button(
|
||||
self: &Rc<Self>,
|
||||
|
|
@ -141,14 +140,14 @@ 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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tablet_event_pad_strip(
|
||||
self: &Rc<Self>,
|
||||
|
|
@ -162,14 +161,14 @@ 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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tablet_event_pad_dial(
|
||||
self: &Rc<Self>,
|
||||
|
|
@ -182,14 +181,14 @@ 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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TabletPad {
|
||||
|
|
|
|||
|
|
@ -258,15 +258,15 @@ impl TabletTool {
|
|||
tool.send_motion(x, y);
|
||||
tool.send_frame(time);
|
||||
});
|
||||
if let Some(changes) = changes {
|
||||
if changes.down == Some(true) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TabletToolOpt {
|
||||
|
|
|
|||
|
|
@ -57,11 +57,11 @@ 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 {
|
||||
if obj.version >= BUSTYPE_SINCE
|
||||
&& let Some(bustype) = tablet.bustype
|
||||
{
|
||||
obj.send_bustype(bustype);
|
||||
}
|
||||
}
|
||||
obj.send_done();
|
||||
tablet.bindings.add(self, &obj);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,12 +87,12 @@ 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 {
|
||||
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(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -252,13 +252,13 @@ 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 {
|
||||
if state.cursor_rectangle != val
|
||||
&& let Some(con) = &con
|
||||
{
|
||||
for (_, popup) in &con.input_method.popups {
|
||||
popup.schedule_positioning();
|
||||
}
|
||||
}
|
||||
}
|
||||
state.cursor_rectangle = val;
|
||||
}
|
||||
if let Some(val) = pending.content_type {
|
||||
|
|
@ -282,11 +282,9 @@ impl ZwpTextInputV3RequestHandler for ZwpTextInputV3 {
|
|||
}
|
||||
state.surrounding_text = val;
|
||||
}
|
||||
if sent_any {
|
||||
if let Some(con) = &con {
|
||||
if sent_any && let Some(con) = &con {
|
||||
con.input_method.send_done();
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -854,11 +854,11 @@ impl WlSurface {
|
|||
ss.surface.set_toplevel(tl.clone());
|
||||
}
|
||||
}
|
||||
if self.seat_state.is_active() {
|
||||
if let Some(tl) = &tl {
|
||||
if self.seat_state.is_active()
|
||||
&& let Some(tl) = &tl
|
||||
{
|
||||
tl.tl_surface_active_changed(true);
|
||||
}
|
||||
}
|
||||
self.toplevel.set(tl);
|
||||
}
|
||||
|
||||
|
|
@ -977,8 +977,9 @@ 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() {
|
||||
if let Some(xsurface) = self.ext.get().into_xsurface()
|
||||
&& let Some(window) = xsurface.xwindow.get()
|
||||
{
|
||||
self.client
|
||||
.state
|
||||
.xwayland
|
||||
|
|
@ -986,7 +987,6 @@ impl WlSurface {
|
|||
.push(XWaylandEvent::Configure(window));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const MAX_DAMAGE: usize = 32;
|
||||
|
|
@ -1152,15 +1152,13 @@ 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() {
|
||||
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() {
|
||||
color_description_changed = true;
|
||||
|
|
@ -1360,11 +1358,11 @@ 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 {
|
||||
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,13 +1435,12 @@ 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() {
|
||||
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,15 +1875,15 @@ 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() {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -604,11 +604,11 @@ 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) {
|
||||
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();
|
||||
back.damage.damage(slice::from_ref(&buf.rect));
|
||||
|
|
@ -643,11 +643,11 @@ 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() {
|
||||
if let Some(staging) = &staging_opt
|
||||
&& staging.size() != back_tex.staging_size()
|
||||
{
|
||||
staging_opt = None;
|
||||
}
|
||||
}
|
||||
let staging = match staging_opt {
|
||||
Some(s) => s,
|
||||
None => {
|
||||
|
|
@ -682,14 +682,14 @@ impl CommitDataCollector {
|
|||
if buffer.is_shm() {
|
||||
self.shm_uploads += 1;
|
||||
}
|
||||
if !pending.explicit_sync {
|
||||
if let Some(dmabuf) = &buffer.dmabuf {
|
||||
if !pending.explicit_sync
|
||||
&& let Some(dmabuf) = &buffer.dmabuf
|
||||
{
|
||||
for plane in &dmabuf.planes {
|
||||
self.implicit_dmabufs.push(plane.fd.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(point) = pending.acquire_point.take() {
|
||||
self.acquire_points.push(point);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,14 +79,13 @@ 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 {
|
||||
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,8 +248,9 @@ 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) {
|
||||
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();
|
||||
|
|
@ -257,7 +258,6 @@ impl<T: TrayItem> SurfaceExt for T {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn extents_changed(&self) {
|
||||
let data = self.data();
|
||||
|
|
|
|||
|
|
@ -260,11 +260,11 @@ 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() {
|
||||
if let Some(ps) = committed
|
||||
&& let Some(mut state) = ps.pending.state.take()
|
||||
{
|
||||
self.surface.apply_state(&mut state)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,11 +59,11 @@ 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() {
|
||||
if let Some(xwindow) = self.xwindow.get()
|
||||
&& xwindow.tl_accepts_keyboard_focus()
|
||||
{
|
||||
return Some(xwindow.x.surface.clone());
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -183,12 +183,12 @@ 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() {
|
||||
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(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Change {
|
||||
|
|
|
|||
|
|
@ -110,13 +110,13 @@ 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() {
|
||||
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(
|
||||
self.parent
|
||||
|
|
@ -453,12 +453,12 @@ 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() {
|
||||
if old_extents != new_extents
|
||||
&& let Some(ext) = self.ext.get()
|
||||
{
|
||||
ext.extents_changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, mut x: i32, mut y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
if let Some(geo) = self.geometry.get() {
|
||||
|
|
@ -518,15 +518,16 @@ 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() {
|
||||
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() {
|
||||
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();
|
||||
|
|
@ -536,7 +537,6 @@ impl SurfaceExt for XdgSurface {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -371,12 +371,12 @@ impl StackedNode for XdgPopup {
|
|||
|
||||
fn stacked_set_visible(&self, visible: bool) {
|
||||
if visible {
|
||||
if let Some(parent) = self.parent.get() {
|
||||
if !parent.visible() {
|
||||
if let Some(parent) = self.parent.get()
|
||||
&& !parent.visible()
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
self.set_visible(visible);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -433,13 +433,11 @@ 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() {
|
||||
if fullscreen && let Some(ws) = self.xdg.workspace.get() {
|
||||
self.toplevel_data
|
||||
.set_fullscreen2(&self.state, self.clone(), &ws);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn prepare_toplevel_drag(&self) {
|
||||
if self.toplevel_data.parent.get().is_none() {
|
||||
|
|
@ -470,8 +468,9 @@ 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 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() {
|
||||
|
|
@ -490,7 +489,6 @@ impl XdgToplevel {
|
|||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if self.is_mapped.replace(should_be_mapped) == should_be_mapped {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -384,12 +384,12 @@ impl ZwlrLayerSurfaceV1 {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
if self.exclusive_size.replace(exclusive_size) != exclusive_size {
|
||||
if let Some(output) = self.output.node.get() {
|
||||
if self.exclusive_size.replace(exclusive_size) != exclusive_size
|
||||
&& let Some(output) = self.output.node.get()
|
||||
{
|
||||
output.update_exclusive_zones();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn pre_commit(&self, pending: &mut PendingState) -> Result<(), ZwlrLayerSurfaceV1Error> {
|
||||
let pending = pending.layer_surface.get_or_insert_default_ext();
|
||||
|
|
@ -422,11 +422,11 @@ 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) {
|
||||
if let Some(ee) = self.exclusive_edge.get()
|
||||
&& !self.anchor.get().contains(ee)
|
||||
{
|
||||
return Err(ZwlrLayerSurfaceV1Error::ExclusiveEdgeNotAnchored);
|
||||
}
|
||||
}
|
||||
self.configure();
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -539,11 +539,11 @@ 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() {
|
||||
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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,8 +136,9 @@ 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() {
|
||||
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) {
|
||||
|
|
@ -149,7 +150,6 @@ impl ExtWorkspaceGroupHandleV1RequestHandler for ExtWorkspaceGroupHandleV1 {
|
|||
manager.schedule_done();
|
||||
}
|
||||
}
|
||||
}
|
||||
self.detach();
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -77,11 +77,11 @@ impl ExtWorkspaceHandleV1 {
|
|||
};
|
||||
let mut state = 0;
|
||||
let output = ws.output.get();
|
||||
if let Some(active) = output.workspace.get() {
|
||||
if active.id == ws.id {
|
||||
if let Some(active) = output.workspace.get()
|
||||
&& active.id == ws.id
|
||||
{
|
||||
state |= STATE_ACTIVE;
|
||||
}
|
||||
}
|
||||
if ws.attention_requests.active() {
|
||||
state |= STATE_URGENT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,13 +55,13 @@ impl WpDrmLeaseDeviceV1Global {
|
|||
}
|
||||
}
|
||||
for c in dev.connectors.lock().keys() {
|
||||
if let Some(o) = client.state.outputs.get(c) {
|
||||
if o.monitor_info.non_desktop {
|
||||
if let Some(o) = client.state.outputs.get(c)
|
||||
&& o.monitor_info.non_desktop
|
||||
{
|
||||
obj.create_connector(&o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
obj.send_done();
|
||||
self.bindings.add(client, &obj);
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ 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() {
|
||||
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);
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -72,13 +72,13 @@ 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() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl XdgToplevelDragV1RequestHandler for XdgToplevelDragV1 {
|
||||
|
|
@ -133,8 +133,9 @@ impl XdgToplevelDragV1 {
|
|||
}
|
||||
|
||||
pub fn finish_drag(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
if self.source.data.was_used() {
|
||||
if let Some(tl) = self.toplevel.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();
|
||||
|
|
@ -144,7 +145,6 @@ impl XdgToplevelDragV1 {
|
|||
y.round_down() - self.y_off.get(),
|
||||
);
|
||||
}
|
||||
}
|
||||
self.detach();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,17 +111,15 @@ 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 {
|
||||
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() {
|
||||
if !with_damage && let Some(global) = self.output.get() {
|
||||
global.connector.damage();
|
||||
}
|
||||
}
|
||||
self.with_damage.set(with_damage);
|
||||
node.screencopies
|
||||
.set((self.client.id, self.id), self.clone());
|
||||
|
|
|
|||
|
|
@ -37,8 +37,9 @@ impl ZwpLinuxDmabufV1Global {
|
|||
});
|
||||
track!(client, obj);
|
||||
client.add_client_obj(&obj)?;
|
||||
if version < FEEDBACK_SINCE_VERSION {
|
||||
if let Some(ctx) = client.state.render_ctx.get() {
|
||||
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);
|
||||
|
|
@ -49,7 +50,6 @@ impl ZwpLinuxDmabufV1Global {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,19 +249,19 @@ where
|
|||
}
|
||||
let node = 'node: {
|
||||
for f in &files {
|
||||
if let Some(file) = f.file_name() {
|
||||
if file.as_bytes().starts_with_str("renderD") {
|
||||
if let Some(file) = f.file_name()
|
||||
&& file.as_bytes().starts_with_str("renderD")
|
||||
{
|
||||
break 'node f;
|
||||
}
|
||||
}
|
||||
}
|
||||
for f in &files {
|
||||
if let Some(file) = f.file_name() {
|
||||
if file.as_bytes().starts_with_str("card") {
|
||||
if let Some(file) = f.file_name()
|
||||
&& file.as_bytes().starts_with_str("card")
|
||||
{
|
||||
break 'node f;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Err(TestBackendError::NoDrmNode);
|
||||
};
|
||||
let file = match uapi::open(node.as_path(), c::O_RDWR | c::O_CLOEXEC, 0) {
|
||||
|
|
|
|||
|
|
@ -533,13 +533,14 @@ impl PwClientNode {
|
|||
if let Some(mt) = obj.get_param(SPA_FORMAT_VIDEO_size.0)? {
|
||||
format.video_size = Some(mt.pod.get_rectangle()?);
|
||||
}
|
||||
if let Some(mt) = obj.get_param(SPA_FORMAT_VIDEO_format.0)? {
|
||||
if let Some(fmt) = pw_formats().get(&SpaVideoFormat(mt.pod.get_id()?)) {
|
||||
if let Some(mt) = obj.get_param(SPA_FORMAT_VIDEO_format.0)?
|
||||
&& let Some(fmt) = pw_formats().get(&SpaVideoFormat(mt.pod.get_id()?))
|
||||
{
|
||||
format.format = Some(*fmt);
|
||||
}
|
||||
}
|
||||
if let Some(mt) = obj.get_param(SPA_FORMAT_VIDEO_modifier.0)? {
|
||||
if let PwPod::Choice(mods) = mt.pod {
|
||||
if let Some(mt) = obj.get_param(SPA_FORMAT_VIDEO_modifier.0)?
|
||||
&& let PwPod::Choice(mods) = mt.pod
|
||||
{
|
||||
let mut p1 = mods.elements.elements;
|
||||
p1.read_pod_body_packed(PW_TYPE_Long, 8)?;
|
||||
while p1.len() > 0 {
|
||||
|
|
@ -552,7 +553,6 @@ impl PwClientNode {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(mt) = obj.get_param(SPA_FORMAT_VIDEO_framerate.0)? {
|
||||
format.framerate = Some(mt.pod.get_fraction()?);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,12 +71,12 @@ impl PwCore {
|
|||
let mut p2 = s1.fields;
|
||||
let id = p2.read_uint()?;
|
||||
let seq = p2.read_uint()?;
|
||||
if let Some(obj) = self.con.objects.get(&id) {
|
||||
if obj.data().sync_id.get() <= seq {
|
||||
if let Some(obj) = self.con.objects.get(&id)
|
||||
&& obj.data().sync_id.get() <= seq
|
||||
{
|
||||
obj.data().sync_id.set(seq);
|
||||
obj.done();
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -177,14 +177,15 @@ impl<'a> PwParser<'a> {
|
|||
|
||||
pub fn read_value(&mut self) -> Result<PwPod<'a>, PwParserError> {
|
||||
let mut v = self.read_pod();
|
||||
if let Ok(PwPod::Choice(v)) = &mut v {
|
||||
if v.ty == PW_CHOICE_None && v.elements.n_elements > 0 {
|
||||
if let Ok(PwPod::Choice(v)) = &mut v
|
||||
&& v.ty == PW_CHOICE_None
|
||||
&& v.elements.n_elements > 0
|
||||
{
|
||||
return v
|
||||
.elements
|
||||
.elements
|
||||
.read_pod_body_packed(v.elements.ty, v.elements.child_len);
|
||||
}
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1202,14 +1202,15 @@ impl<'a> PwPod<'a> {
|
|||
}
|
||||
|
||||
pub fn get_value(mut self) -> Result<PwPod<'a>, PwParserError> {
|
||||
if let PwPod::Choice(v) = &mut self {
|
||||
if v.ty == PW_CHOICE_None && v.elements.n_elements > 0 {
|
||||
if let PwPod::Choice(v) = &mut self
|
||||
&& v.ty == PW_CHOICE_None
|
||||
&& v.elements.n_elements > 0
|
||||
{
|
||||
return v
|
||||
.elements
|
||||
.elements
|
||||
.read_pod_body_packed(v.elements.ty, v.elements.child_len);
|
||||
}
|
||||
}
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -325,12 +325,12 @@ impl<'a> Debug for PwPodObject<'a> {
|
|||
s.field("type", &self.ty);
|
||||
let name;
|
||||
let mut id: &dyn Debug = &self.id;
|
||||
if let Some(d) = debugger {
|
||||
if let Some(n) = d.id_name(self.id) {
|
||||
if let Some(d) = debugger
|
||||
&& let Some(n) = d.id_name(self.id)
|
||||
{
|
||||
name = n;
|
||||
id = &name;
|
||||
}
|
||||
}
|
||||
s.field("id", id);
|
||||
s.field(
|
||||
"props",
|
||||
|
|
|
|||
|
|
@ -179,11 +179,11 @@ impl UsrJayRenderCtxOwner for PortalDisplay {
|
|||
};
|
||||
let dev_id = drm.dev();
|
||||
let mut render_ctx = None;
|
||||
if let Some(ctx) = self.state.render_ctxs.get(&dev_id) {
|
||||
if let Some(ctx) = ctx.upgrade() {
|
||||
if let Some(ctx) = self.state.render_ctxs.get(&dev_id)
|
||||
&& let Some(ctx) = ctx.upgrade()
|
||||
{
|
||||
render_ctx = Some(ctx);
|
||||
}
|
||||
}
|
||||
if render_ctx.is_none() {
|
||||
let ctx = match create_gfx_context(
|
||||
&self.state.eng,
|
||||
|
|
@ -553,11 +553,11 @@ pub(super) async fn watch_displays(state: Rc<PortalState>) {
|
|||
}
|
||||
};
|
||||
for event in events {
|
||||
if event.mask.contains(c::IN_CREATE) {
|
||||
if let Ok(s) = std::str::from_utf8(event.name().as_ustr().as_bytes()) {
|
||||
if event.mask.contains(c::IN_CREATE)
|
||||
&& let Ok(s) = std::str::from_utf8(event.name().as_ustr().as_bytes())
|
||||
{
|
||||
maybe_add_display(&state, s).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -353,8 +353,9 @@ impl StartedScreencast {
|
|||
return Err(BufferAllocationError::NoRenderContext);
|
||||
};
|
||||
let mut usage = BO_USE_RENDERING;
|
||||
if let Some(sf) = &ctx.server_formats {
|
||||
if let Some(format) = sf.get(&format.drm) {
|
||||
if let Some(sf) = &ctx.server_formats
|
||||
&& let Some(format) = sf.get(&format.drm)
|
||||
{
|
||||
let no_render_usage = modifiers.iter().all(|m| {
|
||||
format
|
||||
.write_modifiers
|
||||
|
|
@ -366,7 +367,6 @@ impl StartedScreencast {
|
|||
usage = BufferUsage::none();
|
||||
}
|
||||
}
|
||||
}
|
||||
let buffer = ctx.ctx.ctx.allocator().create_bo(
|
||||
&self.dpy.state.dma_buf_ids,
|
||||
self.width.get(),
|
||||
|
|
|
|||
|
|
@ -56,11 +56,11 @@ impl Renderer<'_> {
|
|||
|
||||
pub fn render_output(&mut self, output: &OutputNode, x: i32, y: i32) {
|
||||
if self.state.lock.locked.get() {
|
||||
if let Some(surface) = output.lock_surface.get() {
|
||||
if surface.surface.buffer.is_some() {
|
||||
if let Some(surface) = output.lock_surface.get()
|
||||
&& surface.surface.buffer.is_some()
|
||||
{
|
||||
self.render_surface(&surface.surface, x, y, None);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
let opos = output.global.pos.get();
|
||||
|
|
@ -134,8 +134,9 @@ impl Renderer<'_> {
|
|||
self.state.color_manager.srgb_srgb(),
|
||||
);
|
||||
}
|
||||
if let Some(status) = &rd.status {
|
||||
if let Some(texture) = status.tex.texture() {
|
||||
if let Some(status) = &rd.status
|
||||
&& let Some(texture) = status.tex.texture()
|
||||
{
|
||||
let (x, y) = self.base.scale_point(x + status.tex_x, y);
|
||||
self.base.render_texture(
|
||||
&texture,
|
||||
|
|
@ -153,7 +154,6 @@ impl Renderer<'_> {
|
|||
srgb_srgb,
|
||||
);
|
||||
}
|
||||
}
|
||||
for item in output.tray_items.iter() {
|
||||
let data = item.data();
|
||||
if data.surface.buffer.is_some() {
|
||||
|
|
@ -185,15 +185,15 @@ impl Renderer<'_> {
|
|||
render_layer!(output.layers[2]);
|
||||
render_layer!(output.layers[3]);
|
||||
render_stacked!(self.state.root.stacked_above_layers);
|
||||
if let Some(ws) = output.workspace.get() {
|
||||
if ws.render_highlight.get() > 0 {
|
||||
if let Some(ws) = output.workspace.get()
|
||||
&& ws.render_highlight.get() > 0
|
||||
{
|
||||
let color = self.state.theme.colors.highlight.get();
|
||||
let bounds = ws.position.get().at_point(x, y + th + 1);
|
||||
self.base.ops.push(GfxApiOpt::Sync);
|
||||
self.base.fill_boxes(&[bounds], &color, srgb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render_workspace(&mut self, workspace: &WorkspaceNode, x: i32, y: i32) {
|
||||
if let Some(node) = workspace.container.get() {
|
||||
|
|
@ -214,8 +214,9 @@ impl Renderer<'_> {
|
|||
&Color::from_srgba_straight(20, 20, 20, 255),
|
||||
&self.state.color_manager.srgb_srgb().linear,
|
||||
);
|
||||
if let Some(tex) = placeholder.textures.borrow().get(&self.base.scale) {
|
||||
if let Some(texture) = tex.texture() {
|
||||
if let Some(tex) = placeholder.textures.borrow().get(&self.base.scale)
|
||||
&& let Some(texture) = tex.texture()
|
||||
{
|
||||
let (tex_width, tex_height) = texture.size();
|
||||
let x = x + (pos.width() - tex_width) / 2;
|
||||
let y = y + (pos.height() - tex_height) / 2;
|
||||
|
|
@ -235,7 +236,6 @@ impl Renderer<'_> {
|
|||
self.state.color_manager.srgb_srgb(),
|
||||
);
|
||||
}
|
||||
}
|
||||
self.render_tl_aux(placeholder.tl_data(), bounds, true);
|
||||
}
|
||||
|
||||
|
|
@ -560,8 +560,9 @@ impl Renderer<'_> {
|
|||
}
|
||||
x1 += th;
|
||||
}
|
||||
if let Some(title) = floating.title_textures.borrow().get(&self.base.scale) {
|
||||
if let Some(texture) = title.texture() {
|
||||
if let Some(title) = floating.title_textures.borrow().get(&self.base.scale)
|
||||
&& let Some(texture) = title.texture()
|
||||
{
|
||||
let (x, y) = self.base.scale_point(x1, y1);
|
||||
self.base.render_texture(
|
||||
&texture,
|
||||
|
|
@ -579,7 +580,6 @@ impl Renderer<'_> {
|
|||
srgb_srgb,
|
||||
);
|
||||
}
|
||||
}
|
||||
let body = Rect::new_sized(
|
||||
x + bw,
|
||||
y + bw + th + 1,
|
||||
|
|
|
|||
|
|
@ -199,11 +199,11 @@ impl RendererBase<'_> {
|
|||
let mut target_x = [x, x + twidth];
|
||||
let mut target_y = [y, y + theight];
|
||||
|
||||
if let Some(bounds) = bounds {
|
||||
if bound_target(&mut target_x, &mut target_y, &mut texcoord, bounds) {
|
||||
if let Some(bounds) = bounds
|
||||
&& bound_target(&mut target_x, &mut target_y, &mut texcoord, bounds)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let target = FramebufferRect::new(
|
||||
target_x[0] as f32,
|
||||
|
|
|
|||
55
src/state.rs
55
src/state.rs
|
|
@ -500,23 +500,23 @@ impl State {
|
|||
}
|
||||
if self.render_ctx.is_none() {
|
||||
for dev in self.drm_devs.lock().values() {
|
||||
if let Ok(version) = dev.dev.version() {
|
||||
if version.name.contains_str("nvidia") {
|
||||
if let Ok(version) = dev.dev.version()
|
||||
&& version.name.contains_str("nvidia")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
dev.make_render_device();
|
||||
if self.render_ctx.is_some() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if self.render_ctx.is_none() {
|
||||
if let Some(dev) = self.drm_devs.lock().values().next() {
|
||||
if self.render_ctx.is_none()
|
||||
&& let Some(dev) = self.drm_devs.lock().values().next()
|
||||
{
|
||||
dev.make_render_device();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_render_ctx(&self, ctx: Option<Rc<dyn GfxContext>>) {
|
||||
self.render_ctx.set(ctx.clone());
|
||||
|
|
@ -600,22 +600,23 @@ impl State {
|
|||
cursor_user_groups.render_ctx_changed();
|
||||
}
|
||||
|
||||
if let Some(ctx) = &ctx {
|
||||
if !self.render_ctx_ever_initialized.replace(true) {
|
||||
if let Some(ctx) = &ctx
|
||||
&& !self.render_ctx_ever_initialized.replace(true)
|
||||
{
|
||||
self.add_global(&Rc::new(WlDrmGlobal::new(self.globals.name())));
|
||||
self.add_global(&Rc::new(ZwpLinuxDmabufV1Global::new(self.globals.name())));
|
||||
if let Some(ctx) = ctx.sync_obj_ctx() {
|
||||
if ctx.supports_async_wait() && self.explicit_sync_enabled.get() {
|
||||
if let Some(ctx) = ctx.sync_obj_ctx()
|
||||
&& ctx.supports_async_wait()
|
||||
&& self.explicit_sync_enabled.get()
|
||||
{
|
||||
self.add_global(&Rc::new(WpLinuxDrmSyncobjManagerV1Global::new(
|
||||
self.globals.name(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
if let Some(config) = self.config.get() {
|
||||
config.graphics_initialized();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for watcher in self.render_ctx_watchers.lock().values() {
|
||||
watcher.send_render_ctx(ctx.clone());
|
||||
|
|
@ -761,11 +762,11 @@ impl State {
|
|||
let Some(seat) = seat else {
|
||||
return;
|
||||
};
|
||||
if let Some(config) = self.config.get() {
|
||||
if !config.auto_focus(node.tl_data()) {
|
||||
if let Some(config) = self.config.get()
|
||||
&& !config.auto_focus(node.tl_data())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
node.node_do_focus(&seat, Direction::Unspecified);
|
||||
}
|
||||
|
||||
|
|
@ -856,12 +857,12 @@ impl State {
|
|||
if let Some(client) = client {
|
||||
'update_range: {
|
||||
let mut serials = client.serials.borrow_mut();
|
||||
if let Some(last) = serials.back_mut() {
|
||||
if last.hi.wrapping_add(1) == serial {
|
||||
if let Some(last) = serials.back_mut()
|
||||
&& last.hi.wrapping_add(1) == serial
|
||||
{
|
||||
last.hi = serial;
|
||||
break 'update_range;
|
||||
}
|
||||
}
|
||||
if serials.len() >= NUM_CACHED_SERIAL_RANGES {
|
||||
serials.pop_front();
|
||||
}
|
||||
|
|
@ -1002,12 +1003,12 @@ impl State {
|
|||
}
|
||||
|
||||
pub fn refresh_hardware_cursors(&self) {
|
||||
if let Some(g) = self.cursor_user_group_hardware_cursor.get() {
|
||||
if let Some(u) = g.active() {
|
||||
if let Some(g) = self.cursor_user_group_hardware_cursor.get()
|
||||
&& let Some(u) = g.active()
|
||||
{
|
||||
u.update_hardware_cursor();
|
||||
return;
|
||||
}
|
||||
}
|
||||
self.damage_hardware_cursors(false)
|
||||
}
|
||||
|
||||
|
|
@ -1122,18 +1123,16 @@ impl State {
|
|||
false,
|
||||
src_cd,
|
||||
);
|
||||
if render_hardware_cursors {
|
||||
if let Some(cursor_user_group) = self.cursor_user_group_hardware_cursor.get() {
|
||||
if let Some(cursor_user) = cursor_user_group.active() {
|
||||
if let Some(cursor) = cursor_user.get() {
|
||||
if render_hardware_cursors
|
||||
&& let Some(cursor_user_group) = self.cursor_user_group_hardware_cursor.get()
|
||||
&& let Some(cursor_user) = cursor_user_group.active()
|
||||
&& let Some(cursor) = cursor_user.get()
|
||||
{
|
||||
let (mut x, mut y) = cursor_user.position();
|
||||
x = x + x_off - Fixed::from_int(position.x1());
|
||||
y = y + y_off - Fixed::from_int(position.y1());
|
||||
cursor.render(&mut renderer, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
target.render(
|
||||
target_acquire_sync,
|
||||
target_release_sync,
|
||||
|
|
|
|||
12
src/text.rs
12
src/text.rs
|
|
@ -504,11 +504,11 @@ impl CpuJob for RenderJob {
|
|||
data.complete(Ok(()));
|
||||
return;
|
||||
}
|
||||
if let Some(t) = &tex {
|
||||
if !t.compatible_with(ARGB8888, rt.width, rt.height, rt.stride) {
|
||||
if let Some(t) = &tex
|
||||
&& !t.compatible_with(ARGB8888, rt.width, rt.height, rt.stride)
|
||||
{
|
||||
tex = None;
|
||||
}
|
||||
}
|
||||
let tex = match tex {
|
||||
Some(t) => t,
|
||||
_ => {
|
||||
|
|
@ -527,11 +527,11 @@ impl CpuJob for RenderJob {
|
|||
}
|
||||
};
|
||||
let mut staging_opt = data.staging.take();
|
||||
if let Some(staging) = &staging_opt {
|
||||
if staging.size() != tex.staging_size() {
|
||||
if let Some(staging) = &staging_opt
|
||||
&& staging.size() != tex.staging_size()
|
||||
{
|
||||
staging_opt = None;
|
||||
}
|
||||
}
|
||||
let staging = match staging_opt {
|
||||
Some(s) => s,
|
||||
None => data
|
||||
|
|
|
|||
|
|
@ -593,14 +593,14 @@ impl ContainerNode {
|
|||
if let Some(op) = &seat_state.op {
|
||||
match op.kind {
|
||||
SeatOpKind::Move => {
|
||||
if let CursorType::Seat(_) = id {
|
||||
if self.state.ui_drag_threshold_reached((x, y), (op.x, op.y)) {
|
||||
if let CursorType::Seat(_) = id
|
||||
&& self.state.ui_drag_threshold_reached((x, y), (op.x, op.y))
|
||||
{
|
||||
let node = op.child.node.clone();
|
||||
drop(seats);
|
||||
seat.start_tile_drag(&node);
|
||||
}
|
||||
}
|
||||
}
|
||||
SeatOpKind::Resize {
|
||||
dist_left,
|
||||
dist_right,
|
||||
|
|
@ -1004,14 +1004,15 @@ impl ContainerNode {
|
|||
pub fn move_child(self: Rc<Self>, child: Rc<dyn ToplevelNode>, direction: Direction) {
|
||||
// CASE 1: This is the only child of the container. Replace the container by the child.
|
||||
if self.num_children.get() == 1 {
|
||||
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||
if !self.toplevel_data.is_fullscreen.get() && parent.cnode_accepts_child(&*child) {
|
||||
if let Some(parent) = self.toplevel_data.parent.get()
|
||||
&& !self.toplevel_data.is_fullscreen.get()
|
||||
&& parent.cnode_accepts_child(&*child)
|
||||
{
|
||||
parent.cnode_replace_child(self.deref(), child.clone());
|
||||
self.toplevel_data.parent.take();
|
||||
self.child_nodes.borrow_mut().clear();
|
||||
self.tl_destroy();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
let (split, prev) = direction_to_split(direction);
|
||||
|
|
@ -1028,18 +1029,18 @@ impl ContainerNode {
|
|||
false => cc.next(),
|
||||
};
|
||||
if let Some(neighbor) = neighbor {
|
||||
if let Some(cn) = neighbor.node.clone().node_into_container() {
|
||||
if cn.cnode_accepts_child(&*child) {
|
||||
if let Some(mc) = self.mono_child.get() {
|
||||
if mc.node.node_id() == child.node_id() {
|
||||
if let Some(cn) = neighbor.node.clone().node_into_container()
|
||||
&& cn.cnode_accepts_child(&*child)
|
||||
{
|
||||
if let Some(mc) = self.mono_child.get()
|
||||
&& mc.node.node_id() == child.node_id()
|
||||
{
|
||||
self.activate_child2(&neighbor, true);
|
||||
}
|
||||
}
|
||||
self.cnode_remove_child2(&*child, true);
|
||||
cn.insert_child(child, direction);
|
||||
return;
|
||||
}
|
||||
}
|
||||
match prev {
|
||||
true => neighbor.prepend_existing(&cc),
|
||||
false => neighbor.append_existing(&cc),
|
||||
|
|
@ -1118,13 +1119,13 @@ impl ContainerNode {
|
|||
let rect = Rect::new(0, 0, width, height).unwrap();
|
||||
node.content.set(rect);
|
||||
node.position_content();
|
||||
if let Some(mono) = self.mono_child.get() {
|
||||
if mono.node.node_id() == node.node.node_id() {
|
||||
if let Some(mono) = self.mono_child.get()
|
||||
&& mono.node.node_id() == node.node.node_id()
|
||||
{
|
||||
let body = self.mono_body.get();
|
||||
self.mono_content.set(rect.at_point(body.x1(), body.y1()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn pull_child_properties(self: &Rc<Self>, child: &NodeRef<ContainerChild>) {
|
||||
let data = child.node.tl_data();
|
||||
|
|
@ -1154,12 +1155,10 @@ impl ContainerNode {
|
|||
if set || propagate {
|
||||
self.toplevel_data.set_wants_attention(set);
|
||||
}
|
||||
if propagate {
|
||||
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||
if propagate && let Some(parent) = self.toplevel_data.parent.get() {
|
||||
parent.cnode_child_attention_request_changed(self, set);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_mono(self: &Rc<Self>) {
|
||||
if self.mono_child.is_some() {
|
||||
|
|
@ -1751,12 +1750,12 @@ impl Node for ContainerNode {
|
|||
) {
|
||||
let id = CursorType::TabletTool(tool.id);
|
||||
self.pointer_move(tool.seat(), id, tool.cursor(), x, y, false);
|
||||
if let Some(changes) = changes {
|
||||
if let Some(pressed) = changes.down {
|
||||
if let Some(changes) = changes
|
||||
&& let Some(pressed) = changes.down
|
||||
{
|
||||
self.button(id, tool.seat(), time_usec, pressed, BTN_LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn node_into_container(self: Rc<Self>) -> Option<Rc<ContainerNode>> {
|
||||
Some(self.clone())
|
||||
|
|
@ -2047,16 +2046,15 @@ impl ContainingNode for ContainerNode {
|
|||
if bottom_outside {
|
||||
y2 = new_y2.map(|v| v.max(y1.unwrap_or(pos.y1()) + th + 1));
|
||||
}
|
||||
if (x1.is_some() && x1 != Some(pos.x1()))
|
||||
if ((x1.is_some() && x1 != Some(pos.x1()))
|
||||
|| (x2.is_some() && x2 != Some(pos.x2()))
|
||||
|| (y1.is_some() && y1 != Some(pos.y1()))
|
||||
|| (y2.is_some() && y2 != Some(pos.y2()))
|
||||
|| (y2.is_some() && y2 != Some(pos.y2())))
|
||||
&& let Some(parent) = self.toplevel_data.parent.get()
|
||||
{
|
||||
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||
parent.cnode_resize_child(&*self, x1, y1, x2, y2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn cnode_pinned(&self) -> bool {
|
||||
self.tl_pinned()
|
||||
|
|
|
|||
|
|
@ -426,12 +426,10 @@ impl FloatNode {
|
|||
if update_visible {
|
||||
self.stacked_set_visible(ws.float_visible());
|
||||
}
|
||||
if update_pinned {
|
||||
if let Some(pl) = &*self.pinned_link.borrow_mut() {
|
||||
if update_pinned && let Some(pl) = &*self.pinned_link.borrow_mut() {
|
||||
ws.output.get().pinned.add_last_existing(pl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn after_ws_move(self: &Rc<Self>, output: &Rc<OutputNode>) {
|
||||
if let Some(pinned) = &*self.pinned_link.borrow() {
|
||||
|
|
@ -588,11 +586,11 @@ impl FloatNode {
|
|||
if !pressed {
|
||||
return;
|
||||
}
|
||||
if cursor_data.op_type == OpType::Move {
|
||||
if let Some(tl) = self.child.get() {
|
||||
if cursor_data.op_type == OpType::Move
|
||||
&& let Some(tl) = self.child.get()
|
||||
{
|
||||
tl.node_do_focus(seat, Direction::Unspecified);
|
||||
}
|
||||
}
|
||||
if cursor_data.double_click_state.click(
|
||||
&self.state,
|
||||
time_usec,
|
||||
|
|
@ -600,13 +598,12 @@ impl FloatNode {
|
|||
cursor_data.y,
|
||||
) && cursor_data.op_type == OpType::Move
|
||||
&& !is_icon_press
|
||||
&& let Some(tl) = self.child.get()
|
||||
{
|
||||
if let Some(tl) = self.child.get() {
|
||||
drop(cursors);
|
||||
toplevel_set_floating(&self.state, tl, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
cursor_data.op_active = true;
|
||||
let pos = self.position.get();
|
||||
match cursor_data.op_type {
|
||||
|
|
@ -830,8 +827,9 @@ impl Node for FloatNode {
|
|||
y: Fixed,
|
||||
) {
|
||||
self.pointer_move(CursorType::TabletTool(tool.id), tool.cursor(), x, y, false);
|
||||
if let Some(changes) = changes {
|
||||
if let Some(pressed) = changes.down {
|
||||
if let Some(changes) = changes
|
||||
&& let Some(pressed) = changes.down
|
||||
{
|
||||
self.button(
|
||||
CursorType::TabletTool(tool.id),
|
||||
tool.cursor(),
|
||||
|
|
@ -841,7 +839,6 @@ impl Node for FloatNode {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn node_into_float(self: Rc<Self>) -> Option<Rc<FloatNode>> {
|
||||
Some(self.clone())
|
||||
|
|
|
|||
|
|
@ -1367,8 +1367,9 @@ impl Node for OutputNode {
|
|||
usecase: FindTreeUsecase,
|
||||
) -> FindTreeResult {
|
||||
if self.state.lock.locked.get() {
|
||||
if usecase != FindTreeUsecase::SelectToplevel {
|
||||
if let Some(ls) = self.lock_surface.get() {
|
||||
if usecase != FindTreeUsecase::SelectToplevel
|
||||
&& let Some(ls) = self.lock_surface.get()
|
||||
{
|
||||
tree.push(FoundNode {
|
||||
node: ls.clone(),
|
||||
x,
|
||||
|
|
@ -1376,7 +1377,6 @@ impl Node for OutputNode {
|
|||
});
|
||||
return ls.node_find_tree_at(x, y, tree, usecase);
|
||||
}
|
||||
}
|
||||
return FindTreeResult::AcceptsInput;
|
||||
}
|
||||
let bar_height = self.state.theme.sizes.title_height.get() + 1;
|
||||
|
|
|
|||
|
|
@ -444,12 +444,13 @@ impl ToplevelData {
|
|||
return;
|
||||
}
|
||||
self.changed_properties.set(props | change);
|
||||
if props.is_none() && change.is_some() {
|
||||
if let Some(node) = self.slf.upgrade() {
|
||||
if props.is_none()
|
||||
&& change.is_some()
|
||||
&& let Some(node) = self.slf.upgrade()
|
||||
{
|
||||
mgr.changed(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn destroy_node(&self, node: &dyn Node) {
|
||||
for jay_tl in self.jay_toplevels.lock().drain_values() {
|
||||
|
|
@ -878,11 +879,11 @@ pub fn default_tile_drag_bounds<T: ToplevelNodeBase + ?Sized>(t: &T, split: Cont
|
|||
}
|
||||
|
||||
pub fn toplevel_parent_container(tl: &dyn ToplevelNode) -> Option<Rc<ContainerNode>> {
|
||||
if let Some(parent) = tl.tl_data().parent.get() {
|
||||
if let Some(container) = parent.node_into_container() {
|
||||
if let Some(parent) = tl.tl_data().parent.get()
|
||||
&& let Some(container) = parent.node_into_container()
|
||||
{
|
||||
return Some(container);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -228,11 +228,11 @@ impl WorkspaceNode {
|
|||
} else {
|
||||
node.tl_set_visible(false);
|
||||
}
|
||||
if let Some(surface) = node.tl_scanout_surface() {
|
||||
if let Some(fb) = self.output.get().global.connector.connector.drm_feedback() {
|
||||
if let Some(surface) = node.tl_scanout_surface()
|
||||
&& let Some(fb) = self.output.get().global.connector.connector.drm_feedback()
|
||||
{
|
||||
surface.send_feedback(&fb);
|
||||
}
|
||||
}
|
||||
self.output.get().update_presentation_type();
|
||||
}
|
||||
|
||||
|
|
@ -242,11 +242,11 @@ impl WorkspaceNode {
|
|||
if self.visible.get() {
|
||||
self.output.get().fullscreen_changed();
|
||||
}
|
||||
if let Some(surface) = node.tl_scanout_surface() {
|
||||
if let Some(fb) = surface.client.state.drm_feedback.get() {
|
||||
if let Some(surface) = node.tl_scanout_surface()
|
||||
&& let Some(fb) = surface.client.state.drm_feedback.get()
|
||||
{
|
||||
surface.send_feedback(&fb);
|
||||
}
|
||||
}
|
||||
self.output.get().update_presentation_type();
|
||||
}
|
||||
}
|
||||
|
|
@ -376,8 +376,9 @@ impl Node for WorkspaceNode {
|
|||
|
||||
impl ContainingNode for WorkspaceNode {
|
||||
fn cnode_replace_child(self: Rc<Self>, old: &dyn Node, new: Rc<dyn ToplevelNode>) {
|
||||
if let Some(container) = self.container.get() {
|
||||
if container.node_id() == old.node_id() {
|
||||
if let Some(container) = self.container.get()
|
||||
&& container.node_id() == old.node_id()
|
||||
{
|
||||
let new = match new.node_into_container() {
|
||||
Some(c) => c,
|
||||
_ => {
|
||||
|
|
@ -388,25 +389,24 @@ impl ContainingNode for WorkspaceNode {
|
|||
self.set_container(&new);
|
||||
return;
|
||||
}
|
||||
}
|
||||
log::error!("Trying to replace child that's not a child");
|
||||
}
|
||||
|
||||
fn cnode_remove_child2(self: Rc<Self>, child: &dyn Node, _preserve_focus: bool) {
|
||||
if let Some(container) = self.container.get() {
|
||||
if container.node_id() == child.node_id() {
|
||||
if let Some(container) = self.container.get()
|
||||
&& container.node_id() == child.node_id()
|
||||
{
|
||||
self.discard_child_properties(&*container);
|
||||
self.container.set(None);
|
||||
self.state.damage(self.position.get());
|
||||
return;
|
||||
}
|
||||
}
|
||||
if let Some(fs) = self.fullscreen.get() {
|
||||
if fs.node_id() == child.node_id() {
|
||||
if let Some(fs) = self.fullscreen.get()
|
||||
&& fs.node_id() == child.node_id()
|
||||
{
|
||||
self.remove_fullscreen_node();
|
||||
return;
|
||||
}
|
||||
}
|
||||
log::error!("Trying to remove child that's not a child");
|
||||
}
|
||||
|
||||
|
|
@ -436,11 +436,11 @@ pub fn move_ws_to_output(
|
|||
config: WsMoveConfig,
|
||||
) {
|
||||
let source = ws.output.get();
|
||||
if let Some(visible) = source.workspace.get() {
|
||||
if visible.id == ws.id {
|
||||
if let Some(visible) = source.workspace.get()
|
||||
&& visible.id == ws.id
|
||||
{
|
||||
source.workspace.take();
|
||||
}
|
||||
}
|
||||
let mut new_source_ws = None;
|
||||
if !config.source_is_destroyed && !source.is_dummy && source.workspace.is_none() {
|
||||
new_source_ws = source
|
||||
|
|
@ -459,12 +459,12 @@ pub fn move_ws_to_output(
|
|||
}
|
||||
ws.set_output(&target);
|
||||
'link: {
|
||||
if let Some(before) = config.before {
|
||||
if let Some(link) = &*before.output_link.borrow() {
|
||||
if let Some(before) = config.before
|
||||
&& let Some(link) = &*before.output_link.borrow()
|
||||
{
|
||||
link.prepend_existing(ws);
|
||||
break 'link;
|
||||
}
|
||||
}
|
||||
target.workspaces.add_last_existing(&ws);
|
||||
}
|
||||
let make_visible = !target.is_dummy
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@ impl AsyncEvent {
|
|||
}
|
||||
|
||||
pub fn trigger(&self) {
|
||||
if self.triggers.fetch_add(1) == 0 {
|
||||
if let Some(waker) = self.waker.take() {
|
||||
if self.triggers.fetch_add(1) == 0
|
||||
&& let Some(waker) = self.waker.take()
|
||||
{
|
||||
waker.wake();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn triggered(&self) -> AsyncEventTriggered {
|
||||
AsyncEventTriggered { ae: self }
|
||||
|
|
|
|||
|
|
@ -133,14 +133,13 @@ pub fn double_fork() -> Result<Option<OwnedFd>, ForkerError> {
|
|||
}
|
||||
|
||||
pub fn ensure_reaper() -> c::pid_t {
|
||||
if let Ok(id) = env::var(REAPER_VAR) {
|
||||
if let Ok(id) = c::pid_t::from_str(&id) {
|
||||
if uapi::getppid() == id {
|
||||
if let Ok(id) = env::var(REAPER_VAR)
|
||||
&& let Ok(id) = c::pid_t::from_str(&id)
|
||||
&& uapi::getppid() == id
|
||||
{
|
||||
set_deathsig();
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
let reaper_pid = uapi::getpid();
|
||||
unsafe {
|
||||
c::prctl(c::PR_SET_CHILD_SUBREAPER, 1);
|
||||
|
|
|
|||
|
|
@ -165,11 +165,9 @@ fn reopen(fd: c::c_int, need_primary: bool) -> Result<Rc<OwnedFd>, DrmError> {
|
|||
if get_node_type_from_fd(fd).map_err(DrmError::GetDeviceType)? == NodeType::Render {
|
||||
break 'path uapi::format_ustr!("/proc/self/fd/{}", fd);
|
||||
}
|
||||
if !need_primary {
|
||||
if let Ok(path) = render_node_name(fd) {
|
||||
if !need_primary && let Ok(path) = render_node_name(fd) {
|
||||
break 'path path;
|
||||
}
|
||||
}
|
||||
device_node_name(fd)?
|
||||
};
|
||||
match uapi::open(path, c::O_RDWR | c::O_CLOEXEC, 0) {
|
||||
|
|
@ -441,11 +439,11 @@ impl DrmMaster {
|
|||
Err(e) => return Err(DrmError::GemHandle(e)),
|
||||
};
|
||||
let mut handles = self.gem_handles.borrow_mut();
|
||||
if let Some(h) = handles.get(&handle) {
|
||||
if let Some(h) = h.upgrade() {
|
||||
if let Some(h) = handles.get(&handle)
|
||||
&& let Some(h) = h.upgrade()
|
||||
{
|
||||
return Ok(h);
|
||||
}
|
||||
}
|
||||
let h = Rc::new(GemHandle {
|
||||
master: self.clone(),
|
||||
handle,
|
||||
|
|
|
|||
|
|
@ -55,12 +55,12 @@ impl JaySelectToplevelEventHandler for UsrJaySelectToplevel {
|
|||
Some(tl)
|
||||
};
|
||||
'send: {
|
||||
if self.version >= ID_SINCE {
|
||||
if let Some(tl) = tl {
|
||||
if self.version >= ID_SINCE
|
||||
&& let Some(tl) = tl
|
||||
{
|
||||
tl.owner.set(Some(slf.clone()));
|
||||
break 'send;
|
||||
}
|
||||
}
|
||||
self.send(tl);
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -53,11 +53,11 @@ impl ZwpLinuxDmabufV1EventHandler for UsrLinuxDmabuf {
|
|||
}
|
||||
|
||||
fn modifier(&self, ev: Modifier, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
if let Some(format) = formats().get(&ev.format) {
|
||||
if let Some(owner) = self.owner.get()
|
||||
&& let Some(format) = formats().get(&ev.format)
|
||||
{
|
||||
owner.modifier(format, ev.modifier);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,22 +102,23 @@ impl Incoming {
|
|||
Some(e) => XconError::ExtensionError(e, code),
|
||||
_ => XconError::CoreError(code),
|
||||
};
|
||||
if let Some(first) = reply_handlers.front() {
|
||||
if first.serial() == serial {
|
||||
if let Some(first) = reply_handlers.front()
|
||||
&& first.serial() == serial
|
||||
{
|
||||
let handler = reply_handlers.pop_front().unwrap();
|
||||
drop(reply_handlers);
|
||||
handler.handle_error(e);
|
||||
break 'handle_error;
|
||||
}
|
||||
}
|
||||
log::error!(
|
||||
"Received an error with no corresponding handler: {}",
|
||||
ErrorFmt(e)
|
||||
);
|
||||
}
|
||||
1 => {
|
||||
if let Some(first) = reply_handlers.front() {
|
||||
if first.serial() == serial {
|
||||
if let Some(first) = reply_handlers.front()
|
||||
&& first.serial() == serial
|
||||
{
|
||||
let handler = reply_handlers.pop_front().unwrap();
|
||||
drop(reply_handlers);
|
||||
let mut fds = vec![];
|
||||
|
|
@ -140,12 +141,7 @@ impl Incoming {
|
|||
let msg_buf = mem::transmute::<&[u8], &'static [u8]>(&msg_buf[..]);
|
||||
Parser::new(msg_buf, fds)
|
||||
};
|
||||
handler.handle_result(
|
||||
&self.socket,
|
||||
&mut parser,
|
||||
mem::take(&mut msg_buf),
|
||||
)?;
|
||||
}
|
||||
handler.handle_result(&self.socket, &mut parser, mem::take(&mut msg_buf))?;
|
||||
}
|
||||
}
|
||||
ev => 'handle_event: {
|
||||
|
|
|
|||
|
|
@ -185,11 +185,11 @@ impl<T: XIpc> SelectionData<T> {
|
|||
}
|
||||
|
||||
fn seat_removed(&self, id: SeatId) {
|
||||
if let Some(offer) = self.active_offer.get() {
|
||||
if offer.offer.get_seat().id() == id {
|
||||
if let Some(offer) = self.active_offer.get()
|
||||
&& offer.offer.get_seat().id() == id
|
||||
{
|
||||
self.active_offer.take();
|
||||
}
|
||||
}
|
||||
self.offers.remove(&id);
|
||||
self.sources.remove(&id);
|
||||
}
|
||||
|
|
@ -782,11 +782,11 @@ impl Wm {
|
|||
destroy_data_offer::<T>(&offer);
|
||||
return;
|
||||
}
|
||||
if !enhanced.active.replace(true) {
|
||||
if let Some(old) = sd.active_offer.set(Some(enhanced)) {
|
||||
if !enhanced.active.replace(true)
|
||||
&& let Some(old) = sd.active_offer.set(Some(enhanced))
|
||||
{
|
||||
old.active.set(false);
|
||||
}
|
||||
}
|
||||
let so = SetSelectionOwner {
|
||||
owner: sd.win.get(),
|
||||
selection: sd.selection.get(),
|
||||
|
|
@ -895,13 +895,13 @@ impl Wm {
|
|||
seat: SeatId,
|
||||
source: DataSourceId,
|
||||
) {
|
||||
if let Some(cur) = sd.sources.get(&seat) {
|
||||
if cur.source_data().id == source {
|
||||
if let Some(cur) = sd.sources.get(&seat)
|
||||
&& cur.source_data().id == source
|
||||
{
|
||||
sd.sources.remove(&seat);
|
||||
destroy_data_source::<T>(&cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_xwayland_configure(&mut self, window: Rc<Xwindow>) {
|
||||
if window.data.destroyed.get() {
|
||||
|
|
@ -1010,14 +1010,14 @@ impl Wm {
|
|||
// log::info!("xwm or => return");
|
||||
return;
|
||||
}
|
||||
if initiator == Initiator::X {
|
||||
if let Some(window) = window.window.get() {
|
||||
if initiator == Initiator::X
|
||||
&& let Some(window) = window.window.get()
|
||||
{
|
||||
let seats = self.state.globals.seats.lock();
|
||||
for seat in seats.values() {
|
||||
seat.focus_toplevel(window.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
if send_to_x {
|
||||
let accepts_input = window.info.icccm_hints.input.get();
|
||||
let mask = if accepts_input {
|
||||
|
|
@ -1237,8 +1237,9 @@ impl Wm {
|
|||
if let Some(old) = data.parent.take() {
|
||||
old.children.remove(&data.window_id);
|
||||
}
|
||||
if let Some(w) = buf.first() {
|
||||
if let Some(w) = self.windows.get(w) {
|
||||
if let Some(w) = buf.first()
|
||||
&& let Some(w) = self.windows.get(w)
|
||||
{
|
||||
if data.is_ancestor_of(w.clone()) {
|
||||
log::error!("Cannot set WM_TRANSIENT_FOR because it would create a cycle");
|
||||
return;
|
||||
|
|
@ -1247,7 +1248,6 @@ impl Wm {
|
|||
data.parent.set(Some(w.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn load_window_wm_protocols(&self, data: &Rc<XwindowData>) {
|
||||
let mut buf = vec![];
|
||||
|
|
@ -1506,15 +1506,15 @@ impl Wm {
|
|||
};
|
||||
if let Ok(res) = self.c.call(&c).await {
|
||||
for id in res.get().ids.iter() {
|
||||
if id.spec.mask.contains(RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) {
|
||||
if let Some(first) = id.value.first() {
|
||||
if id.spec.mask.contains(RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID)
|
||||
&& let Some(first) = id.value.first()
|
||||
{
|
||||
data.info.pid.set(Some(*first));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
window.map_status_changed();
|
||||
}
|
||||
|
||||
|
|
@ -1886,9 +1886,10 @@ impl Wm {
|
|||
let new_window = self.windows.get(&event.event);
|
||||
let mut focus_window = self.focus_window.as_ref();
|
||||
let mut send_to_x = true;
|
||||
if let Some(window) = new_window {
|
||||
if let Some(w) = window.window.get() {
|
||||
if let Some(prev) = focus_window {
|
||||
if let Some(window) = new_window
|
||||
&& let Some(w) = window.window.get()
|
||||
&& let Some(prev) = focus_window
|
||||
{
|
||||
let prev_pid = prev.info.pid.get();
|
||||
let new_pid = window.info.pid.get();
|
||||
if prev_pid.is_some()
|
||||
|
|
@ -1901,8 +1902,6 @@ impl Wm {
|
|||
send_to_x = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let fw = focus_window.cloned();
|
||||
self.focus_window(fw.as_ref(), Initiator::X, send_to_x)
|
||||
.await;
|
||||
|
|
@ -2132,15 +2131,14 @@ impl Wm {
|
|||
|
||||
fn update_override_redirect(&self, data: &Rc<XwindowData>, or: u8) {
|
||||
let or = or != 0;
|
||||
if data.info.override_redirect.replace(or) != or {
|
||||
// log::info!("xwin {} or {}", data.window_id, or);
|
||||
if let Some(window) = data.window.get() {
|
||||
if data.info.override_redirect.replace(or) != or
|
||||
&& let Some(window) = data.window.get()
|
||||
{
|
||||
window.tl_destroy();
|
||||
window.update_toplevel();
|
||||
window.map_status_changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_map_notify(&mut self, event: &Event) -> Result<(), XWaylandError> {
|
||||
let event: MapNotify = event.parse()?;
|
||||
|
|
@ -2283,11 +2281,11 @@ impl Wm {
|
|||
Some(d) => d,
|
||||
_ => return Ok(()),
|
||||
};
|
||||
if let Some(window) = data.window.get() {
|
||||
if window.is_mapped() {
|
||||
if let Some(window) = data.window.get()
|
||||
&& window.is_mapped()
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
let de = data.info.pending_extents.get();
|
||||
let mut x1 = de.x1();
|
||||
let mut y1 = de.y1();
|
||||
|
|
@ -2346,12 +2344,12 @@ impl Wm {
|
|||
}
|
||||
|
||||
async fn handle_minimize_requested(&self, data: &Rc<XwindowData>) -> bool {
|
||||
if let Some(w) = data.window.get() {
|
||||
if w.toplevel_data.active_surfaces.active() {
|
||||
if let Some(w) = data.window.get()
|
||||
&& w.toplevel_data.active_surfaces.active()
|
||||
{
|
||||
self.set_wm_state(data, ICCCM_WM_STATE_NORMAL).await;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
self.set_wm_state(data, ICCCM_WM_STATE_ICONIC).await;
|
||||
true
|
||||
}
|
||||
|
|
@ -2461,11 +2459,11 @@ impl Wm {
|
|||
minimized = self.handle_minimize_requested(data).await;
|
||||
}
|
||||
}
|
||||
if fullscreen != data.info.fullscreen.get() {
|
||||
if let Some(w) = data.window.get() {
|
||||
if fullscreen != data.info.fullscreen.get()
|
||||
&& let Some(w) = data.window.get()
|
||||
{
|
||||
w.tl_set_fullscreen(fullscreen, None);
|
||||
}
|
||||
}
|
||||
data.info.fullscreen.set(fullscreen);
|
||||
data.info.maximized_horz.set(maximized_horz);
|
||||
data.info.maximized_vert.set(maximized_vert);
|
||||
|
|
|
|||
|
|
@ -340,11 +340,11 @@ impl Parser for ConfigParser<'_> {
|
|||
}
|
||||
}
|
||||
let mut window_management_key = None;
|
||||
if let Some(value) = window_management_key_val {
|
||||
if let Some(key) = parse_modified_keysym_str(self.0, value.span, value.value) {
|
||||
if let Some(value) = window_management_key_val
|
||||
&& let Some(key) = parse_modified_keysym_str(self.0, value.span, value.value)
|
||||
{
|
||||
window_management_key = Some(key);
|
||||
}
|
||||
}
|
||||
let mut vrr = None;
|
||||
if let Some(value) = vrr_val {
|
||||
match value.parse(&mut VrrParser(self.0)) {
|
||||
|
|
|
|||
|
|
@ -387,36 +387,36 @@ impl DrmDeviceMatch {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(syspath) = syspath {
|
||||
if d.syspath() != *syspath {
|
||||
if let Some(syspath) = syspath
|
||||
&& d.syspath() != *syspath
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(devnode) = devnode {
|
||||
if d.devnode() != *devnode {
|
||||
if let Some(devnode) = devnode
|
||||
&& d.devnode() != *devnode
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(model) = model_name {
|
||||
if d.model() != *model {
|
||||
if let Some(model) = model_name
|
||||
&& d.model() != *model
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(vendor) = vendor_name {
|
||||
if d.vendor() != *vendor {
|
||||
if let Some(vendor) = vendor_name
|
||||
&& d.vendor() != *vendor
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(vendor) = vendor {
|
||||
if d.pci_id().vendor != *vendor {
|
||||
if let Some(vendor) = vendor
|
||||
&& d.pci_id().vendor != *vendor
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(model) = model {
|
||||
if d.pci_id().model != *model {
|
||||
if let Some(model) = model
|
||||
&& d.pci_id().model != *model
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
@ -449,11 +449,11 @@ impl InputMatch {
|
|||
is_gesture,
|
||||
is_switch,
|
||||
} => {
|
||||
if let Some(name) = name {
|
||||
if d.name() != *name {
|
||||
if let Some(name) = name
|
||||
&& d.name() != *name
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(tag) = tag {
|
||||
let matches = apply_recursive_match(
|
||||
"input device",
|
||||
|
|
@ -466,23 +466,23 @@ impl InputMatch {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(syspath) = syspath {
|
||||
if d.syspath() != *syspath {
|
||||
if let Some(syspath) = syspath
|
||||
&& d.syspath() != *syspath
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(devnode) = devnode {
|
||||
if d.devnode() != *devnode {
|
||||
if let Some(devnode) = devnode
|
||||
&& d.devnode() != *devnode
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
macro_rules! check_cap {
|
||||
($is:expr, $cap:ident) => {
|
||||
if let Some(is) = *$is {
|
||||
if d.has_capability(jay_config::input::capability::$cap) != is {
|
||||
if let Some(is) = *$is
|
||||
&& d.has_capability(jay_config::input::capability::$cap) != is
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
check_cap!(is_keyboard, CAP_KEYBOARD);
|
||||
|
|
@ -527,11 +527,11 @@ impl Input {
|
|||
if let Some(v) = self.transform_matrix {
|
||||
c.set_transform_matrix(v);
|
||||
}
|
||||
if let Some(v) = &self.keymap {
|
||||
if let Some(km) = state.get_keymap(v) {
|
||||
if let Some(v) = &self.keymap
|
||||
&& let Some(km) = state.get_keymap(v)
|
||||
{
|
||||
c.set_keymap(km);
|
||||
}
|
||||
}
|
||||
if let Some(output) = &self.output {
|
||||
if let Some(output) = output {
|
||||
for connector in connectors() {
|
||||
|
|
@ -590,26 +590,26 @@ impl OutputMatch {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(connector) = &connector {
|
||||
if c.name() != *connector {
|
||||
if let Some(connector) = &connector
|
||||
&& c.name() != *connector
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(serial_number) = &serial_number {
|
||||
if c.serial_number() != *serial_number {
|
||||
if let Some(serial_number) = &serial_number
|
||||
&& c.serial_number() != *serial_number
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(manufacturer) = &manufacturer {
|
||||
if c.manufacturer() != *manufacturer {
|
||||
if let Some(manufacturer) = &manufacturer
|
||||
&& c.manufacturer() != *manufacturer
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(model) = &model {
|
||||
if c.model() != *model {
|
||||
if let Some(model) = &model
|
||||
&& c.model() != *model
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
@ -624,11 +624,11 @@ impl ConnectorMatch {
|
|||
match self {
|
||||
ConnectorMatch::Any(m) => m.iter().any(|m| m.matches(c)),
|
||||
ConnectorMatch::All { connector } => {
|
||||
if let Some(connector) = &connector {
|
||||
if c.name() != *connector {
|
||||
if let Some(connector) = &connector
|
||||
&& c.name() != *connector
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
@ -679,11 +679,11 @@ impl Output {
|
|||
c.set_vrr_cursor_hz(hz);
|
||||
}
|
||||
}
|
||||
if let Some(tearing) = &self.tearing {
|
||||
if let Some(mode) = tearing.mode {
|
||||
if let Some(tearing) = &self.tearing
|
||||
&& let Some(mode) = tearing.mode
|
||||
{
|
||||
c.set_tearing_mode(mode);
|
||||
}
|
||||
}
|
||||
if let Some(format) = self.format {
|
||||
c.set_format(format);
|
||||
}
|
||||
|
|
@ -858,12 +858,12 @@ impl State {
|
|||
let actions = actions.clone();
|
||||
dev.on_switch_event(move |ev| {
|
||||
for (match_, actions) in &*actions {
|
||||
if match_.matches(dev, &state) {
|
||||
if let Some(action) = actions.get(&ev) {
|
||||
if match_.matches(dev, &state)
|
||||
&& let Some(action) = actions.get(&ev)
|
||||
{
|
||||
action();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1214,11 +1214,11 @@ fn load_config(initial_load: bool, persistent: &Rc<PersistentState>) {
|
|||
set_vrr_cursor_hz(hz);
|
||||
}
|
||||
}
|
||||
if let Some(tearing) = config.tearing {
|
||||
if let Some(mode) = tearing.mode {
|
||||
if let Some(tearing) = config.tearing
|
||||
&& let Some(mode) = tearing.mode
|
||||
{
|
||||
set_tearing_mode(mode);
|
||||
}
|
||||
}
|
||||
set_libei_socket_enabled(config.libei.enable_socket.unwrap_or(false));
|
||||
if let Some(enabled) = config.ui_drag.enabled {
|
||||
set_ui_drag_enabled(enabled);
|
||||
|
|
@ -1226,21 +1226,21 @@ fn load_config(initial_load: bool, persistent: &Rc<PersistentState>) {
|
|||
if let Some(threshold) = config.ui_drag.threshold {
|
||||
set_ui_drag_threshold(threshold);
|
||||
}
|
||||
if let Some(xwayland) = config.xwayland {
|
||||
if let Some(mode) = xwayland.scaling_mode {
|
||||
if let Some(xwayland) = config.xwayland
|
||||
&& let Some(mode) = xwayland.scaling_mode
|
||||
{
|
||||
set_x_scaling_mode(mode);
|
||||
}
|
||||
}
|
||||
if let Some(cm) = config.color_management {
|
||||
if let Some(enabled) = cm.enabled {
|
||||
if let Some(cm) = config.color_management
|
||||
&& let Some(enabled) = cm.enabled
|
||||
{
|
||||
set_color_management_enabled(enabled);
|
||||
}
|
||||
}
|
||||
if let Some(float) = config.float {
|
||||
if let Some(show) = float.show_pin_icon {
|
||||
if let Some(float) = config.float
|
||||
&& let Some(show) = float.show_pin_icon
|
||||
{
|
||||
set_show_float_pin_icon(show);
|
||||
}
|
||||
}
|
||||
if let Some(key) = config.pointer_revert_key {
|
||||
persistent.seat.set_pointer_revert_key(key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,17 +179,15 @@ impl<'a> Parser<'a, '_> {
|
|||
b'u' => 4,
|
||||
_ => 8,
|
||||
};
|
||||
if s.len() - pos >= len {
|
||||
if let Ok(s) = std::str::from_utf8(&s[pos..pos + len]) {
|
||||
if let Ok(n) = u32::from_str_radix(s, 16) {
|
||||
if let Some(c) = char::from_u32(n) {
|
||||
if s.len() - pos >= len
|
||||
&& let Ok(s) = std::str::from_utf8(&s[pos..pos + len])
|
||||
&& let Ok(n) = u32::from_str_radix(s, 16)
|
||||
&& let Some(c) = char::from_u32(n)
|
||||
{
|
||||
pos += len;
|
||||
let _ = write!(res, "{c}");
|
||||
break 'unicode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.extend_from_slice(&s[pos - 2..]);
|
||||
}
|
||||
b' ' | b'\t' | b'\n' => {
|
||||
|
|
@ -322,12 +320,12 @@ impl<'a> Parser<'a, '_> {
|
|||
fn parse_table_header(&mut self) -> Result<(Spanned<Key>, bool), Spanned<ParserError>> {
|
||||
let lo = self.next(false)?.span.lo;
|
||||
let mut append = false;
|
||||
if let Some(token) = self.lexer.peek(false) {
|
||||
if token.value == Token::LeftBracket {
|
||||
if let Some(token) = self.lexer.peek(false)
|
||||
&& token.value == Token::LeftBracket
|
||||
{
|
||||
let _ = self.next(false);
|
||||
append = true;
|
||||
}
|
||||
}
|
||||
let key = self.parse_key()?;
|
||||
let mut hi = self.parse_exact(Token::RightBracket, false)?.hi;
|
||||
if append {
|
||||
|
|
@ -366,14 +364,13 @@ impl<'a> Parser<'a, '_> {
|
|||
if let RawEntryMut::Occupied(mut old) =
|
||||
dst.raw_entry_mut_v1().from_key(key.value.as_str())
|
||||
{
|
||||
if append_last {
|
||||
if let Value::Array(array) = &mut old.get_mut().value {
|
||||
if append_last && let Value::Array(array) = &mut old.get_mut().value {
|
||||
array.push(value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if let Value::Table(old) = &mut old.get_mut().value {
|
||||
if let Value::Table(new) = value.value {
|
||||
if let Value::Table(old) = &mut old.get_mut().value
|
||||
&& let Value::Table(new) = value.value
|
||||
{
|
||||
for (k, v) in new {
|
||||
let mut keys = Key::new();
|
||||
keys.push_back(k);
|
||||
|
|
@ -381,7 +378,6 @@ impl<'a> Parser<'a, '_> {
|
|||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
self.error_handler
|
||||
.redefinition(ParserError::Redefined.spanned(key.span), old.key().span);
|
||||
old.shift_remove();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue