chore: Move some rendering-related state into the shell
This commit is contained in:
parent
cd90371c1e
commit
cf0b0f9d2d
6 changed files with 45 additions and 43 deletions
|
|
@ -477,9 +477,7 @@ where
|
||||||
pub fn workspace_elements<R>(
|
pub fn workspace_elements<R>(
|
||||||
_gpu: Option<&DrmNode>,
|
_gpu: Option<&DrmNode>,
|
||||||
renderer: &mut R,
|
renderer: &mut R,
|
||||||
shell: &Shell,
|
shell: &Arc<RwLock<Shell>>,
|
||||||
config: &Config,
|
|
||||||
theme: &Theme,
|
|
||||||
now: Time<Monotonic>,
|
now: Time<Monotonic>,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
previous: Option<(WorkspaceHandle, usize, WorkspaceDelta)>,
|
previous: Option<(WorkspaceHandle, usize, WorkspaceDelta)>,
|
||||||
|
|
@ -495,7 +493,10 @@ where
|
||||||
CosmicMappedRenderElement<R>: RenderElement<R>,
|
CosmicMappedRenderElement<R>: RenderElement<R>,
|
||||||
WorkspaceRenderElement<R>: RenderElement<R>,
|
WorkspaceRenderElement<R>: RenderElement<R>,
|
||||||
{
|
{
|
||||||
|
let theme = shell.read().unwrap().theme().clone();
|
||||||
let seats = shell
|
let seats = shell
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
.seats
|
.seats
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
|
|
@ -504,7 +505,7 @@ where
|
||||||
let mut elements = cursor_elements(
|
let mut elements = cursor_elements(
|
||||||
renderer,
|
renderer,
|
||||||
seats.iter(),
|
seats.iter(),
|
||||||
theme,
|
&theme,
|
||||||
now,
|
now,
|
||||||
output,
|
output,
|
||||||
cursor_mode,
|
cursor_mode,
|
||||||
|
|
@ -535,6 +536,8 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let shell = shell.read().unwrap();
|
||||||
|
|
||||||
// If session locked, only show session lock surfaces
|
// If session locked, only show session lock surfaces
|
||||||
if let Some(session_lock) = &shell.session_lock {
|
if let Some(session_lock) = &shell.session_lock {
|
||||||
elements.extend(
|
elements.extend(
|
||||||
|
|
@ -606,7 +609,7 @@ where
|
||||||
Vec::new()
|
Vec::new()
|
||||||
};
|
};
|
||||||
|
|
||||||
let active_hint = if config.cosmic_conf.active_hint {
|
let active_hint = if shell.active_hint {
|
||||||
theme.active_hint as u8
|
theme.active_hint as u8
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
|
|
@ -695,7 +698,7 @@ where
|
||||||
|
|
||||||
let offset = match previous.as_ref() {
|
let offset = match previous.as_ref() {
|
||||||
Some((previous, previous_idx, start)) => {
|
Some((previous, previous_idx, start)) => {
|
||||||
let layout = config.cosmic_conf.workspaces.workspace_layout;
|
let layout = shell.workspaces.layout;
|
||||||
|
|
||||||
let workspace = shell
|
let workspace = shell
|
||||||
.workspaces
|
.workspaces
|
||||||
|
|
@ -964,9 +967,7 @@ pub fn render_output<'d, R, Target, OffTarget>(
|
||||||
target: Target,
|
target: Target,
|
||||||
damage_tracker: &'d mut OutputDamageTracker,
|
damage_tracker: &'d mut OutputDamageTracker,
|
||||||
age: usize,
|
age: usize,
|
||||||
shell: &Shell,
|
shell: &Arc<RwLock<Shell>>,
|
||||||
config: &Config,
|
|
||||||
theme: &Theme,
|
|
||||||
now: Time<Monotonic>,
|
now: Time<Monotonic>,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
cursor_mode: CursorMode,
|
cursor_mode: CursorMode,
|
||||||
|
|
@ -989,12 +990,14 @@ where
|
||||||
WorkspaceRenderElement<R>: RenderElement<R>,
|
WorkspaceRenderElement<R>: RenderElement<R>,
|
||||||
Target: Clone,
|
Target: Clone,
|
||||||
{
|
{
|
||||||
let (previous_workspace, workspace) = shell.workspaces.active(output);
|
let shell_ref = shell.read().unwrap();
|
||||||
let (previous_idx, idx) = shell.workspaces.active_num(output);
|
let (previous_workspace, workspace) = shell_ref.workspaces.active(output);
|
||||||
|
let (previous_idx, idx) = shell_ref.workspaces.active_num(output);
|
||||||
let previous_workspace = previous_workspace
|
let previous_workspace = previous_workspace
|
||||||
.zip(previous_idx)
|
.zip(previous_idx)
|
||||||
.map(|((w, start), idx)| (w.handle, idx, start));
|
.map(|((w, start), idx)| (w.handle, idx, start));
|
||||||
let workspace = (workspace.handle, idx);
|
let workspace = (workspace.handle, idx);
|
||||||
|
std::mem::drop(shell_ref);
|
||||||
|
|
||||||
let result = render_workspace(
|
let result = render_workspace(
|
||||||
gpu,
|
gpu,
|
||||||
|
|
@ -1004,8 +1007,6 @@ where
|
||||||
age,
|
age,
|
||||||
None,
|
None,
|
||||||
shell,
|
shell,
|
||||||
config,
|
|
||||||
theme,
|
|
||||||
now,
|
now,
|
||||||
output,
|
output,
|
||||||
previous_workspace,
|
previous_workspace,
|
||||||
|
|
@ -1118,9 +1119,7 @@ pub fn render_workspace<'d, R, Target, OffTarget>(
|
||||||
damage_tracker: &'d mut OutputDamageTracker,
|
damage_tracker: &'d mut OutputDamageTracker,
|
||||||
age: usize,
|
age: usize,
|
||||||
additional_damage: Option<Vec<Rectangle<i32, Logical>>>,
|
additional_damage: Option<Vec<Rectangle<i32, Logical>>>,
|
||||||
shell: &Shell,
|
shell: &Arc<RwLock<Shell>>,
|
||||||
config: &Config,
|
|
||||||
theme: &Theme,
|
|
||||||
now: Time<Monotonic>,
|
now: Time<Monotonic>,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
previous: Option<(WorkspaceHandle, usize, WorkspaceDelta)>,
|
previous: Option<(WorkspaceHandle, usize, WorkspaceDelta)>,
|
||||||
|
|
@ -1154,8 +1153,6 @@ where
|
||||||
gpu,
|
gpu,
|
||||||
renderer,
|
renderer,
|
||||||
shell,
|
shell,
|
||||||
config,
|
|
||||||
theme,
|
|
||||||
now,
|
now,
|
||||||
output,
|
output,
|
||||||
previous,
|
previous,
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,7 @@ impl WinitState {
|
||||||
surface.clone(),
|
surface.clone(),
|
||||||
&mut self.damage_tracker,
|
&mut self.damage_tracker,
|
||||||
age,
|
age,
|
||||||
&*state.shell.read().unwrap(),
|
&state.shell,
|
||||||
&state.config,
|
|
||||||
&state.theme,
|
|
||||||
state.clock.now(),
|
state.clock.now(),
|
||||||
&self.output,
|
&self.output,
|
||||||
CursorMode::NotDefault,
|
CursorMode::NotDefault,
|
||||||
|
|
|
||||||
|
|
@ -219,9 +219,7 @@ impl Surface {
|
||||||
buffer.clone(),
|
buffer.clone(),
|
||||||
&mut self.damage_tracker,
|
&mut self.damage_tracker,
|
||||||
age as usize,
|
age as usize,
|
||||||
&*state.shell.read().unwrap(),
|
&state.shell,
|
||||||
&state.config,
|
|
||||||
&state.theme,
|
|
||||||
state.clock.now(),
|
state.clock.now(),
|
||||||
&self.output,
|
&self.output,
|
||||||
render::CursorMode::NotDefault,
|
render::CursorMode::NotDefault,
|
||||||
|
|
|
||||||
|
|
@ -1671,17 +1671,10 @@ impl State {
|
||||||
}
|
}
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
Action::Debug => {
|
Action::Debug => {
|
||||||
self.common.egui.active = !self.common.egui.active;
|
let mut shell = self.common.shell.write().unwrap();
|
||||||
for mapped in self
|
shell.debug_active = !shell.debug_active;
|
||||||
.common
|
for mapped in shell.workspaces.spaces().flat_map(|w| w.mapped()) {
|
||||||
.shell
|
mapped.set_debug(shell.debug_active);
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
.workspaces
|
|
||||||
.spaces()
|
|
||||||
.flat_map(|w| w.mapped())
|
|
||||||
{
|
|
||||||
mapped.set_debug(self.common.egui.active);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "debug"))]
|
#[cfg(not(feature = "debug"))]
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,10 @@ use std::{
|
||||||
};
|
};
|
||||||
use wayland_backend::server::ClientId;
|
use wayland_backend::server::ClientId;
|
||||||
|
|
||||||
use cosmic_comp_config::{workspace::WorkspaceMode, TileBehavior};
|
use cosmic_comp_config::{
|
||||||
|
workspace::{WorkspaceLayout, WorkspaceMode},
|
||||||
|
TileBehavior,
|
||||||
|
};
|
||||||
use cosmic_protocols::workspace::v1::server::zcosmic_workspace_handle_v1::{
|
use cosmic_protocols::workspace::v1::server::zcosmic_workspace_handle_v1::{
|
||||||
State as WState, TilingState,
|
State as WState, TilingState,
|
||||||
};
|
};
|
||||||
|
|
@ -200,6 +203,7 @@ pub struct Shell {
|
||||||
pub seats: Seats,
|
pub seats: Seats,
|
||||||
|
|
||||||
theme: cosmic::Theme,
|
theme: cosmic::Theme,
|
||||||
|
pub active_hint: bool,
|
||||||
overview_mode: OverviewMode,
|
overview_mode: OverviewMode,
|
||||||
swap_indicator: Option<SwapIndicator>,
|
swap_indicator: Option<SwapIndicator>,
|
||||||
resize_mode: ResizeMode,
|
resize_mode: ResizeMode,
|
||||||
|
|
@ -212,6 +216,9 @@ pub struct Shell {
|
||||||
Output,
|
Output,
|
||||||
)>,
|
)>,
|
||||||
resize_indicator: Option<ResizeIndicator>,
|
resize_indicator: Option<ResizeIndicator>,
|
||||||
|
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
debug_active: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -552,6 +559,7 @@ impl WorkspaceSet {
|
||||||
pub struct Workspaces {
|
pub struct Workspaces {
|
||||||
pub sets: IndexMap<Output, WorkspaceSet>,
|
pub sets: IndexMap<Output, WorkspaceSet>,
|
||||||
backup_set: Option<WorkspaceSet>,
|
backup_set: Option<WorkspaceSet>,
|
||||||
|
pub layout: WorkspaceLayout,
|
||||||
mode: WorkspaceMode,
|
mode: WorkspaceMode,
|
||||||
autotile: bool,
|
autotile: bool,
|
||||||
autotile_behavior: TileBehavior,
|
autotile_behavior: TileBehavior,
|
||||||
|
|
@ -563,6 +571,7 @@ impl Workspaces {
|
||||||
Workspaces {
|
Workspaces {
|
||||||
sets: IndexMap::new(),
|
sets: IndexMap::new(),
|
||||||
backup_set: None,
|
backup_set: None,
|
||||||
|
layout: config.cosmic_conf.workspaces.workspace_layout,
|
||||||
mode: config.cosmic_conf.workspaces.workspace_mode,
|
mode: config.cosmic_conf.workspaces.workspace_mode,
|
||||||
autotile: config.cosmic_conf.autotile,
|
autotile: config.cosmic_conf.autotile,
|
||||||
autotile_behavior: config.cosmic_conf.autotile_behavior,
|
autotile_behavior: config.cosmic_conf.autotile_behavior,
|
||||||
|
|
@ -736,6 +745,7 @@ impl Workspaces {
|
||||||
) {
|
) {
|
||||||
let old_mode = self.mode;
|
let old_mode = self.mode;
|
||||||
self.mode = config.cosmic_conf.workspaces.workspace_mode;
|
self.mode = config.cosmic_conf.workspaces.workspace_mode;
|
||||||
|
self.layout = config.cosmic_conf.workspaces.workspace_layout;
|
||||||
|
|
||||||
if self.sets.len() <= 1 {
|
if self.sets.len() <= 1 {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1091,6 +1101,8 @@ impl Common {
|
||||||
|
|
||||||
pub fn update_config(&mut self) {
|
pub fn update_config(&mut self) {
|
||||||
let mut shell = self.shell.write().unwrap();
|
let mut shell = self.shell.write().unwrap();
|
||||||
|
shell.active_hint = self.config.cosmic_conf.active_hint;
|
||||||
|
|
||||||
let mut workspace_state = self.workspace_state.update();
|
let mut workspace_state = self.workspace_state.update();
|
||||||
shell.workspaces.update_config(
|
shell.workspaces.update_config(
|
||||||
&self.config,
|
&self.config,
|
||||||
|
|
@ -1147,11 +1159,15 @@ impl Shell {
|
||||||
session_lock: None,
|
session_lock: None,
|
||||||
|
|
||||||
theme,
|
theme,
|
||||||
|
active_hint: config.cosmic_conf.active_hint,
|
||||||
overview_mode: OverviewMode::None,
|
overview_mode: OverviewMode::None,
|
||||||
swap_indicator: None,
|
swap_indicator: None,
|
||||||
resize_mode: ResizeMode::None,
|
resize_mode: ResizeMode::None,
|
||||||
resize_state: None,
|
resize_state: None,
|
||||||
resize_indicator: None,
|
resize_indicator: None,
|
||||||
|
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
debug_active: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1833,7 +1849,7 @@ impl Shell {
|
||||||
));
|
));
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
{
|
{
|
||||||
mapped.set_debug(state.common.egui.active);
|
mapped.set_debug(self.debug_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
let workspace_empty = workspace.mapped().next().is_none();
|
let workspace_empty = workspace.mapped().next().is_none();
|
||||||
|
|
@ -3162,6 +3178,10 @@ impl Shell {
|
||||||
.set_theme(theme.clone(), xdg_activation_state);
|
.set_theme(theme.clone(), xdg_activation_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn theme(&self) -> &cosmic::Theme {
|
||||||
|
&self.theme
|
||||||
|
}
|
||||||
|
|
||||||
pub fn take_presentation_feedback(
|
pub fn take_presentation_feedback(
|
||||||
&self,
|
&self,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
|
|
|
||||||
|
|
@ -284,9 +284,7 @@ pub fn render_workspace_to_buffer(
|
||||||
dt,
|
dt,
|
||||||
age,
|
age,
|
||||||
additional_damage,
|
additional_damage,
|
||||||
&*common.shell.read().unwrap(),
|
&common.shell,
|
||||||
&common.config,
|
|
||||||
&common.theme,
|
|
||||||
common.clock.now(),
|
common.clock.now(),
|
||||||
&output,
|
&output,
|
||||||
None,
|
None,
|
||||||
|
|
@ -312,9 +310,7 @@ pub fn render_workspace_to_buffer(
|
||||||
dt,
|
dt,
|
||||||
age,
|
age,
|
||||||
additional_damage,
|
additional_damage,
|
||||||
&*common.shell.read().unwrap(),
|
&common.shell,
|
||||||
&common.config,
|
|
||||||
&common.theme,
|
|
||||||
common.clock.now(),
|
common.clock.now(),
|
||||||
&output,
|
&output,
|
||||||
None,
|
None,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue