anvil: Introduce InputInitData to simplify function prototypes
This commit is contained in:
parent
35d8cea547
commit
5552c81a32
|
@ -38,48 +38,40 @@ pub struct AnvilInputHandler {
|
||||||
running: Arc<AtomicBool>,
|
running: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct InputInitData {
|
||||||
|
pub pointer: PointerHandle,
|
||||||
|
pub keyboard: KeyboardHandle,
|
||||||
|
pub window_map: Rc<RefCell<MyWindowMap>>,
|
||||||
|
pub screen_size: (u32, u32),
|
||||||
|
pub running: Arc<AtomicBool>,
|
||||||
|
pub pointer_location: Rc<RefCell<(f64, f64)>>,
|
||||||
|
}
|
||||||
|
|
||||||
impl AnvilInputHandler {
|
impl AnvilInputHandler {
|
||||||
pub fn new(
|
pub fn new(log: Logger, data: InputInitData) -> AnvilInputHandler {
|
||||||
log: Logger,
|
|
||||||
pointer: PointerHandle,
|
|
||||||
keyboard: KeyboardHandle,
|
|
||||||
window_map: Rc<RefCell<MyWindowMap>>,
|
|
||||||
screen_size: (u32, u32),
|
|
||||||
running: Arc<AtomicBool>,
|
|
||||||
pointer_location: Rc<RefCell<(f64, f64)>>,
|
|
||||||
) -> AnvilInputHandler {
|
|
||||||
AnvilInputHandler {
|
AnvilInputHandler {
|
||||||
log,
|
log,
|
||||||
pointer,
|
pointer: data.pointer,
|
||||||
keyboard,
|
keyboard: data.keyboard,
|
||||||
window_map,
|
window_map: data.window_map,
|
||||||
screen_size,
|
screen_size: data.screen_size,
|
||||||
running,
|
running: data.running,
|
||||||
pointer_location,
|
pointer_location: data.pointer_location,
|
||||||
#[cfg(feature = "udev")]
|
#[cfg(feature = "udev")]
|
||||||
session: None,
|
session: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "udev")]
|
#[cfg(feature = "udev")]
|
||||||
pub fn new_with_session(
|
pub fn new_with_session(log: Logger, data: InputInitData, session: AutoSession) -> AnvilInputHandler {
|
||||||
log: Logger,
|
|
||||||
pointer: PointerHandle,
|
|
||||||
keyboard: KeyboardHandle,
|
|
||||||
window_map: Rc<RefCell<MyWindowMap>>,
|
|
||||||
screen_size: (u32, u32),
|
|
||||||
running: Arc<AtomicBool>,
|
|
||||||
pointer_location: Rc<RefCell<(f64, f64)>>,
|
|
||||||
session: AutoSession,
|
|
||||||
) -> AnvilInputHandler {
|
|
||||||
AnvilInputHandler {
|
AnvilInputHandler {
|
||||||
log,
|
log,
|
||||||
pointer,
|
pointer: data.pointer,
|
||||||
keyboard,
|
keyboard: data.keyboard,
|
||||||
window_map,
|
window_map: data.window_map,
|
||||||
screen_size,
|
screen_size: data.screen_size,
|
||||||
running,
|
running: data.running,
|
||||||
pointer_location,
|
pointer_location: data.pointer_location,
|
||||||
session: Some(session),
|
session: Some(session),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ use smithay::{
|
||||||
|
|
||||||
use crate::buffer_utils::BufferUtils;
|
use crate::buffer_utils::BufferUtils;
|
||||||
use crate::glium_drawer::GliumDrawer;
|
use crate::glium_drawer::GliumDrawer;
|
||||||
use crate::input_handler::AnvilInputHandler;
|
use crate::input_handler::{AnvilInputHandler, InputInitData};
|
||||||
use crate::shell::{MyWindowMap, Roles};
|
use crate::shell::{MyWindowMap, Roles};
|
||||||
use crate::state::AnvilState;
|
use crate::state::AnvilState;
|
||||||
|
|
||||||
|
@ -205,12 +205,14 @@ pub fn run_udev(
|
||||||
let mut libinput_backend = LibinputInputBackend::new(libinput_context, log.clone());
|
let mut libinput_backend = LibinputInputBackend::new(libinput_context, log.clone());
|
||||||
libinput_backend.set_handler(AnvilInputHandler::new_with_session(
|
libinput_backend.set_handler(AnvilInputHandler::new_with_session(
|
||||||
log.clone(),
|
log.clone(),
|
||||||
|
InputInitData {
|
||||||
pointer,
|
pointer,
|
||||||
keyboard,
|
keyboard,
|
||||||
state.window_map.clone(),
|
window_map: state.window_map.clone(),
|
||||||
(w, h),
|
screen_size: (w, h),
|
||||||
state.running.clone(),
|
running: state.running.clone(),
|
||||||
pointer_location,
|
pointer_location,
|
||||||
|
},
|
||||||
session,
|
session,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ use slog::Logger;
|
||||||
|
|
||||||
use crate::buffer_utils::BufferUtils;
|
use crate::buffer_utils::BufferUtils;
|
||||||
use crate::glium_drawer::GliumDrawer;
|
use crate::glium_drawer::GliumDrawer;
|
||||||
use crate::input_handler::AnvilInputHandler;
|
use crate::input_handler::{AnvilInputHandler, InputInitData};
|
||||||
use crate::state::AnvilState;
|
use crate::state::AnvilState;
|
||||||
|
|
||||||
pub fn run_winit(
|
pub fn run_winit(
|
||||||
|
@ -113,12 +113,14 @@ pub fn run_winit(
|
||||||
|
|
||||||
input.set_handler(AnvilInputHandler::new(
|
input.set_handler(AnvilInputHandler::new(
|
||||||
log.clone(),
|
log.clone(),
|
||||||
|
InputInitData {
|
||||||
pointer,
|
pointer,
|
||||||
keyboard,
|
keyboard,
|
||||||
state.window_map.clone(),
|
window_map: state.window_map.clone(),
|
||||||
(0, 0),
|
screen_size: (0, 0),
|
||||||
state.running.clone(),
|
running: state.running.clone(),
|
||||||
pointer_location.clone(),
|
pointer_location: pointer_location.clone(),
|
||||||
|
},
|
||||||
));
|
));
|
||||||
|
|
||||||
info!(log, "Initialization completed, starting the main loop.");
|
info!(log, "Initialization completed, starting the main loop.");
|
||||||
|
|
Loading…
Reference in New Issue