menu: Allow toggling sticky state

This commit is contained in:
Victoria Brekenfeld 2023-12-20 20:19:42 +00:00 committed by Victoria Brekenfeld
parent e0d207fbe1
commit d2e394b957
7 changed files with 187 additions and 24 deletions

View file

@ -108,6 +108,8 @@ pub struct CosmicMapped {
pub last_geometry: Arc<Mutex<Option<Rectangle<i32, Local>>>>,
pub moved_since_mapped: Arc<AtomicBool>,
pub floating_tiled: Arc<Mutex<Option<TiledCorners>>>,
//sticky
pub previous_layer: Arc<Mutex<Option<ManagedLayer>>>,
#[cfg(feature = "debug")]
debug: Arc<Mutex<Option<smithay_egui::EguiState>>>,
@ -1118,6 +1120,7 @@ impl From<CosmicWindow> for CosmicMapped {
last_geometry: Arc::new(Mutex::new(None)),
moved_since_mapped: Arc::new(AtomicBool::new(false)),
floating_tiled: Arc::new(Mutex::new(None)),
previous_layer: Arc::new(Mutex::new(None)),
#[cfg(feature = "debug")]
debug: Arc::new(Mutex::new(None)),
}
@ -1135,6 +1138,7 @@ impl From<CosmicStack> for CosmicMapped {
last_geometry: Arc::new(Mutex::new(None)),
moved_since_mapped: Arc::new(AtomicBool::new(false)),
floating_tiled: Arc::new(Mutex::new(None)),
previous_layer: Arc::new(Mutex::new(None)),
#[cfg(feature = "debug")]
debug: Arc::new(Mutex::new(None)),
}

View file

@ -692,12 +692,27 @@ impl Program for CosmicStackInternal {
if let Some(mapped) =
state.common.shell.element_for_wl_surface(&surface).cloned()
{
if let Some(workspace) = state.common.shell.space_for_mut(&mapped) {
let position = workspace
let position = if let Some((output, set)) =
state.common.shell.workspaces.sets.iter().find(|(_, set)| {
set.sticky_layer.mapped().any(|m| m == &mapped)
}) {
set.sticky_layer
.element_geometry(&mapped)
.unwrap()
.loc
.to_global(&workspace.output);
.to_global(output)
} else if let Some(workspace) =
state.common.shell.space_for_mut(&mapped)
{
workspace
.element_geometry(&mapped)
.unwrap()
.loc
.to_global(&workspace.output)
} else {
return;
};
let mut cursor = seat
.get_pointer()
.unwrap()
@ -712,7 +727,6 @@ impl Program for CosmicStackInternal {
cursor - position.as_logical(),
true,
);
}
}
});
}

View file

@ -292,12 +292,27 @@ impl Program for CosmicWindowInternal {
if let Some(mapped) =
state.common.shell.element_for_wl_surface(&surface).cloned()
{
if let Some(workspace) = state.common.shell.space_for_mut(&mapped) {
let position = workspace
let position = if let Some((output, set)) =
state.common.shell.workspaces.sets.iter().find(|(_, set)| {
set.sticky_layer.mapped().any(|m| m == &mapped)
}) {
set.sticky_layer
.element_geometry(&mapped)
.unwrap()
.loc
.to_global(&workspace.output);
.to_global(output)
} else if let Some(workspace) =
state.common.shell.space_for_mut(&mapped)
{
workspace
.element_geometry(&mapped)
.unwrap()
.loc
.to_global(&workspace.output)
} else {
return;
};
let mut cursor = seat
.get_pointer()
.unwrap()
@ -312,7 +327,6 @@ impl Program for CosmicWindowInternal {
cursor - position.as_logical(),
false,
);
}
}
});
}