Skip to content

Commit

Permalink
Merge pull request #194 from pop-os/ws-refactor_jammy
Browse files Browse the repository at this point in the history
Overhaul of workspace code
  • Loading branch information
Drakulix authored Oct 26, 2023
2 parents c38a236 + a957393 commit 7300e23
Show file tree
Hide file tree
Showing 41 changed files with 3,591 additions and 3,363 deletions.
560 changes: 309 additions & 251 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ libsystemd = { version = "0.6", optional = true }
wayland-backend = "0.3.2"
wayland-scanner = "0.31.0"
cosmic-comp-config = { path = "cosmic-comp-config" }
cosmic-config = { git = "https://github.com/pop-os/libcosmic/", rev = "f91287d", features = ["calloop"] }
cosmic-config = { git = "https://github.com/pop-os/libcosmic/", features = ["calloop", "macro"] }
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", branch = "main", default-features = false, features = ["server"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "f91287d", default-features = false }
iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic/", rev = "f91287d" }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", default-features = false }
iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic/" }
tiny-skia = "0.10"
ordered-float = "4.0"
glow = "0.12.0"
Expand All @@ -53,6 +53,7 @@ once_cell = "1.18.0"
i18n-embed = { version = "0.14", features = ["fluent-system", "desktop-requester"] }
i18n-embed-fl = "0.7"
rust-embed = "8.0"
libc = "0.2.149"

[dependencies.id_tree]
git = "https://github.com/Drakulix/id-tree.git"
Expand Down Expand Up @@ -87,7 +88,4 @@ debug = true
lto = "fat"

[patch."https://github.com/Smithay/smithay.git"]
smithay = { git = "https://github.com/smithay//smithay", rev = "d60b1b83e" }

[patch.crates-io]
calloop = { git = "https://github.com/Smithay/calloop", rev = "71b6e633b1" }
smithay = { git = "https://github.com/pop-os/smithay", branch = "x11_fixes" }
63 changes: 37 additions & 26 deletions src/backend/kms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -25,7 +26,7 @@ use smithay::{
Allocator, Format, Fourcc,
},
drm::{
compositor::{BlitFrameResultError, DrmCompositor, FrameError},
compositor::{BlitFrameResultError, DrmCompositor, FrameError, PrimaryPlaneElement},
DrmDevice, DrmDeviceFd, DrmEvent, DrmEventTime, DrmNode, NodeType,
},
egl::{EGLContext, EGLDevice, EGLDisplay},
Expand Down Expand Up @@ -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,
Expand All @@ -82,7 +83,6 @@ use std::{
collections::{HashMap, HashSet},
ffi::CStr,
fmt,
os::unix::io::FromRawFd,
path::PathBuf,
time::Duration,
};
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -1014,8 +1012,14 @@ impl Device {
interface,
PhysicalProperties {
size: (phys_w as i32, phys_h as i32).into(),
// TODO: We need to read that from the connector properties
subpixel: Subpixel::Unknown,
subpixel: match conn_info.subpixel() {
connector::SubPixel::HorizontalRgb => Subpixel::HorizontalRgb,
connector::SubPixel::HorizontalBgr => Subpixel::HorizontalBgr,
connector::SubPixel::VerticalRgb => Subpixel::VerticalRgb,
connector::SubPixel::VerticalBgr => Subpixel::VerticalBgr,
connector::SubPixel::None => Subpixel::None,
_ => Subpixel::Unknown,
},
make: edid_info
.as_ref()
.map(|info| info.manufacturer.clone())
Expand Down Expand Up @@ -1093,8 +1097,8 @@ fn render_node_for_output(
) -> DrmNode {
let workspace = shell.active_space(output);
let nodes = workspace
.get_fullscreen(output)
.map(|w| vec![w.surface()])
.get_fullscreen()
.map(|w| vec![w.clone()])
.unwrap_or_else(|| workspace.windows().collect::<Vec<_>>())
.into_iter()
.flat_map(|w| w.wl_surface().and_then(|s| source_node_for_surface(&s, dh)))
Expand Down Expand Up @@ -1235,8 +1239,11 @@ impl Surface {
})?;
self.fps.elements();

let res =
compositor.render_frame::<_, _, GlesTexture>(&mut renderer, &elements, CLEAR_COLOR);
let res = compositor.render_frame::<_, _, GlesTexture>(
&mut renderer,
&elements,
CLEAR_COLOR, // TODO use a theme neutral color
);
self.fps.render();

match res {
Expand All @@ -1247,6 +1254,11 @@ impl Surface {
None
};

if frame_result.needs_sync() {
if let PrimaryPlaneElement::Swapchain(elem) = &frame_result.primary_element {
elem.sync.wait();
}
}
match compositor.queue_frame(feedback) {
Ok(()) | Err(FrameError::EmptyFrame) => {}
Err(err) => {
Expand Down Expand Up @@ -1507,7 +1519,6 @@ impl KmsState {
false
};

shell.refresh_outputs();
if recreated {
let sessions = output.pending_buffers().collect::<Vec<_>>();
if let Err(err) = self.schedule_render(
Expand Down
Loading

0 comments on commit 7300e23

Please sign in to comment.