On Wayland, make wl_subcompositor protocol optional
This protocol is only used for (optional) Client Side Decorations (where) the compositor still takes the burden of compositing various window parts together, via subsurfaces that all belong to a single window. If this core protocol is not available, as is the case on gamescope, disable CSD.
This commit is contained in:
parent
3eea505440
commit
becdd0dbd2
3 changed files with 17 additions and 10 deletions
|
|
@ -17,6 +17,7 @@ Unreleased` header.
|
||||||
misinterpreted during a drag and drop operation.
|
misinterpreted during a drag and drop operation.
|
||||||
- On X11, fix a bug where focusing the window would panic.
|
- On X11, fix a bug where focusing the window would panic.
|
||||||
- On macOS, fix `refresh_rate_millihertz`.
|
- On macOS, fix `refresh_rate_millihertz`.
|
||||||
|
- On Wayland, disable Client Side Decorations when `wl_subcompositor` is not supported.
|
||||||
|
|
||||||
# 0.29.4
|
# 0.29.4
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ pub struct WinitState {
|
||||||
pub compositor_state: Arc<CompositorState>,
|
pub compositor_state: Arc<CompositorState>,
|
||||||
|
|
||||||
/// The state of the subcompositor.
|
/// The state of the subcompositor.
|
||||||
pub subcompositor_state: Arc<SubcompositorState>,
|
pub subcompositor_state: Option<Arc<SubcompositorState>>,
|
||||||
|
|
||||||
/// The seat state responsible for all sorts of input.
|
/// The seat state responsible for all sorts of input.
|
||||||
pub seat_state: SeatState,
|
pub seat_state: SeatState,
|
||||||
|
|
@ -124,12 +124,17 @@ impl WinitState {
|
||||||
let registry_state = RegistryState::new(globals);
|
let registry_state = RegistryState::new(globals);
|
||||||
let compositor_state =
|
let compositor_state =
|
||||||
CompositorState::bind(globals, queue_handle).map_err(WaylandError::Bind)?;
|
CompositorState::bind(globals, queue_handle).map_err(WaylandError::Bind)?;
|
||||||
let subcompositor_state = SubcompositorState::bind(
|
let subcompositor_state = match SubcompositorState::bind(
|
||||||
compositor_state.wl_compositor().clone(),
|
compositor_state.wl_compositor().clone(),
|
||||||
globals,
|
globals,
|
||||||
queue_handle,
|
queue_handle,
|
||||||
)
|
) {
|
||||||
.map_err(WaylandError::Bind)?;
|
Ok(c) => Some(c),
|
||||||
|
Err(e) => {
|
||||||
|
warn!("Subcompositor protocol not available, ignoring CSD: {e:?}");
|
||||||
|
None
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let output_state = OutputState::new(globals, queue_handle);
|
let output_state = OutputState::new(globals, queue_handle);
|
||||||
let monitors = output_state.outputs().map(MonitorHandle::new).collect();
|
let monitors = output_state.outputs().map(MonitorHandle::new).collect();
|
||||||
|
|
@ -151,7 +156,7 @@ impl WinitState {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
registry_state,
|
registry_state,
|
||||||
compositor_state: Arc::new(compositor_state),
|
compositor_state: Arc::new(compositor_state),
|
||||||
subcompositor_state: Arc::new(subcompositor_state),
|
subcompositor_state: subcompositor_state.map(Arc::new),
|
||||||
output_state,
|
output_state,
|
||||||
seat_state,
|
seat_state,
|
||||||
shm: Shm::bind(globals, queue_handle).map_err(WaylandError::Bind)?,
|
shm: Shm::bind(globals, queue_handle).map_err(WaylandError::Bind)?,
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ impl WindowState {
|
||||||
&mut self,
|
&mut self,
|
||||||
configure: WindowConfigure,
|
configure: WindowConfigure,
|
||||||
shm: &Shm,
|
shm: &Shm,
|
||||||
subcompositor: &Arc<SubcompositorState>,
|
subcompositor: &Option<Arc<SubcompositorState>>,
|
||||||
event_sink: &mut EventSink,
|
event_sink: &mut EventSink,
|
||||||
) -> LogicalSize<u32> {
|
) -> LogicalSize<u32> {
|
||||||
// NOTE: when using fractional scaling or wl_compositor@v6 the scaling
|
// NOTE: when using fractional scaling or wl_compositor@v6 the scaling
|
||||||
|
|
@ -265,10 +265,11 @@ impl WindowState {
|
||||||
self.stateless_size = self.size;
|
self.stateless_size = self.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if configure.decoration_mode == DecorationMode::Client
|
if let Some(subcompositor) = subcompositor.as_ref().filter(|_| {
|
||||||
&& self.frame.is_none()
|
configure.decoration_mode == DecorationMode::Client
|
||||||
&& !self.csd_fails
|
&& self.frame.is_none()
|
||||||
{
|
&& !self.csd_fails
|
||||||
|
}) {
|
||||||
match WinitFrame::new(
|
match WinitFrame::new(
|
||||||
&self.window,
|
&self.window,
|
||||||
shm,
|
shm,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue