all: use let chains
This commit is contained in:
parent
3d5d146d65
commit
286857971a
89 changed files with 1516 additions and 1574 deletions
|
|
@ -17,12 +17,11 @@ 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) {
|
||||
write!(version_string, " ({})", commit.trim())?;
|
||||
}
|
||||
}
|
||||
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)?;
|
||||
|
|
|
|||
|
|
@ -595,13 +595,12 @@ 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)? {
|
||||
needs_lt = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
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));
|
||||
|
|
@ -674,11 +673,11 @@ 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)? {
|
||||
has_fds = true;
|
||||
break;
|
||||
}
|
||||
if let Field::Real(f) = field
|
||||
&& type_has_fds(&f.ty, protocols)?
|
||||
{
|
||||
has_fds = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
s.has_fds.set(Some(has_fds));
|
||||
|
|
@ -1519,10 +1518,10 @@ 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() {
|
||||
writeln!(f, " {},", rf.name)?;
|
||||
}
|
||||
if let Field::Real(rf) = field
|
||||
&& rf.value.is_none()
|
||||
{
|
||||
writeln!(f, " {},", rf.name)?;
|
||||
}
|
||||
}
|
||||
writeln!(f, " }})")?;
|
||||
|
|
|
|||
|
|
@ -1857,22 +1857,22 @@ 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)) {
|
||||
let o = oe.get_mut();
|
||||
if o.latched.is_empty() {
|
||||
if o.cb.is_none() {
|
||||
self.send(&ClientMessage::RemoveShortcut { seat, mods, sym });
|
||||
oe.remove();
|
||||
} else if o.cb_mask != o.registered_mask {
|
||||
o.registered_mask = o.cb_mask;
|
||||
self.send(&ClientMessage::AddShortcut2 {
|
||||
seat,
|
||||
mods: ms.mods,
|
||||
mod_mask: o.cb_mask,
|
||||
sym: ms.sym,
|
||||
});
|
||||
}
|
||||
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() {
|
||||
self.send(&ClientMessage::RemoveShortcut { seat, mods, sym });
|
||||
oe.remove();
|
||||
} else if o.cb_mask != o.registered_mask {
|
||||
o.registered_mask = o.cb_mask;
|
||||
self.send(&ClientMessage::AddShortcut2 {
|
||||
seat,
|
||||
mods: ms.mods,
|
||||
mod_mask: o.cb_mask,
|
||||
sym: ms.sym,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -441,10 +441,10 @@ 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) {
|
||||
return Ok((ty, idx));
|
||||
}
|
||||
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,13 +247,13 @@ 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() {
|
||||
crtc.active.value.set(!idle);
|
||||
change.change_object(crtc.id, |c| {
|
||||
c.change(crtc.active.id, (!idle) as _);
|
||||
});
|
||||
}
|
||||
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) {
|
||||
|
|
@ -283,10 +283,10 @@ 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() {
|
||||
res.push(fd);
|
||||
}
|
||||
if let Some(dev) = dev
|
||||
&& let Some(fd) = dev.fd.get()
|
||||
{
|
||||
res.push(fd);
|
||||
}
|
||||
}
|
||||
res
|
||||
|
|
@ -428,11 +428,11 @@ 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() {
|
||||
return uapi::fcntl_dupfd_cloexec(fd.raw(), 0)
|
||||
.map_err(|e| LibInputError::DupFd(e.into()));
|
||||
}
|
||||
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,25 +537,25 @@ 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() {
|
||||
dev.device().set_accel_profile(profile);
|
||||
self.effective
|
||||
.accel_profile
|
||||
.set(Some(dev.device().accel_profile()));
|
||||
}
|
||||
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() {
|
||||
dev.device().set_click_method(method);
|
||||
self.effective
|
||||
.click_method
|
||||
.set(Some(dev.device().click_method()));
|
||||
}
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -595,13 +595,13 @@ 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() {
|
||||
dev.device().set_left_handed(left_handed);
|
||||
self.effective
|
||||
.left_handed
|
||||
.set(Some(dev.device().left_handed()));
|
||||
}
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -629,13 +629,13 @@ 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() {
|
||||
dev.device().set_accel_speed(speed);
|
||||
self.effective
|
||||
.accel_speed
|
||||
.set(Some(dev.device().accel_speed()));
|
||||
}
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -653,13 +653,13 @@ 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() {
|
||||
dev.device().set_calibration_matrix(m);
|
||||
self.effective
|
||||
.calibration_matrix
|
||||
.set(Some(dev.device().get_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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -677,13 +677,13 @@ 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() {
|
||||
dev.device().set_tap_enabled(enabled);
|
||||
self.effective
|
||||
.tap_enabled
|
||||
.set(Some(dev.device().tap_enabled()));
|
||||
}
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -693,13 +693,13 @@ 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() {
|
||||
dev.device().set_drag_enabled(enabled);
|
||||
self.effective
|
||||
.drag_enabled
|
||||
.set(Some(dev.device().drag_enabled()));
|
||||
}
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -709,13 +709,13 @@ 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() {
|
||||
dev.device().set_drag_lock_enabled(enabled);
|
||||
self.effective
|
||||
.drag_lock_enabled
|
||||
.set(Some(dev.device().drag_lock_enabled()));
|
||||
}
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -725,13 +725,13 @@ 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() {
|
||||
dev.device().set_natural_scrolling_enabled(enabled);
|
||||
self.effective
|
||||
.natural_scrolling_enabled
|
||||
.set(Some(dev.device().natural_scrolling_enabled()));
|
||||
}
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -763,13 +763,13 @@ 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() {
|
||||
dev.device().set_middle_button_emulation_enabled(enabled);
|
||||
self.effective
|
||||
.middle_button_emulation_enabled
|
||||
.set(Some(dev.device().middle_button_emulation_enabled()));
|
||||
}
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -345,10 +345,10 @@ 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 {
|
||||
break 'dev dev;
|
||||
}
|
||||
if let Some(dev) = slots[slot].clone()
|
||||
&& dev.id == device_id
|
||||
{
|
||||
break 'dev dev;
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -200,13 +200,13 @@ 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 {
|
||||
log::error!(
|
||||
"Could not wait for cursor sync file to complete: {}",
|
||||
ErrorFmt(e)
|
||||
);
|
||||
}
|
||||
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(
|
||||
|
|
@ -216,36 +216,36 @@ impl MetalConnector {
|
|||
cursor_programming.as_ref(),
|
||||
present_fb.as_ref(),
|
||||
);
|
||||
if res.is_err() {
|
||||
if let Some(dsd_id) = direct_scanout_id {
|
||||
let fb = self.prepare_present_fb(
|
||||
&cd,
|
||||
&linear_cd,
|
||||
buffer,
|
||||
&plane,
|
||||
latched.as_ref().unwrap(),
|
||||
false,
|
||||
)?;
|
||||
present_fb = Some(fb);
|
||||
self.await_present_fb(present_fb.as_mut()).await;
|
||||
res = self.program_connector(
|
||||
version,
|
||||
&crtc,
|
||||
&plane,
|
||||
cursor_programming.as_ref(),
|
||||
present_fb.as_ref(),
|
||||
);
|
||||
if res.is_ok() {
|
||||
let mut cache = self.scanout_buffers.borrow_mut();
|
||||
if let Some(buffer) = cache.remove(&dsd_id) {
|
||||
cache.insert(
|
||||
dsd_id,
|
||||
DirectScanoutCache {
|
||||
tex: buffer.tex,
|
||||
fb: None,
|
||||
},
|
||||
);
|
||||
}
|
||||
if res.is_err()
|
||||
&& let Some(dsd_id) = direct_scanout_id
|
||||
{
|
||||
let fb = self.prepare_present_fb(
|
||||
&cd,
|
||||
&linear_cd,
|
||||
buffer,
|
||||
&plane,
|
||||
latched.as_ref().unwrap(),
|
||||
false,
|
||||
)?;
|
||||
present_fb = Some(fb);
|
||||
self.await_present_fb(present_fb.as_mut()).await;
|
||||
res = self.program_connector(
|
||||
version,
|
||||
&crtc,
|
||||
&plane,
|
||||
cursor_programming.as_ref(),
|
||||
present_fb.as_ref(),
|
||||
);
|
||||
if res.is_ok() {
|
||||
let mut cache = self.scanout_buffers.borrow_mut();
|
||||
if let Some(buffer) = cache.remove(&dsd_id) {
|
||||
cache.insert(
|
||||
dsd_id,
|
||||
DirectScanoutCache {
|
||||
tex: buffer.tex,
|
||||
fb: None,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -369,20 +369,22 @@ 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() {
|
||||
c.change(plane.in_fence_fd, sf.0.raw() as u64);
|
||||
}
|
||||
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() {
|
||||
changes.change_object(plane.id, |c| {
|
||||
c.change(plane.fb_id, fb.fb.id().0 as _);
|
||||
});
|
||||
}
|
||||
// Work around https://gitlab.freedesktop.org/drm/amd/-/issues/2186
|
||||
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 {
|
||||
|
|
@ -408,10 +410,10 @@ 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() {
|
||||
c.change(plane.in_fence_fd, sf.0.raw() as u64);
|
||||
}
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -606,11 +608,11 @@ impl MetalConnector {
|
|||
}
|
||||
}
|
||||
}
|
||||
if let Some(clear) = pass.clear {
|
||||
if clear != Color::SOLID_BLACK {
|
||||
// Background could be visible.
|
||||
return None;
|
||||
}
|
||||
if let Some(clear) = pass.clear
|
||||
&& clear != Color::SOLID_BLACK
|
||||
{
|
||||
// Background could be visible.
|
||||
return None;
|
||||
}
|
||||
ct
|
||||
};
|
||||
|
|
@ -683,10 +685,10 @@ 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) {
|
||||
break 'format f;
|
||||
}
|
||||
if let Some(opaque) = dmabuf.format.opaque
|
||||
&& let Some(f) = plane.formats.get(&opaque.drm)
|
||||
{
|
||||
break 'format f;
|
||||
}
|
||||
return None;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -759,13 +759,13 @@ 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) {
|
||||
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();
|
||||
}
|
||||
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,15 +856,13 @@ 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) {
|
||||
dev.unprocessed_change.set(true);
|
||||
log::error!("Could not dis/enable connector: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -930,11 +928,11 @@ 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) {
|
||||
dev.unprocessed_change.set(true);
|
||||
log::error!("Could not override non-desktop setting: {}", ErrorFmt(e));
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -991,11 +989,11 @@ 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) {
|
||||
dev.unprocessed_change.set(true);
|
||||
log::error!("Could not change format: {}", ErrorFmt(e));
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1376,10 +1374,10 @@ fn create_connector_display_data(
|
|||
}
|
||||
}
|
||||
for desc in &edid.base_block.descriptors {
|
||||
if let Some(desc) = desc {
|
||||
if let Descriptor::DisplayRangeLimitsAndAdditionalTiming(timings) = desc {
|
||||
break 'fetch_min_hz timings.vertical_field_rate_min as u64;
|
||||
}
|
||||
if let Some(desc) = desc
|
||||
&& let Descriptor::DisplayRangeLimitsAndAdditionalTiming(timings) = desc
|
||||
{
|
||||
break 'fetch_min_hz timings.vertical_field_rate_min as u64;
|
||||
}
|
||||
}
|
||||
0
|
||||
|
|
@ -1450,11 +1448,11 @@ 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) {
|
||||
log::warn!("Discarding previously desired mode");
|
||||
*mode_opt = None;
|
||||
}
|
||||
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,12 +1852,11 @@ 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() {
|
||||
dev.dev.leases_to_break.set(lease_id, lease);
|
||||
}
|
||||
}
|
||||
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 => {}
|
||||
|
|
@ -1908,12 +1905,11 @@ 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() {
|
||||
dev.dev.leases_to_break.set(lease_id, lease);
|
||||
}
|
||||
}
|
||||
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 {
|
||||
|
|
@ -2493,13 +2489,13 @@ 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 {
|
||||
log::warn!(
|
||||
"Cannot preserve connector whose primary plane is attached to a different crtc"
|
||||
);
|
||||
fail!(c.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();
|
||||
|
|
@ -2510,11 +2506,11 @@ impl MetalBackend {
|
|||
fail!(c.id);
|
||||
}
|
||||
}
|
||||
if let Some(m) = &dd.colorspace {
|
||||
if m.value.get() != dd.persistent.color_space.get().to_drm() {
|
||||
log::debug!("Connector has wrong colorspace");
|
||||
fail!(c.id);
|
||||
}
|
||||
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);
|
||||
|
|
@ -2541,23 +2537,22 @@ 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 {
|
||||
return;
|
||||
}
|
||||
}
|
||||
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() {
|
||||
match sync.create_signaled_sync_file() {
|
||||
Ok(sf) => {
|
||||
self.signaled_sync_file.set(Some(sf));
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("Could not create signaled sync file: {}", ErrorFmt(e));
|
||||
}
|
||||
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));
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("Could not create signaled sync file: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2675,32 +2670,31 @@ 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) {
|
||||
log::error!("Could not assign a crtc: {}", ErrorFmt(e));
|
||||
}
|
||||
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));
|
||||
}
|
||||
{
|
||||
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) {
|
||||
log::warn!("Fast commit failed, retrying with modeset: {}", ErrorFmt(e));
|
||||
flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
};
|
||||
|
|
@ -2775,11 +2769,11 @@ 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() {
|
||||
log::debug!("Connector has wrong colorspace");
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
|
|
@ -3139,10 +3133,9 @@ 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);
|
||||
}
|
||||
break 'primary_plane (plane.clone(), &format.modifiers);
|
||||
}
|
||||
}
|
||||
return Err(MetalError::NoPrimaryPlaneForConnector);
|
||||
|
|
@ -3189,12 +3182,11 @@ 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;
|
||||
}
|
||||
cursor_plane = Some(plane.clone());
|
||||
cursor_modifiers = &format.modifiers;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let mut cursor_buffers = None;
|
||||
|
|
|
|||
|
|
@ -265,12 +265,11 @@ 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) {
|
||||
log::error!("Could not kill Xwayland: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,11 +78,11 @@ 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) {
|
||||
data.invalid_request(&*obj, request);
|
||||
return Err(e);
|
||||
}
|
||||
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)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,21 +76,18 @@ 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()) {
|
||||
sigbus_impossible = stat.st_size as u64 >= len as u64;
|
||||
}
|
||||
}
|
||||
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 {
|
||||
log::debug!(
|
||||
"Client {} ({}) has created a shm buffer that might cause SIGBUS",
|
||||
client.pid_info.comm,
|
||||
client.id,
|
||||
);
|
||||
}
|
||||
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 [][..]
|
||||
|
|
|
|||
|
|
@ -200,10 +200,10 @@ 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()) {
|
||||
log::error!("Could not unlink {}: {}", path, ErrorFmt(OsError(e.0)));
|
||||
}
|
||||
if let Some(path) = &self.path
|
||||
&& let Err(e) = uapi::unlink(path.as_str())
|
||||
{
|
||||
log::error!("Could not unlink {}: {}", path, ErrorFmt(OsError(e.0)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -963,10 +963,10 @@ 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() {
|
||||
workspace = self.get_workspace_by_name(&ws.name);
|
||||
}
|
||||
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,12 +975,11 @@ 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() {
|
||||
workspace = self.get_workspace_by_name(&ws.name);
|
||||
}
|
||||
}
|
||||
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,12 +1899,12 @@ 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() {
|
||||
self.client_matchers.set(id, matcher);
|
||||
self.respond(Response::CreateClientMatcher { matcher: id });
|
||||
return Ok(());
|
||||
}
|
||||
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![];
|
||||
|
|
@ -2000,12 +1999,12 @@ 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() {
|
||||
self.window_matchers.set(id, matcher);
|
||||
self.respond(Response::CreateWindowMatcher { matcher: id });
|
||||
return Ok(());
|
||||
}
|
||||
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![];
|
||||
|
|
|
|||
|
|
@ -107,13 +107,13 @@ 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.leaf.strong_count() == 0 {
|
||||
return;
|
||||
}
|
||||
on_unmatch();
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -79,10 +79,10 @@ 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() {
|
||||
node.data().destroyed().remove(&self.id);
|
||||
}
|
||||
if let Some(node) = self.data.borrow_mut().remove(&target_id)
|
||||
&& let Some(node) = node.node.upgrade()
|
||||
{
|
||||
node.data().destroyed().remove(&self.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ impl TlmMatchClient {
|
|||
}
|
||||
|
||||
pub fn handle(&self, node: &ToplevelData) {
|
||||
if let Some(client) = &node.client {
|
||||
if self.node.get(client) {
|
||||
let data = self.downstream.get_or_create(node);
|
||||
self.downstream.update_matched(node, data, true, false);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@ 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() {
|
||||
return val;
|
||||
}
|
||||
if let Ok(size) = env::var(XCURSOR_SIZE)
|
||||
&& let Ok(val) = size.parse()
|
||||
{
|
||||
return val;
|
||||
}
|
||||
24
|
||||
});
|
||||
|
|
|
|||
|
|
@ -78,14 +78,14 @@ impl CursorUserGroup {
|
|||
}
|
||||
|
||||
fn damage_active(&self) {
|
||||
if let Some(active) = self.active.get() {
|
||||
if let Some(cursor) = active.cursor.get() {
|
||||
let (x, y) = active.pos.get();
|
||||
let x_int = x.round_down();
|
||||
let y_int = y.round_down();
|
||||
let extents = cursor.extents_at_scale(Scale::default());
|
||||
self.state.damage2(true, extents.move_(x_int, y_int));
|
||||
}
|
||||
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();
|
||||
let extents = cursor.extents_at_scale(Scale::default());
|
||||
self.state.damage2(true, extents.move_(x_int, y_int));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -136,10 +136,10 @@ impl CursorUserGroup {
|
|||
}
|
||||
|
||||
pub fn set_visible(&self, visible: bool) {
|
||||
if let Some(user) = self.active.get() {
|
||||
if let Some(cursor) = user.cursor.get() {
|
||||
cursor.set_visible(visible);
|
||||
}
|
||||
if let Some(user) = self.active.get()
|
||||
&& let Some(cursor) = user.cursor.get()
|
||||
{
|
||||
cursor.set_visible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -369,11 +369,11 @@ 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) {
|
||||
self.update_hardware_cursor();
|
||||
return;
|
||||
}
|
||||
if let Some(new) = cursor.as_ref()
|
||||
&& rc_eq(&old, new)
|
||||
{
|
||||
self.update_hardware_cursor();
|
||||
return;
|
||||
}
|
||||
old.handle_unset();
|
||||
if self.software_cursor() {
|
||||
|
|
@ -409,17 +409,17 @@ 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() {
|
||||
let (old_x, old_y) = self.pos.get();
|
||||
let old_x_int = old_x.round_down();
|
||||
let old_y_int = old_y.round_down();
|
||||
let extents = cursor.extents_at_scale(Scale::default());
|
||||
self.group
|
||||
.state
|
||||
.damage2(true, extents.move_(old_x_int, old_y_int));
|
||||
self.group.state.damage2(true, extents.move_(x_int, y_int));
|
||||
}
|
||||
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();
|
||||
let extents = cursor.extents_at_scale(Scale::default());
|
||||
self.group
|
||||
.state
|
||||
.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);
|
||||
|
|
|
|||
|
|
@ -243,12 +243,12 @@ 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() {
|
||||
handoff.pidfd.set(Some(res));
|
||||
if let Some(w) = handoff.waiter.take() {
|
||||
w.wake();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -937,24 +937,23 @@ 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() {
|
||||
cursor.tick();
|
||||
let (mut x, mut y) = cursor_user.position();
|
||||
x -= Fixed::from_int(rect.x1());
|
||||
y -= Fixed::from_int(rect.y1());
|
||||
cursor.render(&mut renderer, x, y);
|
||||
}
|
||||
}
|
||||
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());
|
||||
y -= Fixed::from_int(rect.y1());
|
||||
cursor.render(&mut renderer, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(visualizer) = visualizer {
|
||||
if let Some(cursor_rect) = cursor_rect {
|
||||
visualizer.render(&cursor_rect, &mut renderer.base);
|
||||
}
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -296,12 +296,11 @@ 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 {
|
||||
resv.set_sync_file(user, &file);
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
|
@ -429,10 +428,10 @@ 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) {
|
||||
log::error!("Could not import sync file into dmabuf: {}", ErrorFmt(e));
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ 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) {
|
||||
res.insert(s.to_string());
|
||||
}
|
||||
if name.len() > 0
|
||||
&& let Ok(s) = str::from_utf8(name)
|
||||
{
|
||||
res.insert(s.to_string());
|
||||
}
|
||||
}
|
||||
Some(res)
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ 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() {
|
||||
return Ok(buffer);
|
||||
}
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -669,10 +669,10 @@ impl VulkanBoMapping {
|
|||
|
||||
impl Drop for VulkanBoMapping {
|
||||
fn drop(&mut self) {
|
||||
if self.upload {
|
||||
if let Err(e) = self.upload() {
|
||||
log::error!("Could not upload to image: {}", ErrorFmt(e));
|
||||
}
|
||||
if self.upload
|
||||
&& let Err(e) = self.upload()
|
||||
{
|
||||
log::error!("Could not upload to image: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -721,10 +721,10 @@ fn validate_modifier(
|
|||
if disjoint && !modifier.features.contains(FormatFeatureFlags::DISJOINT) {
|
||||
return false;
|
||||
}
|
||||
if let Some(plane_count) = plane_count {
|
||||
if plane_count != modifier.planes {
|
||||
return false;
|
||||
}
|
||||
if let Some(plane_count) = plane_count
|
||||
&& plane_count != modifier.planes
|
||||
{
|
||||
return false;
|
||||
}
|
||||
let Some(limits) = modifier.transfer_limits else {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -558,15 +558,15 @@ 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() {
|
||||
log::error!(
|
||||
"Blend buffer has invalid size: {:?} != {:?}",
|
||||
bb.size(),
|
||||
self.size()
|
||||
);
|
||||
blend_buffer = None;
|
||||
}
|
||||
if let Some(bb) = &blend_buffer
|
||||
&& bb.size() != self.size()
|
||||
{
|
||||
log::error!(
|
||||
"Blend buffer has invalid size: {:?} != {:?}",
|
||||
bb.size(),
|
||||
self.size()
|
||||
);
|
||||
blend_buffer = None;
|
||||
}
|
||||
self.renderer
|
||||
.execute(
|
||||
|
|
|
|||
|
|
@ -670,11 +670,12 @@ 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 {
|
||||
p.instances += f.instances;
|
||||
continue;
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
|
@ -874,10 +875,10 @@ 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 {
|
||||
*addr += buffer.buffer.address;
|
||||
}
|
||||
if let VulkanOp::Tex(c) = op
|
||||
&& let Some(addr) = &mut c.color_management_data_address
|
||||
{
|
||||
*addr += buffer.buffer.address;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1037,28 +1038,28 @@ 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() {
|
||||
let color = memory
|
||||
.color_transforms
|
||||
.apply_to_color(clear_cd, target_cd, *clear);
|
||||
let clear_value = ClearValue {
|
||||
color: ClearColorValue {
|
||||
float32: color.to_array(target_cd.transfer_function),
|
||||
},
|
||||
};
|
||||
let use_load_clear = clear_rects.len() == 1 && {
|
||||
let rect = &clear_rects[0].rect;
|
||||
rect.offset.x == 0
|
||||
&& rect.offset.y == 0
|
||||
&& rect.extent.width == target.width
|
||||
&& rect.extent.height == target.height
|
||||
};
|
||||
if use_load_clear {
|
||||
load_clear = Some(clear_value);
|
||||
} else {
|
||||
manual_clear = Some(clear_value);
|
||||
}
|
||||
if let Some(clear) = clear
|
||||
&& clear_rects.is_not_empty()
|
||||
{
|
||||
let color = memory
|
||||
.color_transforms
|
||||
.apply_to_color(clear_cd, target_cd, *clear);
|
||||
let clear_value = ClearValue {
|
||||
color: ClearColorValue {
|
||||
float32: color.to_array(target_cd.transfer_function),
|
||||
},
|
||||
};
|
||||
let use_load_clear = clear_rects.len() == 1 && {
|
||||
let rect = &clear_rects[0].rect;
|
||||
rect.offset.x == 0
|
||||
&& rect.offset.y == 0
|
||||
&& rect.extent.width == target.width
|
||||
&& rect.extent.height == target.height
|
||||
};
|
||||
if use_load_clear {
|
||||
load_clear = Some(clear_value);
|
||||
} else {
|
||||
manual_clear = Some(clear_value);
|
||||
}
|
||||
}
|
||||
let mut rendering_attachment_info = RenderingAttachmentInfo::default()
|
||||
|
|
@ -1560,11 +1561,11 @@ 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) {
|
||||
log::error!("Could not import sync file into dmabuf: {}", ErrorFmt(e));
|
||||
log::warn!("Relying on implicit sync");
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1577,20 +1578,18 @@ 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 {
|
||||
data.last_gfx_use.set(Some(sync_file.clone()));
|
||||
}
|
||||
}
|
||||
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 {
|
||||
data.last_gfx_use.set(Some(sync_file.clone()));
|
||||
}
|
||||
}
|
||||
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,10 +1749,10 @@ 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 {
|
||||
break 'opaque false;
|
||||
}
|
||||
if let Some(a) = c.alpha
|
||||
&& a < 1.0
|
||||
{
|
||||
break 'opaque false;
|
||||
}
|
||||
if !c.opaque {
|
||||
let tex = c.tex.as_vk(&self.device.device);
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@ impl VulkanShmImage {
|
|||
damage: Option<&[Rect]>,
|
||||
) -> Result<(), VulkanError> {
|
||||
img.renderer.check_defunct()?;
|
||||
if let Some(damage) = damage {
|
||||
if damage.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
if let Some(damage) = damage
|
||||
&& damage.is_empty()
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
let copy = |full: bool, off, x, y, width, height| {
|
||||
let mut builder = BufferImageCopy2::default()
|
||||
|
|
@ -169,10 +169,10 @@ 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 {
|
||||
transfer_queue_family_idx = 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)
|
||||
|
|
|
|||
|
|
@ -102,13 +102,12 @@ impl ExtImageCopyCaptureFrameV1 {
|
|||
let mut shm_staging = self.session.shm_staging.take();
|
||||
match storage {
|
||||
WlBufferStorage::Shm { mem, stride } => {
|
||||
if let Some(b) = &shm_bridge {
|
||||
if b.physical_size() != buffer.rect.size()
|
||||
if let Some(b) = &shm_bridge
|
||||
&& (b.physical_size() != buffer.rect.size()
|
||||
|| b.format() != buffer.format
|
||||
|| b.stride() != *stride
|
||||
{
|
||||
shm_bridge = None;
|
||||
}
|
||||
|| b.stride() != *stride)
|
||||
{
|
||||
shm_bridge = None;
|
||||
}
|
||||
let bridge = match shm_bridge {
|
||||
Some(b) => b,
|
||||
|
|
@ -129,10 +128,10 @@ impl ExtImageCopyCaptureFrameV1 {
|
|||
}
|
||||
}
|
||||
};
|
||||
if let Some(s) = &shm_staging {
|
||||
if s.size() != bridge.staging_size() {
|
||||
shm_staging = None;
|
||||
}
|
||||
if let Some(s) = &shm_staging
|
||||
&& s.size() != bridge.staging_size()
|
||||
{
|
||||
shm_staging = None;
|
||||
}
|
||||
let staging = match shm_staging {
|
||||
Some(s) => s,
|
||||
|
|
|
|||
|
|
@ -125,10 +125,10 @@ impl ExtImageCopyCaptureSessionV1 {
|
|||
}
|
||||
|
||||
fn stop_pending_frame(&self) {
|
||||
if let Some(frame) = self.frame.get() {
|
||||
if let FrameStatus::Capturing | FrameStatus::Captured = self.status.get() {
|
||||
frame.fail(FrameFailureReason::Stopped);
|
||||
}
|
||||
if let Some(frame) = self.frame.get()
|
||||
&& let FrameStatus::Capturing | FrameStatus::Captured = self.status.get()
|
||||
{
|
||||
frame.fail(FrameFailureReason::Stopped);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -223,22 +223,22 @@ impl ExtImageCopyCaptureSessionV1 {
|
|||
y_off: i32,
|
||||
size: Option<(i32, i32)>,
|
||||
) {
|
||||
if self.status.get() == FrameStatus::Capturing {
|
||||
if let Some(frame) = self.frame.get() {
|
||||
frame.copy_texture(
|
||||
on,
|
||||
texture,
|
||||
cd,
|
||||
resv,
|
||||
acquire_sync,
|
||||
release_sync,
|
||||
render_hardware_cursors,
|
||||
x_off,
|
||||
y_off,
|
||||
size,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if self.status.get() == FrameStatus::Capturing
|
||||
&& let Some(frame) = self.frame.get()
|
||||
{
|
||||
frame.copy_texture(
|
||||
on,
|
||||
texture,
|
||||
cd,
|
||||
resv,
|
||||
acquire_sync,
|
||||
release_sync,
|
||||
render_hardware_cursors,
|
||||
x_off,
|
||||
y_off,
|
||||
size,
|
||||
);
|
||||
return;
|
||||
}
|
||||
self.force_capture.set(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,17 +64,17 @@ impl ExtSessionLockV1RequestHandler for ExtSessionLockV1 {
|
|||
track!(new.client, new);
|
||||
new.install()?;
|
||||
self.client.add_client_obj(&new)?;
|
||||
if !self.finished.get() {
|
||||
if let Some(node) = output.global.node() {
|
||||
if node.lock_surface.is_some() {
|
||||
return Err(ExtSessionLockV1Error::OutputAlreadyLocked);
|
||||
}
|
||||
node.set_lock_surface(Some(new.clone()));
|
||||
let pos = node.global.pos.get();
|
||||
new.change_extents(pos);
|
||||
new.surface.set_output(&node);
|
||||
self.client.state.tree_changed();
|
||||
if !self.finished.get()
|
||||
&& let Some(node) = output.global.node()
|
||||
{
|
||||
if node.lock_surface.is_some() {
|
||||
return Err(ExtSessionLockV1Error::OutputAlreadyLocked);
|
||||
}
|
||||
node.set_lock_surface(Some(new.clone()));
|
||||
let pos = node.global.pos.get();
|
||||
new.change_extents(pos);
|
||||
new.surface.set_output(&node);
|
||||
self.client.state.tree_changed();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -414,10 +414,9 @@ pub fn destroy_data_offer<T: IpcVtable>(offer: &T::Offer) {
|
|||
if src_data.offers.is_empty()
|
||||
&& src_data.role.get() == Role::Dnd
|
||||
&& data.shared.state.get().contains(OFFER_STATE_DROPPED)
|
||||
&& let Some(seat) = src_data.seat.take()
|
||||
{
|
||||
if let Some(seat) = src_data.seat.take() {
|
||||
T::unset(&seat, data.shared.role.get());
|
||||
}
|
||||
T::unset(&seat, data.shared.role.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,13 +90,13 @@ impl WlDataOffer {
|
|||
}
|
||||
|
||||
pub fn send_source_actions(&self) {
|
||||
if let Some(src) = self.data.source.get() {
|
||||
if let Some(source_actions) = src.source_data().actions.get() {
|
||||
self.client.event(SourceActions {
|
||||
self_id: self.id,
|
||||
source_actions,
|
||||
})
|
||||
}
|
||||
if let Some(src) = self.data.source.get()
|
||||
&& let Some(source_actions) = src.source_data().actions.get()
|
||||
{
|
||||
self.client.event(SourceActions {
|
||||
self_id: self.id,
|
||||
source_actions,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,51 +136,51 @@ impl JayInput {
|
|||
.map(uapi::as_bytes)
|
||||
.unwrap_or_default(),
|
||||
});
|
||||
if let Some(output) = data.data.output.get() {
|
||||
if let Some(output) = output.get() {
|
||||
self.client.event(InputDeviceOutput {
|
||||
self_id: self.id,
|
||||
id: data.id.raw(),
|
||||
output: &output.connector.name,
|
||||
});
|
||||
}
|
||||
if let Some(output) = data.data.output.get()
|
||||
&& let Some(output) = output.get()
|
||||
{
|
||||
self.client.event(InputDeviceOutput {
|
||||
self_id: self.id,
|
||||
id: data.id.raw(),
|
||||
output: &output.connector.name,
|
||||
});
|
||||
}
|
||||
if self.version >= CALIBRATION_MATRIX_SINCE {
|
||||
if let Some(m) = dev.calibration_matrix() {
|
||||
self.client.event(CalibrationMatrix {
|
||||
self_id: self.id,
|
||||
m00: m[0][0],
|
||||
m01: m[0][1],
|
||||
m02: m[0][2],
|
||||
m10: m[1][0],
|
||||
m11: m[1][1],
|
||||
m12: m[1][2],
|
||||
});
|
||||
}
|
||||
if self.version >= CALIBRATION_MATRIX_SINCE
|
||||
&& let Some(m) = dev.calibration_matrix()
|
||||
{
|
||||
self.client.event(CalibrationMatrix {
|
||||
self_id: self.id,
|
||||
m00: m[0][0],
|
||||
m01: m[0][1],
|
||||
m02: m[0][2],
|
||||
m10: m[1][0],
|
||||
m11: m[1][1],
|
||||
m12: m[1][2],
|
||||
});
|
||||
}
|
||||
if self.version >= CLICK_METHOD_SINCE {
|
||||
if let Some(click_method) = dev.click_method() {
|
||||
self.client.event(ClickMethod {
|
||||
self_id: self.id,
|
||||
click_method: match click_method {
|
||||
InputDeviceClickMethod::None => LIBINPUT_CONFIG_CLICK_METHOD_NONE.0,
|
||||
InputDeviceClickMethod::Clickfinger => {
|
||||
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER.0
|
||||
}
|
||||
InputDeviceClickMethod::ButtonAreas => {
|
||||
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS.0
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
if self.version >= CLICK_METHOD_SINCE
|
||||
&& let Some(click_method) = dev.click_method()
|
||||
{
|
||||
self.client.event(ClickMethod {
|
||||
self_id: self.id,
|
||||
click_method: match click_method {
|
||||
InputDeviceClickMethod::None => LIBINPUT_CONFIG_CLICK_METHOD_NONE.0,
|
||||
InputDeviceClickMethod::Clickfinger => {
|
||||
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER.0
|
||||
}
|
||||
InputDeviceClickMethod::ButtonAreas => {
|
||||
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS.0
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
if self.version >= MIDDLE_BUTTON_EMULATION_SINCE {
|
||||
if let Some(middle_button_emulation) = dev.middle_button_emulation_enabled() {
|
||||
self.client.event(MiddleButtonEmulation {
|
||||
self_id: self.id,
|
||||
middle_button_emulation_enabled: middle_button_emulation as _,
|
||||
});
|
||||
}
|
||||
if self.version >= MIDDLE_BUTTON_EMULATION_SINCE
|
||||
&& let Some(middle_button_emulation) = dev.middle_button_emulation_enabled()
|
||||
{
|
||||
self.client.event(MiddleButtonEmulation {
|
||||
self_id: self.id,
|
||||
middle_button_emulation_enabled: middle_button_emulation as _,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -404,10 +404,10 @@ impl JayInputRequestHandler for JayInput {
|
|||
let seat = self.seat(req.name)?;
|
||||
self.send_seat(&seat);
|
||||
for dev in self.client.state.input_device_handlers.borrow().values() {
|
||||
if let Some(attached) = dev.data.seat.get() {
|
||||
if attached.id() == seat.id() {
|
||||
self.send_input_device(dev);
|
||||
}
|
||||
if let Some(attached) = dev.data.seat.get()
|
||||
&& attached.id() == seat.id()
|
||||
{
|
||||
self.send_input_device(dev);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -216,10 +216,10 @@ impl JayRandr {
|
|||
fn get_device(&self, name: &str) -> Option<Rc<DrmDevData>> {
|
||||
let mut candidates = vec![];
|
||||
for dev in self.client.state.drm_devs.lock().values() {
|
||||
if let Some(node) = &dev.devnode {
|
||||
if node.ends_with(name) {
|
||||
candidates.push(dev.clone());
|
||||
}
|
||||
if let Some(node) = &dev.devnode
|
||||
&& node.ends_with(name)
|
||||
{
|
||||
candidates.push(dev.clone());
|
||||
}
|
||||
}
|
||||
if candidates.len() == 1 {
|
||||
|
|
|
|||
|
|
@ -56,27 +56,27 @@ impl JayReexec {
|
|||
let _ = waitpid(pid, 0);
|
||||
}
|
||||
Forked::Child { .. } => {
|
||||
if let Ok(f) = fork_with_pidfd(false) {
|
||||
if let Forked::Child { .. } = f {
|
||||
drop(p2);
|
||||
fds.sort_by_key(|fd| fd.raw());
|
||||
let c2_dup = fds.last().unwrap().raw() + 1;
|
||||
let c1_dup = c2_dup + 1;
|
||||
let _ = dup2(c1.raw(), c1_dup);
|
||||
let _ = dup2(c2.raw(), c2_dup);
|
||||
for (idx, fd) in fds.iter().enumerate() {
|
||||
let _ = dup2(fd.raw(), idx as _);
|
||||
}
|
||||
let c2_dup_dup = fds.len() as _;
|
||||
let _ = dup2(c2_dup, c2_dup_dup);
|
||||
let _ = close_range(c2_dup_dup as c::c_uint + 1, !0, 0);
|
||||
let mut pollfd = c::pollfd {
|
||||
fd: c2_dup_dup,
|
||||
events: 0,
|
||||
revents: 0,
|
||||
};
|
||||
let _ = uapi::poll(from_mut(&mut pollfd), -1);
|
||||
if let Ok(f) = fork_with_pidfd(false)
|
||||
&& let Forked::Child { .. } = f
|
||||
{
|
||||
drop(p2);
|
||||
fds.sort_by_key(|fd| fd.raw());
|
||||
let c2_dup = fds.last().unwrap().raw() + 1;
|
||||
let c1_dup = c2_dup + 1;
|
||||
let _ = dup2(c1.raw(), c1_dup);
|
||||
let _ = dup2(c2.raw(), c2_dup);
|
||||
for (idx, fd) in fds.iter().enumerate() {
|
||||
let _ = dup2(fd.raw(), idx as _);
|
||||
}
|
||||
let c2_dup_dup = fds.len() as _;
|
||||
let _ = dup2(c2_dup, c2_dup_dup);
|
||||
let _ = close_range(c2_dup_dup as c::c_uint + 1, !0, 0);
|
||||
let mut pollfd = c::pollfd {
|
||||
fd: c2_dup_dup,
|
||||
events: 0,
|
||||
revents: 0,
|
||||
};
|
||||
let _ = uapi::poll(from_mut(&mut pollfd), -1);
|
||||
}
|
||||
unsafe {
|
||||
c::_exit(0);
|
||||
|
|
|
|||
|
|
@ -655,10 +655,8 @@ impl JayScreencastRequestHandler for JayScreencast {
|
|||
slf.schedule_realloc_or_reconfigure();
|
||||
}
|
||||
|
||||
if capture_rules_changed {
|
||||
if let Some(Target::Output(o)) = self.target.get() {
|
||||
o.screencast_changed();
|
||||
}
|
||||
if capture_rules_changed && let Some(Target::Output(o)) = self.target.get() {
|
||||
o.screencast_changed();
|
||||
}
|
||||
|
||||
if self.running.get() {
|
||||
|
|
|
|||
|
|
@ -158,10 +158,8 @@ impl WlBuffer {
|
|||
return;
|
||||
}
|
||||
let had_texture = self.reset_gfx_objects(surface);
|
||||
if had_texture {
|
||||
if let Some(surface) = surface {
|
||||
self.update_texture_or_log(surface, true);
|
||||
}
|
||||
if had_texture && let Some(surface) = surface {
|
||||
self.update_texture_or_log(surface, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -234,19 +232,17 @@ impl WlBuffer {
|
|||
};
|
||||
match storage {
|
||||
WlBufferStorage::Shm { mem, stride } => {
|
||||
if sync_shm {
|
||||
if let Some(ctx) = self.client.state.render_ctx.get() {
|
||||
let tex = ctx.async_shmem_texture(
|
||||
self.format,
|
||||
self.width,
|
||||
self.height,
|
||||
*stride,
|
||||
&self.client.state.cpu_worker,
|
||||
)?;
|
||||
mem.access(|mem| tex.clone().sync_upload(mem, Region::new2(self.rect)))??;
|
||||
surface.shm_textures.front().tex.set(Some(tex));
|
||||
surface.shm_textures.front().damage.clear();
|
||||
}
|
||||
if sync_shm && let Some(ctx) = self.client.state.render_ctx.get() {
|
||||
let tex = ctx.async_shmem_texture(
|
||||
self.format,
|
||||
self.width,
|
||||
self.height,
|
||||
*stride,
|
||||
&self.client.state.cpu_worker,
|
||||
)?;
|
||||
mem.access(|mem| tex.clone().sync_upload(mem, Region::new2(self.rect)))??;
|
||||
surface.shm_textures.front().tex.set(Some(tex));
|
||||
surface.shm_textures.front().damage.clear();
|
||||
}
|
||||
}
|
||||
WlBufferStorage::Dmabuf { img, tex, .. } => {
|
||||
|
|
|
|||
|
|
@ -442,14 +442,14 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
fn maybe_constrain_pointer_node(&self) {
|
||||
if let Some(pn) = self.pointer_node() {
|
||||
if let Some(surface) = pn.node_into_surface() {
|
||||
let (mut x, mut y) = self.pointer_cursor.position();
|
||||
let (sx, sy) = surface.buffer_abs_pos.get().position();
|
||||
x -= Fixed::from_int(sx);
|
||||
y -= Fixed::from_int(sy);
|
||||
self.maybe_constrain(&surface, x, y);
|
||||
}
|
||||
if let Some(pn) = self.pointer_node()
|
||||
&& let Some(surface) = pn.node_into_surface()
|
||||
{
|
||||
let (mut x, mut y) = self.pointer_cursor.position();
|
||||
let (sx, sy) = surface.buffer_abs_pos.get().position();
|
||||
x -= Fixed::from_int(sx);
|
||||
y -= Fixed::from_int(sy);
|
||||
self.maybe_constrain(&surface, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -513,10 +513,10 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
pub fn get_kb_state(&self, keymap: &Rc<KbvmMap>) -> Rc<RefCell<KbvmState>> {
|
||||
if let Some(weak) = self.kb_states.get(&keymap.id) {
|
||||
if let Some(state) = weak.upgrade() {
|
||||
return state;
|
||||
}
|
||||
if let Some(weak) = self.kb_states.get(&keymap.id)
|
||||
&& let Some(state) = weak.upgrade()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
self.kb_states
|
||||
.lock()
|
||||
|
|
@ -548,13 +548,12 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
pub fn set_mono(&self, mono: bool) {
|
||||
if let Some(tl) = self.keyboard_node.get().node_toplevel() {
|
||||
if let Some(parent) = tl.tl_data().parent.get() {
|
||||
if let Some(container) = parent.node_into_container() {
|
||||
let node = if mono { Some(tl.deref()) } else { None };
|
||||
container.set_mono(node);
|
||||
}
|
||||
}
|
||||
if let Some(tl) = self.keyboard_node.get().node_toplevel()
|
||||
&& let Some(parent) = tl.tl_data().parent.get()
|
||||
&& let Some(container) = parent.node_into_container()
|
||||
{
|
||||
let node = if mono { Some(tl.deref()) } else { None };
|
||||
container.set_mono(node);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -573,12 +572,11 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
pub fn focus_parent(self: &Rc<Self>) {
|
||||
if let Some(tl) = self.keyboard_node.get().node_toplevel() {
|
||||
if let Some(parent) = tl.tl_data().parent.get() {
|
||||
if let Some(tl) = parent.node_toplevel() {
|
||||
self.focus_node(tl);
|
||||
}
|
||||
}
|
||||
if let Some(tl) = self.keyboard_node.get().node_toplevel()
|
||||
&& let Some(parent) = tl.tl_data().parent.get()
|
||||
&& let Some(tl) = parent.node_toplevel()
|
||||
{
|
||||
self.focus_node(tl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -642,12 +640,11 @@ impl WlSeatGlobal {
|
|||
|
||||
pub fn move_focused(self: &Rc<Self>, direction: Direction) {
|
||||
let kb_node = self.keyboard_node.get();
|
||||
if let Some(tl) = kb_node.node_toplevel() {
|
||||
if let Some(parent) = tl.tl_data().parent.get() {
|
||||
if let Some(c) = parent.node_into_container() {
|
||||
c.move_child(tl, direction);
|
||||
}
|
||||
}
|
||||
if let Some(tl) = kb_node.node_toplevel()
|
||||
&& let Some(parent) = tl.tl_data().parent.get()
|
||||
&& let Some(c) = parent.node_into_container()
|
||||
{
|
||||
c.move_child(tl, direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -662,10 +659,10 @@ impl WlSeatGlobal {
|
|||
X: ipc::IpcVtable<Device = XIpcDevice>,
|
||||
S: DynDataSource,
|
||||
{
|
||||
if let (Some(new), Some(old)) = (&src, &field.get()) {
|
||||
if new.source_data().id == old.source_data().id {
|
||||
return Ok(());
|
||||
}
|
||||
if let (Some(new), Some(old)) = (&src, &field.get())
|
||||
&& new.source_data().id == old.source_data().id
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
if let Some(new) = &src {
|
||||
ipc::attach_seat(&**new, self, ipc::Role::Selection)?;
|
||||
|
|
@ -753,10 +750,10 @@ impl WlSeatGlobal {
|
|||
if let Some(serial) = serial {
|
||||
self.selection_serial.set(serial);
|
||||
}
|
||||
if let Some(selection) = &selection {
|
||||
if selection.toplevel_drag.is_some() {
|
||||
return Err(WlSeatError::OfferHasDrag);
|
||||
}
|
||||
if let Some(selection) = &selection
|
||||
&& selection.toplevel_drag.is_some()
|
||||
{
|
||||
return Err(WlSeatError::OfferHasDrag);
|
||||
}
|
||||
self.set_selection(selection)
|
||||
}
|
||||
|
|
@ -784,10 +781,10 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
pub fn may_modify_primary_selection(&self, client: &Rc<Client>, serial: Option<u64>) -> bool {
|
||||
if let Some(serial) = serial {
|
||||
if serial < self.primary_selection_serial.get() {
|
||||
return false;
|
||||
}
|
||||
if let Some(serial) = serial
|
||||
&& serial < self.primary_selection_serial.get()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
self.keyboard_node.get().node_client_id() == Some(client.id)
|
||||
|| self.pointer_node().and_then(|n| n.node_client_id()) == Some(client.id)
|
||||
|
|
@ -935,10 +932,10 @@ impl WlSeatGlobal {
|
|||
if let Some(icon) = self.dnd_icon() {
|
||||
icon.surface().set_visible(visible);
|
||||
}
|
||||
if let Some(tl_drag) = self.toplevel_drag() {
|
||||
if let Some(tl) = tl_drag.toplevel.get() {
|
||||
tl.tl_set_visible(visible);
|
||||
}
|
||||
if let Some(tl_drag) = self.toplevel_drag()
|
||||
&& let Some(tl) = tl_drag.toplevel.get()
|
||||
{
|
||||
tl.tl_set_visible(visible);
|
||||
}
|
||||
if let Some(im) = self.input_method.get() {
|
||||
for (_, popup) in &im.popups {
|
||||
|
|
@ -1086,10 +1083,10 @@ impl CursorUserOwner for WlSeatGlobal {
|
|||
if let Some(dnd) = self.pointer_owner.dnd_icon() {
|
||||
dnd.surface().set_output(output);
|
||||
}
|
||||
if let Some(drag) = self.pointer_owner.toplevel_drag() {
|
||||
if let Some(tl) = drag.toplevel.get() {
|
||||
tl.xdg.set_output(output);
|
||||
}
|
||||
if let Some(drag) = self.pointer_owner.toplevel_drag()
|
||||
&& let Some(tl) = drag.toplevel.get()
|
||||
{
|
||||
tl.xdg.set_output(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1161,20 +1158,20 @@ impl WlSeatRequestHandler for WlSeat {
|
|||
.global
|
||||
.pointer_node()
|
||||
.and_then(|n| n.node_into_surface());
|
||||
if let Some(surface) = surface {
|
||||
if surface.client.id == self.client.id {
|
||||
let (x, y) = self.global.pointer_cursor.position();
|
||||
let (x_int, y_int) = surface
|
||||
.buffer_abs_pos
|
||||
.get()
|
||||
.translate(x.round_down(), y.round_down());
|
||||
p.send_enter(
|
||||
self.client.next_serial(),
|
||||
surface.id,
|
||||
x.apply_fract(x_int),
|
||||
y.apply_fract(y_int),
|
||||
);
|
||||
}
|
||||
if let Some(surface) = surface
|
||||
&& surface.client.id == self.client.id
|
||||
{
|
||||
let (x, y) = self.global.pointer_cursor.position();
|
||||
let (x_int, y_int) = surface
|
||||
.buffer_abs_pos
|
||||
.get()
|
||||
.translate(x.round_down(), y.round_down());
|
||||
p.send_enter(
|
||||
self.client.next_serial(),
|
||||
surface.id,
|
||||
x.apply_fract(x_int),
|
||||
y.apply_fract(y_int),
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -1184,14 +1181,14 @@ impl WlSeatRequestHandler for WlSeat {
|
|||
track!(self.client, p);
|
||||
self.client.add_client_obj(&p)?;
|
||||
self.keyboards.set(req.id, p.clone());
|
||||
if let Some(surface) = self.global.keyboard_node.get().node_into_surface() {
|
||||
if surface.client.id == self.client.id {
|
||||
p.enter(
|
||||
self.client.next_serial(),
|
||||
surface.id,
|
||||
&self.global.seat_kb_state.get().borrow().kb_state,
|
||||
);
|
||||
}
|
||||
if let Some(surface) = self.global.keyboard_node.get().node_into_surface()
|
||||
&& surface.client.id == self.client.id
|
||||
{
|
||||
p.enter(
|
||||
self.client.next_serial(),
|
||||
surface.id,
|
||||
&self.global.seat_kb_state.get().borrow().kb_state,
|
||||
);
|
||||
}
|
||||
if self.version >= REPEAT_INFO_SINCE {
|
||||
let (rate, delay) = self.global.repeat_rate.get();
|
||||
|
|
@ -1277,10 +1274,10 @@ pub fn collect_kb_foci(node: Rc<dyn Node>) -> SmallVec<[Rc<WlSeatGlobal>; 3]> {
|
|||
impl DeviceHandlerData {
|
||||
pub fn set_seat(&self, seat: Option<Rc<WlSeatGlobal>>) {
|
||||
if let Some(new) = &seat {
|
||||
if let Some(old) = self.seat.get() {
|
||||
if old.id() == new.id() {
|
||||
return;
|
||||
}
|
||||
if let Some(old) = self.seat.get()
|
||||
&& old.id() == new.id()
|
||||
{
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if self.seat.is_none() {
|
||||
|
|
@ -1340,10 +1337,10 @@ impl DeviceHandlerData {
|
|||
}
|
||||
|
||||
pub fn get_rect(&self, state: &State) -> Rect {
|
||||
if let Some(output) = self.output.get() {
|
||||
if let Some(output) = output.get() {
|
||||
return output.pos.get();
|
||||
}
|
||||
if let Some(output) = self.output.get()
|
||||
&& let Some(output) = output.get()
|
||||
{
|
||||
return output.pos.get();
|
||||
}
|
||||
state.root.extents.get()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -524,10 +524,10 @@ impl WlSeatGlobal {
|
|||
ei_seat.handle_motion_abs(time_usec, x, y);
|
||||
});
|
||||
let (x, y) = self.set_pointer_cursor_position(x, y);
|
||||
if let Some(c) = self.constraint.get() {
|
||||
if c.ty == ConstraintType::Lock || !c.contains(x.round_down(), y.round_down()) {
|
||||
c.deactivate(false);
|
||||
}
|
||||
if let Some(c) = self.constraint.get()
|
||||
&& (c.ty == ConstraintType::Lock || !c.contains(x.round_down(), y.round_down()))
|
||||
{
|
||||
c.deactivate(false);
|
||||
}
|
||||
self.state.for_each_seat_tester(|t| {
|
||||
t.send_pointer_abs(self.id, time_usec, x, y);
|
||||
|
|
@ -839,16 +839,16 @@ impl WlSeatGlobal {
|
|||
if sym == self.revert_key.get().0 && mods == 0 {
|
||||
revert_pointer_to_default = true;
|
||||
}
|
||||
if !self.state.lock.locked.get() {
|
||||
if let Some(key_mods) = scs.get(&sym) {
|
||||
for (key_mods, mask) in key_mods {
|
||||
if mods & mask == key_mods {
|
||||
shortcuts.push(InvokedShortcut {
|
||||
unmasked_mods: Modifiers(mods),
|
||||
effective_mods: Modifiers(key_mods),
|
||||
sym: KeySym(sym),
|
||||
});
|
||||
}
|
||||
if !self.state.lock.locked.get()
|
||||
&& let Some(key_mods) = scs.get(&sym)
|
||||
{
|
||||
for (key_mods, mask) in key_mods {
|
||||
if mods & mask == key_mods {
|
||||
shortcuts.push(InvokedShortcut {
|
||||
unmasked_mods: Modifiers(mods),
|
||||
effective_mods: Modifiers(key_mods),
|
||||
sym: KeySym(sym),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1169,10 +1169,8 @@ impl WlSeatGlobal {
|
|||
p.send_button(serial, time, button, state)
|
||||
});
|
||||
self.surface_pointer_frame(surface);
|
||||
if pressed {
|
||||
if let Some(node) = surface.get_focus_node() {
|
||||
self.focus_node_with_serial(node, serial);
|
||||
}
|
||||
if pressed && let Some(node) = surface.get_focus_node() {
|
||||
self.focus_node_with_serial(node, serial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1225,10 +1223,10 @@ impl WlSeatGlobal {
|
|||
impl WlSeatGlobal {
|
||||
pub fn motion_surface(&self, n: &WlSurface, x: Fixed, y: Fixed) {
|
||||
'send_motion: {
|
||||
if let Some(constraint) = self.constraint.get() {
|
||||
if constraint.ty == ConstraintType::Lock {
|
||||
break 'send_motion;
|
||||
}
|
||||
if let Some(constraint) = self.constraint.get()
|
||||
&& constraint.ty == ConstraintType::Lock
|
||||
{
|
||||
break 'send_motion;
|
||||
}
|
||||
let time = (self.pos_time_usec.get() / 1000) as u32;
|
||||
self.surface_pointer_event(Version::ALL, n, |p| p.send_motion(time, x, y));
|
||||
|
|
@ -1299,10 +1297,10 @@ impl WlSeatGlobal {
|
|||
// Unfocus callbacks
|
||||
impl WlSeatGlobal {
|
||||
pub fn unfocus_surface(&self, surface: &WlSurface) {
|
||||
if let Some(ti) = self.text_input.take() {
|
||||
if let Some(con) = ti.connection.get() {
|
||||
con.disconnect(TextDisconnectReason::FocusLost);
|
||||
}
|
||||
if let Some(ti) = self.text_input.take()
|
||||
&& let Some(con) = ti.connection.get()
|
||||
{
|
||||
con.disconnect(TextDisconnectReason::FocusLost);
|
||||
}
|
||||
if let Some(tis) = self.text_inputs.borrow().get(&surface.client.id) {
|
||||
for ti in tis.lock().values() {
|
||||
|
|
|
|||
|
|
@ -530,10 +530,8 @@ impl PointerOwner for DndPointerOwner {
|
|||
}
|
||||
target.node_on_dnd_leave(&self.dnd);
|
||||
target.node_seat_state().remove_dnd_target(seat);
|
||||
if !should_drop {
|
||||
if let Some(src) = &self.dnd.src {
|
||||
ipc::detach_seat(&**src, seat);
|
||||
}
|
||||
if !should_drop && let Some(src) = &self.dnd.src {
|
||||
ipc::detach_seat(&**src, seat);
|
||||
}
|
||||
if let Some(icon) = self.icon.get() {
|
||||
icon.disable();
|
||||
|
|
|
|||
|
|
@ -97,17 +97,16 @@ impl WlSeatGlobal {
|
|||
group_idx: u32,
|
||||
mode: u32,
|
||||
) {
|
||||
if let Some(pad) = self.tablet.pads.get(&pad) {
|
||||
if let Some(group) = pad.groups.get(group_idx as usize) {
|
||||
if group.mode.replace(mode) != mode {
|
||||
self.state.for_each_seat_tester(|t| {
|
||||
t.send_tablet_pad_mode_switch(self.id, pad.dev, time_usec, group_idx, mode)
|
||||
});
|
||||
if pad.tablet.is_some() {
|
||||
let node = pad.node.get();
|
||||
node.node_on_tablet_pad_mode_switch(&pad, group, time_usec, mode);
|
||||
}
|
||||
}
|
||||
if let Some(pad) = self.tablet.pads.get(&pad)
|
||||
&& let Some(group) = pad.groups.get(group_idx as usize)
|
||||
&& group.mode.replace(mode) != mode
|
||||
{
|
||||
self.state.for_each_seat_tester(|t| {
|
||||
t.send_tablet_pad_mode_switch(self.id, pad.dev, time_usec, group_idx, mode)
|
||||
});
|
||||
if pad.tablet.is_some() {
|
||||
let node = pad.node.get();
|
||||
node.node_on_tablet_pad_mode_switch(&pad, group, time_usec, mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -141,11 +140,11 @@ impl WlSeatGlobal {
|
|||
self.state.for_each_seat_tester(|t| {
|
||||
t.send_tablet_pad_ring(self.id, pad.dev, time_usec, ring, source, angle)
|
||||
});
|
||||
if pad.tablet.is_some() {
|
||||
if let Some(ring) = pad.rings.get(ring as usize) {
|
||||
let node = self.keyboard_node.get();
|
||||
node.node_on_tablet_pad_ring(&pad, ring, source, angle, time_usec);
|
||||
}
|
||||
if pad.tablet.is_some()
|
||||
&& let Some(ring) = pad.rings.get(ring as usize)
|
||||
{
|
||||
let node = self.keyboard_node.get();
|
||||
node.node_on_tablet_pad_ring(&pad, ring, source, angle, time_usec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -162,11 +161,11 @@ impl WlSeatGlobal {
|
|||
self.state.for_each_seat_tester(|t| {
|
||||
t.send_tablet_pad_strip(self.id, pad.dev, time_usec, strip, source, position)
|
||||
});
|
||||
if pad.tablet.is_some() {
|
||||
if let Some(strip) = pad.strips.get(strip as usize) {
|
||||
let node = pad.node.get();
|
||||
node.node_on_tablet_pad_strip(&pad, strip, source, position, time_usec);
|
||||
}
|
||||
if pad.tablet.is_some()
|
||||
&& let Some(strip) = pad.strips.get(strip as usize)
|
||||
{
|
||||
let node = pad.node.get();
|
||||
node.node_on_tablet_pad_strip(&pad, strip, source, position, time_usec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -182,11 +181,11 @@ impl WlSeatGlobal {
|
|||
self.state.for_each_seat_tester(|t| {
|
||||
t.send_tablet_pad_dial(self.id, pad.dev, time_usec, value120, dial)
|
||||
});
|
||||
if pad.tablet.is_some() {
|
||||
if let Some(dial) = pad.dials.get(dial as usize) {
|
||||
let node = self.keyboard_node.get();
|
||||
node.node_on_tablet_pad_dial(&pad, dial, value120, time_usec);
|
||||
}
|
||||
if pad.tablet.is_some()
|
||||
&& let Some(dial) = pad.dials.get(dial as usize)
|
||||
{
|
||||
let node = self.keyboard_node.get();
|
||||
node.node_on_tablet_pad_dial(&pad, dial, value120, time_usec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,12 +258,12 @@ impl TabletTool {
|
|||
tool.send_motion(x, y);
|
||||
tool.send_frame(time);
|
||||
});
|
||||
if let Some(changes) = changes {
|
||||
if changes.down == Some(true) {
|
||||
n.client.focus_stealing_serial.set(Some(serial.get()));
|
||||
if let Some(node) = n.get_focus_node() {
|
||||
self.tablet.seat.focus_node_with_serial(node, serial.get());
|
||||
}
|
||||
if let Some(changes) = changes
|
||||
&& changes.down == Some(true)
|
||||
{
|
||||
n.client.focus_stealing_serial.set(Some(serial.get()));
|
||||
if let Some(node) = n.get_focus_node() {
|
||||
self.tablet.seat.focus_node_with_serial(node, serial.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,10 +57,10 @@ impl ZwpTabletSeatV2 {
|
|||
obj.send_name(&tablet.name);
|
||||
obj.send_id(tablet.vid, tablet.pid);
|
||||
obj.send_path(&tablet.path);
|
||||
if obj.version >= BUSTYPE_SINCE {
|
||||
if let Some(bustype) = tablet.bustype {
|
||||
obj.send_bustype(bustype);
|
||||
}
|
||||
if obj.version >= BUSTYPE_SINCE
|
||||
&& let Some(bustype) = tablet.bustype
|
||||
{
|
||||
obj.send_bustype(bustype);
|
||||
}
|
||||
obj.send_done();
|
||||
tablet.bindings.add(self, &obj);
|
||||
|
|
|
|||
|
|
@ -87,11 +87,11 @@ impl ZwpTextInputManagerV3RequestHandler for ZwpTextInputManagerV3 {
|
|||
.entry(self.client.id)
|
||||
.or_default()
|
||||
.set(req.id, ti.clone());
|
||||
if let Some(surface) = seat.global.keyboard_node.get().node_into_surface() {
|
||||
if surface.client.id == self.client.id {
|
||||
ti.send_enter(&surface);
|
||||
ti.send_done();
|
||||
}
|
||||
if let Some(surface) = seat.global.keyboard_node.get().node_into_surface()
|
||||
&& surface.client.id == self.client.id
|
||||
{
|
||||
ti.send_enter(&surface);
|
||||
ti.send_done();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -252,11 +252,11 @@ impl ZwpTextInputV3RequestHandler for ZwpTextInputV3 {
|
|||
}
|
||||
let con = self.connection.get();
|
||||
if let Some(val) = pending.cursor_rect {
|
||||
if state.cursor_rectangle != val {
|
||||
if let Some(con) = &con {
|
||||
for (_, popup) in &con.input_method.popups {
|
||||
popup.schedule_positioning();
|
||||
}
|
||||
if state.cursor_rectangle != val
|
||||
&& let Some(con) = &con
|
||||
{
|
||||
for (_, popup) in &con.input_method.popups {
|
||||
popup.schedule_positioning();
|
||||
}
|
||||
}
|
||||
state.cursor_rectangle = val;
|
||||
|
|
@ -282,10 +282,8 @@ impl ZwpTextInputV3RequestHandler for ZwpTextInputV3 {
|
|||
}
|
||||
state.surrounding_text = val;
|
||||
}
|
||||
if sent_any {
|
||||
if let Some(con) = &con {
|
||||
con.input_method.send_done();
|
||||
}
|
||||
if sent_any && let Some(con) = &con {
|
||||
con.input_method.send_done();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -854,10 +854,10 @@ impl WlSurface {
|
|||
ss.surface.set_toplevel(tl.clone());
|
||||
}
|
||||
}
|
||||
if self.seat_state.is_active() {
|
||||
if let Some(tl) = &tl {
|
||||
tl.tl_surface_active_changed(true);
|
||||
}
|
||||
if self.seat_state.is_active()
|
||||
&& let Some(tl) = &tl
|
||||
{
|
||||
tl.tl_surface_active_changed(true);
|
||||
}
|
||||
self.toplevel.set(tl);
|
||||
}
|
||||
|
|
@ -977,14 +977,14 @@ impl WlSurface {
|
|||
if let Some(fs) = self.fractional_scale.get() {
|
||||
fs.send_preferred_scale();
|
||||
}
|
||||
if let Some(xsurface) = self.ext.get().into_xsurface() {
|
||||
if let Some(window) = xsurface.xwindow.get() {
|
||||
self.client
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Configure(window));
|
||||
}
|
||||
if let Some(xsurface) = self.ext.get().into_xsurface()
|
||||
&& let Some(window) = xsurface.xwindow.get()
|
||||
{
|
||||
self.client
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Configure(window));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1152,14 +1152,12 @@ impl WlSurface {
|
|||
viewport_changed = true;
|
||||
self.src_rect.set(src_rect);
|
||||
}
|
||||
if viewport_changed {
|
||||
if let Some(rect) = self.src_rect.get() {
|
||||
if self.dst_size.is_none() {
|
||||
if !rect[2].is_integer() || !rect[3].is_integer() {
|
||||
return Err(WlSurfaceError::NonIntegerViewportSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
if viewport_changed
|
||||
&& let Some(rect) = self.src_rect.get()
|
||||
&& self.dst_size.is_none()
|
||||
&& (!rect[2].is_integer() || !rect[3].is_integer())
|
||||
{
|
||||
return Err(WlSurfaceError::NonIntegerViewportSize);
|
||||
}
|
||||
let mut color_description_changed = false;
|
||||
if let Some(desc) = pending.color_description.take() {
|
||||
|
|
@ -1360,10 +1358,10 @@ impl WlSurface {
|
|||
self.is_opaque.set(is_opaque);
|
||||
}
|
||||
let mut tearing_changed = false;
|
||||
if let Some(tearing) = pending.tearing.take() {
|
||||
if self.tearing.replace(tearing) != tearing {
|
||||
tearing_changed = true;
|
||||
}
|
||||
if let Some(tearing) = pending.tearing.take()
|
||||
&& self.tearing.replace(tearing) != tearing
|
||||
{
|
||||
tearing_changed = true;
|
||||
}
|
||||
if let Some(content_type) = pending.content_type.take() {
|
||||
self.content_type.set(content_type);
|
||||
|
|
@ -1437,12 +1435,11 @@ impl WlSurface {
|
|||
pending.surface_damage.clear();
|
||||
pending.damage_full = false;
|
||||
pending.fifo_barrier_wait = false;
|
||||
if tearing_changed {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
if tl.tl_data().is_fullscreen.get() {
|
||||
self.output.get().update_presentation_type();
|
||||
}
|
||||
}
|
||||
if tearing_changed
|
||||
&& let Some(tl) = self.toplevel.get()
|
||||
&& tl.tl_data().is_fullscreen.get()
|
||||
{
|
||||
self.output.get().update_presentation_type();
|
||||
}
|
||||
self.commit_version.fetch_add(1);
|
||||
Ok(())
|
||||
|
|
@ -1878,14 +1875,14 @@ impl Node for WlSurface {
|
|||
}
|
||||
|
||||
fn node_on_focus(self: Rc<Self>, seat: &WlSeatGlobal) {
|
||||
if let Some(xsurface) = self.ext.get().into_xsurface() {
|
||||
if let Some(window) = xsurface.xwindow.get() {
|
||||
self.client
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Activate(window.data.clone()));
|
||||
}
|
||||
if let Some(xsurface) = self.ext.get().into_xsurface()
|
||||
&& let Some(window) = xsurface.xwindow.get()
|
||||
{
|
||||
self.client
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Activate(window.data.clone()));
|
||||
}
|
||||
seat.focus_surface(&self);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -604,10 +604,10 @@ fn schedule_async_upload(
|
|||
};
|
||||
let back = surface.shm_textures.back();
|
||||
let mut back_tex_opt = back.tex.get();
|
||||
if let Some(back_tex) = &back_tex_opt {
|
||||
if !back_tex.compatible_with(buf.format, buf.rect.width(), buf.rect.height(), *stride) {
|
||||
back_tex_opt = None;
|
||||
}
|
||||
if let Some(back_tex) = &back_tex_opt
|
||||
&& !back_tex.compatible_with(buf.format, buf.rect.width(), buf.rect.height(), *stride)
|
||||
{
|
||||
back_tex_opt = None;
|
||||
}
|
||||
let damage_full = || {
|
||||
back.damage.clear();
|
||||
|
|
@ -643,10 +643,10 @@ fn schedule_async_upload(
|
|||
}
|
||||
};
|
||||
let mut staging_opt = surface.shm_staging.get();
|
||||
if let Some(staging) = &staging_opt {
|
||||
if staging.size() != back_tex.staging_size() {
|
||||
staging_opt = None;
|
||||
}
|
||||
if let Some(staging) = &staging_opt
|
||||
&& staging.size() != back_tex.staging_size()
|
||||
{
|
||||
staging_opt = None;
|
||||
}
|
||||
let staging = match staging_opt {
|
||||
Some(s) => s,
|
||||
|
|
@ -682,11 +682,11 @@ impl CommitDataCollector {
|
|||
if buffer.is_shm() {
|
||||
self.shm_uploads += 1;
|
||||
}
|
||||
if !pending.explicit_sync {
|
||||
if let Some(dmabuf) = &buffer.dmabuf {
|
||||
for plane in &dmabuf.planes {
|
||||
self.implicit_dmabufs.push(plane.fd.clone());
|
||||
}
|
||||
if !pending.explicit_sync
|
||||
&& let Some(dmabuf) = &buffer.dmabuf
|
||||
{
|
||||
for plane in &dmabuf.planes {
|
||||
self.implicit_dmabufs.push(plane.fd.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,13 +79,12 @@ impl ExtSessionLockSurfaceV1RequestHandler for ExtSessionLockSurfaceV1 {
|
|||
|
||||
impl ExtSessionLockSurfaceV1 {
|
||||
pub fn destroy_node(&self) {
|
||||
if let Some(output) = &self.output.node() {
|
||||
if let Some(ls) = output.lock_surface.get() {
|
||||
if ls.node_id == self.node_id {
|
||||
output.set_lock_surface(None);
|
||||
self.client.state.tree_changed();
|
||||
}
|
||||
}
|
||||
if let Some(output) = &self.output.node()
|
||||
&& let Some(ls) = output.lock_surface.get()
|
||||
&& ls.node_id == self.node_id
|
||||
{
|
||||
output.set_lock_surface(None);
|
||||
self.client.state.tree_changed();
|
||||
}
|
||||
self.surface.destroy_node();
|
||||
self.seat_state.destroy_node(self);
|
||||
|
|
|
|||
|
|
@ -248,12 +248,12 @@ impl<T: TrayItem> SurfaceExt for T {
|
|||
}
|
||||
if data.surface.buffer.is_some() {
|
||||
data.surface.set_visible(data.visible.get());
|
||||
if let Some(node) = data.output.node() {
|
||||
if !data.attached.replace(true) {
|
||||
let link = node.tray_items.add_last(self.clone());
|
||||
data.linked_node.set(Some(link));
|
||||
node.update_tray_positions();
|
||||
}
|
||||
if let Some(node) = data.output.node()
|
||||
&& !data.attached.replace(true)
|
||||
{
|
||||
let link = node.tray_items.add_last(self.clone());
|
||||
data.linked_node.set(Some(link));
|
||||
node.update_tray_positions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,10 +260,10 @@ impl WlSubsurface {
|
|||
fn on_desync(&self) -> Result<(), WlSurfaceError> {
|
||||
let committed = &mut *self.parent.pending.borrow_mut();
|
||||
let committed = committed.subsurfaces.get_mut(&self.unique_id);
|
||||
if let Some(ps) = committed {
|
||||
if let Some(mut state) = ps.pending.state.take() {
|
||||
self.surface.apply_state(&mut state)?;
|
||||
}
|
||||
if let Some(ps) = committed
|
||||
&& let Some(mut state) = ps.pending.state.take()
|
||||
{
|
||||
self.surface.apply_state(&mut state)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,10 +59,10 @@ impl SurfaceExt for XSurface {
|
|||
}
|
||||
|
||||
fn focus_node(&self) -> Option<Rc<dyn Node>> {
|
||||
if let Some(xwindow) = self.xwindow.get() {
|
||||
if xwindow.tl_accepts_keyboard_focus() {
|
||||
return Some(xwindow.x.surface.clone());
|
||||
}
|
||||
if let Some(xwindow) = self.xwindow.get()
|
||||
&& xwindow.tl_accepts_keyboard_focus()
|
||||
{
|
||||
return Some(xwindow.x.surface.clone());
|
||||
}
|
||||
None
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,10 +183,10 @@ impl XwindowData {
|
|||
|
||||
pub fn title_changed(&self) {
|
||||
let title = self.info.title.borrow_mut();
|
||||
if let Some(w) = self.window.get() {
|
||||
if let Some(p) = w.toplevel_data.parent.get() {
|
||||
p.node_child_title_changed(w.deref(), title.as_deref().unwrap_or(""));
|
||||
}
|
||||
if let Some(w) = self.window.get()
|
||||
&& let Some(p) = w.toplevel_data.parent.get()
|
||||
{
|
||||
p.node_child_title_changed(w.deref(), title.as_deref().unwrap_or(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,12 +110,12 @@ impl XdgPopupParent for Popup {
|
|||
let state = &surface.client.state;
|
||||
if surface.buffer.is_some() {
|
||||
let mut any_set = false;
|
||||
if wl.is_none() {
|
||||
if let Some(ws) = self.parent.workspace.get() {
|
||||
self.popup.xdg.set_workspace(&ws);
|
||||
*wl = Some(ws.stacked.add_last(self.popup.clone()));
|
||||
any_set = true;
|
||||
}
|
||||
if wl.is_none()
|
||||
&& let Some(ws) = self.parent.workspace.get()
|
||||
{
|
||||
self.popup.xdg.set_workspace(&ws);
|
||||
*wl = Some(ws.stacked.add_last(self.popup.clone()));
|
||||
any_set = true;
|
||||
}
|
||||
if dl.is_none() {
|
||||
*dl = Some(
|
||||
|
|
@ -453,10 +453,10 @@ impl XdgSurface {
|
|||
new_extents = new_extents.intersect(geometry);
|
||||
}
|
||||
self.extents.set(new_extents);
|
||||
if old_extents != new_extents {
|
||||
if let Some(ext) = self.ext.get() {
|
||||
ext.extents_changed();
|
||||
}
|
||||
if old_extents != new_extents
|
||||
&& let Some(ext) = self.ext.get()
|
||||
{
|
||||
ext.extents_changed();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -518,22 +518,22 @@ impl SurfaceExt for XdgSurface {
|
|||
self: Rc<Self>,
|
||||
pending: &mut PendingState,
|
||||
) -> Result<(), WlSurfaceError> {
|
||||
if !self.have_initial_commit.get() {
|
||||
if let Some(ext) = self.ext.get() {
|
||||
ext.initial_configure()?;
|
||||
self.do_send_configure();
|
||||
self.have_initial_commit.set(true);
|
||||
}
|
||||
if !self.have_initial_commit.get()
|
||||
&& let Some(ext) = self.ext.get()
|
||||
{
|
||||
ext.initial_configure()?;
|
||||
self.do_send_configure();
|
||||
self.have_initial_commit.set(true);
|
||||
}
|
||||
if let Some(pending) = &mut pending.xdg_surface {
|
||||
if let Some(geometry) = pending.geometry.take() {
|
||||
let prev = self.geometry.replace(Some(geometry));
|
||||
if prev != Some(geometry) {
|
||||
self.update_extents();
|
||||
self.update_surface_position();
|
||||
if let Some(ext) = self.ext.get() {
|
||||
ext.geometry_changed();
|
||||
}
|
||||
if let Some(pending) = &mut pending.xdg_surface
|
||||
&& let Some(geometry) = pending.geometry.take()
|
||||
{
|
||||
let prev = self.geometry.replace(Some(geometry));
|
||||
if prev != Some(geometry) {
|
||||
self.update_extents();
|
||||
self.update_surface_position();
|
||||
if let Some(ext) = self.ext.get() {
|
||||
ext.geometry_changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -371,10 +371,10 @@ impl StackedNode for XdgPopup {
|
|||
|
||||
fn stacked_set_visible(&self, visible: bool) {
|
||||
if visible {
|
||||
if let Some(parent) = self.parent.get() {
|
||||
if !parent.visible() {
|
||||
return;
|
||||
}
|
||||
if let Some(parent) = self.parent.get()
|
||||
&& !parent.visible()
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
self.set_visible(visible);
|
||||
|
|
|
|||
|
|
@ -433,11 +433,9 @@ impl XdgToplevel {
|
|||
fn map_tiled(self: &Rc<Self>) {
|
||||
self.state.map_tiled(self.clone());
|
||||
let fullscreen = self.states.borrow().contains(&STATE_FULLSCREEN);
|
||||
if fullscreen {
|
||||
if let Some(ws) = self.xdg.workspace.get() {
|
||||
self.toplevel_data
|
||||
.set_fullscreen2(&self.state, self.clone(), &ws);
|
||||
}
|
||||
if fullscreen && let Some(ws) = self.xdg.workspace.get() {
|
||||
self.toplevel_data
|
||||
.set_fullscreen2(&self.state, self.clone(), &ws);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -470,26 +468,26 @@ impl XdgToplevel {
|
|||
}
|
||||
let surface = &self.xdg.surface;
|
||||
let should_be_mapped = surface.buffer.is_some();
|
||||
if let Some(drag) = self.drag.get() {
|
||||
if drag.is_ongoing() {
|
||||
if should_be_mapped {
|
||||
if !self.is_mapped.replace(true) {
|
||||
if let Some(seat) = drag.source.data.seat.get() {
|
||||
self.xdg.set_output(&seat.get_output());
|
||||
}
|
||||
self.toplevel_data.broadcast(self.clone());
|
||||
self.tl_set_visible(self.state.root_visible());
|
||||
self.xdg.damage();
|
||||
}
|
||||
self.extents_changed();
|
||||
} else {
|
||||
if self.is_mapped.replace(false) {
|
||||
self.tl_set_visible(false);
|
||||
self.xdg.damage();
|
||||
if let Some(drag) = self.drag.get()
|
||||
&& drag.is_ongoing()
|
||||
{
|
||||
if should_be_mapped {
|
||||
if !self.is_mapped.replace(true) {
|
||||
if let Some(seat) = drag.source.data.seat.get() {
|
||||
self.xdg.set_output(&seat.get_output());
|
||||
}
|
||||
self.toplevel_data.broadcast(self.clone());
|
||||
self.tl_set_visible(self.state.root_visible());
|
||||
self.xdg.damage();
|
||||
}
|
||||
self.extents_changed();
|
||||
} else {
|
||||
if self.is_mapped.replace(false) {
|
||||
self.tl_set_visible(false);
|
||||
self.xdg.damage();
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if self.is_mapped.replace(should_be_mapped) == should_be_mapped {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -384,10 +384,10 @@ impl ZwlrLayerSurfaceV1 {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
if self.exclusive_size.replace(exclusive_size) != exclusive_size {
|
||||
if let Some(output) = self.output.node.get() {
|
||||
output.update_exclusive_zones();
|
||||
}
|
||||
if self.exclusive_size.replace(exclusive_size) != exclusive_size
|
||||
&& let Some(output) = self.output.node.get()
|
||||
{
|
||||
output.update_exclusive_zones();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -422,10 +422,10 @@ impl ZwlrLayerSurfaceV1 {
|
|||
if height == 0 && !anchor.contains(TOP | BOTTOM) {
|
||||
return Err(ZwlrLayerSurfaceV1Error::HeightZero);
|
||||
}
|
||||
if let Some(ee) = self.exclusive_edge.get() {
|
||||
if !self.anchor.get().contains(ee) {
|
||||
return Err(ZwlrLayerSurfaceV1Error::ExclusiveEdgeNotAnchored);
|
||||
}
|
||||
if let Some(ee) = self.exclusive_edge.get()
|
||||
&& !self.anchor.get().contains(ee)
|
||||
{
|
||||
return Err(ZwlrLayerSurfaceV1Error::ExclusiveEdgeNotAnchored);
|
||||
}
|
||||
self.configure();
|
||||
Ok(())
|
||||
|
|
@ -539,10 +539,10 @@ impl ZwlrLayerSurfaceV1 {
|
|||
self.seat_state.destroy_node(self);
|
||||
self.client.state.tree_changed();
|
||||
self.last_configure.take();
|
||||
if self.exclusive_size.take().is_not_empty() {
|
||||
if let Some(node) = self.output.node() {
|
||||
node.update_exclusive_zones();
|
||||
}
|
||||
if self.exclusive_size.take().is_not_empty()
|
||||
&& let Some(node) = self.output.node()
|
||||
{
|
||||
node.update_exclusive_zones();
|
||||
}
|
||||
for popup in self.popups.lock().drain_values() {
|
||||
popup.popup.destroy_node();
|
||||
|
|
|
|||
|
|
@ -136,19 +136,19 @@ impl ExtWorkspaceGroupHandleV1RequestHandler for ExtWorkspaceGroupHandleV1 {
|
|||
}
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(manager) = self.manager.get() {
|
||||
if let Some(node) = self.output.node() {
|
||||
let mut sent_any = false;
|
||||
for ws in node.workspaces.iter() {
|
||||
if let Some(ws) = ws.ext_workspaces.get(&self.manager_id) {
|
||||
self.send_workspace_leave(&ws);
|
||||
sent_any = true;
|
||||
}
|
||||
}
|
||||
if sent_any {
|
||||
manager.schedule_done();
|
||||
if let Some(manager) = self.manager.get()
|
||||
&& let Some(node) = self.output.node()
|
||||
{
|
||||
let mut sent_any = false;
|
||||
for ws in node.workspaces.iter() {
|
||||
if let Some(ws) = ws.ext_workspaces.get(&self.manager_id) {
|
||||
self.send_workspace_leave(&ws);
|
||||
sent_any = true;
|
||||
}
|
||||
}
|
||||
if sent_any {
|
||||
manager.schedule_done();
|
||||
}
|
||||
}
|
||||
self.detach();
|
||||
self.client.remove_obj(self)?;
|
||||
|
|
|
|||
|
|
@ -77,10 +77,10 @@ impl ExtWorkspaceHandleV1 {
|
|||
};
|
||||
let mut state = 0;
|
||||
let output = ws.output.get();
|
||||
if let Some(active) = output.workspace.get() {
|
||||
if active.id == ws.id {
|
||||
state |= STATE_ACTIVE;
|
||||
}
|
||||
if let Some(active) = output.workspace.get()
|
||||
&& active.id == ws.id
|
||||
{
|
||||
state |= STATE_ACTIVE;
|
||||
}
|
||||
if ws.attention_requests.active() {
|
||||
state |= STATE_URGENT;
|
||||
|
|
|
|||
|
|
@ -55,10 +55,10 @@ impl WpDrmLeaseDeviceV1Global {
|
|||
}
|
||||
}
|
||||
for c in dev.connectors.lock().keys() {
|
||||
if let Some(o) = client.state.outputs.get(c) {
|
||||
if o.monitor_info.non_desktop {
|
||||
obj.create_connector(&o);
|
||||
}
|
||||
if let Some(o) = client.state.outputs.get(c)
|
||||
&& o.monitor_info.non_desktop
|
||||
{
|
||||
obj.create_connector(&o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,10 +55,10 @@ impl XdgActivationTokenV1RequestHandler for XdgActivationTokenV1 {
|
|||
let token = activation_token();
|
||||
self.client.state.activation_tokens.set(token, ());
|
||||
let mut tokens = self.client.activation_tokens.borrow_mut();
|
||||
if tokens.len() >= MAX_TOKENS_PER_CLIENT {
|
||||
if let Some(oldest) = tokens.pop_front() {
|
||||
self.client.state.activation_tokens.remove(&oldest);
|
||||
}
|
||||
if tokens.len() >= MAX_TOKENS_PER_CLIENT
|
||||
&& let Some(oldest) = tokens.pop_front()
|
||||
{
|
||||
self.client.state.activation_tokens.remove(&oldest);
|
||||
}
|
||||
tokens.push_back(token);
|
||||
self.send_done(token);
|
||||
|
|
|
|||
|
|
@ -72,11 +72,11 @@ impl XdgToplevelDragV1 {
|
|||
}
|
||||
|
||||
pub fn render(&self, renderer: &mut Renderer<'_>, cursor_rect: &Rect, x: i32, y: i32) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
if tl.xdg.surface.buffer.get().is_some() {
|
||||
let (x, y) = cursor_rect.translate(x - self.x_off.get(), y - self.y_off.get());
|
||||
renderer.render_xdg_surface(&tl.xdg, x, y, None)
|
||||
}
|
||||
if let Some(tl) = self.toplevel.get()
|
||||
&& tl.xdg.surface.buffer.get().is_some()
|
||||
{
|
||||
let (x, y) = cursor_rect.translate(x - self.x_off.get(), y - self.y_off.get());
|
||||
renderer.render_xdg_surface(&tl.xdg, x, y, None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -133,17 +133,17 @@ impl XdgToplevelDragV1 {
|
|||
}
|
||||
|
||||
pub fn finish_drag(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
if self.source.data.was_used() {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
let output = seat.get_output();
|
||||
let (x, y) = seat.pointer_cursor().position();
|
||||
tl.drag.take();
|
||||
tl.after_toplevel_drag(
|
||||
&output,
|
||||
x.round_down() - self.x_off.get(),
|
||||
y.round_down() - self.y_off.get(),
|
||||
);
|
||||
}
|
||||
if self.source.data.was_used()
|
||||
&& let Some(tl) = self.toplevel.get()
|
||||
{
|
||||
let output = seat.get_output();
|
||||
let (x, y) = seat.pointer_cursor().position();
|
||||
tl.drag.take();
|
||||
tl.after_toplevel_drag(
|
||||
&output,
|
||||
x.round_down() - self.x_off.get(),
|
||||
y.round_down() - self.y_off.get(),
|
||||
);
|
||||
}
|
||||
self.detach();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,16 +111,14 @@ impl ZwlrScreencopyFrameV1 {
|
|||
return Err(ZwlrScreencopyFrameV1Error::InvalidBufferFormat);
|
||||
}
|
||||
buffer.update_framebuffer()?;
|
||||
if let Some(WlBufferStorage::Shm { stride, .. }) = buffer.storage.borrow_mut().deref() {
|
||||
if *stride != self.rect.width() * 4 {
|
||||
return Err(ZwlrScreencopyFrameV1Error::InvalidBufferStride);
|
||||
}
|
||||
if let Some(WlBufferStorage::Shm { stride, .. }) = buffer.storage.borrow_mut().deref()
|
||||
&& *stride != self.rect.width() * 4
|
||||
{
|
||||
return Err(ZwlrScreencopyFrameV1Error::InvalidBufferStride);
|
||||
}
|
||||
self.buffer.set(Some(buffer));
|
||||
if !with_damage {
|
||||
if let Some(global) = self.output.get() {
|
||||
global.connector.damage();
|
||||
}
|
||||
if !with_damage && let Some(global) = self.output.get() {
|
||||
global.connector.damage();
|
||||
}
|
||||
self.with_damage.set(with_damage);
|
||||
node.screencopies
|
||||
|
|
|
|||
|
|
@ -37,15 +37,15 @@ impl ZwpLinuxDmabufV1Global {
|
|||
});
|
||||
track!(client, obj);
|
||||
client.add_client_obj(&obj)?;
|
||||
if version < FEEDBACK_SINCE_VERSION {
|
||||
if let Some(ctx) = client.state.render_ctx.get() {
|
||||
let formats = ctx.formats();
|
||||
for format in formats.values() {
|
||||
obj.send_format(format.format.drm);
|
||||
if version >= MODIFIERS_SINCE_VERSION {
|
||||
for &modifier in &format.read_modifiers {
|
||||
obj.send_modifier(format.format.drm, modifier);
|
||||
}
|
||||
if version < FEEDBACK_SINCE_VERSION
|
||||
&& let Some(ctx) = client.state.render_ctx.get()
|
||||
{
|
||||
let formats = ctx.formats();
|
||||
for format in formats.values() {
|
||||
obj.send_format(format.format.drm);
|
||||
if version >= MODIFIERS_SINCE_VERSION {
|
||||
for &modifier in &format.read_modifiers {
|
||||
obj.send_modifier(format.format.drm, modifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,17 +249,17 @@ where
|
|||
}
|
||||
let node = 'node: {
|
||||
for f in &files {
|
||||
if let Some(file) = f.file_name() {
|
||||
if file.as_bytes().starts_with_str("renderD") {
|
||||
break 'node f;
|
||||
}
|
||||
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") {
|
||||
break 'node f;
|
||||
}
|
||||
if let Some(file) = f.file_name()
|
||||
&& file.as_bytes().starts_with_str("card")
|
||||
{
|
||||
break 'node f;
|
||||
}
|
||||
}
|
||||
return Err(TestBackendError::NoDrmNode);
|
||||
|
|
|
|||
|
|
@ -533,23 +533,23 @@ 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()?)) {
|
||||
format.format = Some(*fmt);
|
||||
}
|
||||
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 {
|
||||
let mut p1 = mods.elements.elements;
|
||||
p1.read_pod_body_packed(PW_TYPE_Long, 8)?;
|
||||
while p1.len() > 0 {
|
||||
let modifier = p1.read_pod_body_packed(PW_TYPE_Long, 8)?;
|
||||
if let PwPod::Long(modifier) = modifier {
|
||||
format
|
||||
.modifiers
|
||||
.get_or_insert_default_ext()
|
||||
.push(modifier as u64);
|
||||
}
|
||||
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 {
|
||||
let modifier = p1.read_pod_body_packed(PW_TYPE_Long, 8)?;
|
||||
if let PwPod::Long(modifier) = modifier {
|
||||
format
|
||||
.modifiers
|
||||
.get_or_insert_default_ext()
|
||||
.push(modifier as u64);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,11 +71,11 @@ 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 {
|
||||
obj.data().sync_id.set(seq);
|
||||
obj.done();
|
||||
}
|
||||
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,13 +177,14 @@ 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 {
|
||||
return v
|
||||
.elements
|
||||
.elements
|
||||
.read_pod_body_packed(v.elements.ty, v.elements.child_len);
|
||||
}
|
||||
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,13 +1202,14 @@ 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 {
|
||||
return v
|
||||
.elements
|
||||
.elements
|
||||
.read_pod_body_packed(v.elements.ty, v.elements.child_len);
|
||||
}
|
||||
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,11 +325,11 @@ 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) {
|
||||
name = n;
|
||||
id = &name;
|
||||
}
|
||||
if let Some(d) = debugger
|
||||
&& let Some(n) = d.id_name(self.id)
|
||||
{
|
||||
name = n;
|
||||
id = &name;
|
||||
}
|
||||
s.field("id", id);
|
||||
s.field(
|
||||
|
|
|
|||
|
|
@ -179,10 +179,10 @@ 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() {
|
||||
render_ctx = Some(ctx);
|
||||
}
|
||||
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(
|
||||
|
|
@ -553,10 +553,10 @@ 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()) {
|
||||
maybe_add_display(&state, s).await;
|
||||
}
|
||||
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,18 +353,18 @@ 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) {
|
||||
let no_render_usage = modifiers.iter().all(|m| {
|
||||
format
|
||||
.write_modifiers
|
||||
.get(m)
|
||||
.map(|w| !w.needs_render_usage)
|
||||
.unwrap_or(false)
|
||||
});
|
||||
if no_render_usage {
|
||||
usage = BufferUsage::none();
|
||||
}
|
||||
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
|
||||
.get(m)
|
||||
.map(|w| !w.needs_render_usage)
|
||||
.unwrap_or(false)
|
||||
});
|
||||
if no_render_usage {
|
||||
usage = BufferUsage::none();
|
||||
}
|
||||
}
|
||||
let buffer = ctx.ctx.ctx.allocator().create_bo(
|
||||
|
|
|
|||
140
src/renderer.rs
140
src/renderer.rs
|
|
@ -56,10 +56,10 @@ 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() {
|
||||
self.render_surface(&surface.surface, x, y, None);
|
||||
}
|
||||
if let Some(surface) = output.lock_surface.get()
|
||||
&& surface.surface.buffer.is_some()
|
||||
{
|
||||
self.render_surface(&surface.surface, x, y, None);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -134,25 +134,25 @@ impl Renderer<'_> {
|
|||
self.state.color_manager.srgb_srgb(),
|
||||
);
|
||||
}
|
||||
if let Some(status) = &rd.status {
|
||||
if let Some(texture) = status.tex.texture() {
|
||||
let (x, y) = self.base.scale_point(x + status.tex_x, y);
|
||||
self.base.render_texture(
|
||||
&texture,
|
||||
None,
|
||||
x,
|
||||
y,
|
||||
None,
|
||||
None,
|
||||
scale,
|
||||
Some(&bar_bg),
|
||||
None,
|
||||
AcquireSync::None,
|
||||
ReleaseSync::None,
|
||||
false,
|
||||
srgb_srgb,
|
||||
);
|
||||
}
|
||||
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,
|
||||
None,
|
||||
x,
|
||||
y,
|
||||
None,
|
||||
None,
|
||||
scale,
|
||||
Some(&bar_bg),
|
||||
None,
|
||||
AcquireSync::None,
|
||||
ReleaseSync::None,
|
||||
false,
|
||||
srgb_srgb,
|
||||
);
|
||||
}
|
||||
for item in output.tray_items.iter() {
|
||||
let data = item.data();
|
||||
|
|
@ -185,13 +185,13 @@ 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 {
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -214,27 +214,27 @@ 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() {
|
||||
let (tex_width, tex_height) = texture.size();
|
||||
let x = x + (pos.width() - tex_width) / 2;
|
||||
let y = y + (pos.height() - tex_height) / 2;
|
||||
self.base.render_texture(
|
||||
&texture,
|
||||
None,
|
||||
x,
|
||||
y,
|
||||
None,
|
||||
None,
|
||||
self.base.scale,
|
||||
bounds,
|
||||
None,
|
||||
AcquireSync::None,
|
||||
ReleaseSync::None,
|
||||
false,
|
||||
self.state.color_manager.srgb_srgb(),
|
||||
);
|
||||
}
|
||||
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;
|
||||
self.base.render_texture(
|
||||
&texture,
|
||||
None,
|
||||
x,
|
||||
y,
|
||||
None,
|
||||
None,
|
||||
self.base.scale,
|
||||
bounds,
|
||||
None,
|
||||
AcquireSync::None,
|
||||
ReleaseSync::None,
|
||||
false,
|
||||
self.state.color_manager.srgb_srgb(),
|
||||
);
|
||||
}
|
||||
self.render_tl_aux(placeholder.tl_data(), bounds, true);
|
||||
}
|
||||
|
|
@ -560,25 +560,25 @@ impl Renderer<'_> {
|
|||
}
|
||||
x1 += th;
|
||||
}
|
||||
if let Some(title) = floating.title_textures.borrow().get(&self.base.scale) {
|
||||
if let Some(texture) = title.texture() {
|
||||
let (x, y) = self.base.scale_point(x1, y1);
|
||||
self.base.render_texture(
|
||||
&texture,
|
||||
None,
|
||||
x,
|
||||
y,
|
||||
None,
|
||||
None,
|
||||
self.base.scale,
|
||||
Some(&bounds),
|
||||
None,
|
||||
AcquireSync::None,
|
||||
ReleaseSync::None,
|
||||
false,
|
||||
srgb_srgb,
|
||||
);
|
||||
}
|
||||
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,
|
||||
None,
|
||||
x,
|
||||
y,
|
||||
None,
|
||||
None,
|
||||
self.base.scale,
|
||||
Some(&bounds),
|
||||
None,
|
||||
AcquireSync::None,
|
||||
ReleaseSync::None,
|
||||
false,
|
||||
srgb_srgb,
|
||||
);
|
||||
}
|
||||
let body = Rect::new_sized(
|
||||
x + bw,
|
||||
|
|
|
|||
|
|
@ -199,10 +199,10 @@ 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) {
|
||||
return;
|
||||
}
|
||||
if let Some(bounds) = bounds
|
||||
&& bound_target(&mut target_x, &mut target_y, &mut texcoord, bounds)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let target = FramebufferRect::new(
|
||||
|
|
|
|||
93
src/state.rs
93
src/state.rs
|
|
@ -500,20 +500,20 @@ 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") {
|
||||
continue;
|
||||
}
|
||||
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() {
|
||||
dev.make_render_device();
|
||||
}
|
||||
if self.render_ctx.is_none()
|
||||
&& let Some(dev) = self.drm_devs.lock().values().next()
|
||||
{
|
||||
dev.make_render_device();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -600,20 +600,21 @@ impl State {
|
|||
cursor_user_groups.render_ctx_changed();
|
||||
}
|
||||
|
||||
if let Some(ctx) = &ctx {
|
||||
if !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() {
|
||||
self.add_global(&Rc::new(WpLinuxDrmSyncobjManagerV1Global::new(
|
||||
self.globals.name(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
if let Some(config) = self.config.get() {
|
||||
config.graphics_initialized();
|
||||
}
|
||||
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()
|
||||
&& 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -761,10 +762,10 @@ impl State {
|
|||
let Some(seat) = seat else {
|
||||
return;
|
||||
};
|
||||
if let Some(config) = self.config.get() {
|
||||
if !config.auto_focus(node.tl_data()) {
|
||||
return;
|
||||
}
|
||||
if let Some(config) = self.config.get()
|
||||
&& !config.auto_focus(node.tl_data())
|
||||
{
|
||||
return;
|
||||
}
|
||||
node.node_do_focus(&seat, Direction::Unspecified);
|
||||
}
|
||||
|
|
@ -856,11 +857,11 @@ 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 {
|
||||
last.hi = serial;
|
||||
break 'update_range;
|
||||
}
|
||||
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,11 +1003,11 @@ 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() {
|
||||
u.update_hardware_cursor();
|
||||
return;
|
||||
}
|
||||
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,17 +1123,15 @@ 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() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
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,
|
||||
|
|
|
|||
16
src/text.rs
16
src/text.rs
|
|
@ -504,10 +504,10 @@ impl CpuJob for RenderJob {
|
|||
data.complete(Ok(()));
|
||||
return;
|
||||
}
|
||||
if let Some(t) = &tex {
|
||||
if !t.compatible_with(ARGB8888, rt.width, rt.height, rt.stride) {
|
||||
tex = None;
|
||||
}
|
||||
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,10 +527,10 @@ impl CpuJob for RenderJob {
|
|||
}
|
||||
};
|
||||
let mut staging_opt = data.staging.take();
|
||||
if let Some(staging) = &staging_opt {
|
||||
if staging.size() != tex.staging_size() {
|
||||
staging_opt = None;
|
||||
}
|
||||
if let Some(staging) = &staging_opt
|
||||
&& staging.size() != tex.staging_size()
|
||||
{
|
||||
staging_opt = None;
|
||||
}
|
||||
let staging = match staging_opt {
|
||||
Some(s) => s,
|
||||
|
|
|
|||
|
|
@ -593,12 +593,12 @@ 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)) {
|
||||
let node = op.child.node.clone();
|
||||
drop(seats);
|
||||
seat.start_tile_drag(&node);
|
||||
}
|
||||
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 {
|
||||
|
|
@ -1004,13 +1004,14 @@ 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) {
|
||||
parent.cnode_replace_child(self.deref(), child.clone());
|
||||
self.toplevel_data.parent.take();
|
||||
self.child_nodes.borrow_mut().clear();
|
||||
self.tl_destroy();
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
@ -1028,17 +1029,17 @@ 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() {
|
||||
self.activate_child2(&neighbor, true);
|
||||
}
|
||||
}
|
||||
self.cnode_remove_child2(&*child, true);
|
||||
cn.insert_child(child, direction);
|
||||
return;
|
||||
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),
|
||||
|
|
@ -1118,11 +1119,11 @@ 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() {
|
||||
let body = self.mono_body.get();
|
||||
self.mono_content.set(rect.at_point(body.x1(), body.y1()));
|
||||
}
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1154,10 +1155,8 @@ impl ContainerNode {
|
|||
if set || propagate {
|
||||
self.toplevel_data.set_wants_attention(set);
|
||||
}
|
||||
if propagate {
|
||||
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||
parent.cnode_child_attention_request_changed(self, set);
|
||||
}
|
||||
if propagate && let Some(parent) = self.toplevel_data.parent.get() {
|
||||
parent.cnode_child_attention_request_changed(self, set);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1751,10 +1750,10 @@ 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 {
|
||||
self.button(id, tool.seat(), time_usec, pressed, BTN_LEFT);
|
||||
}
|
||||
if let Some(changes) = changes
|
||||
&& let Some(pressed) = changes.down
|
||||
{
|
||||
self.button(id, tool.seat(), time_usec, pressed, BTN_LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2047,14 +2046,13 @@ 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);
|
||||
}
|
||||
parent.cnode_resize_child(&*self, x1, y1, x2, y2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -426,10 +426,8 @@ impl FloatNode {
|
|||
if update_visible {
|
||||
self.stacked_set_visible(ws.float_visible());
|
||||
}
|
||||
if update_pinned {
|
||||
if let Some(pl) = &*self.pinned_link.borrow_mut() {
|
||||
ws.output.get().pinned.add_last_existing(pl);
|
||||
}
|
||||
if update_pinned && let Some(pl) = &*self.pinned_link.borrow_mut() {
|
||||
ws.output.get().pinned.add_last_existing(pl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -588,10 +586,10 @@ impl FloatNode {
|
|||
if !pressed {
|
||||
return;
|
||||
}
|
||||
if cursor_data.op_type == OpType::Move {
|
||||
if let Some(tl) = self.child.get() {
|
||||
tl.node_do_focus(seat, Direction::Unspecified);
|
||||
}
|
||||
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,
|
||||
|
|
@ -600,12 +598,11 @@ 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;
|
||||
}
|
||||
drop(cursors);
|
||||
toplevel_set_floating(&self.state, tl, false);
|
||||
return;
|
||||
}
|
||||
cursor_data.op_active = true;
|
||||
let pos = self.position.get();
|
||||
|
|
@ -830,16 +827,16 @@ 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 {
|
||||
self.button(
|
||||
CursorType::TabletTool(tool.id),
|
||||
tool.cursor(),
|
||||
tool.seat(),
|
||||
time_usec,
|
||||
pressed,
|
||||
);
|
||||
}
|
||||
if let Some(changes) = changes
|
||||
&& let Some(pressed) = changes.down
|
||||
{
|
||||
self.button(
|
||||
CursorType::TabletTool(tool.id),
|
||||
tool.cursor(),
|
||||
tool.seat(),
|
||||
time_usec,
|
||||
pressed,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1367,15 +1367,15 @@ 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() {
|
||||
tree.push(FoundNode {
|
||||
node: ls.clone(),
|
||||
x,
|
||||
y,
|
||||
});
|
||||
return ls.node_find_tree_at(x, y, tree, usecase);
|
||||
}
|
||||
if usecase != FindTreeUsecase::SelectToplevel
|
||||
&& let Some(ls) = self.lock_surface.get()
|
||||
{
|
||||
tree.push(FoundNode {
|
||||
node: ls.clone(),
|
||||
x,
|
||||
y,
|
||||
});
|
||||
return ls.node_find_tree_at(x, y, tree, usecase);
|
||||
}
|
||||
return FindTreeResult::AcceptsInput;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -444,10 +444,11 @@ impl ToplevelData {
|
|||
return;
|
||||
}
|
||||
self.changed_properties.set(props | change);
|
||||
if props.is_none() && change.is_some() {
|
||||
if let Some(node) = self.slf.upgrade() {
|
||||
mgr.changed(node);
|
||||
}
|
||||
if props.is_none()
|
||||
&& change.is_some()
|
||||
&& let Some(node) = self.slf.upgrade()
|
||||
{
|
||||
mgr.changed(node);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -878,10 +879,10 @@ 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() {
|
||||
return Some(container);
|
||||
}
|
||||
if let Some(parent) = tl.tl_data().parent.get()
|
||||
&& let Some(container) = parent.node_into_container()
|
||||
{
|
||||
return Some(container);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,10 +228,10 @@ 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() {
|
||||
surface.send_feedback(&fb);
|
||||
}
|
||||
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,10 +242,10 @@ 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() {
|
||||
surface.send_feedback(&fb);
|
||||
}
|
||||
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,36 +376,36 @@ 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() {
|
||||
let new = match new.node_into_container() {
|
||||
Some(c) => c,
|
||||
_ => {
|
||||
log::error!("cnode_replace_child called with non-container new");
|
||||
return;
|
||||
}
|
||||
};
|
||||
self.set_container(&new);
|
||||
return;
|
||||
}
|
||||
if let Some(container) = self.container.get()
|
||||
&& container.node_id() == old.node_id()
|
||||
{
|
||||
let new = match new.node_into_container() {
|
||||
Some(c) => c,
|
||||
_ => {
|
||||
log::error!("cnode_replace_child called with non-container new");
|
||||
return;
|
||||
}
|
||||
};
|
||||
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() {
|
||||
self.discard_child_properties(&*container);
|
||||
self.container.set(None);
|
||||
self.state.damage(self.position.get());
|
||||
return;
|
||||
}
|
||||
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() {
|
||||
self.remove_fullscreen_node();
|
||||
return;
|
||||
}
|
||||
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,10 +436,10 @@ 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 {
|
||||
source.workspace.take();
|
||||
}
|
||||
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() {
|
||||
|
|
@ -459,11 +459,11 @@ 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() {
|
||||
link.prepend_existing(ws);
|
||||
break 'link;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ impl AsyncEvent {
|
|||
}
|
||||
|
||||
pub fn trigger(&self) {
|
||||
if self.triggers.fetch_add(1) == 0 {
|
||||
if let Some(waker) = self.waker.take() {
|
||||
waker.wake();
|
||||
}
|
||||
if self.triggers.fetch_add(1) == 0
|
||||
&& let Some(waker) = self.waker.take()
|
||||
{
|
||||
waker.wake();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,13 +133,12 @@ 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 {
|
||||
set_deathsig();
|
||||
return 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 {
|
||||
|
|
|
|||
|
|
@ -165,10 +165,8 @@ 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) {
|
||||
break 'path path;
|
||||
}
|
||||
if !need_primary && let Ok(path) = render_node_name(fd) {
|
||||
break 'path path;
|
||||
}
|
||||
device_node_name(fd)?
|
||||
};
|
||||
|
|
@ -441,10 +439,10 @@ 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() {
|
||||
return Ok(h);
|
||||
}
|
||||
if let Some(h) = handles.get(&handle)
|
||||
&& let Some(h) = h.upgrade()
|
||||
{
|
||||
return Ok(h);
|
||||
}
|
||||
let h = Rc::new(GemHandle {
|
||||
master: self.clone(),
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ impl JaySelectToplevelEventHandler for UsrJaySelectToplevel {
|
|||
Some(tl)
|
||||
};
|
||||
'send: {
|
||||
if self.version >= ID_SINCE {
|
||||
if let Some(tl) = tl {
|
||||
tl.owner.set(Some(slf.clone()));
|
||||
break 'send;
|
||||
}
|
||||
if self.version >= ID_SINCE
|
||||
&& let Some(tl) = tl
|
||||
{
|
||||
tl.owner.set(Some(slf.clone()));
|
||||
break 'send;
|
||||
}
|
||||
self.send(tl);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@ 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) {
|
||||
owner.modifier(format, ev.modifier);
|
||||
}
|
||||
if let Some(owner) = self.owner.get()
|
||||
&& let Some(format) = formats().get(&ev.format)
|
||||
{
|
||||
owner.modifier(format, ev.modifier);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,13 +102,13 @@ impl Incoming {
|
|||
Some(e) => XconError::ExtensionError(e, code),
|
||||
_ => XconError::CoreError(code),
|
||||
};
|
||||
if let Some(first) = reply_handlers.front() {
|
||||
if first.serial() == serial {
|
||||
let handler = reply_handlers.pop_front().unwrap();
|
||||
drop(reply_handlers);
|
||||
handler.handle_error(e);
|
||||
break 'handle_error;
|
||||
}
|
||||
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: {}",
|
||||
|
|
@ -116,36 +116,32 @@ impl Incoming {
|
|||
);
|
||||
}
|
||||
1 => {
|
||||
if let Some(first) = reply_handlers.front() {
|
||||
if first.serial() == serial {
|
||||
let handler = reply_handlers.pop_front().unwrap();
|
||||
drop(reply_handlers);
|
||||
let mut fds = vec![];
|
||||
if handler.has_fds() {
|
||||
let num_fds = msg_buf[1] as usize;
|
||||
if self.incoming.fds.len() < num_fds {
|
||||
return Err(XconError::MissingFds);
|
||||
}
|
||||
fds.extend(self.incoming.fds.drain(..num_fds));
|
||||
if let Some(first) = reply_handlers.front()
|
||||
&& first.serial() == serial
|
||||
{
|
||||
let handler = reply_handlers.pop_front().unwrap();
|
||||
drop(reply_handlers);
|
||||
let mut fds = vec![];
|
||||
if handler.has_fds() {
|
||||
let num_fds = msg_buf[1] as usize;
|
||||
if self.incoming.fds.len() < num_fds {
|
||||
return Err(XconError::MissingFds);
|
||||
}
|
||||
let length =
|
||||
u32::from_ne_bytes([msg_buf[4], msg_buf[5], msg_buf[6], msg_buf[7]])
|
||||
as usize;
|
||||
if length > MAX_LENGTH_UNITS {
|
||||
return Err(XconError::ExcessiveMessageSize);
|
||||
}
|
||||
let length = length * 4;
|
||||
self.incoming.fill_msg_buf(length, &mut msg_buf).await?;
|
||||
let mut parser = unsafe {
|
||||
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),
|
||||
)?;
|
||||
fds.extend(self.incoming.fds.drain(..num_fds));
|
||||
}
|
||||
let length =
|
||||
u32::from_ne_bytes([msg_buf[4], msg_buf[5], msg_buf[6], msg_buf[7]])
|
||||
as usize;
|
||||
if length > MAX_LENGTH_UNITS {
|
||||
return Err(XconError::ExcessiveMessageSize);
|
||||
}
|
||||
let length = length * 4;
|
||||
self.incoming.fill_msg_buf(length, &mut msg_buf).await?;
|
||||
let mut parser = unsafe {
|
||||
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))?;
|
||||
}
|
||||
}
|
||||
ev => 'handle_event: {
|
||||
|
|
|
|||
|
|
@ -185,10 +185,10 @@ 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 {
|
||||
self.active_offer.take();
|
||||
}
|
||||
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,10 +782,10 @@ impl Wm {
|
|||
destroy_data_offer::<T>(&offer);
|
||||
return;
|
||||
}
|
||||
if !enhanced.active.replace(true) {
|
||||
if let Some(old) = sd.active_offer.set(Some(enhanced)) {
|
||||
old.active.set(false);
|
||||
}
|
||||
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(),
|
||||
|
|
@ -895,11 +895,11 @@ impl Wm {
|
|||
seat: SeatId,
|
||||
source: DataSourceId,
|
||||
) {
|
||||
if let Some(cur) = sd.sources.get(&seat) {
|
||||
if cur.source_data().id == source {
|
||||
sd.sources.remove(&seat);
|
||||
destroy_data_source::<T>(&cur);
|
||||
}
|
||||
if let Some(cur) = sd.sources.get(&seat)
|
||||
&& cur.source_data().id == source
|
||||
{
|
||||
sd.sources.remove(&seat);
|
||||
destroy_data_source::<T>(&cur);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1010,12 +1010,12 @@ impl Wm {
|
|||
// log::info!("xwm or => return");
|
||||
return;
|
||||
}
|
||||
if initiator == Initiator::X {
|
||||
if let Some(window) = window.window.get() {
|
||||
let seats = self.state.globals.seats.lock();
|
||||
for seat in seats.values() {
|
||||
seat.focus_toplevel(window.clone());
|
||||
}
|
||||
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 {
|
||||
|
|
@ -1237,15 +1237,15 @@ 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 data.is_ancestor_of(w.clone()) {
|
||||
log::error!("Cannot set WM_TRANSIENT_FOR because it would create a cycle");
|
||||
return;
|
||||
}
|
||||
w.children.set(data.window_id, data.clone());
|
||||
data.parent.set(Some(w.clone()));
|
||||
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;
|
||||
}
|
||||
w.children.set(data.window_id, data.clone());
|
||||
data.parent.set(Some(w.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1506,11 +1506,11 @@ 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() {
|
||||
data.info.pid.set(Some(*first));
|
||||
break;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1886,21 +1886,20 @@ 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 {
|
||||
let prev_pid = prev.info.pid.get();
|
||||
let new_pid = window.info.pid.get();
|
||||
if prev_pid.is_some()
|
||||
&& prev_pid == new_pid
|
||||
&& revent.serial() >= self.last_input_serial
|
||||
&& w.x.surface.node_visible()
|
||||
{
|
||||
// log::info!("xwm ACCEPT");
|
||||
focus_window = new_window;
|
||||
send_to_x = false;
|
||||
}
|
||||
}
|
||||
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()
|
||||
&& prev_pid == new_pid
|
||||
&& revent.serial() >= self.last_input_serial
|
||||
&& w.x.surface.node_visible()
|
||||
{
|
||||
// log::info!("xwm ACCEPT");
|
||||
focus_window = new_window;
|
||||
send_to_x = false;
|
||||
}
|
||||
}
|
||||
let fw = focus_window.cloned();
|
||||
|
|
@ -2132,13 +2131,12 @@ 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() {
|
||||
window.tl_destroy();
|
||||
window.update_toplevel();
|
||||
window.map_status_changed();
|
||||
}
|
||||
if data.info.override_redirect.replace(or) != or
|
||||
&& let Some(window) = data.window.get()
|
||||
{
|
||||
window.tl_destroy();
|
||||
window.update_toplevel();
|
||||
window.map_status_changed();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2283,10 +2281,10 @@ impl Wm {
|
|||
Some(d) => d,
|
||||
_ => return Ok(()),
|
||||
};
|
||||
if let Some(window) = data.window.get() {
|
||||
if window.is_mapped() {
|
||||
return Ok(());
|
||||
}
|
||||
if let Some(window) = data.window.get()
|
||||
&& window.is_mapped()
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
let de = data.info.pending_extents.get();
|
||||
let mut x1 = de.x1();
|
||||
|
|
@ -2346,11 +2344,11 @@ 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() {
|
||||
self.set_wm_state(data, ICCCM_WM_STATE_NORMAL).await;
|
||||
return false;
|
||||
}
|
||||
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,10 +2459,10 @@ impl Wm {
|
|||
minimized = self.handle_minimize_requested(data).await;
|
||||
}
|
||||
}
|
||||
if fullscreen != data.info.fullscreen.get() {
|
||||
if let Some(w) = data.window.get() {
|
||||
w.tl_set_fullscreen(fullscreen, None);
|
||||
}
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -340,10 +340,10 @@ 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) {
|
||||
window_management_key = Some(key);
|
||||
}
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -387,35 +387,35 @@ impl DrmDeviceMatch {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(syspath) = syspath {
|
||||
if d.syspath() != *syspath {
|
||||
return false;
|
||||
}
|
||||
if let Some(syspath) = syspath
|
||||
&& d.syspath() != *syspath
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(devnode) = devnode {
|
||||
if d.devnode() != *devnode {
|
||||
return false;
|
||||
}
|
||||
if let Some(devnode) = devnode
|
||||
&& d.devnode() != *devnode
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(model) = model_name {
|
||||
if d.model() != *model {
|
||||
return false;
|
||||
}
|
||||
if let Some(model) = model_name
|
||||
&& d.model() != *model
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(vendor) = vendor_name {
|
||||
if d.vendor() != *vendor {
|
||||
return false;
|
||||
}
|
||||
if let Some(vendor) = vendor_name
|
||||
&& d.vendor() != *vendor
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(vendor) = vendor {
|
||||
if d.pci_id().vendor != *vendor {
|
||||
return false;
|
||||
}
|
||||
if let Some(vendor) = vendor
|
||||
&& d.pci_id().vendor != *vendor
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(model) = model {
|
||||
if d.pci_id().model != *model {
|
||||
return false;
|
||||
}
|
||||
if let Some(model) = model
|
||||
&& d.pci_id().model != *model
|
||||
{
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
@ -449,10 +449,10 @@ impl InputMatch {
|
|||
is_gesture,
|
||||
is_switch,
|
||||
} => {
|
||||
if let Some(name) = name {
|
||||
if d.name() != *name {
|
||||
return false;
|
||||
}
|
||||
if let Some(name) = name
|
||||
&& d.name() != *name
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(tag) = tag {
|
||||
let matches = apply_recursive_match(
|
||||
|
|
@ -466,22 +466,22 @@ impl InputMatch {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(syspath) = syspath {
|
||||
if d.syspath() != *syspath {
|
||||
return false;
|
||||
}
|
||||
if let Some(syspath) = syspath
|
||||
&& d.syspath() != *syspath
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(devnode) = devnode {
|
||||
if d.devnode() != *devnode {
|
||||
return false;
|
||||
}
|
||||
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 {
|
||||
return false;
|
||||
}
|
||||
if let Some(is) = *$is
|
||||
&& d.has_capability(jay_config::input::capability::$cap) != is
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -527,10 +527,10 @@ 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) {
|
||||
c.set_keymap(km);
|
||||
}
|
||||
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 {
|
||||
|
|
@ -590,25 +590,25 @@ impl OutputMatch {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(connector) = &connector {
|
||||
if c.name() != *connector {
|
||||
return false;
|
||||
}
|
||||
if let Some(connector) = &connector
|
||||
&& c.name() != *connector
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(serial_number) = &serial_number {
|
||||
if c.serial_number() != *serial_number {
|
||||
return false;
|
||||
}
|
||||
if let Some(serial_number) = &serial_number
|
||||
&& c.serial_number() != *serial_number
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(manufacturer) = &manufacturer {
|
||||
if c.manufacturer() != *manufacturer {
|
||||
return false;
|
||||
}
|
||||
if let Some(manufacturer) = &manufacturer
|
||||
&& c.manufacturer() != *manufacturer
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(model) = &model {
|
||||
if c.model() != *model {
|
||||
return false;
|
||||
}
|
||||
if let Some(model) = &model
|
||||
&& c.model() != *model
|
||||
{
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
@ -624,10 +624,10 @@ 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 {
|
||||
return false;
|
||||
}
|
||||
if let Some(connector) = &connector
|
||||
&& c.name() != *connector
|
||||
{
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
@ -679,10 +679,10 @@ impl Output {
|
|||
c.set_vrr_cursor_hz(hz);
|
||||
}
|
||||
}
|
||||
if let Some(tearing) = &self.tearing {
|
||||
if let Some(mode) = tearing.mode {
|
||||
c.set_tearing_mode(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,10 +858,10 @@ 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) {
|
||||
action();
|
||||
}
|
||||
if match_.matches(dev, &state)
|
||||
&& let Some(action) = actions.get(&ev)
|
||||
{
|
||||
action();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -1214,10 +1214,10 @@ 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 {
|
||||
set_tearing_mode(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 {
|
||||
|
|
@ -1226,20 +1226,20 @@ 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 {
|
||||
set_x_scaling_mode(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 {
|
||||
set_color_management_enabled(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 {
|
||||
set_show_float_pin_icon(show);
|
||||
}
|
||||
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,16 +179,14 @@ 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) {
|
||||
pos += len;
|
||||
let _ = write!(res, "{c}");
|
||||
break 'unicode;
|
||||
}
|
||||
}
|
||||
}
|
||||
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..]);
|
||||
}
|
||||
|
|
@ -322,11 +320,11 @@ 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 {
|
||||
let _ = self.next(false);
|
||||
append = true;
|
||||
}
|
||||
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;
|
||||
|
|
@ -366,21 +364,19 @@ 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 {
|
||||
array.push(value);
|
||||
return;
|
||||
}
|
||||
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 {
|
||||
for (k, v) in new {
|
||||
let mut keys = Key::new();
|
||||
keys.push_back(k);
|
||||
self.insert(old, &mut keys, v, false, false);
|
||||
}
|
||||
return;
|
||||
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);
|
||||
self.insert(old, &mut keys, v, false, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
self.error_handler
|
||||
.redefinition(ParserError::Redefined.spanned(key.span), old.key().span);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue