diff --git a/src/backend/render/mod.rs b/src/backend/render/mod.rs index 76f853e1..e08f2b5e 100644 --- a/src/backend/render/mod.rs +++ b/src/backend/render/mod.rs @@ -66,8 +66,6 @@ pub type GlMultiFrame<'a, 'b, 'frame> = pub static CLEAR_COLOR: [f32; 4] = [0.153, 0.161, 0.165, 1.0]; pub static FOCUS_INDICATOR_COLOR: [f32; 4] = [0.580, 0.921, 0.921, 1.0]; -pub static FOCUS_INDICATOR_THICKNESS: f32 = 4.0; -pub static FOCUS_INDICATOR_RADIUS: f32 = 8.0; pub static FOCUS_INDICATOR_SHADER: &str = include_str!("./shaders/focus_indicator.frag"); pub struct IndicatorShader(pub Gles2PixelProgram); @@ -87,8 +85,9 @@ impl IndicatorShader { pub fn element( renderer: &R, geo: Rectangle, + thickness: u8, ) -> PixelShaderElement { - let thickness = FOCUS_INDICATOR_THICKNESS; + let thickness: f32 = thickness as f32; let thickness_loc = (thickness as i32, thickness as i32); let thickness_size = ((thickness * 2.0) as i32, (thickness * 2.0) as i32); let geo = Rectangle::from_loc_and_size( @@ -120,7 +119,7 @@ impl IndicatorShader { vec![ Uniform::new("color", [color[0], color[1], color[2]]), Uniform::new("thickness", thickness), - Uniform::new("radius", FOCUS_INDICATOR_RADIUS), + Uniform::new("radius", thickness * 2.0), ], ); if !user_data.insert_if_missing(|| IndicatorElement(RefCell::new(elem.clone()))) { @@ -301,6 +300,7 @@ where &state.shell.override_redirect_windows, state.xwayland_state.as_mut(), (!move_active && active_output).then_some(&last_active_seat), + state.config.static_conf.active_hint, exclude_workspace_overview, ) .map_err(|_| OutputNoMode)? diff --git a/src/config/mod.rs b/src/config/mod.rs index c7107dc1..b5e0af94 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -37,6 +37,8 @@ pub struct StaticConfig { pub workspace_mode: WorkspaceMode, pub workspace_amount: WorkspaceAmount, pub tiling_enabled: bool, + #[serde(default = "default_active_hint")] + pub active_hint: u8, } #[derive(Debug, Deserialize, Clone, Copy, PartialEq, Eq)] @@ -77,6 +79,10 @@ fn default_enabled() -> bool { true } +fn default_active_hint() -> u8 { + 4 +} + #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] pub struct OutputConfig { pub mode: ((i32, i32), Option), @@ -221,6 +227,7 @@ impl Config { workspace_mode: WorkspaceMode::Global, workspace_amount: WorkspaceAmount::Dynamic, tiling_enabled: false, + active_hint: default_active_hint(), } } diff --git a/src/shell/layout/floating/grabs/moving.rs b/src/shell/layout/floating/grabs/moving.rs index 9f1d94b1..047150bb 100644 --- a/src/shell/layout/floating/grabs/moving.rs +++ b/src/shell/layout/floating/grabs/moving.rs @@ -34,6 +34,7 @@ pub type SeatMoveGrabState = RefCell>; pub struct MoveGrabState { window: CosmicMapped, window_offset: Point, + indicator_thickness: u8, } impl MoveGrabState { @@ -59,11 +60,17 @@ impl MoveGrabState { let scale = output.current_scale().fractional_scale().into(); let render_location = cursor_at.to_i32_round() - output.geometry().loc + self.window_offset; - let mut elements: Vec = vec![CosmicMappedRenderElement::from(IndicatorShader::element( - renderer, - Rectangle::from_loc_and_size(render_location, self.window.geometry().size), - )) - .into()]; + let mut elements: Vec = Vec::new(); + if self.indicator_thickness > 0 { + elements.push( + CosmicMappedRenderElement::from(IndicatorShader::element( + renderer, + Rectangle::from_loc_and_size(render_location, self.window.geometry().size), + self.indicator_thickness, + )) + .into(), + ); + } elements.extend(AsRenderElements::::render_elements::( &self.window, renderer, @@ -172,6 +179,7 @@ impl MoveSurfaceGrab { seat: &Seat, initial_cursor_location: Point, initial_window_location: Point, + indicator_thickness: u8, ) -> MoveSurfaceGrab { let output = seat.active_output(); let mut outputs = HashSet::new(); @@ -182,6 +190,7 @@ impl MoveSurfaceGrab { window: window.clone(), window_offset: dbg!(initial_window_location) - dbg!(initial_cursor_location.to_i32_round()), + indicator_thickness, }; *seat diff --git a/src/shell/layout/floating/mod.rs b/src/shell/layout/floating/mod.rs index 3b380ec2..cc519011 100644 --- a/src/shell/layout/floating/mod.rs +++ b/src/shell/layout/floating/mod.rs @@ -349,6 +349,7 @@ impl FloatingLayout { renderer: &mut R, output: &Output, focused: Option<&CosmicMapped>, + indicator_thickness: u8, ) -> Vec> where R: Renderer + ImportAll + ImportMem + AsGlowRenderer, @@ -372,14 +373,17 @@ impl FloatingLayout { output_scale.into(), ); if focused == Some(elem) { - let element = IndicatorShader::element( - renderer, - Rectangle::from_loc_and_size( - self.space.element_location(elem).unwrap(), - elem.geometry().size, - ), - ); - elements.insert(0, element.into()); + if indicator_thickness > 0 { + let element = IndicatorShader::element( + renderer, + Rectangle::from_loc_and_size( + self.space.element_location(elem).unwrap(), + elem.geometry().size, + ), + indicator_thickness, + ); + elements.insert(0, element.into()); + } } elements }) diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index 9223b656..a94a678e 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -1306,6 +1306,7 @@ impl TilingLayout { renderer: &mut R, output: &Output, focused: Option<&CosmicMapped>, + indicator_thickness: u8, ) -> Result>, OutputNotMapped> where R: Renderer + ImportAll + ImportMem + AsGlowRenderer, @@ -1383,11 +1384,14 @@ impl TilingLayout { Scale::from(output_scale), ); if focused == Some(mapped) { - let element = IndicatorShader::element( - renderer, - Rectangle::from_loc_and_size(loc, mapped.geometry().size), - ); - elements.insert(0, element.into()); + if indicator_thickness > 0 { + let element = IndicatorShader::element( + renderer, + Rectangle::from_loc_and_size(loc, mapped.geometry().size), + indicator_thickness, + ); + elements.insert(0, element.into()); + } } elements }) diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 6668cfe3..5eb7e8b8 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -1278,8 +1278,13 @@ impl Shell { .windows() .find(|(w, _)| w.wl_surface().as_ref() == Some(surface)) .unwrap(); - if let Some(grab) = workspace.move_request(&window, &seat, &output, start_data) - { + if let Some(grab) = workspace.move_request( + &window, + &seat, + &output, + start_data, + state.common.config.static_conf.active_hint, + ) { let handle = workspace.handle; state .common diff --git a/src/shell/workspace.rs b/src/shell/workspace.rs index ac512887..9d14e2ea 100644 --- a/src/shell/workspace.rs +++ b/src/shell/workspace.rs @@ -319,6 +319,7 @@ impl Workspace { seat: &Seat, output: &Output, start_data: PointerGrabStartData, + indicator_thickness: u8, ) -> Option { let pointer = seat.get_pointer().unwrap(); let pos = pointer.current_location(); @@ -348,6 +349,7 @@ impl Workspace { seat, pos, initial_window_location, + indicator_thickness, )) } else { None // TODO @@ -439,6 +441,7 @@ impl Workspace { override_redirect_windows: &[X11Surface], xwm_state: Option<&'a mut XWaylandState>, draw_focus_indicator: Option<&Seat>, + indicator_thickness: u8, exclude_workspace_overview: bool, ) -> Result>, OutputNotMapped> where @@ -572,7 +575,7 @@ impl Workspace { // floating surfaces render_elements.extend( self.floating_layer - .render_output::(renderer, output, focused.as_ref()) + .render_output::(renderer, output, focused.as_ref(), indicator_thickness) .into_iter() .map(WorkspaceRenderElement::from), ); @@ -580,7 +583,7 @@ impl Workspace { //tiling surfaces render_elements.extend( self.tiling_layer - .render_output::(renderer, output, focused.as_ref())? + .render_output::(renderer, output, focused.as_ref(), indicator_thickness)? .into_iter() .map(WorkspaceRenderElement::from), );