shell: Properly propagate tiling state
This commit is contained in:
parent
037a210c90
commit
5a8840b12e
4 changed files with 62 additions and 20 deletions
|
|
@ -92,5 +92,5 @@
|
||||||
},
|
},
|
||||||
workspace_mode: OutputBound,
|
workspace_mode: OutputBound,
|
||||||
workspace_amount: Dynamic,
|
workspace_amount: Dynamic,
|
||||||
floating_default: false,
|
tiling_enabled: false,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ pub struct StaticConfig {
|
||||||
pub key_bindings: HashMap<KeyPattern, Action>,
|
pub key_bindings: HashMap<KeyPattern, Action>,
|
||||||
pub workspace_mode: WorkspaceMode,
|
pub workspace_mode: WorkspaceMode,
|
||||||
pub workspace_amount: WorkspaceAmount,
|
pub workspace_amount: WorkspaceAmount,
|
||||||
pub floating_default: bool,
|
pub tiling_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, Clone, Copy, PartialEq, Eq)]
|
||||||
|
|
@ -219,7 +219,7 @@ impl Config {
|
||||||
key_bindings: HashMap::new(),
|
key_bindings: HashMap::new(),
|
||||||
workspace_mode: WorkspaceMode::Global,
|
workspace_mode: WorkspaceMode::Global,
|
||||||
workspace_amount: WorkspaceAmount::Dynamic,
|
workspace_amount: WorkspaceAmount::Dynamic,
|
||||||
floating_default: false,
|
tiling_enabled: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ pub struct Shell {
|
||||||
pub popups: PopupManager,
|
pub popups: PopupManager,
|
||||||
pub outputs: Vec<Output>,
|
pub outputs: Vec<Output>,
|
||||||
pub workspaces: WorkspaceMode,
|
pub workspaces: WorkspaceMode,
|
||||||
pub floating_default: bool,
|
pub tiling_enabled: bool,
|
||||||
pub pending_windows: Vec<(CosmicSurface, Seat<State>)>,
|
pub pending_windows: Vec<(CosmicSurface, Seat<State>)>,
|
||||||
pub pending_layers: Vec<(LayerSurface, Output, Seat<State>)>,
|
pub pending_layers: Vec<(LayerSurface, Output, Seat<State>)>,
|
||||||
pub override_redirect_windows: Vec<OverrideRedirectWindow>,
|
pub override_redirect_windows: Vec<OverrideRedirectWindow>,
|
||||||
|
|
@ -90,6 +90,7 @@ pub struct WorkspaceSet {
|
||||||
amount: WorkspaceAmount,
|
amount: WorkspaceAmount,
|
||||||
group: WorkspaceGroupHandle,
|
group: WorkspaceGroupHandle,
|
||||||
idx: usize,
|
idx: usize,
|
||||||
|
tiling_enabled: bool,
|
||||||
pub(crate) workspaces: Vec<Workspace>,
|
pub(crate) workspaces: Vec<Workspace>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,6 +104,7 @@ fn create_workspace(
|
||||||
state: &mut WorkspaceUpdateGuard<'_, State>,
|
state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
group_handle: &WorkspaceGroupHandle,
|
group_handle: &WorkspaceGroupHandle,
|
||||||
active: bool,
|
active: bool,
|
||||||
|
tiling: bool,
|
||||||
) -> Workspace {
|
) -> Workspace {
|
||||||
let workspace_handle = state.create_workspace(&group_handle).unwrap();
|
let workspace_handle = state.create_workspace(&group_handle).unwrap();
|
||||||
if active {
|
if active {
|
||||||
|
|
@ -112,7 +114,7 @@ fn create_workspace(
|
||||||
&workspace_handle,
|
&workspace_handle,
|
||||||
[WorkspaceCapabilities::Activate].into_iter(),
|
[WorkspaceCapabilities::Activate].into_iter(),
|
||||||
);
|
);
|
||||||
Workspace::new(workspace_handle)
|
Workspace::new(workspace_handle, tiling)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WorkspaceSet {
|
impl WorkspaceSet {
|
||||||
|
|
@ -120,12 +122,13 @@ impl WorkspaceSet {
|
||||||
state: &mut WorkspaceUpdateGuard<'_, State>,
|
state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
amount: WorkspaceAmount,
|
amount: WorkspaceAmount,
|
||||||
idx: usize,
|
idx: usize,
|
||||||
|
tiling_enabled: bool,
|
||||||
) -> WorkspaceSet {
|
) -> WorkspaceSet {
|
||||||
let group_handle = state.create_workspace_group();
|
let group_handle = state.create_workspace_group();
|
||||||
|
|
||||||
let workspaces = match amount {
|
let workspaces = match amount {
|
||||||
WorkspaceAmount::Dynamic => {
|
WorkspaceAmount::Dynamic => {
|
||||||
let workspace = create_workspace(state, &group_handle, true);
|
let workspace = create_workspace(state, &group_handle, true, tiling_enabled);
|
||||||
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,
|
||||||
|
|
@ -135,7 +138,7 @@ impl WorkspaceSet {
|
||||||
}
|
}
|
||||||
WorkspaceAmount::Static(len) => (0..len)
|
WorkspaceAmount::Static(len) => (0..len)
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
let workspace = create_workspace(state, &group_handle, i == 0);
|
let workspace = create_workspace(state, &group_handle, i == 0, tiling_enabled);
|
||||||
workspace_set_idx(state, i + 1, idx, &workspace.handle);
|
workspace_set_idx(state, i + 1, idx, &workspace.handle);
|
||||||
state.set_workspace_capabilities(
|
state.set_workspace_capabilities(
|
||||||
&workspace.handle,
|
&workspace.handle,
|
||||||
|
|
@ -151,6 +154,7 @@ impl WorkspaceSet {
|
||||||
amount,
|
amount,
|
||||||
group: group_handle,
|
group: group_handle,
|
||||||
idx,
|
idx,
|
||||||
|
tiling_enabled,
|
||||||
workspaces,
|
workspaces,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -188,7 +192,8 @@ impl WorkspaceSet {
|
||||||
|
|
||||||
// add empty at the end, if necessary
|
// add empty at the end, if necessary
|
||||||
if self.workspaces.last().unwrap().windows().next().is_some() {
|
if self.workspaces.last().unwrap().windows().next().is_some() {
|
||||||
let mut workspace = create_workspace(&mut state, &self.group, false);
|
let mut workspace =
|
||||||
|
create_workspace(&mut state, &self.group, false, self.tiling_enabled);
|
||||||
workspace_set_idx(
|
workspace_set_idx(
|
||||||
&mut state,
|
&mut state,
|
||||||
self.workspaces.len() as u8 + 1,
|
self.workspaces.len() as u8 + 1,
|
||||||
|
|
@ -271,7 +276,8 @@ impl WorkspaceSet {
|
||||||
// add empty ones
|
// add empty ones
|
||||||
let outputs = outputs.collect::<Vec<_>>();
|
let outputs = outputs.collect::<Vec<_>>();
|
||||||
while amount > self.workspaces.len() {
|
while amount > self.workspaces.len() {
|
||||||
let mut workspace = create_workspace(&mut state, &self.group, false);
|
let mut workspace =
|
||||||
|
create_workspace(&mut state, &self.group, false, self.tiling_enabled);
|
||||||
workspace_set_idx(
|
workspace_set_idx(
|
||||||
&mut state,
|
&mut state,
|
||||||
self.workspaces.len() as u8 + 1,
|
self.workspaces.len() as u8 + 1,
|
||||||
|
|
@ -296,6 +302,15 @@ impl WorkspaceSet {
|
||||||
workspace_set_idx(state, i as u8 + 1, idx, &workspace.handle);
|
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)]
|
#[derive(Debug)]
|
||||||
|
|
@ -309,10 +324,11 @@ impl WorkspaceMode {
|
||||||
config: crate::config::WorkspaceMode,
|
config: crate::config::WorkspaceMode,
|
||||||
amount: WorkspaceAmount,
|
amount: WorkspaceAmount,
|
||||||
state: &mut WorkspaceUpdateGuard<'_, State>,
|
state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
|
tiling_enabled: bool,
|
||||||
) -> WorkspaceMode {
|
) -> WorkspaceMode {
|
||||||
match config {
|
match config {
|
||||||
crate::config::WorkspaceMode::Global => {
|
crate::config::WorkspaceMode::Global => {
|
||||||
WorkspaceMode::Global(WorkspaceSet::new(state, amount, 0))
|
WorkspaceMode::Global(WorkspaceSet::new(state, amount, 0, tiling_enabled))
|
||||||
}
|
}
|
||||||
crate::config::WorkspaceMode::OutputBound => {
|
crate::config::WorkspaceMode::OutputBound => {
|
||||||
WorkspaceMode::OutputBound(HashMap::new(), amount)
|
WorkspaceMode::OutputBound(HashMap::new(), amount)
|
||||||
|
|
@ -412,6 +428,17 @@ impl WorkspaceMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update_tiling_status(&mut self, seat: &Seat<State>, tiling: bool) {
|
||||||
|
match self {
|
||||||
|
WorkspaceMode::Global(set) => set.update_tiling_status(seat, tiling),
|
||||||
|
WorkspaceMode::OutputBound(sets, _) => {
|
||||||
|
for set in sets.values_mut() {
|
||||||
|
set.update_tiling_status(seat, tiling)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Shell {
|
impl Shell {
|
||||||
|
|
@ -439,18 +466,19 @@ impl Shell {
|
||||||
|_| true,
|
|_| true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let tiling_enabled = config.static_conf.tiling_enabled;
|
||||||
let mode = WorkspaceMode::new(
|
let mode = WorkspaceMode::new(
|
||||||
config.static_conf.workspace_mode,
|
config.static_conf.workspace_mode,
|
||||||
config.static_conf.workspace_amount,
|
config.static_conf.workspace_amount,
|
||||||
&mut workspace_state.update(),
|
&mut workspace_state.update(),
|
||||||
|
tiling_enabled,
|
||||||
);
|
);
|
||||||
let floating_default = config.static_conf.floating_default;
|
|
||||||
|
|
||||||
Shell {
|
Shell {
|
||||||
popups: PopupManager::new(None),
|
popups: PopupManager::new(None),
|
||||||
outputs: Vec::new(),
|
outputs: Vec::new(),
|
||||||
workspaces: mode,
|
workspaces: mode,
|
||||||
floating_default,
|
tiling_enabled,
|
||||||
|
|
||||||
pending_windows: Vec::new(),
|
pending_windows: Vec::new(),
|
||||||
pending_layers: Vec::new(),
|
pending_layers: Vec::new(),
|
||||||
|
|
@ -476,7 +504,8 @@ impl Shell {
|
||||||
WorkspaceMode::OutputBound(sets, amount) => {
|
WorkspaceMode::OutputBound(sets, amount) => {
|
||||||
// TODO: Restore previously assigned workspaces, if possible!
|
// TODO: Restore previously assigned workspaces, if possible!
|
||||||
if !sets.contains_key(output) {
|
if !sets.contains_key(output) {
|
||||||
let set = WorkspaceSet::new(&mut state, *amount, sets.len());
|
let set =
|
||||||
|
WorkspaceSet::new(&mut state, *amount, sets.len(), self.tiling_enabled);
|
||||||
state.add_group_output(&set.group, &output);
|
state.add_group_output(&set.group, &output);
|
||||||
sets.insert(output.clone(), set);
|
sets.insert(output.clone(), set);
|
||||||
}
|
}
|
||||||
|
|
@ -521,6 +550,9 @@ impl Shell {
|
||||||
|
|
||||||
match &mut self.workspaces {
|
match &mut self.workspaces {
|
||||||
WorkspaceMode::OutputBound(sets, _) => {
|
WorkspaceMode::OutputBound(sets, _) => {
|
||||||
|
// TODO:
|
||||||
|
// If amount::static merge them instead of appending
|
||||||
|
|
||||||
if let Some(set) = sets.remove(output) {
|
if let Some(set) = sets.remove(output) {
|
||||||
// TODO: Heuristic which output to move to.
|
// TODO: Heuristic which output to move to.
|
||||||
// It is supposed to be the *most* internal, we just pick the first one for now
|
// It is supposed to be the *most* internal, we just pick the first one for now
|
||||||
|
|
@ -599,7 +631,12 @@ impl Shell {
|
||||||
};
|
};
|
||||||
|
|
||||||
// in this case we have to merge our sets, preserving placing of windows as nicely as possible
|
// in this case we have to merge our sets, preserving placing of windows as nicely as possible
|
||||||
let mut new_set = WorkspaceSet::new(&mut state, WorkspaceAmount::Static(0), 0);
|
let mut new_set = WorkspaceSet::new(
|
||||||
|
&mut state,
|
||||||
|
WorkspaceAmount::Static(0),
|
||||||
|
0,
|
||||||
|
self.tiling_enabled,
|
||||||
|
);
|
||||||
for output in &self.outputs {
|
for output in &self.outputs {
|
||||||
state.add_group_output(&new_set.group, output);
|
state.add_group_output(&new_set.group, output);
|
||||||
}
|
}
|
||||||
|
|
@ -660,7 +697,7 @@ impl Shell {
|
||||||
);
|
);
|
||||||
workspace_set_idx(&mut state, i as u8 + 1, 0, &workspace_handle);
|
workspace_set_idx(&mut state, i as u8 + 1, 0, &workspace_handle);
|
||||||
|
|
||||||
let mut new_workspace = Workspace::new(workspace_handle);
|
let mut new_workspace = Workspace::new(workspace_handle, self.tiling_enabled);
|
||||||
for output in self.outputs.iter() {
|
for output in self.outputs.iter() {
|
||||||
new_workspace.map_output(output, output.current_location());
|
new_workspace.map_output(output, output.current_location());
|
||||||
}
|
}
|
||||||
|
|
@ -705,7 +742,12 @@ impl Shell {
|
||||||
// split workspaces apart, preserving window positions relative to their outputs
|
// split workspaces apart, preserving window positions relative to their outputs
|
||||||
let mut sets = HashMap::new();
|
let mut sets = HashMap::new();
|
||||||
for (i, output) in self.outputs.iter().enumerate() {
|
for (i, output) in self.outputs.iter().enumerate() {
|
||||||
let set = WorkspaceSet::new(&mut state, WorkspaceAmount::Static(0), i);
|
let set = WorkspaceSet::new(
|
||||||
|
&mut state,
|
||||||
|
WorkspaceAmount::Static(0),
|
||||||
|
i,
|
||||||
|
self.tiling_enabled,
|
||||||
|
);
|
||||||
state.add_group_output(&set.group, output);
|
state.add_group_output(&set.group, output);
|
||||||
sets.insert(output.clone(), set);
|
sets.insert(output.clone(), set);
|
||||||
}
|
}
|
||||||
|
|
@ -770,7 +812,7 @@ impl Shell {
|
||||||
.filter(|(key, _)| *key == output)
|
.filter(|(key, _)| *key == output)
|
||||||
.map(|(o, w)| (o.clone(), w.clone()))
|
.map(|(o, w)| (o.clone(), w.clone()))
|
||||||
.collect(),
|
.collect(),
|
||||||
..Workspace::new(new_workspace_handle)
|
..Workspace::new(new_workspace_handle, true)
|
||||||
};
|
};
|
||||||
for toplevel in new_workspace.windows() {
|
for toplevel in new_workspace.windows() {
|
||||||
self.toplevel_info_state
|
self.toplevel_info_state
|
||||||
|
|
@ -1036,7 +1078,7 @@ impl Shell {
|
||||||
{
|
{
|
||||||
mapped.set_debug(state.common.egui.active);
|
mapped.set_debug(state.common.egui.active);
|
||||||
}
|
}
|
||||||
if layout::should_be_floating(&window) || state.common.shell.floating_default {
|
if layout::should_be_floating(&window) || !workspace.tiling_enabled {
|
||||||
workspace.floating_layer.map(mapped.clone(), &seat, None);
|
workspace.floating_layer.map(mapped.clone(), &seat, None);
|
||||||
} else {
|
} else {
|
||||||
let focus_stack = workspace.focus_stack.get(&seat);
|
let focus_stack = workspace.focus_stack.get(&seat);
|
||||||
|
|
|
||||||
|
|
@ -61,11 +61,11 @@ pub enum ManagedState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Workspace {
|
impl Workspace {
|
||||||
pub fn new(handle: WorkspaceHandle) -> Workspace {
|
pub fn new(handle: WorkspaceHandle, tiling_enabled: bool) -> Workspace {
|
||||||
Workspace {
|
Workspace {
|
||||||
tiling_layer: TilingLayout::new(),
|
tiling_layer: TilingLayout::new(),
|
||||||
floating_layer: FloatingLayout::new(),
|
floating_layer: FloatingLayout::new(),
|
||||||
tiling_enabled: true,
|
tiling_enabled,
|
||||||
fullscreen: HashMap::new(),
|
fullscreen: HashMap::new(),
|
||||||
handle,
|
handle,
|
||||||
focus_stack: FocusStacks::default(),
|
focus_stack: FocusStacks::default(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue