fix(wayland): account for surface data map panic
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
use super::{state::WaylandState, surface::CoreSurface};
|
use super::{state::WaylandState, surface::CoreSurface};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
|
backend::renderer::utils::on_commit_buffer_handler,
|
||||||
delegate_compositor,
|
delegate_compositor,
|
||||||
reexports::wayland_server::protocol::wl_surface::WlSurface,
|
reexports::wayland_server::protocol::wl_surface::WlSurface,
|
||||||
wayland::compositor::{self, CompositorHandler, CompositorState},
|
wayland::compositor::{self, CompositorHandler, CompositorState},
|
||||||
@@ -11,6 +12,7 @@ impl CompositorHandler for WaylandState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn commit(&mut self, surface: &WlSurface) {
|
fn commit(&mut self, surface: &WlSurface) {
|
||||||
|
on_commit_buffer_handler(surface);
|
||||||
compositor::with_states(surface, |data| {
|
compositor::with_states(surface, |data| {
|
||||||
data.data_map.insert_if_missing_threadsafe(|| {
|
data.data_map.insert_if_missing_threadsafe(|| {
|
||||||
CoreSurface::new(
|
CoreSurface::new(
|
||||||
|
|||||||
@@ -146,9 +146,15 @@ impl Wayland {
|
|||||||
let time_ms = (sk.time_getf() * 1000.) as u64;
|
let time_ms = (sk.time_getf() * 1000.) as u64;
|
||||||
|
|
||||||
for core_surface in CORE_SURFACES.get_valid_contents() {
|
for core_surface in CORE_SURFACES.get_valid_contents() {
|
||||||
let client_id = core_surface.wl_surface().client().unwrap().id();
|
let client_id = match core_surface.wl_surface().client() {
|
||||||
|
Some(client) => client.id(),
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
let state = self.state.lock();
|
let state = self.state.lock();
|
||||||
let seat_data = state.seats.get(&client_id).unwrap().clone();
|
let seat_data = match state.seats.get(&client_id) {
|
||||||
|
Some(seat_data) => seat_data.clone(),
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
let output = state.output.clone();
|
let output = state.output.clone();
|
||||||
core_surface.process(
|
core_surface.process(
|
||||||
sk,
|
sk,
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ impl ClientData for ClientState {
|
|||||||
|
|
||||||
pub struct WaylandState {
|
pub struct WaylandState {
|
||||||
pub weak_ref: Weak<Mutex<WaylandState>>,
|
pub weak_ref: Weak<Mutex<WaylandState>>,
|
||||||
|
pub log: Logger,
|
||||||
pub display: Arc<Mutex<Display<WaylandState>>>,
|
pub display: Arc<Mutex<Display<WaylandState>>>,
|
||||||
pub display_handle: DisplayHandle,
|
pub display_handle: DisplayHandle,
|
||||||
|
|
||||||
@@ -102,6 +103,7 @@ impl WaylandState {
|
|||||||
Arc::new_cyclic(|weak| {
|
Arc::new_cyclic(|weak| {
|
||||||
Mutex::new(WaylandState {
|
Mutex::new(WaylandState {
|
||||||
weak_ref: weak.clone(),
|
weak_ref: weak.clone(),
|
||||||
|
log,
|
||||||
display,
|
display,
|
||||||
display_handle,
|
display_handle,
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use slog::Logger;
|
|||||||
use smithay::{
|
use smithay::{
|
||||||
backend::renderer::{
|
backend::renderer::{
|
||||||
gles2::{Gles2Renderer, Gles2Texture},
|
gles2::{Gles2Renderer, Gles2Texture},
|
||||||
utils::{import_surface_tree, on_commit_buffer_handler, RendererSurfaceStateUserData},
|
utils::{import_surface_tree, RendererSurfaceStateUserData},
|
||||||
Texture,
|
Texture,
|
||||||
},
|
},
|
||||||
desktop::utils::send_frames_surface_tree,
|
desktop::utils::send_frames_surface_tree,
|
||||||
@@ -18,7 +18,7 @@ use smithay::{
|
|||||||
reexports::wayland_server::{
|
reexports::wayland_server::{
|
||||||
backend::ObjectId, protocol::wl_surface::WlSurface, Display, DisplayHandle, Resource,
|
backend::ObjectId, protocol::wl_surface::WlSurface, Display, DisplayHandle, Resource,
|
||||||
},
|
},
|
||||||
wayland::compositor::{self, SurfaceData},
|
wayland::compositor::{self, SurfaceData, SurfaceUserData},
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
sync::{Arc, Weak},
|
sync::{Arc, Weak},
|
||||||
@@ -128,10 +128,15 @@ impl CoreSurface {
|
|||||||
on_mapped: F,
|
on_mapped: F,
|
||||||
if_mapped: M,
|
if_mapped: M,
|
||||||
) {
|
) {
|
||||||
// Let Smithay handle all the buffer maintenance
|
// Avoid a panic in rare cases
|
||||||
on_commit_buffer_handler(&self.wl_surface());
|
if self.wl_surface().data::<SurfaceUserData>().is_none() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Import all surface buffers into textures
|
// Import all surface buffers into textures
|
||||||
import_surface_tree(renderer, &self.wl_surface(), log).unwrap();
|
if import_surface_tree(renderer, &self.wl_surface(), log).is_err() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let mapped = compositor::with_states(&self.wl_surface(), |data| {
|
let mapped = compositor::with_states(&self.wl_surface(), |data| {
|
||||||
data.data_map
|
data.data_map
|
||||||
|
|||||||
Reference in New Issue
Block a user