mirror of
https://github.com/Smithay/smithay.git
synced 2024-09-28 03:21:14 +02:00
xwm: Add disconnected
method when we lose connection to X server
The compositor can then destroy the `X11Wm`. Which is needed for the `strong_count` of the `Arc<RustConnection>` to drop to `0`.
This commit is contained in:
parent
9c5e5b5b4f
commit
d2d7454763
3 changed files with 22 additions and 9 deletions
|
@ -578,8 +578,11 @@ impl EventSource for X11Backend {
|
|||
|
||||
let post_action = self
|
||||
.source
|
||||
.process_events(readiness, token, |event, _| {
|
||||
X11Inner::process_event(&inner, event, &mut callback);
|
||||
.process_events(readiness, token, |event, _| match event {
|
||||
calloop::channel::Event::Msg(event) => {
|
||||
X11Inner::process_event(&inner, event, &mut callback);
|
||||
}
|
||||
calloop::channel::Event::Closed => {}
|
||||
})
|
||||
.map_err(|_| X11Error::ConnectionLost)?;
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ impl Drop for X11Source {
|
|||
}
|
||||
|
||||
impl EventSource for X11Source {
|
||||
type Event = Event;
|
||||
type Event = ChannelEvent<Event>;
|
||||
type Metadata = ();
|
||||
type Ret = ();
|
||||
type Error = ChannelError;
|
||||
|
@ -108,9 +108,11 @@ impl EventSource for X11Source {
|
|||
C: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret,
|
||||
{
|
||||
if let Some(channel) = &mut self.channel {
|
||||
channel.process_events(readiness, token, move |event, meta| match event {
|
||||
ChannelEvent::Closed => warn!("Event thread exited"),
|
||||
ChannelEvent::Msg(event) => callback(event, meta),
|
||||
channel.process_events(readiness, token, move |event, meta| {
|
||||
if matches!(event, ChannelEvent::Closed) {
|
||||
warn!("Event thread exited");
|
||||
}
|
||||
callback(event, meta)
|
||||
})
|
||||
} else {
|
||||
Ok(PostAction::Remove)
|
||||
|
|
|
@ -386,6 +386,9 @@ pub trait XwmHandler {
|
|||
fn cleared_selection(&mut self, xwm: XwmId, selection: SelectionTarget) {
|
||||
let _ = (xwm, selection);
|
||||
}
|
||||
|
||||
/// WM has lost connection to X server
|
||||
fn disconnected(&mut self, _xwm: XwmId) {}
|
||||
}
|
||||
|
||||
/// The runtime state of an reparenting XWayland window manager.
|
||||
|
@ -878,9 +881,14 @@ impl X11Wm {
|
|||
};
|
||||
|
||||
let event_handle = handle.clone();
|
||||
handle.insert_source(source, move |event, _, data| {
|
||||
if let Err(err) = handle_event(&event_handle, data, id, event) {
|
||||
warn!(id = id.0, err = ?err, "Failed to handle X11 event");
|
||||
handle.insert_source(source, move |event, _, data| match event {
|
||||
calloop::channel::Event::Msg(event) => {
|
||||
if let Err(err) = handle_event(&event_handle, data, id, event) {
|
||||
warn!(id = id.0, err = ?err, "Failed to handle X11 event");
|
||||
}
|
||||
}
|
||||
calloop::channel::Event::Closed => {
|
||||
data.disconnected(id);
|
||||
}
|
||||
})?;
|
||||
Ok(wm)
|
||||
|
|
Loading…
Reference in a new issue