Skip to content

Commit 96e9bf3

Browse files
ids1024Drakulix
authored andcommitted
Initial support for workspace pinning and moving
Adds support for cosmic-workspace-v2 pin, unpin, move_after, and move_before requests. Both features need some work with workspaces span displays mode, so that will need more fixes later. We also want to generate a unique id for pinned workspaces to send in the ext-workspace-v1 protocol. But that isn't a strict requirement for anything. So I haven't yet fully implemented that. We'll also want to persist other things, like workspace naming when that's added. Overall, though, with separate workspaces per display, this is working pretty well.
1 parent d1f4e7b commit 96e9bf3

File tree

14 files changed

+622
-118
lines changed

14 files changed

+622
-118
lines changed

Cargo.lock

Lines changed: 105 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ anyhow = {version = "1.0.51", features = ["backtrace"]}
1515
bitflags = "2.4"
1616
bytemuck = "1.12"
1717
calloop = {version = "0.14.1", features = ["executor"]}
18-
cosmic-comp-config = {path = "cosmic-comp-config"}
18+
cosmic-comp-config = {path = "cosmic-comp-config", features = ["libdisplay-info"]}
1919
cosmic-config = {git = "https://github.com/pop-os/libcosmic/", features = ["calloop", "macro"]}
2020
cosmic-protocols = {git = "https://github.com/pop-os/cosmic-protocols", rev = "e706814", default-features = false, features = ["server"]}
2121
cosmic-settings-config = { git = "https://github.com/pop-os/cosmic-settings-daemon" }
@@ -59,7 +59,7 @@ zbus = "4.4.0"
5959
profiling = { version = "1.0" }
6060
rustix = { version = "0.38.32", features = ["process"] }
6161
smallvec = "1.13.2"
62-
rand = "0.8.5"
62+
rand = "0.9.0"
6363
reis = { version = "0.4", features = ["calloop"] }
6464
# CLI arguments
6565
clap_lex = "0.7"
@@ -119,8 +119,8 @@ inherits = "release"
119119
lto = "fat"
120120

121121
[patch."https://github.com/pop-os/cosmic-protocols"]
122-
cosmic-protocols = { git = "https://github.com/pop-os//cosmic-protocols", rev = "67df697" }
123-
cosmic-client-toolkit = { git = "https://github.com/pop-os//cosmic-protocols", rev = "67df697" }
122+
cosmic-protocols = { git = "https://github.com/pop-os//cosmic-protocols", branch = "main" }
123+
cosmic-client-toolkit = { git = "https://github.com/pop-os//cosmic-protocols", branch = "main" }
124124

125125
[patch."https://github.com/smithay/smithay"]
126126
smithay = { git = "https://github.com/smithay/smithay//", rev = "ce61c9b" }

cosmic-comp-config/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ edition = "2021"
66
[dependencies]
77
cosmic-config = { git = "https://github.com/pop-os/libcosmic/" }
88
input = "0.9.0"
9+
libdisplay-info = { version = "0.2.0", optional = true }
910
serde = { version = "1", features = ["derive"] }

cosmic-comp-config/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
55
use std::collections::HashMap;
66

77
pub mod input;
8+
pub mod output;
89
pub mod workspace;
910

1011
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
@@ -25,6 +26,7 @@ pub enum NumlockState {
2526
#[version = 1]
2627
pub struct CosmicCompConfig {
2728
pub workspaces: workspace::WorkspaceConfig,
29+
pub pinned_workspaces: Vec<workspace::PinnedWorkspace>,
2830
pub input_default: input::InputConfig,
2931
pub input_touchpad: input::InputConfig,
3032
pub input_devices: HashMap<String, input::InputConfig>,
@@ -57,6 +59,7 @@ impl Default for CosmicCompConfig {
5759
fn default() -> Self {
5860
Self {
5961
workspaces: Default::default(),
62+
pinned_workspaces: Vec::new(),
6063
input_default: Default::default(),
6164
// By default, enable tap-to-click and disable-while-typing.
6265
input_touchpad: input::InputConfig {

cosmic-comp-config/src/output.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// SPDX-License-Identifier: GPL-3.0-only
2+
3+
use serde::{Deserialize, Serialize};
4+
5+
#[derive(Debug, Deserialize, Serialize, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
6+
pub struct EdidProduct {
7+
pub manufacturer: [char; 3],
8+
pub product: u16,
9+
pub serial: Option<u32>,
10+
pub manufacture_week: i32,
11+
pub manufacture_year: i32,
12+
pub model_year: Option<i32>,
13+
}
14+
15+
#[cfg(feature = "libdisplay-info")]
16+
impl From<libdisplay_info::edid::VendorProduct> for EdidProduct {
17+
fn from(vp: libdisplay_info::edid::VendorProduct) -> Self {
18+
Self {
19+
manufacturer: vp.manufacturer,
20+
product: vp.product,
21+
serial: vp.serial,
22+
manufacture_week: vp.manufacture_week,
23+
manufacture_year: vp.manufacture_year,
24+
model_year: vp.model_year,
25+
}
26+
}
27+
}

cosmic-comp-config/src/workspace.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
use serde::{Deserialize, Serialize};
44

5+
use crate::output::EdidProduct;
6+
57
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
68
pub struct WorkspaceConfig {
79
pub workspace_mode: WorkspaceMode,
@@ -30,3 +32,16 @@ pub enum WorkspaceLayout {
3032
Vertical,
3133
Horizontal,
3234
}
35+
36+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
37+
pub struct OutputMatch {
38+
pub name: String,
39+
pub edid: Option<EdidProduct>,
40+
}
41+
42+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
43+
pub struct PinnedWorkspace {
44+
pub output: OutputMatch,
45+
pub tiling_enabled: bool,
46+
// TODO: name, id
47+
}

0 commit comments

Comments
 (0)