shell: Drop static workspaces
This commit is contained in:
parent
226bf7f49d
commit
c0f7524a09
4 changed files with 157 additions and 261 deletions
|
|
@ -9,7 +9,6 @@ fn default_workspace_layout() -> WorkspaceLayout {
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct WorkspaceConfig {
|
pub struct WorkspaceConfig {
|
||||||
pub workspace_mode: WorkspaceMode,
|
pub workspace_mode: WorkspaceMode,
|
||||||
pub workspace_amount: WorkspaceAmount,
|
|
||||||
#[serde(default = "default_workspace_layout")]
|
#[serde(default = "default_workspace_layout")]
|
||||||
pub workspace_layout: WorkspaceLayout,
|
pub workspace_layout: WorkspaceLayout,
|
||||||
}
|
}
|
||||||
|
|
@ -18,18 +17,11 @@ impl Default for WorkspaceConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
workspace_mode: WorkspaceMode::OutputBound,
|
workspace_mode: WorkspaceMode::OutputBound,
|
||||||
workspace_amount: WorkspaceAmount::Dynamic,
|
|
||||||
workspace_layout: WorkspaceLayout::Vertical,
|
workspace_layout: WorkspaceLayout::Vertical,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
||||||
pub enum WorkspaceAmount {
|
|
||||||
Dynamic,
|
|
||||||
Static(u8),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum WorkspaceMode {
|
pub enum WorkspaceMode {
|
||||||
OutputBound,
|
OutputBound,
|
||||||
|
|
|
||||||
353
src/shell/mod.rs
353
src/shell/mod.rs
|
|
@ -7,7 +7,7 @@ use std::{
|
||||||
};
|
};
|
||||||
use wayland_backend::server::ClientId;
|
use wayland_backend::server::ClientId;
|
||||||
|
|
||||||
use cosmic_comp_config::workspace::{WorkspaceAmount, WorkspaceMode};
|
use cosmic_comp_config::workspace::WorkspaceMode;
|
||||||
use cosmic_protocols::workspace::v1::server::zcosmic_workspace_handle_v1::{
|
use cosmic_protocols::workspace::v1::server::zcosmic_workspace_handle_v1::{
|
||||||
State as WState, TilingState,
|
State as WState, TilingState,
|
||||||
};
|
};
|
||||||
|
|
@ -223,7 +223,7 @@ pub struct SessionLock {
|
||||||
pub struct WorkspaceSet {
|
pub struct WorkspaceSet {
|
||||||
previously_active: Option<(usize, Instant)>,
|
previously_active: Option<(usize, Instant)>,
|
||||||
active: usize,
|
active: usize,
|
||||||
group: WorkspaceGroupHandle,
|
pub group: WorkspaceGroupHandle,
|
||||||
idx: usize,
|
idx: usize,
|
||||||
tiling_enabled: bool,
|
tiling_enabled: bool,
|
||||||
output: Output,
|
output: Output,
|
||||||
|
|
@ -290,6 +290,7 @@ fn move_workspace_to_group(
|
||||||
workspace_state.remove_workspace(old_workspace_handle);
|
workspace_state.remove_workspace(old_workspace_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We will probably need this again at some point
|
||||||
fn merge_workspaces(
|
fn merge_workspaces(
|
||||||
mut workspace: Workspace,
|
mut workspace: Workspace,
|
||||||
into: &mut Workspace,
|
into: &mut Workspace,
|
||||||
|
|
@ -312,52 +313,32 @@ fn merge_workspaces(
|
||||||
into.floating_layer.merge(workspace.floating_layer);
|
into.floating_layer.merge(workspace.floating_layer);
|
||||||
workspace_state.remove_workspace(workspace.handle);
|
workspace_state.remove_workspace(workspace.handle);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
impl WorkspaceSet {
|
impl WorkspaceSet {
|
||||||
fn new(
|
fn new(
|
||||||
state: &mut WorkspaceUpdateGuard<'_, State>,
|
state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
amount: WorkspaceAmount,
|
|
||||||
idx: usize,
|
idx: usize,
|
||||||
tiling_enabled: bool,
|
tiling_enabled: bool,
|
||||||
theme: cosmic::Theme,
|
theme: cosmic::Theme,
|
||||||
) -> WorkspaceSet {
|
) -> WorkspaceSet {
|
||||||
let group_handle = state.create_workspace_group();
|
let group_handle = state.create_workspace_group();
|
||||||
let workspaces = match amount {
|
let workspaces = {
|
||||||
WorkspaceAmount::Dynamic => {
|
let workspace = create_workspace(
|
||||||
let workspace = create_workspace(
|
state,
|
||||||
state,
|
output,
|
||||||
output,
|
&group_handle,
|
||||||
&group_handle,
|
true,
|
||||||
true,
|
tiling_enabled,
|
||||||
tiling_enabled,
|
theme.clone(),
|
||||||
theme.clone(),
|
);
|
||||||
);
|
workspace_set_idx(state, 1, idx, &workspace.handle);
|
||||||
workspace_set_idx(state, 1, idx, &workspace.handle);
|
state.set_workspace_capabilities(
|
||||||
state.set_workspace_capabilities(
|
&workspace.handle,
|
||||||
&workspace.handle,
|
[WorkspaceCapabilities::Activate].into_iter(),
|
||||||
[WorkspaceCapabilities::Activate].into_iter(),
|
);
|
||||||
);
|
vec![workspace]
|
||||||
vec![workspace]
|
|
||||||
}
|
|
||||||
WorkspaceAmount::Static(len) => (0..len)
|
|
||||||
.map(|i| {
|
|
||||||
let workspace = create_workspace(
|
|
||||||
state,
|
|
||||||
output,
|
|
||||||
&group_handle,
|
|
||||||
i == 0,
|
|
||||||
tiling_enabled,
|
|
||||||
theme.clone(),
|
|
||||||
);
|
|
||||||
workspace_set_idx(state, i + 1, idx, &workspace.handle);
|
|
||||||
state.set_workspace_capabilities(
|
|
||||||
&workspace.handle,
|
|
||||||
[WorkspaceCapabilities::Activate].into_iter(),
|
|
||||||
);
|
|
||||||
workspace
|
|
||||||
})
|
|
||||||
.collect(),
|
|
||||||
};
|
};
|
||||||
let sticky_layer = FloatingLayout::new(theme.clone(), output);
|
let sticky_layer = FloatingLayout::new(theme.clone(), output);
|
||||||
|
|
||||||
|
|
@ -439,6 +420,7 @@ impl WorkspaceSet {
|
||||||
self.workspaces.len() as u8 + 1,
|
self.workspaces.len() as u8 + 1,
|
||||||
self.idx,
|
self.idx,
|
||||||
&workspace.handle,
|
&workspace.handle,
|
||||||
|
// this method is only used by code paths related to dynamic workspaces, so this should be fine
|
||||||
);
|
);
|
||||||
self.workspaces.push(workspace);
|
self.workspaces.push(workspace);
|
||||||
}
|
}
|
||||||
|
|
@ -482,53 +464,6 @@ impl WorkspaceSet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ensure_static(
|
|
||||||
&mut self,
|
|
||||||
amount: usize,
|
|
||||||
state: &mut WorkspaceUpdateGuard<State>,
|
|
||||||
toplevel_info: &mut ToplevelInfoState<State, CosmicSurface>,
|
|
||||||
xdg_activation_state: &XdgActivationState,
|
|
||||||
) {
|
|
||||||
if amount < self.workspaces.len() {
|
|
||||||
// merge last ones
|
|
||||||
let overflow = self.workspaces.split_off(amount);
|
|
||||||
if self.active >= self.workspaces.len() {
|
|
||||||
self.active = self.workspaces.len() - 1;
|
|
||||||
state.add_workspace_state(&self.workspaces[self.active].handle, WState::Active);
|
|
||||||
}
|
|
||||||
let last_space = self.workspaces.last_mut().unwrap();
|
|
||||||
|
|
||||||
for workspace in overflow {
|
|
||||||
merge_workspaces(workspace, last_space, state, toplevel_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
last_space.refresh(xdg_activation_state);
|
|
||||||
} else if amount > self.workspaces.len() {
|
|
||||||
// add empty ones
|
|
||||||
while amount > self.workspaces.len() {
|
|
||||||
let workspace = create_workspace(
|
|
||||||
state,
|
|
||||||
&self.output,
|
|
||||||
&self.group,
|
|
||||||
false,
|
|
||||||
self.tiling_enabled,
|
|
||||||
self.theme.clone(),
|
|
||||||
);
|
|
||||||
workspace_set_idx(
|
|
||||||
state,
|
|
||||||
self.workspaces.len() as u8 + 1,
|
|
||||||
self.idx,
|
|
||||||
&workspace.handle,
|
|
||||||
);
|
|
||||||
state.set_workspace_capabilities(
|
|
||||||
&workspace.handle,
|
|
||||||
[WorkspaceCapabilities::Activate].into_iter(),
|
|
||||||
);
|
|
||||||
self.workspaces.push(workspace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update_idx(&mut self, state: &mut WorkspaceUpdateGuard<'_, State>, idx: usize) {
|
fn update_idx(&mut self, state: &mut WorkspaceUpdateGuard<'_, State>, idx: usize) {
|
||||||
self.idx = idx;
|
self.idx = idx;
|
||||||
for (i, workspace) in self.workspaces.iter().enumerate() {
|
for (i, workspace) in self.workspaces.iter().enumerate() {
|
||||||
|
|
@ -541,7 +476,6 @@ impl WorkspaceSet {
|
||||||
pub struct Workspaces {
|
pub struct Workspaces {
|
||||||
pub sets: IndexMap<Output, WorkspaceSet>,
|
pub sets: IndexMap<Output, WorkspaceSet>,
|
||||||
backup_set: Option<WorkspaceSet>,
|
backup_set: Option<WorkspaceSet>,
|
||||||
amount: WorkspaceAmount,
|
|
||||||
mode: WorkspaceMode,
|
mode: WorkspaceMode,
|
||||||
tiling_enabled: bool,
|
tiling_enabled: bool,
|
||||||
theme: cosmic::Theme,
|
theme: cosmic::Theme,
|
||||||
|
|
@ -552,7 +486,6 @@ impl Workspaces {
|
||||||
Workspaces {
|
Workspaces {
|
||||||
sets: IndexMap::new(),
|
sets: IndexMap::new(),
|
||||||
backup_set: None,
|
backup_set: None,
|
||||||
amount: config.workspace.workspace_amount,
|
|
||||||
mode: config.workspace.workspace_mode,
|
mode: config.workspace.workspace_mode,
|
||||||
tiling_enabled: config.static_conf.tiling_enabled,
|
tiling_enabled: config.static_conf.tiling_enabled,
|
||||||
theme,
|
theme,
|
||||||
|
|
@ -581,7 +514,6 @@ impl Workspaces {
|
||||||
WorkspaceSet::new(
|
WorkspaceSet::new(
|
||||||
workspace_state,
|
workspace_state,
|
||||||
&output,
|
&output,
|
||||||
self.amount,
|
|
||||||
self.sets.len(),
|
self.sets.len(),
|
||||||
self.tiling_enabled,
|
self.tiling_enabled,
|
||||||
self.theme.clone(),
|
self.theme.clone(),
|
||||||
|
|
@ -654,30 +586,19 @@ impl Workspaces {
|
||||||
|
|
||||||
let new_set = self.sets.get_mut(&new_output).unwrap();
|
let new_set = self.sets.get_mut(&new_output).unwrap();
|
||||||
let workspace_group = new_set.group;
|
let workspace_group = new_set.group;
|
||||||
for (i, mut workspace) in set.workspaces.into_iter().enumerate() {
|
for mut workspace in set.workspaces.into_iter() {
|
||||||
if matches!(self.amount, WorkspaceAmount::Static(_))
|
// update workspace protocol state
|
||||||
&& i < new_set.workspaces.len()
|
move_workspace_to_group(
|
||||||
{
|
&mut workspace,
|
||||||
merge_workspaces(
|
&workspace_group,
|
||||||
workspace,
|
workspace_state,
|
||||||
&mut new_set.workspaces[i],
|
toplevel_info_state,
|
||||||
workspace_state,
|
);
|
||||||
toplevel_info_state,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// update workspace protocol state
|
|
||||||
move_workspace_to_group(
|
|
||||||
&mut workspace,
|
|
||||||
&workspace_group,
|
|
||||||
workspace_state,
|
|
||||||
toplevel_info_state,
|
|
||||||
);
|
|
||||||
|
|
||||||
// update mapping
|
// update mapping
|
||||||
workspace.set_output(&new_output, toplevel_info_state);
|
workspace.set_output(&new_output, toplevel_info_state);
|
||||||
workspace.refresh(xdg_activation_state);
|
workspace.refresh(xdg_activation_state);
|
||||||
new_set.workspaces.push(workspace);
|
new_set.workspaces.push(workspace);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if self.mode == WorkspaceMode::OutputBound {
|
if self.mode == WorkspaceMode::OutputBound {
|
||||||
workspace_state.remove_workspace_group(set.group);
|
workspace_state.remove_workspace_group(set.group);
|
||||||
|
|
@ -693,7 +614,7 @@ impl Workspaces {
|
||||||
self.backup_set = Some(set);
|
self.backup_set = Some(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.refresh(workspace_state, toplevel_info_state, xdg_activation_state)
|
self.refresh(workspace_state, xdg_activation_state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -715,25 +636,15 @@ impl Workspaces {
|
||||||
Some(set.workspaces.remove(pos))
|
Some(set.workspaces.remove(pos))
|
||||||
}) {
|
}) {
|
||||||
let new_set = self.sets.get_mut(to).unwrap();
|
let new_set = self.sets.get_mut(to).unwrap();
|
||||||
match self.amount {
|
move_workspace_to_group(
|
||||||
WorkspaceAmount::Dynamic => {
|
&mut workspace,
|
||||||
move_workspace_to_group(
|
&new_set.group,
|
||||||
&mut workspace,
|
workspace_state,
|
||||||
&new_set.group,
|
toplevel_info_state,
|
||||||
workspace_state,
|
);
|
||||||
toplevel_info_state,
|
workspace.set_output(to, toplevel_info_state);
|
||||||
);
|
workspace.refresh(xdg_activation_state);
|
||||||
workspace.set_output(to, toplevel_info_state);
|
new_set.workspaces.insert(new_set.active + 1, workspace)
|
||||||
workspace.refresh(xdg_activation_state);
|
|
||||||
new_set.workspaces.insert(new_set.active + 1, workspace)
|
|
||||||
}
|
|
||||||
WorkspaceAmount::Static(_) => merge_workspaces(
|
|
||||||
workspace,
|
|
||||||
&mut new_set.workspaces[new_set.active],
|
|
||||||
workspace_state,
|
|
||||||
toplevel_info_state,
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -741,13 +652,10 @@ impl Workspaces {
|
||||||
&mut self,
|
&mut self,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
toplevel_info_state: &mut ToplevelInfoState<State, CosmicSurface>,
|
|
||||||
xdg_activation_state: &XdgActivationState,
|
xdg_activation_state: &XdgActivationState,
|
||||||
) {
|
) {
|
||||||
let old_mode = self.mode;
|
let old_mode = self.mode;
|
||||||
|
|
||||||
self.mode = config.workspace.workspace_mode;
|
self.mode = config.workspace.workspace_mode;
|
||||||
self.amount = config.workspace.workspace_amount;
|
|
||||||
|
|
||||||
if self.sets.len() <= 1 {
|
if self.sets.len() <= 1 {
|
||||||
return;
|
return;
|
||||||
|
|
@ -808,7 +716,7 @@ impl Workspaces {
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.refresh(workspace_state, toplevel_info_state, xdg_activation_state)
|
self.refresh(workspace_state, xdg_activation_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn recalculate(&mut self) {
|
pub fn recalculate(&mut self) {
|
||||||
|
|
@ -821,111 +729,84 @@ impl Workspaces {
|
||||||
pub fn refresh(
|
pub fn refresh(
|
||||||
&mut self,
|
&mut self,
|
||||||
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
toplevel_info_state: &mut ToplevelInfoState<State, CosmicSurface>,
|
|
||||||
xdg_activation_state: &XdgActivationState,
|
xdg_activation_state: &XdgActivationState,
|
||||||
) {
|
) {
|
||||||
match self.mode {
|
match self.mode {
|
||||||
WorkspaceMode::Global => {
|
WorkspaceMode::Global => {
|
||||||
match self.amount {
|
// this should never happen
|
||||||
WorkspaceAmount::Dynamic => {
|
let max = self
|
||||||
// this should never happen
|
.sets
|
||||||
let max = self
|
.values()
|
||||||
.sets
|
.map(|set| set.workspaces.len())
|
||||||
.values()
|
.max()
|
||||||
.map(|set| set.workspaces.len())
|
.unwrap_or_default();
|
||||||
.max()
|
for set in self
|
||||||
.unwrap_or_default();
|
.sets
|
||||||
for set in self
|
.values_mut()
|
||||||
.sets
|
.filter(|set| set.workspaces.len() < max)
|
||||||
.values_mut()
|
{
|
||||||
.filter(|set| set.workspaces.len() < max)
|
while set.workspaces.len() < max {
|
||||||
{
|
set.add_empty_workspace(workspace_state)
|
||||||
while set.workspaces.len() < max {
|
|
||||||
set.add_empty_workspace(workspace_state)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add empty at the end, if necessary
|
|
||||||
if self
|
|
||||||
.sets
|
|
||||||
.values()
|
|
||||||
.flat_map(|set| set.workspaces.last())
|
|
||||||
.any(|w| w.mapped().next().is_some())
|
|
||||||
{
|
|
||||||
for set in self.sets.values_mut() {
|
|
||||||
set.add_empty_workspace(workspace_state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove empty workspaces in between, if they are not active
|
|
||||||
let len = self.sets[0].workspaces.len();
|
|
||||||
let mut active = self.sets[0].active;
|
|
||||||
let mut keep = vec![true; len];
|
|
||||||
for i in 0..len {
|
|
||||||
let has_windows = self.sets.values().any(|s| {
|
|
||||||
!s.workspaces[i].pending_tokens.is_empty()
|
|
||||||
|| s.workspaces[i].windows().next().is_some()
|
|
||||||
});
|
|
||||||
|
|
||||||
if !has_windows && i != active && i != len - 1 {
|
|
||||||
for workspace in self.sets.values().map(|s| &s.workspaces[i]) {
|
|
||||||
workspace_state.remove_workspace(workspace.handle);
|
|
||||||
}
|
|
||||||
keep[i] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.sets.values_mut().for_each(|s| {
|
|
||||||
let mut iter = keep.iter();
|
|
||||||
s.workspaces.retain(|_| *iter.next().unwrap());
|
|
||||||
});
|
|
||||||
active -= keep.iter().take(active + 1).filter(|keep| !**keep).count();
|
|
||||||
self.sets.values_mut().for_each(|s| {
|
|
||||||
s.active = active;
|
|
||||||
});
|
|
||||||
|
|
||||||
if keep.iter().any(|val| *val == false) {
|
|
||||||
for set in self.sets.values_mut() {
|
|
||||||
for (i, workspace) in set.workspaces.iter().enumerate() {
|
|
||||||
workspace_set_idx(
|
|
||||||
workspace_state,
|
|
||||||
i as u8 + 1,
|
|
||||||
set.idx,
|
|
||||||
&workspace.handle,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
WorkspaceAmount::Static(amount) => {
|
}
|
||||||
for set in self.sets.values_mut() {
|
|
||||||
set.ensure_static(
|
// add empty at the end, if necessary
|
||||||
amount as usize,
|
if self
|
||||||
|
.sets
|
||||||
|
.values()
|
||||||
|
.flat_map(|set| set.workspaces.last())
|
||||||
|
.any(|w| w.mapped().next().is_some())
|
||||||
|
{
|
||||||
|
for set in self.sets.values_mut() {
|
||||||
|
set.add_empty_workspace(workspace_state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove empty workspaces in between, if they are not active
|
||||||
|
let len = self.sets[0].workspaces.len();
|
||||||
|
let mut active = self.sets[0].active;
|
||||||
|
let mut keep = vec![true; len];
|
||||||
|
for i in 0..len {
|
||||||
|
let has_windows = self.sets.values().any(|s| {
|
||||||
|
!s.workspaces[i].pending_tokens.is_empty()
|
||||||
|
|| s.workspaces[i].windows().next().is_some()
|
||||||
|
});
|
||||||
|
|
||||||
|
if !has_windows && i != active && i != len - 1 {
|
||||||
|
for workspace in self.sets.values().map(|s| &s.workspaces[i]) {
|
||||||
|
workspace_state.remove_workspace(workspace.handle);
|
||||||
|
}
|
||||||
|
keep[i] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.sets.values_mut().for_each(|s| {
|
||||||
|
let mut iter = keep.iter();
|
||||||
|
s.workspaces.retain(|_| *iter.next().unwrap());
|
||||||
|
});
|
||||||
|
active -= keep.iter().take(active + 1).filter(|keep| !**keep).count();
|
||||||
|
self.sets.values_mut().for_each(|s| {
|
||||||
|
s.active = active;
|
||||||
|
});
|
||||||
|
|
||||||
|
if keep.iter().any(|val| *val == false) {
|
||||||
|
for set in self.sets.values_mut() {
|
||||||
|
for (i, workspace) in set.workspaces.iter().enumerate() {
|
||||||
|
workspace_set_idx(
|
||||||
workspace_state,
|
workspace_state,
|
||||||
toplevel_info_state,
|
i as u8 + 1,
|
||||||
xdg_activation_state,
|
set.idx,
|
||||||
)
|
&workspace.handle,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WorkspaceMode::OutputBound => match self.amount {
|
WorkspaceMode::OutputBound => {
|
||||||
WorkspaceAmount::Dynamic => {
|
for set in self.sets.values_mut() {
|
||||||
for set in self.sets.values_mut() {
|
set.ensure_last_empty(workspace_state);
|
||||||
set.ensure_last_empty(workspace_state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
WorkspaceAmount::Static(amount) => {
|
}
|
||||||
for set in self.sets.values_mut() {
|
|
||||||
set.ensure_static(
|
|
||||||
amount as usize,
|
|
||||||
workspace_state,
|
|
||||||
toplevel_info_state,
|
|
||||||
xdg_activation_state,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for set in self.sets.values_mut() {
|
for set in self.sets.values_mut() {
|
||||||
|
|
@ -1131,13 +1012,8 @@ impl Shell {
|
||||||
|
|
||||||
pub fn update_config(&mut self, config: &Config) {
|
pub fn update_config(&mut self, config: &Config) {
|
||||||
let mut workspace_state = self.workspace_state.update();
|
let mut workspace_state = self.workspace_state.update();
|
||||||
let toplevel_info_state = &mut self.toplevel_info_state;
|
self.workspaces
|
||||||
self.workspaces.update_config(
|
.update_config(config, &mut workspace_state, &self.xdg_activation_state);
|
||||||
config,
|
|
||||||
&mut workspace_state,
|
|
||||||
toplevel_info_state,
|
|
||||||
&self.xdg_activation_state,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn activate(
|
pub fn activate(
|
||||||
|
|
@ -1545,7 +1421,6 @@ impl Shell {
|
||||||
});
|
});
|
||||||
self.workspaces.refresh(
|
self.workspaces.refresh(
|
||||||
&mut self.workspace_state.update(),
|
&mut self.workspace_state.update(),
|
||||||
&mut self.toplevel_info_state,
|
|
||||||
&self.xdg_activation_state,
|
&self.xdg_activation_state,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -2985,8 +2860,8 @@ fn workspace_set_idx<'a>(
|
||||||
output_pos: usize,
|
output_pos: usize,
|
||||||
handle: &WorkspaceHandle,
|
handle: &WorkspaceHandle,
|
||||||
) {
|
) {
|
||||||
state.set_workspace_name(&handle, format!("{}", idx));
|
state.set_workspace_name(handle, format!("{}", idx));
|
||||||
state.set_workspace_coordinates(&handle, [Some(idx as u32), Some(output_pos as u32), None]);
|
state.set_workspace_coordinates(handle, [Some(idx as u32), Some(output_pos as u32), None]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_grab_preconditions(
|
pub fn check_grab_preconditions(
|
||||||
|
|
|
||||||
|
|
@ -618,20 +618,16 @@ impl Workspace {
|
||||||
seat: &Seat<State>,
|
seat: &Seat<State>,
|
||||||
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
) {
|
) {
|
||||||
if self.tiling_enabled {
|
self.set_tiling(!self.tiling_enabled, seat, workspace_state)
|
||||||
for window in self
|
}
|
||||||
.tiling_layer
|
|
||||||
.mapped()
|
pub fn set_tiling(
|
||||||
.map(|(_, m, _)| m.clone())
|
&mut self,
|
||||||
.collect::<Vec<_>>()
|
tiling: bool,
|
||||||
.into_iter()
|
seat: &Seat<State>,
|
||||||
{
|
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
self.tiling_layer.unmap(&window);
|
) {
|
||||||
self.floating_layer.map(window, None);
|
if tiling {
|
||||||
}
|
|
||||||
workspace_state.set_workspace_tiling_state(&self.handle, TilingState::FloatingOnly);
|
|
||||||
self.tiling_enabled = false;
|
|
||||||
} else {
|
|
||||||
let focus_stack = self.focus_stack.get(seat);
|
let focus_stack = self.focus_stack.get(seat);
|
||||||
for window in self
|
for window in self
|
||||||
.floating_layer
|
.floating_layer
|
||||||
|
|
@ -646,6 +642,19 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
workspace_state.set_workspace_tiling_state(&self.handle, TilingState::TilingEnabled);
|
workspace_state.set_workspace_tiling_state(&self.handle, TilingState::TilingEnabled);
|
||||||
self.tiling_enabled = true;
|
self.tiling_enabled = true;
|
||||||
|
} else {
|
||||||
|
for window in self
|
||||||
|
.tiling_layer
|
||||||
|
.mapped()
|
||||||
|
.map(|(_, m, _)| m.clone())
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.into_iter()
|
||||||
|
{
|
||||||
|
self.tiling_layer.unmap(&window);
|
||||||
|
self.floating_layer.map(window, None);
|
||||||
|
}
|
||||||
|
workspace_state.set_workspace_tiling_state(&self.handle, TilingState::FloatingOnly);
|
||||||
|
self.tiling_enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use crate::{
|
||||||
WorkspaceHandler, WorkspaceState,
|
WorkspaceHandler, WorkspaceState,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use cosmic_protocols::workspace::v1::server::zcosmic_workspace_handle_v1::TilingState;
|
||||||
use smithay::reexports::wayland_server::DisplayHandle;
|
use smithay::reexports::wayland_server::DisplayHandle;
|
||||||
|
|
||||||
impl WorkspaceClientHandler for ClientState {
|
impl WorkspaceClientHandler for ClientState {
|
||||||
|
|
@ -40,6 +41,25 @@ impl WorkspaceHandler for State {
|
||||||
let _ = self.common.shell.activate(&output, idx); // TODO: move cursor?
|
let _ = self.common.shell.activate(&output, idx); // TODO: move cursor?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Request::SetTilingState { workspace, state } => {
|
||||||
|
let seat = self.common.last_active_seat().clone();
|
||||||
|
if let Some(workspace) = self
|
||||||
|
.common
|
||||||
|
.shell
|
||||||
|
.workspaces
|
||||||
|
.space_for_handle_mut(&workspace)
|
||||||
|
{
|
||||||
|
let mut guard = self.common.shell.workspace_state.update();
|
||||||
|
workspace.set_tiling(
|
||||||
|
match state.into_result() {
|
||||||
|
Ok(TilingState::FloatingOnly) => false,
|
||||||
|
_ => true,
|
||||||
|
},
|
||||||
|
&seat,
|
||||||
|
&mut guard,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue