shell: Make active hint size configurable
This commit is contained in:
parent
6492cfb96a
commit
4bf2c8df79
7 changed files with 58 additions and 26 deletions
|
|
@ -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 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_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 static FOCUS_INDICATOR_SHADER: &str = include_str!("./shaders/focus_indicator.frag");
|
||||||
|
|
||||||
pub struct IndicatorShader(pub Gles2PixelProgram);
|
pub struct IndicatorShader(pub Gles2PixelProgram);
|
||||||
|
|
@ -87,8 +85,9 @@ impl IndicatorShader {
|
||||||
pub fn element<R: AsGlowRenderer>(
|
pub fn element<R: AsGlowRenderer>(
|
||||||
renderer: &R,
|
renderer: &R,
|
||||||
geo: Rectangle<i32, Logical>,
|
geo: Rectangle<i32, Logical>,
|
||||||
|
thickness: u8,
|
||||||
) -> PixelShaderElement {
|
) -> PixelShaderElement {
|
||||||
let thickness = FOCUS_INDICATOR_THICKNESS;
|
let thickness: f32 = thickness as f32;
|
||||||
let thickness_loc = (thickness as i32, thickness as i32);
|
let thickness_loc = (thickness as i32, thickness as i32);
|
||||||
let thickness_size = ((thickness * 2.0) as i32, (thickness * 2.0) as i32);
|
let thickness_size = ((thickness * 2.0) as i32, (thickness * 2.0) as i32);
|
||||||
let geo = Rectangle::from_loc_and_size(
|
let geo = Rectangle::from_loc_and_size(
|
||||||
|
|
@ -120,7 +119,7 @@ impl IndicatorShader {
|
||||||
vec![
|
vec![
|
||||||
Uniform::new("color", [color[0], color[1], color[2]]),
|
Uniform::new("color", [color[0], color[1], color[2]]),
|
||||||
Uniform::new("thickness", thickness),
|
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()))) {
|
if !user_data.insert_if_missing(|| IndicatorElement(RefCell::new(elem.clone()))) {
|
||||||
|
|
@ -301,6 +300,7 @@ where
|
||||||
&state.shell.override_redirect_windows,
|
&state.shell.override_redirect_windows,
|
||||||
state.xwayland_state.as_mut(),
|
state.xwayland_state.as_mut(),
|
||||||
(!move_active && active_output).then_some(&last_active_seat),
|
(!move_active && active_output).then_some(&last_active_seat),
|
||||||
|
state.config.static_conf.active_hint,
|
||||||
exclude_workspace_overview,
|
exclude_workspace_overview,
|
||||||
)
|
)
|
||||||
.map_err(|_| OutputNoMode)?
|
.map_err(|_| OutputNoMode)?
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ pub struct StaticConfig {
|
||||||
pub workspace_mode: WorkspaceMode,
|
pub workspace_mode: WorkspaceMode,
|
||||||
pub workspace_amount: WorkspaceAmount,
|
pub workspace_amount: WorkspaceAmount,
|
||||||
pub tiling_enabled: bool,
|
pub tiling_enabled: bool,
|
||||||
|
#[serde(default = "default_active_hint")]
|
||||||
|
pub active_hint: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, Clone, Copy, PartialEq, Eq)]
|
||||||
|
|
@ -77,6 +79,10 @@ fn default_enabled() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_active_hint() -> u8 {
|
||||||
|
4
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
|
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
|
||||||
pub struct OutputConfig {
|
pub struct OutputConfig {
|
||||||
pub mode: ((i32, i32), Option<u32>),
|
pub mode: ((i32, i32), Option<u32>),
|
||||||
|
|
@ -221,6 +227,7 @@ impl Config {
|
||||||
workspace_mode: WorkspaceMode::Global,
|
workspace_mode: WorkspaceMode::Global,
|
||||||
workspace_amount: WorkspaceAmount::Dynamic,
|
workspace_amount: WorkspaceAmount::Dynamic,
|
||||||
tiling_enabled: false,
|
tiling_enabled: false,
|
||||||
|
active_hint: default_active_hint(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ pub type SeatMoveGrabState = RefCell<Option<MoveGrabState>>;
|
||||||
pub struct MoveGrabState {
|
pub struct MoveGrabState {
|
||||||
window: CosmicMapped,
|
window: CosmicMapped,
|
||||||
window_offset: Point<i32, Logical>,
|
window_offset: Point<i32, Logical>,
|
||||||
|
indicator_thickness: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MoveGrabState {
|
impl MoveGrabState {
|
||||||
|
|
@ -59,11 +60,17 @@ impl MoveGrabState {
|
||||||
let scale = output.current_scale().fractional_scale().into();
|
let scale = output.current_scale().fractional_scale().into();
|
||||||
let render_location = cursor_at.to_i32_round() - output.geometry().loc + self.window_offset;
|
let render_location = cursor_at.to_i32_round() - output.geometry().loc + self.window_offset;
|
||||||
|
|
||||||
let mut elements: Vec<I> = vec![CosmicMappedRenderElement::from(IndicatorShader::element(
|
let mut elements: Vec<I> = Vec::new();
|
||||||
renderer,
|
if self.indicator_thickness > 0 {
|
||||||
Rectangle::from_loc_and_size(render_location, self.window.geometry().size),
|
elements.push(
|
||||||
))
|
CosmicMappedRenderElement::from(IndicatorShader::element(
|
||||||
.into()];
|
renderer,
|
||||||
|
Rectangle::from_loc_and_size(render_location, self.window.geometry().size),
|
||||||
|
self.indicator_thickness,
|
||||||
|
))
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
}
|
||||||
elements.extend(AsRenderElements::<R>::render_elements::<I>(
|
elements.extend(AsRenderElements::<R>::render_elements::<I>(
|
||||||
&self.window,
|
&self.window,
|
||||||
renderer,
|
renderer,
|
||||||
|
|
@ -172,6 +179,7 @@ impl MoveSurfaceGrab {
|
||||||
seat: &Seat<State>,
|
seat: &Seat<State>,
|
||||||
initial_cursor_location: Point<f64, Logical>,
|
initial_cursor_location: Point<f64, Logical>,
|
||||||
initial_window_location: Point<i32, Logical>,
|
initial_window_location: Point<i32, Logical>,
|
||||||
|
indicator_thickness: u8,
|
||||||
) -> MoveSurfaceGrab {
|
) -> MoveSurfaceGrab {
|
||||||
let output = seat.active_output();
|
let output = seat.active_output();
|
||||||
let mut outputs = HashSet::new();
|
let mut outputs = HashSet::new();
|
||||||
|
|
@ -182,6 +190,7 @@ impl MoveSurfaceGrab {
|
||||||
window: window.clone(),
|
window: window.clone(),
|
||||||
window_offset: dbg!(initial_window_location)
|
window_offset: dbg!(initial_window_location)
|
||||||
- dbg!(initial_cursor_location.to_i32_round()),
|
- dbg!(initial_cursor_location.to_i32_round()),
|
||||||
|
indicator_thickness,
|
||||||
};
|
};
|
||||||
|
|
||||||
*seat
|
*seat
|
||||||
|
|
|
||||||
|
|
@ -349,6 +349,7 @@ impl FloatingLayout {
|
||||||
renderer: &mut R,
|
renderer: &mut R,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
focused: Option<&CosmicMapped>,
|
focused: Option<&CosmicMapped>,
|
||||||
|
indicator_thickness: u8,
|
||||||
) -> Vec<CosmicMappedRenderElement<R>>
|
) -> Vec<CosmicMappedRenderElement<R>>
|
||||||
where
|
where
|
||||||
R: Renderer + ImportAll + ImportMem + AsGlowRenderer,
|
R: Renderer + ImportAll + ImportMem + AsGlowRenderer,
|
||||||
|
|
@ -372,14 +373,17 @@ impl FloatingLayout {
|
||||||
output_scale.into(),
|
output_scale.into(),
|
||||||
);
|
);
|
||||||
if focused == Some(elem) {
|
if focused == Some(elem) {
|
||||||
let element = IndicatorShader::element(
|
if indicator_thickness > 0 {
|
||||||
renderer,
|
let element = IndicatorShader::element(
|
||||||
Rectangle::from_loc_and_size(
|
renderer,
|
||||||
self.space.element_location(elem).unwrap(),
|
Rectangle::from_loc_and_size(
|
||||||
elem.geometry().size,
|
self.space.element_location(elem).unwrap(),
|
||||||
),
|
elem.geometry().size,
|
||||||
);
|
),
|
||||||
elements.insert(0, element.into());
|
indicator_thickness,
|
||||||
|
);
|
||||||
|
elements.insert(0, element.into());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elements
|
elements
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1306,6 +1306,7 @@ impl TilingLayout {
|
||||||
renderer: &mut R,
|
renderer: &mut R,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
focused: Option<&CosmicMapped>,
|
focused: Option<&CosmicMapped>,
|
||||||
|
indicator_thickness: u8,
|
||||||
) -> Result<Vec<CosmicMappedRenderElement<R>>, OutputNotMapped>
|
) -> Result<Vec<CosmicMappedRenderElement<R>>, OutputNotMapped>
|
||||||
where
|
where
|
||||||
R: Renderer + ImportAll + ImportMem + AsGlowRenderer,
|
R: Renderer + ImportAll + ImportMem + AsGlowRenderer,
|
||||||
|
|
@ -1383,11 +1384,14 @@ impl TilingLayout {
|
||||||
Scale::from(output_scale),
|
Scale::from(output_scale),
|
||||||
);
|
);
|
||||||
if focused == Some(mapped) {
|
if focused == Some(mapped) {
|
||||||
let element = IndicatorShader::element(
|
if indicator_thickness > 0 {
|
||||||
renderer,
|
let element = IndicatorShader::element(
|
||||||
Rectangle::from_loc_and_size(loc, mapped.geometry().size),
|
renderer,
|
||||||
);
|
Rectangle::from_loc_and_size(loc, mapped.geometry().size),
|
||||||
elements.insert(0, element.into());
|
indicator_thickness,
|
||||||
|
);
|
||||||
|
elements.insert(0, element.into());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elements
|
elements
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1278,8 +1278,13 @@ impl Shell {
|
||||||
.windows()
|
.windows()
|
||||||
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface))
|
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface))
|
||||||
.unwrap();
|
.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;
|
let handle = workspace.handle;
|
||||||
state
|
state
|
||||||
.common
|
.common
|
||||||
|
|
|
||||||
|
|
@ -319,6 +319,7 @@ impl Workspace {
|
||||||
seat: &Seat<State>,
|
seat: &Seat<State>,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
start_data: PointerGrabStartData<State>,
|
start_data: PointerGrabStartData<State>,
|
||||||
|
indicator_thickness: u8,
|
||||||
) -> Option<MoveSurfaceGrab> {
|
) -> Option<MoveSurfaceGrab> {
|
||||||
let pointer = seat.get_pointer().unwrap();
|
let pointer = seat.get_pointer().unwrap();
|
||||||
let pos = pointer.current_location();
|
let pos = pointer.current_location();
|
||||||
|
|
@ -348,6 +349,7 @@ impl Workspace {
|
||||||
seat,
|
seat,
|
||||||
pos,
|
pos,
|
||||||
initial_window_location,
|
initial_window_location,
|
||||||
|
indicator_thickness,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
None // TODO
|
None // TODO
|
||||||
|
|
@ -439,6 +441,7 @@ impl Workspace {
|
||||||
override_redirect_windows: &[X11Surface],
|
override_redirect_windows: &[X11Surface],
|
||||||
xwm_state: Option<&'a mut XWaylandState>,
|
xwm_state: Option<&'a mut XWaylandState>,
|
||||||
draw_focus_indicator: Option<&Seat<State>>,
|
draw_focus_indicator: Option<&Seat<State>>,
|
||||||
|
indicator_thickness: u8,
|
||||||
exclude_workspace_overview: bool,
|
exclude_workspace_overview: bool,
|
||||||
) -> Result<Vec<WorkspaceRenderElement<R>>, OutputNotMapped>
|
) -> Result<Vec<WorkspaceRenderElement<R>>, OutputNotMapped>
|
||||||
where
|
where
|
||||||
|
|
@ -572,7 +575,7 @@ impl Workspace {
|
||||||
// floating surfaces
|
// floating surfaces
|
||||||
render_elements.extend(
|
render_elements.extend(
|
||||||
self.floating_layer
|
self.floating_layer
|
||||||
.render_output::<R>(renderer, output, focused.as_ref())
|
.render_output::<R>(renderer, output, focused.as_ref(), indicator_thickness)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(WorkspaceRenderElement::from),
|
.map(WorkspaceRenderElement::from),
|
||||||
);
|
);
|
||||||
|
|
@ -580,7 +583,7 @@ impl Workspace {
|
||||||
//tiling surfaces
|
//tiling surfaces
|
||||||
render_elements.extend(
|
render_elements.extend(
|
||||||
self.tiling_layer
|
self.tiling_layer
|
||||||
.render_output::<R>(renderer, output, focused.as_ref())?
|
.render_output::<R>(renderer, output, focused.as_ref(), indicator_thickness)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(WorkspaceRenderElement::from),
|
.map(WorkspaceRenderElement::from),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue