mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Move focus ring into Tile
For now, will make the open animation better.
This commit is contained in:
@@ -76,7 +76,7 @@ impl TestCase for JustTile {
|
|||||||
let location = Point::from(((size.w - tile_size.w) / 2, (size.h - tile_size.h) / 2));
|
let location = Point::from(((size.w - tile_size.w) / 2, (size.h - tile_size.h) / 2));
|
||||||
|
|
||||||
self.tile
|
self.tile
|
||||||
.render(renderer, location, Scale::from(1.))
|
.render(renderer, location, Scale::from(1.), true)
|
||||||
.map(|elem| Box::new(elem) as _)
|
.map(|elem| Box::new(elem) as _)
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ pub struct Tile<W: LayoutElement> {
|
|||||||
/// The border around the window.
|
/// The border around the window.
|
||||||
border: FocusRing,
|
border: FocusRing,
|
||||||
|
|
||||||
|
/// The focus ring around the window.
|
||||||
|
///
|
||||||
|
/// It's supposed to be on the Workspace, but for the sake of a nicer open animation it's
|
||||||
|
/// currently here.
|
||||||
|
focus_ring: FocusRing,
|
||||||
|
|
||||||
/// Whether this tile is fullscreen.
|
/// Whether this tile is fullscreen.
|
||||||
///
|
///
|
||||||
/// This will update only when the `window` actually goes fullscreen, rather than right away,
|
/// This will update only when the `window` actually goes fullscreen, rather than right away,
|
||||||
@@ -49,6 +55,7 @@ impl<W: LayoutElement> Tile<W> {
|
|||||||
Self {
|
Self {
|
||||||
window,
|
window,
|
||||||
border: FocusRing::new(options.border),
|
border: FocusRing::new(options.border),
|
||||||
|
focus_ring: FocusRing::new(options.focus_ring),
|
||||||
is_fullscreen: false, // FIXME: up-to-date fullscreen right away, but we need size.
|
is_fullscreen: false, // FIXME: up-to-date fullscreen right away, but we need size.
|
||||||
fullscreen_backdrop: SolidColorBuffer::new((0, 0), [0., 0., 0., 1.]),
|
fullscreen_backdrop: SolidColorBuffer::new((0, 0), [0., 0., 0., 1.]),
|
||||||
fullscreen_size: Default::default(),
|
fullscreen_size: Default::default(),
|
||||||
@@ -58,6 +65,7 @@ impl<W: LayoutElement> Tile<W> {
|
|||||||
|
|
||||||
pub fn update_config(&mut self, options: Rc<Options>) {
|
pub fn update_config(&mut self, options: Rc<Options>) {
|
||||||
self.border.update_config(options.border);
|
self.border.update_config(options.border);
|
||||||
|
self.focus_ring.update_config(options.focus_ring);
|
||||||
self.options = options;
|
self.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +84,10 @@ impl<W: LayoutElement> Tile<W> {
|
|||||||
self.window.has_ssd(),
|
self.window.has_ssd(),
|
||||||
);
|
);
|
||||||
self.border.set_active(is_active);
|
self.border.set_active(is_active);
|
||||||
|
|
||||||
|
self.focus_ring
|
||||||
|
.update((0, 0).into(), self.tile_size(), self.has_ssd());
|
||||||
|
self.focus_ring.set_active(is_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window(&self) -> &W {
|
pub fn window(&self) -> &W {
|
||||||
@@ -244,6 +256,7 @@ impl<W: LayoutElement> Tile<W> {
|
|||||||
renderer: &mut R,
|
renderer: &mut R,
|
||||||
location: Point<i32, Logical>,
|
location: Point<i32, Logical>,
|
||||||
scale: Scale<f64>,
|
scale: Scale<f64>,
|
||||||
|
focus_ring: bool,
|
||||||
) -> impl Iterator<Item = TileRenderElement<R>> {
|
) -> impl Iterator<Item = TileRenderElement<R>> {
|
||||||
let window_pos = location + self.window_loc();
|
let window_pos = location + self.window_loc();
|
||||||
let rv = self
|
let rv = self
|
||||||
@@ -264,6 +277,18 @@ impl<W: LayoutElement> Tile<W> {
|
|||||||
});
|
});
|
||||||
let rv = rv.chain(elem.into_iter().flatten());
|
let rv = rv.chain(elem.into_iter().flatten());
|
||||||
|
|
||||||
|
let elem = focus_ring.then(|| {
|
||||||
|
self.focus_ring.render(scale).map(move |elem| {
|
||||||
|
RelocateRenderElement::from_element(
|
||||||
|
elem,
|
||||||
|
location.to_physical_precise_round(scale),
|
||||||
|
Relocate::Relative,
|
||||||
|
)
|
||||||
|
.into()
|
||||||
|
})
|
||||||
|
});
|
||||||
|
let rv = rv.chain(elem.into_iter().flatten());
|
||||||
|
|
||||||
let elem = self.is_fullscreen.then(|| {
|
let elem = self.is_fullscreen.then(|| {
|
||||||
let elem = SolidColorRenderElement::from_buffer(
|
let elem = SolidColorRenderElement::from_buffer(
|
||||||
&self.fullscreen_backdrop,
|
&self.fullscreen_backdrop,
|
||||||
|
|||||||
+5
-36
@@ -10,7 +10,6 @@ use smithay::output::Output;
|
|||||||
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
|
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
|
||||||
use smithay::utils::{Logical, Point, Rectangle, Scale, Size};
|
use smithay::utils::{Logical, Point, Rectangle, Scale, Size};
|
||||||
|
|
||||||
use super::focus_ring::{FocusRing, FocusRingRenderElement};
|
|
||||||
use super::tile::{Tile, TileRenderElement};
|
use super::tile::{Tile, TileRenderElement};
|
||||||
use super::{LayoutElement, Options};
|
use super::{LayoutElement, Options};
|
||||||
use crate::animation::Animation;
|
use crate::animation::Animation;
|
||||||
@@ -47,9 +46,6 @@ pub struct Workspace<W: LayoutElement> {
|
|||||||
/// Index of the currently active column, if any.
|
/// Index of the currently active column, if any.
|
||||||
pub active_column_idx: usize,
|
pub active_column_idx: usize,
|
||||||
|
|
||||||
/// Focus ring buffer and parameters.
|
|
||||||
focus_ring: FocusRing,
|
|
||||||
|
|
||||||
/// Offset of the view computed from the active column.
|
/// Offset of the view computed from the active column.
|
||||||
///
|
///
|
||||||
/// Any gaps, including left padding from work area left exclusive zone, is handled
|
/// Any gaps, including left padding from work area left exclusive zone, is handled
|
||||||
@@ -80,7 +76,6 @@ pub struct OutputId(String);
|
|||||||
niri_render_elements! {
|
niri_render_elements! {
|
||||||
WorkspaceRenderElement => {
|
WorkspaceRenderElement => {
|
||||||
Tile = TileRenderElement<R>,
|
Tile = TileRenderElement<R>,
|
||||||
FocusRing = FocusRingRenderElement,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +189,6 @@ impl<W: LayoutElement> Workspace<W> {
|
|||||||
output: Some(output),
|
output: Some(output),
|
||||||
columns: vec![],
|
columns: vec![],
|
||||||
active_column_idx: 0,
|
active_column_idx: 0,
|
||||||
focus_ring: FocusRing::new(options.focus_ring),
|
|
||||||
view_offset: 0,
|
view_offset: 0,
|
||||||
view_offset_anim: None,
|
view_offset_anim: None,
|
||||||
activate_prev_column_on_removal: false,
|
activate_prev_column_on_removal: false,
|
||||||
@@ -210,7 +204,6 @@ impl<W: LayoutElement> Workspace<W> {
|
|||||||
working_area: Rectangle::from_loc_and_size((0, 0), (1280, 720)),
|
working_area: Rectangle::from_loc_and_size((0, 0), (1280, 720)),
|
||||||
columns: vec![],
|
columns: vec![],
|
||||||
active_column_idx: 0,
|
active_column_idx: 0,
|
||||||
focus_ring: FocusRing::new(options.focus_ring),
|
|
||||||
view_offset: 0,
|
view_offset: 0,
|
||||||
view_offset_anim: None,
|
view_offset_anim: None,
|
||||||
activate_prev_column_on_removal: false,
|
activate_prev_column_on_removal: false,
|
||||||
@@ -230,8 +223,6 @@ impl<W: LayoutElement> Workspace<W> {
|
|||||||
None => (),
|
None => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
let view_pos = self.view_pos();
|
|
||||||
|
|
||||||
for (col_idx, col) in self.columns.iter_mut().enumerate() {
|
for (col_idx, col) in self.columns.iter_mut().enumerate() {
|
||||||
for (tile_idx, tile) in col.tiles.iter_mut().enumerate() {
|
for (tile_idx, tile) in col.tiles.iter_mut().enumerate() {
|
||||||
let is_active = is_active
|
let is_active = is_active
|
||||||
@@ -240,22 +231,6 @@ impl<W: LayoutElement> Workspace<W> {
|
|||||||
tile.advance_animations(current_time, is_active);
|
tile.advance_animations(current_time, is_active);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This shall one day become a proper animation.
|
|
||||||
if !self.columns.is_empty() {
|
|
||||||
let col = &self.columns[self.active_column_idx];
|
|
||||||
let active_tile = &col.tiles[col.active_tile_idx];
|
|
||||||
let size = active_tile.tile_size();
|
|
||||||
let has_ssd = active_tile.has_ssd();
|
|
||||||
|
|
||||||
let tile_pos = Point::from((
|
|
||||||
self.column_x(self.active_column_idx) - view_pos,
|
|
||||||
col.tile_y(col.active_tile_idx),
|
|
||||||
));
|
|
||||||
|
|
||||||
self.focus_ring.update(tile_pos, size, has_ssd);
|
|
||||||
self.focus_ring.set_active(is_active);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn are_animations_ongoing(&self) -> bool {
|
pub fn are_animations_ongoing(&self) -> bool {
|
||||||
@@ -263,9 +238,6 @@ impl<W: LayoutElement> Workspace<W> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_config(&mut self, options: Rc<Options>) {
|
pub fn update_config(&mut self, options: Rc<Options>) {
|
||||||
self.focus_ring.update_config(options.focus_ring);
|
|
||||||
// The focus ring buffer will be updated in a subsequent update_animations call.
|
|
||||||
|
|
||||||
for column in &mut self.columns {
|
for column in &mut self.columns {
|
||||||
column.update_config(options.clone());
|
column.update_config(options.clone());
|
||||||
}
|
}
|
||||||
@@ -1152,17 +1124,14 @@ impl<W: LayoutElement> Workspace<W> {
|
|||||||
let mut first = true;
|
let mut first = true;
|
||||||
|
|
||||||
for (tile, tile_pos) in self.tiles_in_render_order() {
|
for (tile, tile_pos) in self.tiles_in_render_order() {
|
||||||
// Draw the window itself.
|
// For the active tile (which comes first), draw the focus ring.
|
||||||
|
let focus_ring = first;
|
||||||
|
first = false;
|
||||||
|
|
||||||
rv.extend(
|
rv.extend(
|
||||||
tile.render(renderer, tile_pos, output_scale)
|
tile.render(renderer, tile_pos, output_scale, focus_ring)
|
||||||
.map(Into::into),
|
.map(Into::into),
|
||||||
);
|
);
|
||||||
|
|
||||||
// For the active tile (which comes first), draw the focus ring.
|
|
||||||
if first {
|
|
||||||
rv.extend(self.focus_ring.render(output_scale).map(Into::into));
|
|
||||||
first = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rv
|
rv
|
||||||
|
|||||||
Reference in New Issue
Block a user