event loop: Decouple event handler from concrete state

This commit is contained in:
Dorota Czaplejewicz
2022-11-28 14:57:06 +00:00
parent d51408a3e0
commit e7c2350c92
2 changed files with 17 additions and 11 deletions

View File

@ -130,13 +130,14 @@ pub struct Outcome {
pub im: InputMethod,
}
impl Outcome {
impl event_loop::Outcome for Outcome {
type Commands = Commands;
/// Returns the commands needed to apply changes as required by the new state.
/// This implementation doesn't actually take the old state into account,
/// instead issuing all the commands as needed to reach the new state.
/// The receivers of the commands bear the burden
/// of checking if the commands end up being no-ops.
pub fn get_commands_to_reach(&self, new_state: &Self) -> Commands {
fn get_commands_to_reach(&self, new_state: &Self) -> Commands {
// FIXME: handle switching outputs
let (dbus_visible_set, panel_visibility) = match new_state.panel {
animation::Outcome::Visible{output, height, ..}
@ -440,6 +441,7 @@ Outcome:
impl ActorState for Application {
type Event = Event;
type Outcome = Outcome;
fn apply_event(self, e: Self::Event, time: Instant) -> Self {
Self::apply_event(self, e, time)