mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-08 12:30:00 +03:00
Compare commits
7 Commits
connection
...
macos-clea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d960cbc30 | ||
|
|
f33d2d5d5a | ||
|
|
e46fe60b3e | ||
|
|
37a4e236b8 | ||
|
|
b8063a8138 | ||
|
|
5a3a21c2c0 | ||
|
|
3ec23d7171 |
@@ -813,7 +813,7 @@ impl Dispatch<WlPointer, ()> for State {
|
||||
})),
|
||||
));
|
||||
}
|
||||
wl_pointer::Event::Frame {} => {
|
||||
wl_pointer::Event::Frame => {
|
||||
// TODO properly handle frame events
|
||||
// we simply insert a frame event on the client side
|
||||
// after each event for now
|
||||
|
||||
@@ -390,9 +390,9 @@ fn create_event_tap<'a>(
|
||||
|
||||
if let Some(pos) = pos {
|
||||
res_events.iter().for_each(|e| {
|
||||
event_tx
|
||||
.blocking_send((pos, *e))
|
||||
.expect("Failed to send event");
|
||||
// error must be ignored, since the event channel
|
||||
// may already be closed when the InputCapture instance is dropped.
|
||||
let _ = event_tx.blocking_send((pos, *e));
|
||||
});
|
||||
// Returning None should stop the event from being processed
|
||||
// but core fundation still returns the event
|
||||
@@ -426,8 +426,8 @@ fn event_tap_thread(
|
||||
client_state: Arc<Mutex<InputCaptureState>>,
|
||||
event_tx: Sender<(Position, CaptureEvent)>,
|
||||
notify_tx: Sender<ProducerEvent>,
|
||||
ready: std::sync::mpsc::Sender<Result<(), MacosCaptureCreationError>>,
|
||||
exit: oneshot::Sender<Result<(), &'static str>>,
|
||||
ready: std::sync::mpsc::Sender<Result<CFRunLoop, MacosCaptureCreationError>>,
|
||||
exit: oneshot::Sender<()>,
|
||||
) {
|
||||
let _tap = match create_event_tap(client_state, notify_tx, event_tx) {
|
||||
Err(e) => {
|
||||
@@ -435,18 +435,22 @@ fn event_tap_thread(
|
||||
return;
|
||||
}
|
||||
Ok(tap) => {
|
||||
ready.send(Ok(())).expect("channel closed");
|
||||
let run_loop = CFRunLoop::get_current();
|
||||
ready.send(Ok(run_loop)).expect("channel closed");
|
||||
tap
|
||||
}
|
||||
};
|
||||
log::debug!("running CFRunLoop...");
|
||||
CFRunLoop::run_current();
|
||||
log::debug!("event tap thread exiting!...");
|
||||
|
||||
let _ = exit.send(Err("tap thread exited"));
|
||||
let _ = exit.send(());
|
||||
}
|
||||
|
||||
pub struct MacOSInputCapture {
|
||||
event_rx: Receiver<(Position, CaptureEvent)>,
|
||||
notify_tx: Sender<ProducerEvent>,
|
||||
run_loop: CFRunLoop,
|
||||
}
|
||||
|
||||
impl MacOSInputCapture {
|
||||
@@ -475,36 +479,44 @@ impl MacOSInputCapture {
|
||||
});
|
||||
|
||||
// wait for event tap creation result
|
||||
ready_rx.recv().expect("channel closed")?;
|
||||
let run_loop = ready_rx.recv().expect("channel closed")?;
|
||||
|
||||
let _tap_task: tokio::task::JoinHandle<()> = tokio::task::spawn_local(async move {
|
||||
loop {
|
||||
tokio::select! {
|
||||
producer_event = notify_rx.recv() => {
|
||||
let producer_event = producer_event.expect("channel closed");
|
||||
let Some(producer_event) = producer_event else {
|
||||
break;
|
||||
};
|
||||
let mut state = state.lock().await;
|
||||
state.handle_producer_event(producer_event).await.unwrap_or_else(|e| {
|
||||
log::error!("Failed to handle producer event: {e}");
|
||||
})
|
||||
}
|
||||
|
||||
res = &mut tap_exit_rx => {
|
||||
if let Err(e) = res.expect("channel closed") {
|
||||
log::error!("Tap thread failed: {:?}", e);
|
||||
break;
|
||||
}
|
||||
_ = &mut tap_exit_rx => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// show cursor
|
||||
let _ = CGDisplay::show_cursor(&CGDisplay::main());
|
||||
});
|
||||
|
||||
Ok(Self {
|
||||
event_rx,
|
||||
notify_tx,
|
||||
run_loop,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for MacOSInputCapture {
|
||||
fn drop(&mut self) {
|
||||
self.run_loop.stop();
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Capture for MacOSInputCapture {
|
||||
async fn create(&mut self, pos: Position) -> Result<(), CaptureError> {
|
||||
|
||||
@@ -22,9 +22,9 @@ use windows::Win32::UI::WindowsAndMessaging::{
|
||||
RegisterClassW, SetWindowsHookExW, TranslateMessage, EDD_GET_DEVICE_INTERFACE_NAME, HHOOK,
|
||||
HMENU, HOOKPROC, KBDLLHOOKSTRUCT, LLKHF_EXTENDED, MSG, MSLLHOOKSTRUCT, WH_KEYBOARD_LL,
|
||||
WH_MOUSE_LL, WINDOW_STYLE, WM_DISPLAYCHANGE, WM_KEYDOWN, WM_KEYUP, WM_LBUTTONDOWN,
|
||||
WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_RBUTTONDOWN,
|
||||
WM_RBUTTONUP, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_USER, WM_XBUTTONDOWN, WM_XBUTTONUP, WNDCLASSW,
|
||||
WNDPROC,
|
||||
WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MOUSEHWHEEL, WM_MOUSEMOVE, WM_MOUSEWHEEL,
|
||||
WM_RBUTTONDOWN, WM_RBUTTONUP, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_USER, WM_XBUTTONDOWN,
|
||||
WM_XBUTTONUP, WNDCLASSW, WNDPROC,
|
||||
};
|
||||
|
||||
use input_event::{
|
||||
@@ -537,6 +537,10 @@ fn to_mouse_event(wparam: WPARAM, lparam: LPARAM) -> Option<PointerEvent> {
|
||||
state: if p == WM_XBUTTONDOWN as usize { 1 } else { 0 },
|
||||
})
|
||||
}
|
||||
WPARAM(p) if p == WM_MOUSEHWHEEL as usize => Some(PointerEvent::AxisDiscrete120 {
|
||||
axis: 1, // Horizontal
|
||||
value: mouse_low_level.mouseData as i32 >> 16,
|
||||
}),
|
||||
w => {
|
||||
log::warn!("unknown mouse event: {w:?}");
|
||||
None
|
||||
|
||||
@@ -23,7 +23,7 @@ impl X11Emulation {
|
||||
pub(crate) fn new() -> Result<Self, X11EmulationCreationError> {
|
||||
let display = unsafe {
|
||||
match xlib::XOpenDisplay(ptr::null()) {
|
||||
d if d == ptr::null::<xlib::Display>() as *mut xlib::Display => {
|
||||
d if std::ptr::eq(d, ptr::null_mut::<xlib::Display>()) => {
|
||||
Err(X11EmulationCreationError::OpenDisplay)
|
||||
}
|
||||
display => Ok(display),
|
||||
|
||||
@@ -143,7 +143,6 @@ impl Emulation for DesktopPortalEmulation<'_> {
|
||||
|
||||
impl AsyncDrop for DesktopPortalEmulation<'_> {
|
||||
#[doc = r" Perform the async cleanup."]
|
||||
#[must_use]
|
||||
#[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)]
|
||||
fn async_drop<'async_trait>(
|
||||
self,
|
||||
|
||||
@@ -8,7 +8,7 @@ use super::KeyObject;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct KeyRow(ObjectSubclass<imp::KeyRow>)
|
||||
@extends gtk::ListBoxRow, gtk::Widget, adw::PreferencesRow, adw::ExpanderRow,
|
||||
@extends gtk::ListBoxRow, gtk::Widget, adw::PreferencesRow, adw::ActionRow,
|
||||
@implements gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ struct ConfigToml {
|
||||
port: Option<u16>,
|
||||
release_bind: Option<Vec<scancode::Linux>>,
|
||||
cert_path: Option<PathBuf>,
|
||||
clients: Vec<TomlClient>,
|
||||
clients: Option<Vec<TomlClient>>,
|
||||
authorized_fingerprints: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
@@ -370,6 +370,7 @@ impl Config {
|
||||
self.config_toml
|
||||
.as_ref()
|
||||
.map(|c| c.clients.clone())
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(From::<TomlClient>::from)
|
||||
|
||||
Reference in New Issue
Block a user