xwayland: Fix display env variable race
This commit is contained in:
parent
7704f65d02
commit
4940d0823d
6 changed files with 16 additions and 10 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -3274,7 +3274,7 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smithay"
|
name = "smithay"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/pop-os/smithay?rev=05f5db5beb#05f5db5beb4932ff48692c9ec4f466363e19e957"
|
source = "git+https://github.com/pop-os/smithay?rev=b231c3dd2a#b231c3dd2a2602539e8042e5f8db212a0adcee24"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"appendlist",
|
"appendlist",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
|
|
|
||||||
|
|
@ -70,4 +70,4 @@ debug = true
|
||||||
lto = "fat"
|
lto = "fat"
|
||||||
|
|
||||||
[patch."https://github.com/Smithay/smithay.git"]
|
[patch."https://github.com/Smithay/smithay.git"]
|
||||||
smithay = { git = "https://github.com/pop-os/smithay", rev = "05f5db5beb" }
|
smithay = { git = "https://github.com/pop-os/smithay", rev = "b231c3dd2a" }
|
||||||
|
|
|
||||||
|
|
@ -914,7 +914,8 @@ impl State {
|
||||||
.common
|
.common
|
||||||
.xwayland_state
|
.xwayland_state
|
||||||
.values()
|
.values()
|
||||||
.find_map(|s| s.display.map(|v| format!(":{}", v)))
|
.next()
|
||||||
|
.map(|s| format!(":{}", s.display))
|
||||||
.unwrap_or(String::new()),
|
.unwrap_or(String::new()),
|
||||||
)
|
)
|
||||||
.env_remove("COSMIC_SESSION_SOCK")
|
.env_remove("COSMIC_SESSION_SOCK")
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,13 @@ pub fn setup_socket(handle: LoopHandle<Data>, state: &State) -> Result<()> {
|
||||||
.into_string()
|
.into_string()
|
||||||
.map_err(|_| anyhow!("wayland socket is no valid utf-8 string?"))?,
|
.map_err(|_| anyhow!("wayland socket is no valid utf-8 string?"))?,
|
||||||
);
|
);
|
||||||
if let Some(display) = state.common.xwayland_state.values().find_map(|s| s.display) {
|
if let Some(display) = state
|
||||||
|
.common
|
||||||
|
.xwayland_state
|
||||||
|
.values()
|
||||||
|
.next()
|
||||||
|
.map(|s| s.display)
|
||||||
|
{
|
||||||
env.insert(String::from("DISPLAY"), format!(":{}", display));
|
env.insert(String::from("DISPLAY"), format!(":{}", display));
|
||||||
}
|
}
|
||||||
let message = serde_json::to_string(&Message::SetEnv { variables: env })
|
let message = serde_json::to_string(&Message::SetEnv { variables: env })
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ pub fn ready(state: &State) {
|
||||||
.common
|
.common
|
||||||
.xwayland_state
|
.xwayland_state
|
||||||
.values()
|
.values()
|
||||||
.find_map(|s| s.display.map(|v| format!(":{}", v)))
|
.next()
|
||||||
|
.map(|s| format!(":{}", s.display))
|
||||||
.unwrap_or(String::new()),
|
.unwrap_or(String::new()),
|
||||||
)
|
)
|
||||||
.status()
|
.status()
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ use smithay::{
|
||||||
|
|
||||||
pub struct XWaylandState {
|
pub struct XWaylandState {
|
||||||
pub xwm: Option<X11Wm>,
|
pub xwm: Option<X11Wm>,
|
||||||
pub display: Option<u32>,
|
pub display: u32,
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
xwayland: XWayland,
|
xwayland: XWayland,
|
||||||
}
|
}
|
||||||
|
|
@ -74,14 +74,12 @@ impl State {
|
||||||
let mut xwayland_state =
|
let mut xwayland_state =
|
||||||
data.state.common.xwayland_state.get_mut(&drm_node).unwrap();
|
data.state.common.xwayland_state.get_mut(&drm_node).unwrap();
|
||||||
xwayland_state.xwm = Some(wm);
|
xwayland_state.xwm = Some(wm);
|
||||||
xwayland_state.display = Some(display);
|
|
||||||
}
|
}
|
||||||
XWaylandEvent::Exited => {
|
XWaylandEvent::Exited => {
|
||||||
if let Some(mut xwayland_state) =
|
if let Some(mut xwayland_state) =
|
||||||
data.state.common.xwayland_state.remove(&drm_node)
|
data.state.common.xwayland_state.remove(&drm_node)
|
||||||
{
|
{
|
||||||
xwayland_state.xwm = None;
|
xwayland_state.xwm = None;
|
||||||
xwayland_state.display = None;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -102,13 +100,13 @@ impl State {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
Ok(_) => {
|
Ok(display) => {
|
||||||
self.common.xwayland_state.insert(
|
self.common.xwayland_state.insert(
|
||||||
drm_node,
|
drm_node,
|
||||||
XWaylandState {
|
XWaylandState {
|
||||||
xwayland,
|
xwayland,
|
||||||
xwm: None,
|
xwm: None,
|
||||||
display: None,
|
display,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue