shell: Move seats into shell
This commit is contained in:
parent
1216cd0b67
commit
647deb81f1
31 changed files with 824 additions and 883 deletions
|
|
@ -48,7 +48,6 @@ use smithay::{
|
|||
udev::{all_gpus, primary_gpu, UdevBackend, UdevEvent},
|
||||
},
|
||||
desktop::utils::OutputPresentationFeedback,
|
||||
input::Seat,
|
||||
output::{Mode as OutputMode, Output, OutputNoMode, PhysicalProperties, Subpixel},
|
||||
reexports::{
|
||||
calloop::{
|
||||
|
|
@ -324,12 +323,10 @@ pub fn init_backend(
|
|||
}
|
||||
}
|
||||
|
||||
let seats = state.common.seats().cloned().collect::<Vec<_>>();
|
||||
state.common.config.read_outputs(
|
||||
&mut state.common.output_configuration_state,
|
||||
&mut state.backend,
|
||||
&mut state.common.shell,
|
||||
seats.into_iter(),
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
for surface in state
|
||||
|
|
@ -701,12 +698,10 @@ impl State {
|
|||
self.common
|
||||
.output_configuration_state
|
||||
.add_heads(wl_outputs.iter());
|
||||
let seats = self.common.seats().cloned().collect::<Vec<_>>();
|
||||
self.common.config.read_outputs(
|
||||
&mut self.common.output_configuration_state,
|
||||
&mut self.backend,
|
||||
&mut self.common.shell,
|
||||
seats.into_iter(),
|
||||
&self.common.event_loop_handle,
|
||||
);
|
||||
|
||||
|
|
@ -836,12 +831,10 @@ impl State {
|
|||
self.common
|
||||
.output_configuration_state
|
||||
.add_heads(outputs_added.iter());
|
||||
let seats = self.common.seats().cloned().collect::<Vec<_>>();
|
||||
self.common.config.read_outputs(
|
||||
&mut self.common.output_configuration_state,
|
||||
&mut self.backend,
|
||||
&mut self.common.shell,
|
||||
seats.iter().cloned(),
|
||||
&self.common.event_loop_handle,
|
||||
);
|
||||
// Don't remove the outputs, before potentially new ones have been initialized.
|
||||
|
|
@ -849,9 +842,7 @@ impl State {
|
|||
// If we have 0 outputs at some point, we won't quit, but shell doesn't know where to move
|
||||
// windows and workspaces to.
|
||||
for output in outputs_removed {
|
||||
self.common
|
||||
.shell
|
||||
.remove_output(&output, seats.iter().cloned());
|
||||
self.common.shell.remove_output(&output);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -896,18 +887,14 @@ impl State {
|
|||
.output_configuration_state
|
||||
.remove_heads(outputs_removed.iter());
|
||||
|
||||
let seats = self.common.seats().cloned().collect::<Vec<_>>();
|
||||
if self.backend.kms().session.is_active() {
|
||||
for output in outputs_removed {
|
||||
self.common
|
||||
.shell
|
||||
.remove_output(&output, seats.iter().cloned());
|
||||
self.common.shell.remove_output(&output);
|
||||
}
|
||||
self.common.config.read_outputs(
|
||||
&mut self.common.output_configuration_state,
|
||||
&mut self.backend,
|
||||
&mut self.common.shell,
|
||||
seats.into_iter(),
|
||||
&self.common.event_loop_handle,
|
||||
);
|
||||
} else {
|
||||
|
|
@ -1201,7 +1188,10 @@ impl Surface {
|
|||
let mut elements = workspace_elements(
|
||||
Some(&render_node),
|
||||
&mut renderer,
|
||||
state,
|
||||
&state.shell,
|
||||
&state.config,
|
||||
&state.theme,
|
||||
state.clock.now(),
|
||||
&self.output,
|
||||
previous_workspace,
|
||||
workspace,
|
||||
|
|
@ -1497,7 +1487,6 @@ impl KmsState {
|
|||
pub fn apply_config_for_output(
|
||||
&mut self,
|
||||
output: &Output,
|
||||
seats: impl Iterator<Item = Seat<State>>,
|
||||
shell: &mut Shell,
|
||||
test_only: bool,
|
||||
loop_handle: &LoopHandle<'_, State>,
|
||||
|
|
@ -1520,7 +1509,7 @@ impl KmsState {
|
|||
|
||||
if !output_config.enabled {
|
||||
if !test_only {
|
||||
shell.remove_output(output, seats);
|
||||
shell.remove_output(output);
|
||||
if surface.surface.take().is_some() {
|
||||
// just drop it
|
||||
surface.pending = false;
|
||||
|
|
|
|||
|
|
@ -48,14 +48,14 @@ pub fn init_backend_auto(
|
|||
.outputs()
|
||||
.next()
|
||||
.with_context(|| "Backend initialized without output")?;
|
||||
let initial_seat = crate::input::add_seat(
|
||||
let initial_seat = crate::shell::create_seat(
|
||||
dh,
|
||||
&mut state.common.seat_state,
|
||||
output,
|
||||
&state.common.config,
|
||||
"seat-0".into(),
|
||||
);
|
||||
state.common.add_seat(initial_seat);
|
||||
state.common.shell.seats.add_seat(initial_seat);
|
||||
}
|
||||
res
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,14 +12,15 @@ use std::{
|
|||
use crate::debug::fps_ui;
|
||||
use crate::{
|
||||
backend::render::element::DamageElement,
|
||||
config::Config,
|
||||
shell::{
|
||||
focus::target::WindowGroup,
|
||||
grabs::{SeatMenuGrabState, SeatMoveGrabState},
|
||||
layout::tiling::ANIMATION_DURATION,
|
||||
CosmicMapped, CosmicMappedRenderElement, OverviewMode, SessionLock, Trigger,
|
||||
CosmicMapped, CosmicMappedRenderElement, OverviewMode, SeatExt, SessionLock, Trigger,
|
||||
WorkspaceDelta, WorkspaceRenderElement,
|
||||
},
|
||||
state::{Common, Fps},
|
||||
state::Fps,
|
||||
utils::prelude::*,
|
||||
wayland::{
|
||||
handlers::{
|
||||
|
|
@ -30,6 +31,7 @@ use crate::{
|
|||
},
|
||||
};
|
||||
|
||||
use cosmic::Theme;
|
||||
use cosmic_comp_config::workspace::WorkspaceLayout;
|
||||
use keyframe::{ease, functions::EaseInOutCubic};
|
||||
use smithay::{
|
||||
|
|
@ -56,7 +58,7 @@ use smithay::{
|
|||
},
|
||||
desktop::{layer_map_for_output, PopupManager},
|
||||
output::{Output, OutputNoMode},
|
||||
utils::{IsAlive, Logical, Point, Rectangle, Scale, Transform},
|
||||
utils::{IsAlive, Logical, Monotonic, Point, Rectangle, Scale, Time, Transform},
|
||||
wayland::{
|
||||
dmabuf::get_dmabuf,
|
||||
shell::wlr_layer::Layer,
|
||||
|
|
@ -387,7 +389,9 @@ pub enum CursorMode {
|
|||
#[profiling::function]
|
||||
pub fn cursor_elements<'frame, R>(
|
||||
renderer: &mut R,
|
||||
state: &Common,
|
||||
shell: &Shell,
|
||||
theme: &Theme,
|
||||
now: Time<Monotonic>,
|
||||
output: &Output,
|
||||
mode: CursorMode,
|
||||
exclude_dnd_icon: bool,
|
||||
|
|
@ -400,7 +404,7 @@ where
|
|||
let scale = output.current_scale().fractional_scale();
|
||||
let mut elements = Vec::new();
|
||||
|
||||
for seat in state.seats() {
|
||||
for seat in shell.seats.iter() {
|
||||
let pointer = match seat.get_pointer() {
|
||||
Some(ptr) => ptr,
|
||||
None => continue,
|
||||
|
|
@ -414,7 +418,7 @@ where
|
|||
seat,
|
||||
location,
|
||||
scale.into(),
|
||||
state.clock.now(),
|
||||
now,
|
||||
mode != CursorMode::NotDefault,
|
||||
)
|
||||
.into_iter()
|
||||
|
|
@ -438,7 +442,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
let theme = state.theme.cosmic();
|
||||
let theme = theme.cosmic();
|
||||
if let Some(grab_elements) = seat
|
||||
.user_data()
|
||||
.get::<SeatMoveGrabState>()
|
||||
|
|
@ -469,7 +473,10 @@ where
|
|||
pub fn workspace_elements<R>(
|
||||
_gpu: Option<&DrmNode>,
|
||||
renderer: &mut R,
|
||||
state: &mut Common,
|
||||
shell: &Shell,
|
||||
config: &Config,
|
||||
theme: &Theme,
|
||||
now: Time<Monotonic>,
|
||||
output: &Output,
|
||||
previous: Option<(WorkspaceHandle, usize, WorkspaceDelta)>,
|
||||
current: (WorkspaceHandle, usize),
|
||||
|
|
@ -486,7 +493,9 @@ where
|
|||
{
|
||||
let mut elements = cursor_elements(
|
||||
renderer,
|
||||
state,
|
||||
shell,
|
||||
theme,
|
||||
now,
|
||||
output,
|
||||
cursor_mode,
|
||||
exclude_workspace_overview,
|
||||
|
|
@ -500,7 +509,8 @@ where
|
|||
if let Some(fps) = _fps.as_mut() {
|
||||
let fps_overlay = fps_ui(
|
||||
_gpu,
|
||||
state,
|
||||
shell,
|
||||
theme,
|
||||
renderer.glow_renderer_mut(),
|
||||
*fps,
|
||||
Rectangle::from_loc_and_size(
|
||||
|
|
@ -516,7 +526,7 @@ where
|
|||
}
|
||||
|
||||
// If session locked, only show session lock surfaces
|
||||
if let Some(session_lock) = &state.shell.session_lock {
|
||||
if let Some(session_lock) = &shell.session_lock {
|
||||
elements.extend(
|
||||
session_lock_elements(renderer, output, session_lock)
|
||||
.into_iter()
|
||||
|
|
@ -525,15 +535,13 @@ where
|
|||
return Ok(elements);
|
||||
}
|
||||
|
||||
let theme = state.theme.cosmic();
|
||||
|
||||
let overview = state.shell.overview_mode();
|
||||
let (resize_mode, resize_indicator) = state.shell.resize_mode();
|
||||
let theme = theme.cosmic();
|
||||
let overview = shell.overview_mode();
|
||||
let (resize_mode, resize_indicator) = shell.resize_mode();
|
||||
let resize_indicator = resize_indicator.map(|indicator| (resize_mode, indicator));
|
||||
let swap_tree = if let OverviewMode::Started(Trigger::KeyboardSwap(_, desc), _) = &overview.0 {
|
||||
if current.0 != desc.handle {
|
||||
state
|
||||
.shell
|
||||
shell
|
||||
.workspaces
|
||||
.space_for_handle(&desc.handle)
|
||||
.map(|w| w.tiling_layer.tree())
|
||||
|
|
@ -548,7 +556,7 @@ where
|
|||
overview.1.map(|indicator| (indicator, swap_tree)),
|
||||
);
|
||||
|
||||
let last_active_seat = state.last_active_seat().clone();
|
||||
let last_active_seat = shell.seats.last_active();
|
||||
let move_active = last_active_seat
|
||||
.user_data()
|
||||
.get::<SeatMoveGrabState>()
|
||||
|
|
@ -559,12 +567,7 @@ where
|
|||
let output_size = output.geometry().size;
|
||||
let output_scale = output.current_scale().fractional_scale();
|
||||
|
||||
let set = state
|
||||
.shell
|
||||
.workspaces
|
||||
.sets
|
||||
.get(output)
|
||||
.ok_or(OutputNoMode)?;
|
||||
let set = shell.workspaces.sets.get(output).ok_or(OutputNoMode)?;
|
||||
let workspace = set
|
||||
.workspaces
|
||||
.iter()
|
||||
|
|
@ -593,7 +596,7 @@ where
|
|||
Vec::new()
|
||||
};
|
||||
|
||||
let active_hint = if state.config.cosmic_conf.active_hint {
|
||||
let active_hint = if config.cosmic_conf.active_hint {
|
||||
theme.active_hint as u8
|
||||
} else {
|
||||
0
|
||||
|
|
@ -603,8 +606,7 @@ where
|
|||
// they need to be over sticky windows, because they could be popups of sticky windows,
|
||||
// and we can't differenciate that.
|
||||
elements.extend(
|
||||
state
|
||||
.shell
|
||||
shell
|
||||
.override_redirect_windows
|
||||
.iter()
|
||||
.filter(|or| {
|
||||
|
|
@ -653,7 +655,7 @@ where
|
|||
};
|
||||
|
||||
let current_focus = (!move_active && is_active_space)
|
||||
.then_some(&last_active_seat)
|
||||
.then_some(last_active_seat)
|
||||
.map(|seat| workspace.focus_stack.get(seat));
|
||||
|
||||
let (w_elements, p_elements) = set.sticky_layer.render(
|
||||
|
|
@ -683,10 +685,9 @@ where
|
|||
|
||||
let offset = match previous.as_ref() {
|
||||
Some((previous, previous_idx, start)) => {
|
||||
let layout = state.config.cosmic_conf.workspaces.workspace_layout;
|
||||
let layout = config.cosmic_conf.workspaces.workspace_layout;
|
||||
|
||||
let workspace = state
|
||||
.shell
|
||||
let workspace = shell
|
||||
.workspaces
|
||||
.space_for_handle(&previous)
|
||||
.ok_or(OutputNoMode)?;
|
||||
|
|
@ -724,7 +725,7 @@ where
|
|||
let (w_elements, p_elements) = workspace
|
||||
.render::<R>(
|
||||
renderer,
|
||||
(!move_active && is_active_space).then_some(&last_active_seat),
|
||||
(!move_active && is_active_space).then_some(last_active_seat),
|
||||
overview.clone(),
|
||||
resize_indicator.clone(),
|
||||
active_hint,
|
||||
|
|
@ -953,7 +954,10 @@ pub fn render_output<'d, R, Target, OffTarget>(
|
|||
target: Target,
|
||||
damage_tracker: &'d mut OutputDamageTracker,
|
||||
age: usize,
|
||||
state: &mut Common,
|
||||
shell: &Shell,
|
||||
config: &Config,
|
||||
theme: &Theme,
|
||||
now: Time<Monotonic>,
|
||||
output: &Output,
|
||||
cursor_mode: CursorMode,
|
||||
fps: Option<&mut Fps>,
|
||||
|
|
@ -975,8 +979,8 @@ where
|
|||
WorkspaceRenderElement<R>: RenderElement<R>,
|
||||
Target: Clone,
|
||||
{
|
||||
let (previous_workspace, workspace) = state.shell.workspaces.active(output);
|
||||
let (previous_idx, idx) = state.shell.workspaces.active_num(output);
|
||||
let (previous_workspace, workspace) = shell.workspaces.active(output);
|
||||
let (previous_idx, idx) = shell.workspaces.active_num(output);
|
||||
let previous_workspace = previous_workspace
|
||||
.zip(previous_idx)
|
||||
.map(|((w, start), idx)| (w.handle, idx, start));
|
||||
|
|
@ -989,7 +993,10 @@ where
|
|||
damage_tracker,
|
||||
age,
|
||||
None,
|
||||
state,
|
||||
shell,
|
||||
config,
|
||||
theme,
|
||||
now,
|
||||
output,
|
||||
previous_workspace,
|
||||
workspace,
|
||||
|
|
@ -1081,7 +1088,7 @@ where
|
|||
})
|
||||
},
|
||||
)? {
|
||||
frame.success(output.current_transform(), damage, state.clock.now());
|
||||
frame.success(output.current_transform(), damage, now);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1099,7 +1106,10 @@ pub fn render_workspace<'d, R, Target, OffTarget>(
|
|||
damage_tracker: &'d mut OutputDamageTracker,
|
||||
age: usize,
|
||||
additional_damage: Option<Vec<Rectangle<i32, Logical>>>,
|
||||
state: &mut Common,
|
||||
shell: &Shell,
|
||||
config: &Config,
|
||||
theme: &Theme,
|
||||
now: Time<Monotonic>,
|
||||
output: &Output,
|
||||
previous: Option<(WorkspaceHandle, usize, WorkspaceDelta)>,
|
||||
current: (WorkspaceHandle, usize),
|
||||
|
|
@ -1136,7 +1146,10 @@ where
|
|||
let mut elements: Vec<CosmicElement<R>> = workspace_elements(
|
||||
gpu,
|
||||
renderer,
|
||||
state,
|
||||
shell,
|
||||
config,
|
||||
theme,
|
||||
now,
|
||||
output,
|
||||
previous,
|
||||
current,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
use crate::{
|
||||
backend::render,
|
||||
config::OutputConfig,
|
||||
input::Devices,
|
||||
shell::{Devices, SeatExt},
|
||||
state::{BackendData, Common},
|
||||
utils::prelude::*,
|
||||
};
|
||||
|
|
@ -63,7 +63,10 @@ impl WinitState {
|
|||
surface.clone(),
|
||||
&mut self.damage_tracker,
|
||||
age,
|
||||
state,
|
||||
&state.shell,
|
||||
&state.config,
|
||||
&state.theme,
|
||||
state.clock.now(),
|
||||
&self.output,
|
||||
CursorMode::NotDefault,
|
||||
#[cfg(not(feature = "debug"))]
|
||||
|
|
@ -198,8 +201,7 @@ pub fn init_backend(
|
|||
}
|
||||
PumpStatus::Exit(_) => {
|
||||
let output = state.backend.winit().output.clone();
|
||||
let seats = state.common.seats().cloned().collect::<Vec<_>>();
|
||||
state.common.shell.remove_output(&output, seats.into_iter());
|
||||
state.common.shell.remove_output(&output);
|
||||
if let Some(token) = token.take() {
|
||||
event_loop_handle.remove(token);
|
||||
}
|
||||
|
|
@ -225,12 +227,10 @@ pub fn init_backend(
|
|||
.output_configuration_state
|
||||
.add_heads(std::iter::once(&output));
|
||||
state.common.shell.add_output(&output);
|
||||
let seats = state.common.seats().cloned().collect::<Vec<_>>();
|
||||
state.common.config.read_outputs(
|
||||
&mut state.common.output_configuration_state,
|
||||
&mut state.backend,
|
||||
&mut state.common.shell,
|
||||
seats.iter().cloned(),
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
state.launch_xwayland(None);
|
||||
|
|
@ -299,7 +299,7 @@ impl State {
|
|||
// here we can handle special cases for winit inputs
|
||||
match event {
|
||||
WinitEvent::Focus(true) => {
|
||||
for seat in self.common.seats().cloned().collect::<Vec<_>>().iter() {
|
||||
for seat in self.common.shell.seats.iter() {
|
||||
let devices = seat.user_data().get::<Devices>().unwrap();
|
||||
if devices.has_device(&WinitVirtualDevice) {
|
||||
seat.set_active_output(&self.backend.winit().output);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
use crate::{
|
||||
backend::render,
|
||||
config::OutputConfig,
|
||||
input::Devices,
|
||||
shell::{Devices, SeatExt},
|
||||
state::{BackendData, Common},
|
||||
utils::prelude::*,
|
||||
};
|
||||
|
|
@ -222,7 +222,10 @@ impl Surface {
|
|||
buffer.clone(),
|
||||
&mut self.damage_tracker,
|
||||
age as usize,
|
||||
state,
|
||||
&state.shell,
|
||||
&state.config,
|
||||
&state.theme,
|
||||
state.clock.now(),
|
||||
&self.output,
|
||||
render::CursorMode::NotDefault,
|
||||
#[cfg(not(feature = "debug"))]
|
||||
|
|
@ -362,12 +365,10 @@ pub fn init_backend(
|
|||
.output_configuration_state
|
||||
.add_heads(std::iter::once(&output));
|
||||
state.common.shell.add_output(&output);
|
||||
let seats = state.common.seats().cloned().collect::<Vec<_>>();
|
||||
state.common.config.read_outputs(
|
||||
&mut state.common.output_configuration_state,
|
||||
&mut state.backend,
|
||||
&mut state.common.shell,
|
||||
seats.iter().cloned(),
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
state.launch_xwayland(None);
|
||||
|
|
@ -394,10 +395,7 @@ pub fn init_backend(
|
|||
.surfaces
|
||||
.retain(|s| s.window.id() != window_id);
|
||||
for output in outputs_removed.into_iter() {
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.remove_output(&output, seats.iter().cloned());
|
||||
state.common.shell.remove_output(&output);
|
||||
}
|
||||
}
|
||||
X11Event::Resized {
|
||||
|
|
@ -506,7 +504,7 @@ impl State {
|
|||
.unwrap();
|
||||
|
||||
let device = event.device();
|
||||
for seat in self.common.seats().cloned().collect::<Vec<_>>().iter() {
|
||||
for seat in self.common.shell.seats.iter() {
|
||||
let devices = seat.user_data().get::<Devices>().unwrap();
|
||||
if devices.has_device(&device) {
|
||||
seat.set_active_output(&output);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue