mirror of
https://github.com/marcoallegretti/WEFT_OS.git
synced 2026-11-22 08:13:59 +00:00
fix(shells): release the rendering context and window before the display goes away
The software rendering path (softbuffer) and the EGL path keep their own Wayland objects on winit's display, so dropping the rendering context after the event loop could destroy proxies on a disconnected display just like the shell client did. Both hosts now release the rendering context and the window in winit's exiting handler as well. The compositor records the keys whose press a shortcut took and takes only those releases, so no client sees a release without its press or keeps a key pressed. check_activation.py watches the panel for six seconds after Alt+F4 instead of sampling it once.
This commit is contained in:
parent
828984be4b
commit
102c20d2b4
5 changed files with 40 additions and 16 deletions
|
|
@ -431,12 +431,17 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ApplicationHandler<ServoWake> for App {
|
impl ApplicationHandler<ServoWake> for App {
|
||||||
/// Releases Servo and the shell protocol objects while winit's Wayland
|
/// Releases everything that holds Wayland objects of winit's display
|
||||||
/// display is still connected; dropped later, the shell client's
|
/// (Servo, the rendering context, whose software and EGL paths keep
|
||||||
/// proxies would be destroyed on a display that is gone.
|
/// their own proxies on it, the shell protocol client and the window)
|
||||||
|
/// while that display is still connected; dropped after the event loop,
|
||||||
|
/// they would be destroyed on a display that is gone. A panic unwinding
|
||||||
|
/// out of a handler skips this.
|
||||||
fn exiting(&mut self, _event_loop: &ActiveEventLoop) {
|
fn exiting(&mut self, _event_loop: &ActiveEventLoop) {
|
||||||
self.shut_down();
|
self.shut_down();
|
||||||
|
self.rendering_context = None;
|
||||||
self.shell_client = None;
|
self.shell_client = None;
|
||||||
|
self.window = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
|
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
|
||||||
|
|
|
||||||
|
|
@ -56,14 +56,22 @@ fn handle_keyboard<B: InputBackend>(state: &mut WeftCompositorState, event: B::K
|
||||||
key_state,
|
key_state,
|
||||||
serial,
|
serial,
|
||||||
time,
|
time,
|
||||||
|_state, mods, keysym| {
|
|state, mods, keysym| {
|
||||||
if mods.alt
|
// A release is taken only when its press was, so no client
|
||||||
&& keysym.modified_sym() == smithay::input::keyboard::keysyms::KEY_F4.into()
|
// sees half of a key.
|
||||||
{
|
let code = keysym.raw_code().raw();
|
||||||
FilterResult::Intercept(key_state == smithay::backend::input::KeyState::Pressed)
|
if key_state == smithay::backend::input::KeyState::Pressed {
|
||||||
} else {
|
if mods.alt
|
||||||
FilterResult::Forward
|
&& keysym.modified_sym() == smithay::input::keyboard::keysyms::KEY_F4.into()
|
||||||
|
{
|
||||||
|
state.suppressed_keys.push(code);
|
||||||
|
return FilterResult::Intercept(true);
|
||||||
|
}
|
||||||
|
} else if let Some(i) = state.suppressed_keys.iter().position(|&k| k == code) {
|
||||||
|
state.suppressed_keys.remove(i);
|
||||||
|
return FilterResult::Intercept(false);
|
||||||
}
|
}
|
||||||
|
FilterResult::Forward
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if close == Some(true) {
|
if close == Some(true) {
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,9 @@ pub struct WeftCompositorState {
|
||||||
pub loop_signal: LoopSignal,
|
pub loop_signal: LoopSignal,
|
||||||
pub loop_handle: LoopHandle<'static, WeftCompositorState>,
|
pub loop_handle: LoopHandle<'static, WeftCompositorState>,
|
||||||
pub gesture_state: GestureState,
|
pub gesture_state: GestureState,
|
||||||
|
/// Keycodes whose press a compositor shortcut took, so their release is
|
||||||
|
/// taken as well and no client sees half of a key.
|
||||||
|
pub suppressed_keys: Vec<u32>,
|
||||||
|
|
||||||
pub compositor_state: CompositorState,
|
pub compositor_state: CompositorState,
|
||||||
pub xdg_shell_state: XdgShellState,
|
pub xdg_shell_state: XdgShellState,
|
||||||
|
|
@ -196,6 +199,7 @@ impl WeftCompositorState {
|
||||||
dmabuf_global: None,
|
dmabuf_global: None,
|
||||||
running: true,
|
running: true,
|
||||||
gesture_state: GestureState::default(),
|
gesture_state: GestureState::default(),
|
||||||
|
suppressed_keys: Vec::new(),
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
appd_ipc: None,
|
appd_ipc: None,
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
|
|
||||||
|
|
@ -346,12 +346,17 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ApplicationHandler<ServoWake> for App {
|
impl ApplicationHandler<ServoWake> for App {
|
||||||
/// Releases Servo and the shell protocol objects while winit's Wayland
|
/// Releases everything that holds Wayland objects of winit's display
|
||||||
/// display is still connected; dropped later, the shell client's
|
/// (Servo, the rendering context, whose software and EGL paths keep
|
||||||
/// proxies would be destroyed on a display that is gone.
|
/// their own proxies on it, the shell protocol client and the window)
|
||||||
|
/// while that display is still connected; dropped after the event loop,
|
||||||
|
/// they would be destroyed on a display that is gone. A panic unwinding
|
||||||
|
/// out of a handler skips this.
|
||||||
fn exiting(&mut self, _event_loop: &ActiveEventLoop) {
|
fn exiting(&mut self, _event_loop: &ActiveEventLoop) {
|
||||||
self.shut_down();
|
self.shut_down();
|
||||||
|
self.rendering_context = None;
|
||||||
self.shell_client = None;
|
self.shell_client = None;
|
||||||
|
self.window = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
|
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
|
||||||
|
|
|
||||||
|
|
@ -230,9 +230,11 @@ def run(args, desktop, store, home):
|
||||||
raise AssertionError("the closed application is still shown")
|
raise AssertionError("the closed application is still shown")
|
||||||
time.sleep(0.3)
|
time.sleep(0.3)
|
||||||
key("alt+F4")
|
key("alt+F4")
|
||||||
time.sleep(2)
|
deadline = time.monotonic() + 6
|
||||||
if area(desktop.capture(), GREEN)[0] != panel:
|
while time.monotonic() < deadline:
|
||||||
raise AssertionError("Alt+F4 closed or moved the shell's panel")
|
if area(desktop.capture(), GREEN)[0] != panel:
|
||||||
|
raise AssertionError("Alt+F4 closed or moved the shell's panel")
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
appd.send({"type": "ACTIVATE_APP", "session_id": 999})
|
appd.send({"type": "ACTIVATE_APP", "session_id": 999})
|
||||||
reply = appd.wait_for(lambda m: m.get("type") == "ERROR", 10)
|
reply = appd.wait_for(lambda m: m.get("type") == "ERROR", 10)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue