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

2
Cargo.lock generated
View file

@ -4556,7 +4556,7 @@ checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7"
[[package]]
name = "smithay"
version = "0.3.0"
source = "git+https://github.com/smithay//smithay?rev=64356be#64356be949f2ad5f70f601cd10255eafed2ce2ce"
source = "git+https://github.com/smithay//smithay?rev=8f132ec#8f132ecded5705e55fc1ce6cfa4b59850c6b038e"
dependencies = [
"appendlist",
"ash",

View file

@ -118,4 +118,4 @@ inherits = "release"
lto = "fat"
[patch."https://github.com/Smithay/smithay.git"]
smithay = {git = "https://github.com/smithay//smithay", rev = "64356be"}
smithay = {git = "https://github.com/smithay//smithay", rev = "8f132ec"}

View file

@ -1478,7 +1478,7 @@ impl Surface {
let buffer = frame.buffer();
if let Ok(dmabuf) = get_dmabuf(&buffer) {
renderer
.bind(dmabuf)
.bind(dmabuf.clone())
.map_err(RenderError::<GlMultiRenderer>::Rendering)?;
} else {
let size = buffer_dimensions(&buffer).ok_or(RenderError::<

View file

@ -10,7 +10,7 @@ use smithay::{
},
gles::GlesTexture,
glow::{GlowFrame, GlowRenderer},
utils::{CommitCounter, DamageSet},
utils::{CommitCounter, DamageSet, OpaqueRegions},
Frame, ImportAll, ImportMem, Renderer,
},
utils::{Buffer as BufferCoords, Logical, Physical, Point, Rectangle, Scale},
@ -142,7 +142,7 @@ where
}
}
fn opaque_regions(&self, scale: Scale<f64>) -> Vec<Rectangle<i32, Physical>> {
fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> {
match self {
CosmicElement::Workspace(elem) => elem.opaque_regions(scale),
CosmicElement::Cursor(elem) => elem.opaque_regions(scale),

View file

@ -1057,7 +1057,9 @@ where
if let (Some(ref damage), _) = &res {
if let Ok(dmabuf) = get_dmabuf(buffer) {
renderer.bind(dmabuf).map_err(RenderError::Rendering)?;
renderer
.bind(dmabuf.clone())
.map_err(RenderError::Rendering)?;
} else {
let size = buffer_dimensions(buffer).unwrap();
let format = with_buffer_contents(buffer, |_, _, data| {

View file

@ -72,6 +72,7 @@ use xkbcommon::xkb::{Keycode, Keysym};
use std::{
any::Any,
borrow::Cow,
cell::RefCell,
os::unix::process::CommandExt,
thread,
@ -642,8 +643,8 @@ impl State {
ptr.frame(self);
// If pointer is now in a constraint region, activate it
if let Some((under, surface_location)) =
new_under.and_then(|(target, loc)| Some((target.wl_surface()?, loc)))
if let Some((under, surface_location)) = new_under
.and_then(|(target, loc)| Some((target.wl_surface()?.into_owned(), loc)))
{
with_pointer_constraint(&under, &ptr, |constraint| match constraint {
Some(constraint) if !constraint.is_active() => {
@ -872,7 +873,9 @@ impl State {
// These cases are handled by the XwaylandKeyboardGrab.
if let Some(target) = shell.element_under(pos, &output) {
if seat.get_keyboard().unwrap().modifier_state().logo {
if let Some(surface) = target.toplevel() {
if let Some(surface) =
target.toplevel().map(Cow::into_owned)
{
let seat_clone = seat.clone();
self.common.event_loop_handle.insert_idle(
move |state| {
@ -1523,7 +1526,8 @@ impl State {
tool.motion(
position.as_logical(),
under.and_then(|(f, loc)| f.wl_surface().map(|s| (s, loc))),
under
.and_then(|(f, loc)| f.wl_surface().map(|s| (s.into_owned(), loc))),
&tablet,
SERIAL_COUNTER.next_serial(),
event.time_msec(),
@ -1573,9 +1577,9 @@ impl State {
if let Some(tablet) = tablet {
match event.state() {
ProximityState::In => {
if let Some(under) =
under.and_then(|(f, loc)| f.wl_surface().map(|s| (s, loc)))
{
if let Some(under) = under.and_then(|(f, loc)| {
f.wl_surface().map(|s| (s.into_owned(), loc))
}) {
tool.proximity_in(
position.as_logical(),
under,

View file

@ -19,7 +19,7 @@ use smithay::{
},
gles::element::PixelShaderElement,
glow::GlowRenderer,
utils::DamageSet,
utils::{DamageSet, OpaqueRegions},
ImportAll, ImportMem, Renderer,
},
},
@ -42,6 +42,7 @@ use smithay::{
};
use std::{
borrow::Cow,
collections::HashMap,
fmt,
hash::Hash,
@ -222,7 +223,7 @@ impl CosmicMapped {
};
if surface_type.contains(WindowSurfaceType::TOPLEVEL) {
if toplevel == *surface {
if *toplevel == *surface {
return true;
}
}
@ -936,10 +937,14 @@ impl KeyboardTarget<State> for CosmicMapped {
}
impl WaylandFocus for CosmicMapped {
fn wl_surface(&self) -> Option<WlSurface> {
fn wl_surface(&self) -> Option<Cow<'_, WlSurface>> {
match &self.element {
CosmicMappedInternal::Window(w) => w.surface().wl_surface().clone(),
CosmicMappedInternal::Stack(s) => s.active().wl_surface().clone(),
CosmicMappedInternal::Window(w) => {
w.surface().wl_surface().map(|s| Cow::Owned(s.into_owned()))
}
CosmicMappedInternal::Stack(s) => {
s.active().wl_surface().map(|s| Cow::Owned(s.into_owned()))
}
_ => None,
}
}
@ -1168,7 +1173,7 @@ where
}
}
fn opaque_regions(&self, scale: Scale<f64>) -> Vec<Rectangle<i32, Physical>> {
fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> {
match self {
CosmicMappedRenderElement::Stack(elem) => elem.opaque_regions(scale),
CosmicMappedRenderElement::Window(elem) => elem.opaque_regions(scale),

View file

@ -55,6 +55,7 @@ use smithay::{
wayland::seat::WaylandFocus,
};
use std::{
borrow::Cow,
cell::RefCell,
fmt,
hash::Hash,
@ -609,7 +610,7 @@ impl CosmicStack {
let seat = seat.clone();
surface.try_force_undecorated(false);
surface.send_configure();
if let Some(surface) = surface.wl_surface() {
if let Some(surface) = surface.wl_surface().map(Cow::into_owned) {
let _ = data.common.event_loop_handle.insert_idle(move |state| {
let res = state.common.shell.write().unwrap().move_request(
&surface,
@ -701,7 +702,10 @@ impl Program for CosmicStackInternal {
Message::DragStart => {
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
let active = self.active.load(Ordering::SeqCst);
if let Some(surface) = self.windows.lock().unwrap()[active].wl_surface() {
if let Some(surface) = self.windows.lock().unwrap()[active]
.wl_surface()
.map(Cow::into_owned)
{
loop_handle.insert_idle(move |state| {
let res = state.common.shell.write().unwrap().move_request(
&surface,
@ -757,7 +761,10 @@ impl Program for CosmicStackInternal {
Message::Menu => {
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
let active = self.active.load(Ordering::SeqCst);
if let Some(surface) = self.windows.lock().unwrap()[active].wl_surface() {
if let Some(surface) = self.windows.lock().unwrap()[active]
.wl_surface()
.map(Cow::into_owned)
{
loop_handle.insert_idle(move |state| {
let shell = state.common.shell.read().unwrap();
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
@ -808,7 +815,10 @@ impl Program for CosmicStackInternal {
}
Message::TabMenu(idx) => {
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
if let Some(surface) = self.windows.lock().unwrap()[idx].wl_surface() {
if let Some(surface) = self.windows.lock().unwrap()[idx]
.wl_surface()
.map(Cow::into_owned)
{
loop_handle.insert_idle(move |state| {
let shell = state.common.shell.read().unwrap();
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
@ -1260,7 +1270,7 @@ impl PointerTarget<State> for CosmicStack {
let seat = seat.clone();
let Some(surface) = self.0.with_program(|p| {
let window = &p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)];
window.wl_surface()
window.wl_surface().map(Cow::into_owned)
}) else {
return;
};
@ -1330,7 +1340,7 @@ impl PointerTarget<State> for CosmicStack {
let seat = seat.clone();
surface.try_force_undecorated(false);
surface.send_configure();
if let Some(surface) = surface.wl_surface() {
if let Some(surface) = surface.wl_surface().map(Cow::into_owned) {
let _ = data.common.event_loop_handle.insert_idle(move |state| {
let res = state.common.shell.write().unwrap().move_request(
&surface,

View file

@ -1,4 +1,5 @@
use std::{
borrow::Cow,
sync::atomic::{AtomicBool, Ordering},
time::Duration,
};
@ -69,7 +70,7 @@ impl From<X11Surface> for CosmicSurface {
impl PartialEq<WlSurface> for CosmicSurface {
fn eq(&self, other: &WlSurface) -> bool {
self.wl_surface().map_or(false, |s| &s == other)
self.wl_surface().map_or(false, |s| &*s == other)
}
}
@ -720,7 +721,7 @@ impl KeyboardTarget<State> for CosmicSurface {
}
impl WaylandFocus for CosmicSurface {
fn wl_surface(&self) -> Option<WlSurface> {
fn wl_surface(&self) -> Option<Cow<'_, WlSurface>> {
self.0.wl_surface()
}
}

View file

@ -45,6 +45,7 @@ use smithay::{
wayland::seat::WaylandFocus,
};
use std::{
borrow::Cow,
cell::RefCell,
fmt,
hash::Hash,
@ -384,7 +385,7 @@ impl Program for CosmicWindowInternal {
match message {
Message::DragStart => {
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
if let Some(surface) = self.window.wl_surface() {
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) {
loop_handle.insert_idle(move |state| {
let res = state.common.shell.write().unwrap().move_request(
&surface,
@ -410,7 +411,7 @@ impl Program for CosmicWindowInternal {
}
}
Message::Minimize => {
if let Some(surface) = self.window.wl_surface() {
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) {
loop_handle.insert_idle(move |state| {
let mut shell = state.common.shell.write().unwrap();
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
@ -420,7 +421,7 @@ impl Program for CosmicWindowInternal {
}
}
Message::Maximize => {
if let Some(surface) = self.window.wl_surface() {
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) {
loop_handle.insert_idle(move |state| {
let mut shell = state.common.shell.write().unwrap();
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
@ -433,7 +434,7 @@ impl Program for CosmicWindowInternal {
Message::Close => self.window.close(),
Message::Menu => {
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
if let Some(surface) = self.window.wl_surface() {
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) {
loop_handle.insert_idle(move |state| {
let shell = state.common.shell.read().unwrap();
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
@ -739,7 +740,7 @@ impl PointerTarget<State> for CosmicWindow {
Some(x) => {
let serial = event.serial;
let seat = seat.clone();
let Some(surface) = self.wl_surface() else {
let Some(surface) = self.wl_surface().map(Cow::into_owned) else {
return;
};
self.0.loop_handle().insert_idle(move |state| {
@ -906,8 +907,12 @@ impl TouchTarget<State> for CosmicWindow {
}
impl WaylandFocus for CosmicWindow {
fn wl_surface(&self) -> Option<WlSurface> {
self.0.with_program(|p| p.window.wl_surface())
fn wl_surface(&self) -> Option<Cow<'_, WlSurface>> {
self.0.with_program(|p| {
p.window
.wl_surface()
.map(|s| Cow::Owned(Cow::into_owned(s)))
})
}
fn same_client_as(&self, object_id: &ObjectId) -> bool {

View file

@ -15,7 +15,7 @@ use smithay::{
shell::wlr_layer::{KeyboardInteractivity, Layer},
},
};
use std::cell::RefCell;
use std::{borrow::Cow, cell::RefCell};
use tracing::{debug, trace};
use self::target::{KeyboardFocusTarget, WindowGroup};
@ -229,7 +229,7 @@ fn raise_with_children(floating_layer: &mut FloatingLayout, focused: &CosmicMapp
.0
.toplevel()
.and_then(|toplevel| toplevel.parent());
parent == focused.active_window().wl_surface()
parent == focused.active_window().wl_surface().map(Cow::into_owned)
})
.cloned()
.collect::<Vec<_>>()

View file

@ -1,4 +1,4 @@
use std::{sync::Weak, time::Duration};
use std::{borrow::Cow, sync::Weak, time::Duration};
use crate::{
shell::{
@ -79,12 +79,12 @@ impl From<KeyboardFocusTarget> for PointerFocusTarget {
let window = elem.active_window();
let surface = window.wl_surface().unwrap();
PointerFocusTarget::WlSurface {
surface,
surface: surface.into_owned(),
toplevel: Some(window.into()),
}
}
KeyboardFocusTarget::Fullscreen(elem) => PointerFocusTarget::WlSurface {
surface: elem.wl_surface().unwrap(),
surface: elem.wl_surface().unwrap().into_owned(),
toplevel: Some(elem.into()),
},
KeyboardFocusTarget::LayerSurface(layer) => PointerFocusTarget::WlSurface {
@ -145,7 +145,7 @@ impl PointerFocusTarget {
.and_then(|s| shell.element_for_surface(&s).map(|mapped| (mapped, s)))
.and_then(|(m, s)| {
m.windows()
.find(|(w, _)| w.wl_surface().map(|s2| s == s2).unwrap_or(false))
.find(|(w, _)| w.wl_surface().map(|s2| s == *s2).unwrap_or(false))
.map(|(s, _)| s)
}),
PointerFocusTarget::StackUI(stack) => Some(stack.active()),
@ -156,10 +156,12 @@ impl PointerFocusTarget {
}
impl KeyboardFocusTarget {
pub fn toplevel(&self) -> Option<WlSurface> {
pub fn toplevel(&self) -> Option<Cow<'_, WlSurface>> {
match self {
KeyboardFocusTarget::Element(mapped) => mapped.wl_surface(),
KeyboardFocusTarget::Popup(PopupKind::Xdg(xdg)) => get_popup_toplevel(&xdg),
KeyboardFocusTarget::Popup(PopupKind::Xdg(xdg)) => {
get_popup_toplevel(&xdg).map(Cow::Owned)
}
_ => None,
}
}
@ -686,14 +688,14 @@ impl KeyboardTarget<State> for KeyboardFocusTarget {
}
impl WaylandFocus for KeyboardFocusTarget {
fn wl_surface(&self) -> Option<WlSurface> {
fn wl_surface(&self) -> Option<Cow<'_, WlSurface>> {
match self {
KeyboardFocusTarget::Element(w) => WaylandFocus::wl_surface(w),
KeyboardFocusTarget::Fullscreen(w) => WaylandFocus::wl_surface(w),
KeyboardFocusTarget::Group(_) => None,
KeyboardFocusTarget::LayerSurface(l) => Some(l.wl_surface().clone()),
KeyboardFocusTarget::Popup(p) => Some(p.wl_surface().clone()),
KeyboardFocusTarget::LockSurface(l) => Some(l.wl_surface().clone()),
KeyboardFocusTarget::LayerSurface(l) => Some(Cow::Borrowed(l.wl_surface())),
KeyboardFocusTarget::Popup(p) => Some(Cow::Borrowed(p.wl_surface())),
KeyboardFocusTarget::LockSurface(l) => Some(Cow::Borrowed(l.wl_surface())),
}
}
fn same_client_as(&self, object_id: &ObjectId) -> bool {
@ -709,9 +711,9 @@ impl WaylandFocus for KeyboardFocusTarget {
}
impl WaylandFocus for PointerFocusTarget {
fn wl_surface(&self) -> Option<WlSurface> {
fn wl_surface(&self) -> Option<Cow<'_, WlSurface>> {
Some(match self {
PointerFocusTarget::WlSurface { surface, .. } => surface.clone(),
PointerFocusTarget::WlSurface { surface, .. } => Cow::Borrowed(surface),
PointerFocusTarget::ResizeFork(_)
| PointerFocusTarget::StackUI(_)
| PointerFocusTarget::WindowUI(_) => {

View file

@ -63,7 +63,7 @@ impl MenuGrabState {
pub fn render<I, R>(&self, renderer: &mut R, output: &Output) -> Vec<I>
where
R: Renderer + ImportMem,
<R as Renderer>::TextureId: 'static,
<R as Renderer>::TextureId: Clone + 'static,
I: From<MemoryRenderBufferRenderElement<R>>,
{
let scale = output.current_scale().fractional_scale();

View file

@ -9,7 +9,7 @@ use smithay::{
},
touch::{
DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent,
TouchGrab, TouchInnerHandle, UpEvent,
OrientationEvent, ShapeEvent, TouchGrab, TouchInnerHandle, UpEvent,
},
},
reexports::wayland_protocols::xdg::shell::server::xdg_toplevel,
@ -387,6 +387,32 @@ impl TouchGrab<State> for ResizeGrab {
}
}
fn shape(
&mut self,
data: &mut State,
handle: &mut TouchInnerHandle<'_, State>,
event: &ShapeEvent,
seq: Serial,
) {
match self {
ResizeGrab::Floating(grab) => TouchGrab::shape(grab, data, handle, event, seq),
ResizeGrab::Tiling(grab) => TouchGrab::shape(grab, data, handle, event, seq),
}
}
fn orientation(
&mut self,
data: &mut State,
handle: &mut TouchInnerHandle<'_, State>,
event: &OrientationEvent,
seq: Serial,
) {
match self {
ResizeGrab::Floating(grab) => TouchGrab::orientation(grab, data, handle, event, seq),
ResizeGrab::Tiling(grab) => TouchGrab::orientation(grab, data, handle, event, seq),
}
}
fn start_data(&self) -> &TouchGrabStartData<State> {
match self {
ResizeGrab::Floating(grab) => TouchGrab::start_data(grab),

View file

@ -633,6 +633,26 @@ impl TouchGrab<State> for MoveGrab {
handle.unset_grab(self, data);
}
fn shape(
&mut self,
data: &mut State,
handle: &mut TouchInnerHandle<'_, State>,
event: &touch::ShapeEvent,
seq: Serial,
) {
handle.shape(data, event, seq)
}
fn orientation(
&mut self,
data: &mut State,
handle: &mut TouchInnerHandle<'_, State>,
event: &touch::OrientationEvent,
seq: Serial,
) {
handle.orientation(data, event, seq)
}
fn start_data(&self) -> &TouchGrabStartData<State> {
match &self.start_data {
GrabStartData::Touch(start_data) => start_data,

View file

@ -23,7 +23,7 @@ use smithay::{
},
touch::{
DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent,
TouchGrab, TouchInnerHandle, UpEvent,
OrientationEvent, ShapeEvent, TouchGrab, TouchInnerHandle, UpEvent,
},
Seat,
},
@ -328,6 +328,26 @@ impl TouchGrab<State> for ResizeSurfaceGrab {
handle.unset_grab(self, data);
}
fn shape(
&mut self,
data: &mut State,
handle: &mut TouchInnerHandle<'_, State>,
event: &ShapeEvent,
seq: Serial,
) {
handle.shape(data, event, seq)
}
fn orientation(
&mut self,
data: &mut State,
handle: &mut TouchInnerHandle<'_, State>,
event: &OrientationEvent,
seq: Serial,
) {
handle.orientation(data, event, seq)
}
fn start_data(&self) -> &TouchGrabStartData<State> {
match &self.start_data {
GrabStartData::Touch(start_data) => start_data,

View file

@ -1132,7 +1132,7 @@ impl FloatingLayout {
};
self.space
.elements()
.find(|elem| elem.wl_surface().as_ref() == Some(&toplevel_surface))
.find(|elem| elem.wl_surface().as_deref() == Some(&toplevel_surface))
}
KeyboardFocusTarget::Element(elem) => self.space.elements().find(|x| *x == &elem),
_ => None,

View file

@ -525,6 +525,16 @@ impl TouchGrab<State> for ResizeForkGrab {
handle.unset_grab(self, data);
}
fn shape(
&mut self,
data: &mut State,
handle: &mut TouchInnerHandle<'_, State>,
event: &ShapeEvent,
seq: Serial,
) {
handle.shape(data, event, seq)
}
fn start_data(&self) -> &TouchGrabStartData<State> {
match &self.start_data {
GrabStartData::Touch(start_data) => start_data,
@ -532,5 +542,15 @@ impl TouchGrab<State> for ResizeForkGrab {
}
}
fn orientation(
&mut self,
data: &mut State,
handle: &mut TouchInnerHandle<'_, State>,
event: &OrientationEvent,
seq: Serial,
) {
handle.orientation(data, event, seq)
}
fn unset(&mut self, _data: &mut State) {}
}

View file

@ -2791,7 +2791,7 @@ impl TilingLayout {
.find(|node| match node.data() {
Data::Mapped { mapped, .. } => mapped
.windows()
.any(|(w, _)| w.wl_surface().as_ref() == Some(&toplevel_surface)),
.any(|(w, _)| w.wl_surface().as_deref() == Some(&toplevel_surface)),
_ => false,
})?;

View file

@ -2206,7 +2206,7 @@ impl Shell {
let mapped = self.element_for_surface(surface).cloned()?;
let (_, relative_loc) = mapped
.windows()
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface))
.find(|(w, _)| w.wl_surface().as_deref() == Some(surface))
.unwrap();
let (global_position, edge, is_tiled, is_stacked, is_sticky, tiling_enabled) =
@ -2279,7 +2279,7 @@ impl Shell {
} else {
let (tab, _) = mapped
.windows()
.find(|(s, _)| s.wl_surface().as_ref() == Some(surface))
.find(|(s, _)| s.wl_surface().as_deref() == Some(surface))
.unwrap();
Box::new(tab_items(&mapped, &tab, is_tiled, &config.static_conf))
as Box<dyn Iterator<Item = Item>>
@ -2320,7 +2320,7 @@ impl Shell {
let (window, _) = old_mapped
.windows()
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface))
.find(|(w, _)| w.wl_surface().as_deref() == Some(surface))
.unwrap();
let mapped = if move_out_of_stack {
@ -2502,7 +2502,7 @@ impl Shell {
.space
.elements()
.chain(workspace.mapped())
.find(|elem| elem.wl_surface().as_ref() == Some(&toplevel_surface))
.find(|elem| elem.wl_surface().as_deref() == Some(&toplevel_surface))
}
KeyboardFocusTarget::Element(elem) => sticky_layer
.space
@ -2664,7 +2664,8 @@ impl Shell {
),
(ResizeGrab, Focus),
)> {
let surface = mapped.active_window().wl_surface()?;
let active_window = mapped.active_window();
let surface = active_window.wl_surface()?;
if mapped.is_fullscreen(true) || mapped.is_maximized(true) {
return None;
}

View file

@ -31,7 +31,7 @@ use smithay::{
},
gles::{GlesError, GlesTexture},
glow::{GlowFrame, GlowRenderer},
utils::DamageSet,
utils::{DamageSet, OpaqueRegions},
ImportAll, ImportMem, Renderer,
},
desktop::{layer_map_for_output, space::SpaceElement},
@ -328,7 +328,7 @@ impl Workspace {
if let Some(signal) = f.animation_signal.take() {
signal.store(true, Ordering::SeqCst);
if let Some(client) =
f.surface.wl_surface().as_ref().and_then(Resource::client)
f.surface.wl_surface().as_deref().and_then(Resource::client)
{
clients.insert(client.id(), client);
}
@ -342,7 +342,7 @@ impl Workspace {
if let Some(signal) = f.animation_signal.take() {
signal.store(true, Ordering::SeqCst);
if let Some(client) =
f.surface.wl_surface().as_ref().and_then(Resource::client)
f.surface.wl_surface().as_deref().and_then(Resource::client)
{
clients.insert(client.id(), client);
}
@ -823,7 +823,7 @@ impl Workspace {
if self
.fullscreen
.as_ref()
.is_some_and(|f| f.surface.wl_surface().as_ref() == Some(&toplevel))
.is_some_and(|f| f.surface.wl_surface().as_deref() == Some(&toplevel))
{
return false;
}
@ -1332,7 +1332,7 @@ where
}
}
fn opaque_regions(&self, scale: Scale<f64>) -> Vec<Rectangle<i32, smithay::utils::Physical>> {
fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, smithay::utils::Physical> {
match self {
WorkspaceRenderElement::OverrideRedirect(elem) => elem.opaque_regions(scale),
WorkspaceRenderElement::Fullscreen(elem) => elem.opaque_regions(scale),

View file

@ -93,6 +93,7 @@ use smithay::{
virtual_keyboard::VirtualKeyboardManagerState,
xdg_activation::XdgActivationState,
xwayland_keyboard_grab::XWaylandKeyboardGrabState,
xwayland_shell::XWaylandShellState,
},
xwayland::XWaylandClientData,
};
@ -219,6 +220,7 @@ pub struct Common {
pub xdg_activation_state: XdgActivationState,
pub workspace_state: WorkspaceState<State>,
pub xwayland_state: Option<XWaylandState>,
pub xwayland_shell_state: XWaylandShellState,
}
#[derive(Debug)]
@ -427,6 +429,7 @@ impl State {
let session_lock_manager_state =
SessionLockManagerState::new::<Self, _>(&dh, client_is_privileged);
XWaylandKeyboardGrabState::new::<Self>(&dh);
let xwayland_shell_state = XWaylandShellState::new::<Self>(&dh);
PointerConstraintsState::new::<Self>(&dh);
PointerGesturesState::new::<Self>(&dh);
TabletManagerState::new::<Self>(&dh);
@ -533,6 +536,7 @@ impl State {
xdg_activation_state,
workspace_state,
xwayland_state: None,
xwayland_shell_state,
},
backend: BackendData::Unset,
ready: Once::new(),

View file

@ -843,7 +843,7 @@ impl<P, R> AsRenderElements<R> for IcedElement<P>
where
P: Program + Send + 'static,
R: Renderer + ImportMem,
<R as Renderer>::TextureId: 'static,
<R as Renderer>::TextureId: Clone + 'static,
{
type RenderElement = MemoryRenderBufferRenderElement<R>;

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);

View file

@ -83,7 +83,6 @@ impl State {
let mut wm = match X11Wm::start_wm(
data.common.event_loop_handle.clone(),
data.common.display_handle.clone(),
x11_socket,
client.clone(),
) {