config: split seat handling
This commit is contained in:
parent
05c40cb46d
commit
ec9ce08c77
2 changed files with 516 additions and 441 deletions
|
|
@ -92,6 +92,7 @@ mod input_devices;
|
|||
mod matchers;
|
||||
mod outputs;
|
||||
mod resources;
|
||||
mod seats;
|
||||
mod theme;
|
||||
mod windows;
|
||||
mod workspaces;
|
||||
|
|
@ -249,21 +250,6 @@ impl ConfigProxyHandler {
|
|||
log::log!(level, "{:?}", debug);
|
||||
}
|
||||
|
||||
fn handle_get_seat(&self, name: &str) {
|
||||
for seat in self.state.globals.seats.lock().values() {
|
||||
if seat.seat_name() == name {
|
||||
self.respond(Response::GetSeat {
|
||||
seat: Seat(seat.id().raw() as _),
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
let seat = self.state.create_seat(name);
|
||||
self.respond(Response::GetSeat {
|
||||
seat: Seat(seat.id().raw() as _),
|
||||
});
|
||||
}
|
||||
|
||||
fn handle_parse_keymap(&self, keymap: &str) -> Result<(), CphError> {
|
||||
let (keymap, res) = match self.state.kb_ctx.parse_keymap(keymap.as_bytes()) {
|
||||
Ok(keymap) => {
|
||||
|
|
@ -314,74 +300,6 @@ impl ConfigProxyHandler {
|
|||
self.state.reload_config();
|
||||
}
|
||||
|
||||
fn handle_get_seat_fullscreen(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
self.respond(Response::GetFullscreen {
|
||||
fullscreen: seat.get_fullscreen(),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_seat_fullscreen(&self, seat: Seat, fullscreen: bool) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_fullscreen(fullscreen);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_keymap(&self, seat: Seat, keymap: Keymap) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
let keymap = if keymap.is_invalid() {
|
||||
self.state.default_keymap.clone()
|
||||
} else {
|
||||
self.get_keymap(keymap)?
|
||||
};
|
||||
seat.set_seat_keymap(&keymap);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_forward(&self, seat: Seat, forward: bool) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_forward(forward);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_focus_follows_mouse_mode(
|
||||
&self,
|
||||
seat: Seat,
|
||||
mode: FocusFollowsMouseMode,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
let focus_follows_mouse = match mode {
|
||||
FocusFollowsMouseMode::True => true,
|
||||
FocusFollowsMouseMode::False => false,
|
||||
};
|
||||
seat.set_focus_follows_mouse(focus_follows_mouse);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_fallback_output_mode(
|
||||
&self,
|
||||
seat: Seat,
|
||||
mode: FallbackOutputMode,
|
||||
) -> Result<(), CphError> {
|
||||
let Ok(mode) = mode.try_into() else {
|
||||
return Err(CphError::UnknownFallbackOutputMode(mode));
|
||||
};
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_fallback_output_mode(mode);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_window_management_enabled(
|
||||
&self,
|
||||
seat: Seat,
|
||||
enabled: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_window_management_enabled(enabled);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_status(&self, status: &str) {
|
||||
self.state.set_status(status);
|
||||
}
|
||||
|
|
@ -403,45 +321,6 @@ impl ConfigProxyHandler {
|
|||
self.respond(Response::GetConfigDir { dir });
|
||||
}
|
||||
|
||||
fn handle_seat_close(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.close();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_focus(&self, seat: Seat, direction: Direction) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.move_focus(direction.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_move(&self, seat: Seat, direction: Direction) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.move_focused(direction.into());
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_get_repeat_rate(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
let (rate, delay) = seat.get_rate();
|
||||
self.respond(Response::GetRepeatRate { rate, delay });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_repeat_rate(&self, seat: Seat, rate: i32, delay: i32) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
if rate < 0 {
|
||||
return Err(CphError::NegativeRepeatRate);
|
||||
}
|
||||
if delay < 0 {
|
||||
return Err(CphError::NegativeRepeatDelay);
|
||||
}
|
||||
seat.set_rate(rate, delay);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_device_handler_data(
|
||||
&self,
|
||||
device: InputDevice,
|
||||
|
|
@ -637,160 +516,6 @@ impl ConfigProxyHandler {
|
|||
self.state.set_color_management_enabled(enabled);
|
||||
}
|
||||
|
||||
fn handle_set_cursor_size(&self, seat: Seat, size: i32) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
if size < 0 {
|
||||
return Err(CphError::NegativeCursorSize);
|
||||
}
|
||||
seat.cursor_group().set_cursor_size(size as _);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_disable_pointer_constraint(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.disable_pointer_constraint();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_use_hardware_cursor(
|
||||
&self,
|
||||
seat: Seat,
|
||||
use_hardware_cursor: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.cursor_group().set_hardware_cursor(use_hardware_cursor);
|
||||
self.state.refresh_hardware_cursors();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_get_seat_float_pinned(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
self.respond(Response::GetFloatPinned {
|
||||
pinned: seat.pinned(),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_seat_float_pinned(&self, seat: Seat, pinned: bool) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_pinned(pinned);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_get_seat_mono(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
self.respond(Response::GetMono {
|
||||
mono: seat.get_mono().unwrap_or(false),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_seat_mono(&self, seat: Seat, mono: bool) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_mono(mono);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_get_seat_split(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
self.respond(Response::GetSplit {
|
||||
axis: seat
|
||||
.get_split()
|
||||
.unwrap_or(ContainerSplit::Horizontal)
|
||||
.into(),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_seat_split(&self, seat: Seat, axis: Axis) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_split(axis.into());
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_seat_toggle_tab(&self, seat: Seat) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.toggle_tab();
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_seat_make_group(
|
||||
&self,
|
||||
seat: Seat,
|
||||
axis: Axis,
|
||||
ephemeral: bool,
|
||||
) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.make_group(axis.into(), ephemeral);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_seat_change_group_opposite(&self, seat: Seat) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.change_group_opposite();
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_seat_equalize(&self, seat: Seat, recursive: bool) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.equalize(recursive);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_seat_move_tab(&self, seat: Seat, right: bool) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.move_tab(right);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_add_shortcut(
|
||||
&self,
|
||||
seat: Seat,
|
||||
mod_mask: Modifiers,
|
||||
mods: Modifiers,
|
||||
sym: KeySym,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.add_shortcut(mod_mask, mods, sym);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_remove_shortcut(
|
||||
&self,
|
||||
seat: Seat,
|
||||
mods: Modifiers,
|
||||
sym: KeySym,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.remove_shortcut(mods, sym);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_get_seats(&self) {
|
||||
let seats = {
|
||||
let seats = self.state.globals.seats.lock();
|
||||
seats
|
||||
.values()
|
||||
.map(|seat| Seat::from_raw(seat.id().raw() as _))
|
||||
.collect()
|
||||
};
|
||||
self.respond(Response::GetSeats { seats });
|
||||
}
|
||||
|
||||
fn handle_run(
|
||||
&self,
|
||||
prog: &str,
|
||||
|
|
@ -819,18 +544,6 @@ impl ConfigProxyHandler {
|
|||
self.state.clean_logs_older_than.set(Some(time));
|
||||
}
|
||||
|
||||
fn handle_create_seat_split(&self, seat: Seat, axis: Axis) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.create_split(axis.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_focus_seat_parent(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.focus_parent();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_quit(&self) {
|
||||
log::info!("Quitting");
|
||||
self.state.ring.stop();
|
||||
|
|
@ -840,159 +553,6 @@ impl ConfigProxyHandler {
|
|||
self.state.backend.get().switch_to(vtnr);
|
||||
}
|
||||
|
||||
fn handle_get_seat_floating(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
self.respond(Response::GetFloating {
|
||||
floating: seat.get_floating().unwrap_or(false),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_seat_floating(&self, seat: Seat, floating: bool) -> Result<(), CphError> {
|
||||
self.state.with_linear_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_floating(floating);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_set_pointer_revert_key(&self, seat: Seat, key: KeySym) -> Result<(), CphError> {
|
||||
self.get_seat(seat)?.set_pointer_revert_key(key);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_focus_history(&self, seat: Seat, timeline: Timeline) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
match timeline {
|
||||
Timeline::Older => seat.focus_prev(),
|
||||
Timeline::Newer => seat.focus_next(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_focus_history_set_only_visible(
|
||||
&self,
|
||||
seat: Seat,
|
||||
visible: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.focus_history_set_visible(visible);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_focus_history_set_same_workspace(
|
||||
&self,
|
||||
seat: Seat,
|
||||
same_workspace: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.focus_history_set_same_workspace(same_workspace);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_focus_layer_rel(
|
||||
&self,
|
||||
seat: Seat,
|
||||
direction: LayerDirection,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
match direction {
|
||||
LayerDirection::Below => seat.focus_layer_below(),
|
||||
LayerDirection::Above => seat.focus_layer_above(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_focus_tiles(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.focus_tiles();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_focus_floats(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.focus_floats();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_toggle_focus_float_tiled(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.toggle_focus_float_tiled();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_middle_click_paste_enabled(&self, enabled: bool) {
|
||||
self.state.set_primary_selection_enabled(enabled);
|
||||
}
|
||||
|
||||
fn handle_seat_create_mark(&self, seat: Seat, kc: Option<u32>) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
if let Some(kc) = kc {
|
||||
seat.create_mark(Keycode::from_evdev(kc));
|
||||
} else {
|
||||
seat.create_mark_interactive();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_jump_to_mark(&self, seat: Seat, kc: Option<u32>) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
if let Some(kc) = kc {
|
||||
seat.jump_to_mark(Keycode::from_evdev(kc));
|
||||
} else {
|
||||
seat.jump_to_mark_interactive();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_copy_mark(&self, seat: Seat, src: u32, dst: u32) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.copy_mark(Keycode::from_evdev(src), Keycode::from_evdev(dst));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_set_simple_im_enabled(&self, seat: Seat, enabled: bool) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_simple_im_enabled(enabled);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_get_simple_im_enabled(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
self.respond(Response::SeatGetSimpleImEnabled {
|
||||
enabled: seat.simple_im_enabled(),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_reload_simple_im(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.reload_simple_im();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_enable_unicode_input(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.enable_unicode_input();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_warp_mouse_to_focus(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.schedule_warp_mouse_to_focus();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_seat_set_mouse_follows_focus(
|
||||
&self,
|
||||
seat: Seat,
|
||||
enabled: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_mouse_follows_focus(enabled);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_destroy_keymap(&self, keymap: Keymap) {
|
||||
self.keymaps.remove(&keymap);
|
||||
}
|
||||
|
|
|
|||
515
src/config/handler/seats.rs
Normal file
515
src/config/handler/seats.rs
Normal file
|
|
@ -0,0 +1,515 @@
|
|||
use super::*;
|
||||
|
||||
impl ConfigProxyHandler {
|
||||
pub(super) fn handle_get_seat(&self, name: &str) {
|
||||
for seat in self.state.globals.seats.lock().values() {
|
||||
if seat.seat_name() == name {
|
||||
self.respond(Response::GetSeat {
|
||||
seat: Seat(seat.id().raw() as _),
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
let seat = self.state.create_seat(name);
|
||||
self.respond(Response::GetSeat {
|
||||
seat: Seat(seat.id().raw() as _),
|
||||
});
|
||||
}
|
||||
|
||||
pub(super) fn handle_get_seat_fullscreen(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
self.respond(Response::GetFullscreen {
|
||||
fullscreen: seat.get_fullscreen(),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_seat_fullscreen(
|
||||
&self,
|
||||
seat: Seat,
|
||||
fullscreen: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_fullscreen(fullscreen);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_keymap(
|
||||
&self,
|
||||
seat: Seat,
|
||||
keymap: Keymap,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
let keymap = if keymap.is_invalid() {
|
||||
self.state.default_keymap.clone()
|
||||
} else {
|
||||
self.get_keymap(keymap)?
|
||||
};
|
||||
seat.set_seat_keymap(&keymap);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_forward(&self, seat: Seat, forward: bool) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_forward(forward);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_focus_follows_mouse_mode(
|
||||
&self,
|
||||
seat: Seat,
|
||||
mode: FocusFollowsMouseMode,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
let focus_follows_mouse = match mode {
|
||||
FocusFollowsMouseMode::True => true,
|
||||
FocusFollowsMouseMode::False => false,
|
||||
};
|
||||
seat.set_focus_follows_mouse(focus_follows_mouse);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_fallback_output_mode(
|
||||
&self,
|
||||
seat: Seat,
|
||||
mode: FallbackOutputMode,
|
||||
) -> Result<(), CphError> {
|
||||
let Ok(mode) = mode.try_into() else {
|
||||
return Err(CphError::UnknownFallbackOutputMode(mode));
|
||||
};
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_fallback_output_mode(mode);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_window_management_enabled(
|
||||
&self,
|
||||
seat: Seat,
|
||||
enabled: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_window_management_enabled(enabled);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_close(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.close();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_focus(
|
||||
&self,
|
||||
seat: Seat,
|
||||
direction: Direction,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.move_focus(direction.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_move(
|
||||
&self,
|
||||
seat: Seat,
|
||||
direction: Direction,
|
||||
) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.move_focused(direction.into());
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn handle_get_repeat_rate(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
let (rate, delay) = seat.get_rate();
|
||||
self.respond(Response::GetRepeatRate { rate, delay });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_repeat_rate(
|
||||
&self,
|
||||
seat: Seat,
|
||||
rate: i32,
|
||||
delay: i32,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
if rate < 0 {
|
||||
return Err(CphError::NegativeRepeatRate);
|
||||
}
|
||||
if delay < 0 {
|
||||
return Err(CphError::NegativeRepeatDelay);
|
||||
}
|
||||
seat.set_rate(rate, delay);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_cursor_size(&self, seat: Seat, size: i32) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
if size < 0 {
|
||||
return Err(CphError::NegativeCursorSize);
|
||||
}
|
||||
seat.cursor_group().set_cursor_size(size as _);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_disable_pointer_constraint(
|
||||
&self,
|
||||
seat: Seat,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.disable_pointer_constraint();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_use_hardware_cursor(
|
||||
&self,
|
||||
seat: Seat,
|
||||
use_hardware_cursor: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.cursor_group().set_hardware_cursor(use_hardware_cursor);
|
||||
self.state.refresh_hardware_cursors();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_get_seat_float_pinned(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
self.respond(Response::GetFloatPinned {
|
||||
pinned: seat.pinned(),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_seat_float_pinned(
|
||||
&self,
|
||||
seat: Seat,
|
||||
pinned: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_pinned(pinned);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_get_seat_mono(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
self.respond(Response::GetMono {
|
||||
mono: seat.get_mono().unwrap_or(false),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_seat_mono(&self, seat: Seat, mono: bool) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_mono(mono);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn handle_get_seat_split(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
self.respond(Response::GetSplit {
|
||||
axis: seat
|
||||
.get_split()
|
||||
.unwrap_or(ContainerSplit::Horizontal)
|
||||
.into(),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_seat_split(&self, seat: Seat, axis: Axis) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_split(axis.into());
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_toggle_tab(&self, seat: Seat) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.toggle_tab();
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_make_group(
|
||||
&self,
|
||||
seat: Seat,
|
||||
axis: Axis,
|
||||
ephemeral: bool,
|
||||
) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.make_group(axis.into(), ephemeral);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_change_group_opposite(&self, seat: Seat) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.change_group_opposite();
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_equalize(
|
||||
&self,
|
||||
seat: Seat,
|
||||
recursive: bool,
|
||||
) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.equalize(recursive);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_move_tab(&self, seat: Seat, right: bool) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.move_tab(right);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn handle_add_shortcut(
|
||||
&self,
|
||||
seat: Seat,
|
||||
mod_mask: Modifiers,
|
||||
mods: Modifiers,
|
||||
sym: KeySym,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.add_shortcut(mod_mask, mods, sym);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_remove_shortcut(
|
||||
&self,
|
||||
seat: Seat,
|
||||
mods: Modifiers,
|
||||
sym: KeySym,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.remove_shortcut(mods, sym);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_get_seats(&self) {
|
||||
let seats = {
|
||||
let seats = self.state.globals.seats.lock();
|
||||
seats
|
||||
.values()
|
||||
.map(|seat| Seat::from_raw(seat.id().raw() as _))
|
||||
.collect()
|
||||
};
|
||||
self.respond(Response::GetSeats { seats });
|
||||
}
|
||||
|
||||
pub(super) fn handle_create_seat_split(
|
||||
&self,
|
||||
seat: Seat,
|
||||
axis: Axis,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.create_split(axis.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_focus_seat_parent(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.focus_parent();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_get_seat_floating(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
self.respond(Response::GetFloating {
|
||||
floating: seat.get_floating().unwrap_or(false),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_seat_floating(
|
||||
&self,
|
||||
seat: Seat,
|
||||
floating: bool,
|
||||
) -> Result<(), CphError> {
|
||||
self.state.with_linear_layout_animations(|| {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_floating(floating);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_pointer_revert_key(
|
||||
&self,
|
||||
seat: Seat,
|
||||
key: KeySym,
|
||||
) -> Result<(), CphError> {
|
||||
self.get_seat(seat)?.set_pointer_revert_key(key);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_focus_history(
|
||||
&self,
|
||||
seat: Seat,
|
||||
timeline: Timeline,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
match timeline {
|
||||
Timeline::Older => seat.focus_prev(),
|
||||
Timeline::Newer => seat.focus_next(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_focus_history_set_only_visible(
|
||||
&self,
|
||||
seat: Seat,
|
||||
visible: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.focus_history_set_visible(visible);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_focus_history_set_same_workspace(
|
||||
&self,
|
||||
seat: Seat,
|
||||
same_workspace: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.focus_history_set_same_workspace(same_workspace);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_focus_layer_rel(
|
||||
&self,
|
||||
seat: Seat,
|
||||
direction: LayerDirection,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
match direction {
|
||||
LayerDirection::Below => seat.focus_layer_below(),
|
||||
LayerDirection::Above => seat.focus_layer_above(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_focus_tiles(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.focus_tiles();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_focus_floats(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.focus_floats();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_toggle_focus_float_tiled(
|
||||
&self,
|
||||
seat: Seat,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.toggle_focus_float_tiled();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_middle_click_paste_enabled(&self, enabled: bool) {
|
||||
self.state.set_primary_selection_enabled(enabled);
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_create_mark(
|
||||
&self,
|
||||
seat: Seat,
|
||||
kc: Option<u32>,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
if let Some(kc) = kc {
|
||||
seat.create_mark(Keycode::from_evdev(kc));
|
||||
} else {
|
||||
seat.create_mark_interactive();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_jump_to_mark(
|
||||
&self,
|
||||
seat: Seat,
|
||||
kc: Option<u32>,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
if let Some(kc) = kc {
|
||||
seat.jump_to_mark(Keycode::from_evdev(kc));
|
||||
} else {
|
||||
seat.jump_to_mark_interactive();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_copy_mark(
|
||||
&self,
|
||||
seat: Seat,
|
||||
src: u32,
|
||||
dst: u32,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.copy_mark(Keycode::from_evdev(src), Keycode::from_evdev(dst));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_set_simple_im_enabled(
|
||||
&self,
|
||||
seat: Seat,
|
||||
enabled: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_simple_im_enabled(enabled);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_get_simple_im_enabled(
|
||||
&self,
|
||||
seat: Seat,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
self.respond(Response::SeatGetSimpleImEnabled {
|
||||
enabled: seat.simple_im_enabled(),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_reload_simple_im(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.reload_simple_im();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_enable_unicode_input(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.enable_unicode_input();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_warp_mouse_to_focus(&self, seat: Seat) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.schedule_warp_mouse_to_focus();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_seat_set_mouse_follows_focus(
|
||||
&self,
|
||||
seat: Seat,
|
||||
enabled: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let seat = self.get_seat(seat)?;
|
||||
seat.set_mouse_follows_focus(enabled);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue