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