workspace: Add tiling_state
This commit is contained in:
parent
ec822e421f
commit
226bf7f49d
4 changed files with 133 additions and 25 deletions
|
|
@ -8,7 +8,9 @@ use std::{
|
|||
use wayland_backend::server::ClientId;
|
||||
|
||||
use cosmic_comp_config::workspace::{WorkspaceAmount, WorkspaceMode};
|
||||
use cosmic_protocols::workspace::v1::server::zcosmic_workspace_handle_v1::State as WState;
|
||||
use cosmic_protocols::workspace::v1::server::zcosmic_workspace_handle_v1::{
|
||||
State as WState, TilingState,
|
||||
};
|
||||
use keyframe::{ease, functions::EaseInOutCubic};
|
||||
use smithay::{
|
||||
desktop::{
|
||||
|
|
@ -238,7 +240,16 @@ fn create_workspace(
|
|||
tiling: bool,
|
||||
theme: cosmic::Theme,
|
||||
) -> Workspace {
|
||||
let workspace_handle = state.create_workspace(&group_handle).unwrap();
|
||||
let workspace_handle = state
|
||||
.create_workspace(
|
||||
&group_handle,
|
||||
if tiling {
|
||||
TilingState::TilingEnabled
|
||||
} else {
|
||||
TilingState::FloatingOnly
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
if active {
|
||||
state.add_workspace_state(&workspace_handle, WState::Active);
|
||||
}
|
||||
|
|
@ -256,7 +267,16 @@ fn move_workspace_to_group(
|
|||
toplevel_info_state: &mut ToplevelInfoState<State, CosmicSurface>,
|
||||
) {
|
||||
let old_workspace_handle = workspace.handle;
|
||||
workspace.handle = workspace_state.create_workspace(group).unwrap();
|
||||
workspace.handle = workspace_state
|
||||
.create_workspace(
|
||||
group,
|
||||
if workspace.tiling_enabled {
|
||||
TilingState::TilingEnabled
|
||||
} else {
|
||||
TilingState::FloatingOnly
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
workspace_state.set_workspace_capabilities(
|
||||
&workspace.handle,
|
||||
[WorkspaceCapabilities::Activate].into_iter(),
|
||||
|
|
@ -515,15 +535,6 @@ impl WorkspaceSet {
|
|||
workspace_set_idx(state, i as u8 + 1, idx, &workspace.handle);
|
||||
}
|
||||
}
|
||||
|
||||
fn update_tiling_status(&mut self, seat: &Seat<State>, tiling_enabled: bool) {
|
||||
self.tiling_enabled = tiling_enabled;
|
||||
for workspace in &mut self.workspaces {
|
||||
if workspace.tiling_enabled != tiling_enabled {
|
||||
workspace.toggle_tiling(seat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -1001,12 +1012,6 @@ impl Workspaces {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn update_tiling_status(&mut self, seat: &Seat<State>, tiling: bool) {
|
||||
for set in self.sets.values_mut() {
|
||||
set.update_tiling_status(seat, tiling)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_theme(&mut self, theme: cosmic::Theme, xdg_activation_state: &XdgActivationState) {
|
||||
for (_, s) in &mut self.sets {
|
||||
s.theme = theme.clone();
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@ use crate::{
|
|||
protocols::{
|
||||
screencopy::{BufferParams, Session as ScreencopySession},
|
||||
toplevel_info::ToplevelInfoState,
|
||||
workspace::WorkspaceHandle,
|
||||
workspace::{WorkspaceHandle, WorkspaceUpdateGuard},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
use cosmic::theme::CosmicTheme;
|
||||
use cosmic_protocols::workspace::v1::server::zcosmic_workspace_handle_v1::TilingState;
|
||||
use id_tree::Tree;
|
||||
use indexmap::IndexSet;
|
||||
use keyframe::{ease, functions::EaseInOutCubic};
|
||||
|
|
@ -612,7 +613,11 @@ impl Workspace {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn toggle_tiling(&mut self, seat: &Seat<State>) {
|
||||
pub fn toggle_tiling(
|
||||
&mut self,
|
||||
seat: &Seat<State>,
|
||||
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||
) {
|
||||
if self.tiling_enabled {
|
||||
for window in self
|
||||
.tiling_layer
|
||||
|
|
@ -624,6 +629,7 @@ impl Workspace {
|
|||
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;
|
||||
} else {
|
||||
let focus_stack = self.focus_stack.get(seat);
|
||||
|
|
@ -638,6 +644,7 @@ impl Workspace {
|
|||
self.tiling_layer
|
||||
.map(window, Some(focus_stack.iter()), None)
|
||||
}
|
||||
workspace_state.set_workspace_tiling_state(&self.handle, TilingState::TilingEnabled);
|
||||
self.tiling_enabled = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue