1
0
Fork 0
forked from wry/wry

config: add focus-tiles action

This commit is contained in:
Julian Orth 2025-07-19 23:00:28 +02:00
parent bd85db5b59
commit 57a49d5299
11 changed files with 61 additions and 1 deletions

View file

@ -383,6 +383,10 @@ impl ConfigClient {
self.send(&ClientMessage::SeatFocusLayerRel { seat, direction }); self.send(&ClientMessage::SeatFocusLayerRel { seat, direction });
} }
pub fn seat_focus_tiles(&self, seat: Seat) {
self.send(&ClientMessage::SeatFocusTiles { seat });
}
pub fn seat_focus(&self, seat: Seat, direction: Direction) { pub fn seat_focus(&self, seat: Seat, direction: Direction) {
self.send(&ClientMessage::SeatFocus { seat, direction }); self.send(&ClientMessage::SeatFocus { seat, direction });
} }

View file

@ -741,6 +741,9 @@ pub enum ClientMessage<'a> {
seat: Seat, seat: Seat,
direction: LayerDirection, direction: LayerDirection,
}, },
SeatFocusTiles {
seat: Seat,
},
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]

View file

@ -316,6 +316,11 @@ impl Seat {
get!().seat_focus_layer_rel(self, direction) get!().seat_focus_layer_rel(self, direction)
} }
/// Moves the keyboard focus to the tile layer.
pub fn focus_tiles(self) {
get!().seat_focus_tiles(self)
}
/// Moves the keyboard focus of the seat in the specified direction. /// Moves the keyboard focus of the seat in the specified direction.
pub fn focus(self, direction: Direction) { pub fn focus(self, direction: Direction) {
get!().seat_focus(self, direction) get!().seat_focus(self, direction)

View file

@ -2198,6 +2198,12 @@ impl ConfigProxyHandler {
Ok(()) Ok(())
} }
fn handle_seat_focus_tiles(&self, seat: Seat) -> Result<(), CphError> {
let seat = self.get_seat(seat)?;
seat.focus_tiles();
Ok(())
}
fn spaces_change(&self) { fn spaces_change(&self) {
struct V; struct V;
impl NodeVisitorBase for V { impl NodeVisitorBase for V {
@ -3055,6 +3061,9 @@ impl ConfigProxyHandler {
ClientMessage::SeatFocusLayerRel { seat, direction } => self ClientMessage::SeatFocusLayerRel { seat, direction } => self
.handle_seat_focus_layer_rel(seat, direction) .handle_seat_focus_layer_rel(seat, direction)
.wrn("seat_focus_layer_rel")?, .wrn("seat_focus_layer_rel")?,
ClientMessage::SeatFocusTiles { seat } => {
self.handle_seat_focus_tiles(seat).wrn("seat_focus_tiles")?
}
} }
Ok(()) Ok(())
} }

View file

@ -936,6 +936,32 @@ impl WlSeatGlobal {
); );
} }
pub fn focus_tiles(self: &Rc<Self>) {
let current = self.keyboard_node.get();
if matches!(
current.node_layer().layer(),
NodeLayer::Tiled | NodeLayer::Fullscreen,
) {
return;
}
let Some(output) = current.node_output() else {
return;
};
let Some(ws) = output.workspace.get() else {
return;
};
let node = match ws.fullscreen.get() {
Some(fs) => fs as Rc<dyn Node>,
_ => match ws.container.get() {
Some(c) => c,
_ => return,
},
};
if node.node_visible() && node.node_accepts_focus() {
node.node_do_focus(self, Direction::Unspecified);
}
}
fn set_selection_<T, X, S>( fn set_selection_<T, X, S>(
self: &Rc<Self>, self: &Rc<Self>,
field: &CloneCell<Option<Rc<dyn DynDataSource>>>, field: &CloneCell<Option<Rc<dyn DynDataSource>>>,

View file

@ -76,6 +76,7 @@ pub enum SimpleCommand {
ToggleBar, ToggleBar,
FocusHistory(Timeline), FocusHistory(Timeline),
FocusLayerRel(LayerDirection), FocusLayerRel(LayerDirection),
FocusTiles,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View file

@ -141,6 +141,7 @@ impl ActionParser<'_> {
"focus-next" => FocusHistory(Timeline::Newer), "focus-next" => FocusHistory(Timeline::Newer),
"focus-below" => FocusLayerRel(LayerDirection::Below), "focus-below" => FocusLayerRel(LayerDirection::Below),
"focus-above" => FocusLayerRel(LayerDirection::Above), "focus-above" => FocusLayerRel(LayerDirection::Above),
"focus-tiles" => FocusTiles,
_ => { _ => {
return Err( return Err(
ActionParserError::UnknownSimpleAction(string.to_string()).spanned(span) ActionParserError::UnknownSimpleAction(string.to_string()).spanned(span)

View file

@ -164,6 +164,10 @@ impl Action {
let persistent = state.persistent.clone(); let persistent = state.persistent.clone();
B::new(move || persistent.seat.focus_layer_rel(direction)) B::new(move || persistent.seat.focus_layer_rel(direction))
} }
SimpleCommand::FocusTiles => {
let persistent = state.persistent.clone();
B::new(move || persistent.seat.focus_tiles())
}
}, },
Action::Multi { actions } => { Action::Multi { actions } => {
let actions: Vec<_> = actions.into_iter().map(|a| a.into_fn(state)).collect(); let actions: Vec<_> = actions.into_iter().map(|a| a.into_fn(state)).collect();

View file

@ -1616,7 +1616,8 @@
"focus-prev", "focus-prev",
"focus-next", "focus-next",
"focus-below", "focus-below",
"focus-above" "focus-above",
"focus-tiles"
] ]
}, },
"Status": { "Status": {

View file

@ -3683,6 +3683,10 @@ The string should have one of the following values:
Focuses the layer above the currently focused layer. Focuses the layer above the currently focused layer.
- `focus-tiles`:
Focuses the tile layer.
<a name="types-Status"></a> <a name="types-Status"></a>

View file

@ -868,6 +868,8 @@ SimpleActionName:
description: Focuses the layer below the currently focused layer. description: Focuses the layer below the currently focused layer.
- value: focus-above - value: focus-above
description: Focuses the layer above the currently focused layer. description: Focuses the layer above the currently focused layer.
- value: focus-tiles
description: Focuses the tile layer.
Color: Color: