mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
screencast: Emit MonitorsChanged
This commit is contained in:
+10
-6
@@ -710,13 +710,8 @@ impl Tty {
|
|||||||
let sequence_delta_plot_name =
|
let sequence_delta_plot_name =
|
||||||
tracy_client::PlotName::new_leak(format!("{output_name} sequence delta"));
|
tracy_client::PlotName::new_leak(format!("{output_name} sequence delta"));
|
||||||
|
|
||||||
self.enabled_outputs
|
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.insert(output_name.clone(), output.clone());
|
|
||||||
|
|
||||||
let surface = Surface {
|
let surface = Surface {
|
||||||
name: output_name,
|
name: output_name.clone(),
|
||||||
compositor,
|
compositor,
|
||||||
dmabuf_feedback,
|
dmabuf_feedback,
|
||||||
vblank_frame: None,
|
vblank_frame: None,
|
||||||
@@ -730,6 +725,13 @@ impl Tty {
|
|||||||
|
|
||||||
niri.add_output(output.clone(), Some(refresh_interval(mode)));
|
niri.add_output(output.clone(), Some(refresh_interval(mode)));
|
||||||
|
|
||||||
|
self.enabled_outputs
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.insert(output_name, output.clone());
|
||||||
|
#[cfg(feature = "dbus")]
|
||||||
|
niri.on_enabled_outputs_changed();
|
||||||
|
|
||||||
// Power on all monitors if necessary and queue a redraw on the new one.
|
// Power on all monitors if necessary and queue a redraw on the new one.
|
||||||
niri.event_loop.insert_idle(move |state| {
|
niri.event_loop.insert_idle(move |state| {
|
||||||
state.niri.activate_monitors(&state.backend);
|
state.niri.activate_monitors(&state.backend);
|
||||||
@@ -769,6 +771,8 @@ impl Tty {
|
|||||||
};
|
};
|
||||||
|
|
||||||
self.enabled_outputs.lock().unwrap().remove(&surface.name);
|
self.enabled_outputs.lock().unwrap().remove(&surface.name);
|
||||||
|
#[cfg(feature = "dbus")]
|
||||||
|
niri.on_enabled_outputs_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_vblank(
|
fn on_vblank(
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use serde::Serialize;
|
|||||||
use smithay::output::Output;
|
use smithay::output::Output;
|
||||||
use zbus::fdo::RequestNameFlags;
|
use zbus::fdo::RequestNameFlags;
|
||||||
use zbus::zvariant::{self, OwnedValue, Type};
|
use zbus::zvariant::{self, OwnedValue, Type};
|
||||||
use zbus::{dbus_interface, fdo};
|
use zbus::{dbus_interface, fdo, SignalContext};
|
||||||
|
|
||||||
use super::Start;
|
use super::Start;
|
||||||
|
|
||||||
@@ -112,7 +112,8 @@ impl DisplayConfig {
|
|||||||
Ok((0, monitors, logical_monitors, HashMap::new()))
|
Ok((0, monitors, logical_monitors, HashMap::new()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: monitors-changed signal.
|
#[dbus_interface(signal)]
|
||||||
|
pub async fn monitors_changed(ctxt: &SignalContext<'_>) -> zbus::Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DisplayConfig {
|
impl DisplayConfig {
|
||||||
|
|||||||
+38
@@ -2759,6 +2759,44 @@ impl Niri {
|
|||||||
constraint.activate();
|
constraint.activate();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "dbus")]
|
||||||
|
pub fn on_enabled_outputs_changed(&self) {
|
||||||
|
let _span = tracy_client::span!("Niri::on_enabled_outputs_changed");
|
||||||
|
|
||||||
|
let Some(dbus) = &self.dbus else { return };
|
||||||
|
let Some(conn_display_config) = dbus.conn_display_config.clone() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
let res = thread::Builder::new()
|
||||||
|
.name("DisplayConfig MonitorsChanged Emitter".to_owned())
|
||||||
|
.spawn(move || {
|
||||||
|
use crate::dbus::mutter_display_config::DisplayConfig;
|
||||||
|
let _span = tracy_client::span!("MonitorsChanged");
|
||||||
|
let iface = match conn_display_config
|
||||||
|
.object_server()
|
||||||
|
.interface::<_, DisplayConfig>("/org/gnome/Mutter/DisplayConfig")
|
||||||
|
{
|
||||||
|
Ok(iface) => iface,
|
||||||
|
Err(err) => {
|
||||||
|
warn!("error getting DisplayConfig interface: {err:?}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
async_io::block_on(async move {
|
||||||
|
if let Err(err) = DisplayConfig::monitors_changed(iface.signal_context()).await
|
||||||
|
{
|
||||||
|
warn!("error emitting MonitorsChanged: {err:?}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if let Err(err) = res {
|
||||||
|
warn!("error spawning a thread to send MonitorsChanged: {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ClientState {
|
pub struct ClientState {
|
||||||
|
|||||||
Reference in New Issue
Block a user