Update smithay
This commit is contained in:
parent
d9e3d60a37
commit
8561ab672b
7 changed files with 49 additions and 55 deletions
|
|
@ -16,6 +16,7 @@ use crate::{
|
|||
|
||||
use anyhow::{Context, Result};
|
||||
use cosmic_protocols::screencopy::v1::server::zcosmic_screencopy_session_v1::FailureReason;
|
||||
use libc::dev_t;
|
||||
use smithay::{
|
||||
backend::{
|
||||
allocator::{
|
||||
|
|
@ -58,7 +59,7 @@ use smithay::{
|
|||
Device as _,
|
||||
},
|
||||
input::{self, Libinput},
|
||||
nix::{fcntl::OFlag, sys::stat::dev_t},
|
||||
rustix::fs::OFlags,
|
||||
wayland_protocols::wp::{
|
||||
linux_dmabuf::zv1::server::zwp_linux_dmabuf_feedback_v1,
|
||||
presentation_time::server::wp_presentation_feedback,
|
||||
|
|
@ -82,7 +83,6 @@ use std::{
|
|||
collections::{HashMap, HashSet},
|
||||
ffi::CStr,
|
||||
fmt,
|
||||
os::unix::io::FromRawFd,
|
||||
path::PathBuf,
|
||||
time::Duration,
|
||||
};
|
||||
|
|
@ -418,23 +418,21 @@ impl State {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
let fd = DrmDeviceFd::new(unsafe {
|
||||
DeviceFd::from_raw_fd(
|
||||
self.backend
|
||||
.kms()
|
||||
.session
|
||||
.open(
|
||||
&path,
|
||||
OFlag::O_RDWR | OFlag::O_CLOEXEC | OFlag::O_NOCTTY | OFlag::O_NONBLOCK,
|
||||
let fd = DrmDeviceFd::new(DeviceFd::from(
|
||||
self.backend
|
||||
.kms()
|
||||
.session
|
||||
.open(
|
||||
&path,
|
||||
OFlags::RDWR | OFlags::CLOEXEC | OFlags::NOCTTY | OFlags::NONBLOCK,
|
||||
)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"Failed to optain file descriptor for drm device: {}",
|
||||
path.display()
|
||||
)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"Failed to optain file descriptor for drm device: {}",
|
||||
path.display()
|
||||
)
|
||||
})?,
|
||||
)
|
||||
});
|
||||
})?,
|
||||
));
|
||||
let (drm, notifier) = DrmDevice::new(fd.clone(), false)
|
||||
.with_context(|| format!("Failed to initialize drm device for: {}", path.display()))?;
|
||||
let drm_node = DrmNode::from_dev_id(dev)?;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use smithay::reexports::{
|
||||
calloop::{generic::Generic, Interest, LoopHandle, Mode, PostAction},
|
||||
nix::{fcntl, unistd},
|
||||
rustix,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
|
|
@ -50,20 +50,24 @@ impl From<UnixStream> for StreamWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
unsafe fn set_cloexec(fd: RawFd) -> rustix::io::Result<()> {
|
||||
if fd == -1 {
|
||||
return Err(rustix::io::Errno::BADF);
|
||||
}
|
||||
let fd = BorrowedFd::borrow_raw(fd);
|
||||
let flags = rustix::io::fcntl_getfd(fd)?;
|
||||
rustix::io::fcntl_setfd(fd, flags | rustix::io::FdFlags::CLOEXEC)
|
||||
}
|
||||
|
||||
pub fn setup_socket(handle: LoopHandle<State>, state: &State) -> Result<()> {
|
||||
if let Ok(fd_num) = std::env::var("COSMIC_SESSION_SOCK") {
|
||||
if let Ok(fd) = fd_num.parse::<RawFd>() {
|
||||
// set CLOEXEC
|
||||
let flags = fcntl::fcntl(fd, fcntl::FcntlArg::F_GETFD);
|
||||
let result = flags
|
||||
.map(|f| fcntl::FdFlag::from_bits(f).unwrap() | fcntl::FdFlag::FD_CLOEXEC)
|
||||
.and_then(|f| fcntl::fcntl(fd, fcntl::FcntlArg::F_SETFD(f)));
|
||||
let mut session_socket = match result {
|
||||
let mut session_socket = match unsafe { set_cloexec(fd) } {
|
||||
// CLOEXEC worked and we can startup with session IPC
|
||||
Ok(_) => unsafe { UnixStream::from_raw_fd(fd) },
|
||||
// CLOEXEC didn't work, something is wrong with the fd, just close it
|
||||
Err(err) => {
|
||||
let _ = unistd::close(fd);
|
||||
unsafe { rustix::io::close(fd) };
|
||||
return Err(err).with_context(|| "Failed to setup session socket");
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -545,7 +545,7 @@ impl MoveGrab {
|
|||
None
|
||||
};
|
||||
|
||||
handle.unset_grab(state, serial, time);
|
||||
handle.unset_grab(state, serial, time, true);
|
||||
|
||||
{
|
||||
let cursor_state = self.seat.user_data().get::<CursorState>().unwrap();
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
|||
|
||||
// It is impossible to get `min_size` and `max_size` of dead toplevel, so we return early.
|
||||
if !self.window.alive() {
|
||||
handle.unset_grab(data, event.serial, event.time);
|
||||
handle.unset_grab(data, event.serial, event.time, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
|||
handle.button(data, event);
|
||||
if handle.current_pressed().is_empty() {
|
||||
// No more buttons are pressed, release the grab.
|
||||
handle.unset_grab(data, event.serial, event.time);
|
||||
handle.unset_grab(data, event.serial, event.time, true);
|
||||
|
||||
// If toplevel is dead, we can't resize it, so we return early.
|
||||
if !self.window.alive() {
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ impl PointerGrab<State> for ResizeForkGrab {
|
|||
let first_elem = iter.next();
|
||||
let second_elem = iter.next();
|
||||
if first_elem.is_none() || second_elem.is_none() {
|
||||
return handle.unset_grab(data, event.serial, event.time);
|
||||
return handle.unset_grab(data, event.serial, event.time, true);
|
||||
};
|
||||
|
||||
match tree.get_mut(&self.node).unwrap().data_mut() {
|
||||
|
|
@ -196,7 +196,7 @@ impl PointerGrab<State> for ResizeForkGrab {
|
|||
let blocker = TilingLayout::update_positions(&output, tree, gaps);
|
||||
tiling_layer.pending_blockers.extend(blocker);
|
||||
} else {
|
||||
handle.unset_grab(data, event.serial, event.time);
|
||||
handle.unset_grab(data, event.serial, event.time, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -221,7 +221,7 @@ impl PointerGrab<State> for ResizeForkGrab {
|
|||
handle.button(data, event);
|
||||
if handle.current_pressed().is_empty() {
|
||||
// No more buttons are pressed, release the grab.
|
||||
handle.unset_grab(data, event.serial, event.time);
|
||||
handle.unset_grab(data, event.serial, event.time, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue