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