dbus refactor
This commit is contained in:
@@ -17,6 +17,7 @@ use crate::{
|
||||
window::OverlayWindowConfig,
|
||||
},
|
||||
};
|
||||
use dbus::message::MatchRule;
|
||||
use glam::{Affine3A, Quat, Vec3, vec3};
|
||||
use slotmap::{SlotMap, new_key_type};
|
||||
use wgui::{
|
||||
@@ -64,6 +65,7 @@ pub fn create_keyboard(
|
||||
};
|
||||
|
||||
backend.active_keymap = backend.add_new_keymap(keymap.as_ref(), app)?;
|
||||
backend.watch_dbus(app);
|
||||
|
||||
Ok(OverlayWindowConfig {
|
||||
name: KEYBOARD_NAME.into(),
|
||||
@@ -112,6 +114,27 @@ impl KeyboardBackend {
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
fn watch_dbus(&mut self, app: &mut AppState) {
|
||||
let rules = [
|
||||
MatchRule::new()
|
||||
.with_member("CurrentInputMethod")
|
||||
.with_interface("org.fcitx.Fcitx.Controller1")
|
||||
.with_path("/controller")
|
||||
.with_sender("org.fcitx.Fcitx5"),
|
||||
MatchRule::new_signal("org.kde.KeyboardLayouts", "layoutChanged").with_path("/Layouts"),
|
||||
];
|
||||
|
||||
for rule in rules {
|
||||
let _ = app.dbus.add_match(
|
||||
rule,
|
||||
Box::new(move |(), _, msg| {
|
||||
log::warn!("new keymap: {msg:?}");
|
||||
true
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn switch_keymap(&mut self, keymap: &XkbKeymap, app: &mut AppState) -> anyhow::Result<()> {
|
||||
let Some(layout_name) = keymap.inner.layouts().next() else {
|
||||
log::error!("XKB keymap without a layout!");
|
||||
|
||||
@@ -20,12 +20,13 @@ impl ScreenBackend {
|
||||
pub fn new_pw(
|
||||
output: &WlxOutput,
|
||||
token: Option<&str>,
|
||||
app: &AppState,
|
||||
app: &mut AppState,
|
||||
) -> anyhow::Result<(Self, Option<String> /* pipewire restore token */)> {
|
||||
let name = output.name.clone();
|
||||
let embed_mouse = !app.session.config.double_cursor_fix;
|
||||
|
||||
let select_screen_result = select_pw_screen(
|
||||
app,
|
||||
&format!(
|
||||
"Now select: {} {} {} @ {},{}",
|
||||
&output.name,
|
||||
@@ -56,6 +57,7 @@ impl ScreenBackend {
|
||||
|
||||
#[allow(clippy::fn_params_excessive_bools)]
|
||||
pub(super) fn select_pw_screen(
|
||||
app: &mut AppState,
|
||||
instructions: &str,
|
||||
token: Option<&str>,
|
||||
embed_mouse: bool,
|
||||
@@ -63,7 +65,6 @@ pub(super) fn select_pw_screen(
|
||||
persist: bool,
|
||||
multiple: bool,
|
||||
) -> Result<PipewireSelectScreenResult, wlx_capture::pipewire::AshpdError> {
|
||||
use crate::subsystem::notifications::DbusNotificationSender;
|
||||
use std::time::Duration;
|
||||
use wlx_capture::pipewire::pipewire_select_screen;
|
||||
|
||||
@@ -80,10 +81,8 @@ pub(super) fn select_pw_screen(
|
||||
task::Poll::Pending => {
|
||||
if Instant::now() >= print_at {
|
||||
log::info!("{instructions}");
|
||||
if let Ok(sender) = DbusNotificationSender::new()
|
||||
&& let Ok(id) = sender.notify_send(instructions, "", 2, 0, 0, true)
|
||||
{
|
||||
notify = Some((sender, id));
|
||||
if let Ok(id) = app.dbus.notify_send(instructions, "", 2, 30, 0, true) {
|
||||
notify = Some(id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -96,8 +95,9 @@ pub(super) fn select_pw_screen(
|
||||
}
|
||||
|
||||
let result = f.await;
|
||||
if let Some((sender, id)) = notify {
|
||||
let _ = sender.notify_close(id);
|
||||
if let Some(id) = notify {
|
||||
//safe unwrap; checked above
|
||||
let _ = app.dbus.notify_close(id);
|
||||
}
|
||||
result
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ pub fn create_screen_renderer_wl(
|
||||
has_wlr_dmabuf: bool,
|
||||
has_wlr_screencopy: bool,
|
||||
pw_token_store: &mut PwTokenMap,
|
||||
app: &AppState,
|
||||
app: &mut AppState,
|
||||
) -> Option<ScreenBackend> {
|
||||
let mut capture: Option<ScreenBackend> = None;
|
||||
if (&*app.session.config.capture_method == "wlr-dmabuf") && has_wlr_dmabuf {
|
||||
|
||||
@@ -54,6 +54,7 @@ pub fn create_screens_x11pw(app: &mut AppState) -> anyhow::Result<ScreenCreateDa
|
||||
let embed_mouse = !app.session.config.double_cursor_fix;
|
||||
|
||||
let select_screen_result = select_pw_screen(
|
||||
app,
|
||||
"Select ALL screens on the screencast pop-up!",
|
||||
token,
|
||||
embed_mouse,
|
||||
|
||||
Reference in New Issue
Block a user