protocol/toplevel_management: Use WorkspaceHandle in argument

Already depends on `WorkspaceHandler`, so it can get the handle, and
toplevel info uses `WorkspaceHandle`s.
This commit is contained in:
Ian Douglas Scott 2025-02-20 10:29:23 -08:00 committed by Victoria Brekenfeld
parent 1f2434e590
commit 0a6f2726cb
2 changed files with 15 additions and 15 deletions

View file

@ -1,6 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
use cosmic_protocols::workspace::v1::server::zcosmic_workspace_handle_v1::ZcosmicWorkspaceHandleV1;
use smithay::{
desktop::{layer_map_for_output, WindowSurfaceType},
input::{pointer::MotionEvent, Seat},
@ -18,6 +17,7 @@ use crate::{
delegate_toplevel_management, toplevel_rectangle_for, ManagementWindow,
ToplevelManagementHandler, ToplevelManagementState,
},
workspace::WorkspaceHandle,
},
};
@ -101,13 +101,9 @@ impl ToplevelManagementHandler for State {
&mut self,
_dh: &DisplayHandle,
window: &<Self as ToplevelInfoHandler>::Window,
workspace: ZcosmicWorkspaceHandleV1,
to_handle: WorkspaceHandle,
_output: Output,
) {
let Some(to_handle) = self.common.workspace_state.get_workspace_handle(&workspace) else {
return;
};
let mut shell = self.common.shell.write().unwrap();
if let Some(mut mapped) = shell.element_for_surface(window).cloned() {
if let Some(from_workspace) = shell.space_for_mut(&mapped) {

View file

@ -12,14 +12,14 @@ use smithay::{
};
pub use cosmic_protocols::toplevel_management::v1::server::zcosmic_toplevel_manager_v1::ZcosmicToplelevelManagementCapabilitiesV1 as ManagementCapabilities;
use cosmic_protocols::{
toplevel_management::v1::server::zcosmic_toplevel_manager_v1::{
self, ZcosmicToplevelManagerV1,
},
workspace::v1::server::zcosmic_workspace_handle_v1::ZcosmicWorkspaceHandleV1,
use cosmic_protocols::toplevel_management::v1::server::zcosmic_toplevel_manager_v1::{
self, ZcosmicToplevelManagerV1,
};
use super::toplevel_info::{window_from_handle, ToplevelInfoHandler, ToplevelState, Window};
use super::{
toplevel_info::{window_from_handle, ToplevelInfoHandler, ToplevelState, Window},
workspace::WorkspaceHandle,
};
#[derive(Debug)]
pub struct ToplevelManagementState {
@ -68,7 +68,7 @@ where
&mut self,
dh: &DisplayHandle,
window: &<Self as ToplevelInfoHandler>::Window,
workspace: ZcosmicWorkspaceHandleV1,
workspace: WorkspaceHandle,
output: Output,
) {
}
@ -255,8 +255,12 @@ where
output,
} => {
let window = window_from_handle(toplevel).unwrap();
if let Some(output) = Output::from_resource(&output) {
state.move_to_workspace(dh, &window, workspace, output);
if let Some(workspace_handle) =
state.workspace_state().get_workspace_handle(&workspace)
{
if let Some(output) = Output::from_resource(&output) {
state.move_to_workspace(dh, &window, workspace_handle, output);
}
}
}
_ => unreachable!(),