mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-05-08 15:18:05 +03:00
macos: hide Reenable warning row once Accessibility is granted
The yellow "input capture is disabled" / "input emulation is disabled" rows were showing simultaneously with the Relaunch toast after a live AX grant, double-prompting the user for the same action. Gate the warning row visibility on Accessibility actually being missing: when AX is granted but capture/emulation remain inactive, we're in the pending-relaunch state and the Relaunch toast is the authoritative prompt. Trigger a status refresh from the AX watcher so the rows hide the instant AX flips to granted, not when the daemon next reports status. On non-macOS platforms the visibility logic is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -274,6 +274,12 @@ fn show_macos_relaunch_dialog(app: &Application, window: &Window) {
|
||||
// otherwise fires into a surface the user can't see.
|
||||
window.present();
|
||||
|
||||
// Refresh the capture/emulation status rows so the yellow
|
||||
// "Reenable" warning disappears. It was showing because the daemon
|
||||
// reports capture/emulation inactive; now that AX is granted the
|
||||
// Relaunch toast is the right prompt and the warning is redundant.
|
||||
window.refresh_capture_emulation_status();
|
||||
|
||||
let toast = adw::Toast::builder()
|
||||
.title(
|
||||
"Accessibility granted. Relaunch Lan Mouse so capture and \
|
||||
|
||||
@@ -450,14 +450,33 @@ impl Window {
|
||||
self.update_capture_emulation_status();
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub(super) fn refresh_capture_emulation_status(&self) {
|
||||
self.update_capture_emulation_status();
|
||||
}
|
||||
|
||||
fn update_capture_emulation_status(&self) {
|
||||
let capture = self.imp().capture_active.get();
|
||||
let emulation = self.imp().emulation_active.get();
|
||||
self.imp().capture_status_row.set_visible(!capture);
|
||||
self.imp().emulation_status_row.set_visible(!emulation);
|
||||
|
||||
// On macOS the yellow "Reenable" row only makes sense when
|
||||
// Accessibility is actually missing. When AX is granted but
|
||||
// capture/emulation are still off, the daemon simply hasn't been
|
||||
// restarted yet — the Relaunch toast covers that state, and a
|
||||
// yellow "grant permission" warning on top of it would be
|
||||
// redundant and confusing.
|
||||
#[cfg(target_os = "macos")]
|
||||
let show_warning = !crate::macos_privacy::accessibility_granted();
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let show_warning = true;
|
||||
|
||||
let show_capture_row = !capture && show_warning;
|
||||
let show_emulation_row = !emulation && show_warning;
|
||||
self.imp().capture_status_row.set_visible(show_capture_row);
|
||||
self.imp().emulation_status_row.set_visible(show_emulation_row);
|
||||
self.imp()
|
||||
.capture_emulation_group
|
||||
.set_visible(!capture || !emulation);
|
||||
.set_visible(show_capture_row || show_emulation_row);
|
||||
}
|
||||
|
||||
pub(super) fn set_authorized_keys(&self, fingerprints: HashMap<String, String>) {
|
||||
|
||||
Reference in New Issue
Block a user