Update smithay, with xwayland shell, Cow, etc.

This commit is contained in:
Ian Douglas Scott 2024-05-13 14:16:21 -07:00 committed by Victoria Brekenfeld
parent dfb3bea595
commit 4f076e0753
32 changed files with 220 additions and 87 deletions

View file

@ -107,7 +107,7 @@ impl CompositorHandler for State {
.buffer
.as_ref()
.and_then(|assignment| match assignment {
BufferAssignment::NewBuffer(buffer) => get_dmabuf(buffer).ok(),
BufferAssignment::NewBuffer(buffer) => get_dmabuf(buffer).ok().cloned(),
_ => None,
})
});
@ -134,7 +134,7 @@ impl CompositorHandler for State {
}
fn commit(&mut self, surface: &WlSurface) {
X11Wm::commit_hook::<State>(surface);
X11Wm::commit_hook::<State>(self, surface);
// first load the buffer for various smithay helper functions (which also initializes the RendererSurfaceState)
on_commit_buffer_handler::<Self>(surface);
@ -153,7 +153,7 @@ impl CompositorHandler for State {
if let Some((window, _, _)) = shell
.pending_windows
.iter()
.find(|(window, _, _)| window.wl_surface().as_ref() == Some(surface))
.find(|(window, _, _)| window.wl_surface().as_deref() == Some(surface))
.cloned()
{
if let Some(toplevel) = window.0.toplevel() {
@ -220,7 +220,7 @@ impl CompositorHandler for State {
.windows()
.any(|(s, _)| {
s.wl_surface()
.as_ref()
.as_deref()
.map(|s| s == surface)
.unwrap_or(false)
})
@ -231,7 +231,7 @@ impl CompositorHandler for State {
let stack = window.stack_ref_mut().unwrap();
if let Some(i) = stack.surfaces().position(|s| {
s.wl_surface()
.as_ref()
.as_deref()
.map(|s| s == surface)
.unwrap_or(false)
}) {

View file

@ -58,7 +58,7 @@ pub fn new_decoration(mapped: &CosmicMapped, surface: &WlSurface) -> KdeMode {
if mapped.is_stack() {
if let Some((window, _)) = mapped
.windows()
.find(|(window, _)| window.wl_surface().as_ref() == Some(surface))
.find(|(window, _)| window.wl_surface().as_deref() == Some(surface))
{
if let Some(toplevel) = window.0.toplevel() {
toplevel
@ -70,7 +70,7 @@ pub fn new_decoration(mapped: &CosmicMapped, surface: &WlSurface) -> KdeMode {
} else {
if let Some((window, _)) = mapped
.windows()
.find(|(window, _)| window.wl_surface().as_ref() == Some(surface))
.find(|(window, _)| window.wl_surface().as_deref() == Some(surface))
{
if let Some(toplevel) = window.0.toplevel() {
toplevel
@ -85,7 +85,7 @@ pub fn new_decoration(mapped: &CosmicMapped, surface: &WlSurface) -> KdeMode {
pub fn request_mode(mapped: &CosmicMapped, surface: &WlSurface, mode: XdgMode) {
if let Some((window, _)) = mapped
.windows()
.find(|(window, _)| window.wl_surface().as_ref() == Some(surface))
.find(|(window, _)| window.wl_surface().as_deref() == Some(surface))
{
if let Some(toplevel) = window.0.toplevel() {
PreferredDecorationMode::update(&window.0, Some(mode));
@ -100,7 +100,7 @@ pub fn request_mode(mapped: &CosmicMapped, surface: &WlSurface, mode: XdgMode) {
pub fn unset_mode(mapped: &CosmicMapped, surface: &WlSurface) {
if let Some((window, _)) = mapped
.windows()
.find(|(window, _)| window.wl_surface().as_ref() == Some(surface))
.find(|(window, _)| window.wl_surface().as_deref() == Some(surface))
{
if let Some(toplevel) = window.0.toplevel() {
PreferredDecorationMode::update(&window.0, None);

View file

@ -38,3 +38,4 @@ pub mod workspace;
pub mod xdg_activation;
pub mod xdg_shell;
pub mod xwayland_keyboard_grab;
pub mod xwayland_shell;

View file

@ -16,9 +16,7 @@ impl PointerConstraintsHandler for State {
// XXX region
if pointer
.current_focus()
.and_then(|x| x.wl_surface())
.as_ref()
== Some(surface)
.map_or(false, |x| x.wl_surface().as_deref() == Some(surface))
{
with_pointer_constraint(surface, pointer, |constraint| {
constraint.unwrap().activate();

View file

@ -280,7 +280,7 @@ pub fn render_workspace_to_buffer(
render_workspace::<_, _, GlesRenderbuffer>(
None,
renderer,
dmabuf,
dmabuf.clone(),
dt,
age,
additional_damage,
@ -581,7 +581,7 @@ pub fn render_window_to_buffer(
}
if let Ok(dmabuf) = get_dmabuf(buffer) {
renderer.bind(dmabuf).map_err(DTError::Rendering)?;
renderer.bind(dmabuf.clone()).map_err(DTError::Rendering)?;
} else {
let size = buffer_dimensions(buffer).unwrap();
let format =
@ -794,7 +794,7 @@ pub fn render_cursor_to_buffer(
);
if let Ok(dmabuf) = get_dmabuf(buffer) {
renderer.bind(dmabuf).map_err(DTError::Rendering)?;
renderer.bind(dmabuf.clone()).map_err(DTError::Rendering)?;
} else {
let size = buffer_dimensions(buffer).unwrap();
let format =

View file

@ -200,7 +200,7 @@ impl XdgShellHandler for State {
let mut shell = self.common.shell.write().unwrap();
if let Some(mapped) = shell.element_for_surface(surface.wl_surface()).cloned() {
if !mapped.is_stack()
|| mapped.active_window().wl_surface().as_ref() == Some(surface.wl_surface())
|| mapped.active_window().wl_surface().as_deref() == Some(surface.wl_surface())
{
shell.minimize_request(&mapped)
}
@ -248,7 +248,7 @@ impl XdgShellHandler for State {
let stack = mapped.stack_ref().unwrap();
let surface = stack
.surfaces()
.find(|s| s.wl_surface().as_ref() == Some(surface.wl_surface()))
.find(|s| s.wl_surface().as_deref() == Some(surface.wl_surface()))
.unwrap();
stack.remove_window(&surface);
CosmicMapped::from(CosmicWindow::new(
@ -286,7 +286,7 @@ impl XdgShellHandler for State {
let stack = mapped.stack_ref().unwrap();
let surface = stack
.surfaces()
.find(|s| s.wl_surface().as_ref() == Some(surface.wl_surface()))
.find(|s| s.wl_surface().as_deref() == Some(surface.wl_surface()))
.unwrap();
stack.remove_window(&surface);
(
@ -325,7 +325,7 @@ impl XdgShellHandler for State {
} else {
let (window, _) = mapped
.windows()
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface.wl_surface()))
.find(|(w, _)| w.wl_surface().as_deref() == Some(surface.wl_surface()))
.unwrap();
workspace.fullscreen_request(&window, None, from, &seat)
}
@ -334,7 +334,7 @@ impl XdgShellHandler for State {
if let Some(o) = shell
.pending_windows
.iter_mut()
.find(|(s, _, _)| s.wl_surface().as_ref() == Some(surface.wl_surface()))
.find(|(s, _, _)| s.wl_surface().as_deref() == Some(surface.wl_surface()))
.map(|(_, _, o)| o)
{
*o = Some(output);
@ -348,7 +348,7 @@ impl XdgShellHandler for State {
if let Some(workspace) = shell.space_for_mut(&mapped) {
let (window, _) = mapped
.windows()
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface.wl_surface()))
.find(|(w, _)| w.wl_surface().as_deref() == Some(surface.wl_surface()))
.unwrap();
if let Some((layer, previous_workspace)) = workspace.unfullscreen_request(&window) {
let old_handle = workspace.handle.clone();

View file

@ -59,7 +59,7 @@ impl Shell {
let (window, offset) = elem
.windows()
.find(|(w, _)| w.wl_surface().as_ref() == Some(&parent))
.find(|(w, _)| w.wl_surface().as_deref() == Some(&parent))
.unwrap();
let window_geo_offset = window.geometry().loc;
let window_loc: Point<i32, Global> =

View file

@ -0,0 +1,15 @@
// SPDX-License-Identifier: GPL-3.0-only
use crate::state::State;
use smithay::{
delegate_xwayland_shell,
wayland::xwayland_shell::{XWaylandShellHandler, XWaylandShellState},
};
impl XWaylandShellHandler for State {
fn xwayland_shell_state(&mut self) -> &mut XWaylandShellState {
&mut self.common.xwayland_shell_state
}
}
delegate_xwayland_shell!(State);