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