deps: Update smithay

This commit is contained in:
Victoria Brekenfeld 2022-08-31 13:01:23 +02:00
parent 9e0a6e1b5f
commit 6690e13d54
31 changed files with 572 additions and 562 deletions

View file

@ -5,7 +5,7 @@ use smithay::{
backend::renderer::utils::{on_commit_buffer_handler, with_renderer_surface_state},
delegate_compositor,
desktop::{layer_map_for_output, Kind, LayerSurface, PopupKind, WindowSurfaceType},
reexports::wayland_server::{protocol::wl_surface::WlSurface, DisplayHandle},
reexports::wayland_server::protocol::wl_surface::WlSurface,
wayland::{
compositor::{with_states, CompositorHandler, CompositorState},
shell::{
@ -19,8 +19,9 @@ use smithay::{
use std::sync::Mutex;
impl State {
fn early_import_surface(&mut self, dh: &DisplayHandle, surface: &WlSurface) {
fn early_import_surface(&mut self, surface: &WlSurface) {
let mut import_nodes = std::collections::HashSet::new();
let dh = &self.common.display_handle;
for output in self.common.shell.outputs_for_surface(&surface) {
if let BackendData::Kms(ref mut kms_state) = &mut self.backend {
if let Some(target) = kms_state.target_node_for_output(&output) {
@ -75,11 +76,7 @@ impl State {
}
}
fn layer_surface_ensure_inital_configure(
&mut self,
surface: &LayerSurface,
dh: &DisplayHandle,
) -> bool {
fn layer_surface_ensure_inital_configure(&mut self, surface: &LayerSurface) -> bool {
// send the initial configure if relevant
let initial_configure_sent = with_states(surface.wl_surface(), |states| {
states
@ -92,7 +89,7 @@ impl State {
});
if !initial_configure_sent {
// compute initial dimensions by mapping
self.common.shell.map_layer(&surface, dh);
Shell::map_layer(self, &surface);
// this will also send a configure
}
initial_configure_sent
@ -104,7 +101,7 @@ impl CompositorHandler for State {
&mut self.common.compositor_state
}
fn commit(&mut self, dh: &DisplayHandle, surface: &WlSurface) {
fn commit(&mut self, surface: &WlSurface) {
// first load the buffer for various smithay helper functions
on_commit_buffer_handler(surface);
@ -125,7 +122,7 @@ impl CompositorHandler for State {
})
{
let output = active_output(&seat, &self.common);
self.common.shell.map_window(&window, &output, dh);
Shell::map_window(self, &window, &output);
} else {
return;
}
@ -141,7 +138,7 @@ impl CompositorHandler for State {
.find(|(layer_surface, _, _)| layer_surface.wl_surface() == surface)
.cloned()
{
if !self.layer_surface_ensure_inital_configure(&layer_surface, dh) {
if !self.layer_surface_ensure_inital_configure(&layer_surface) {
return;
}
};
@ -188,7 +185,7 @@ impl CompositorHandler for State {
// We need to know every potential output for importing to the right gpu and scheduling a render,
// so call this only after every potential surface map operation has been done.
self.early_import_surface(dh, surface);
self.early_import_surface(surface);
// and refresh smithays internal state
self.common.shell.popups.commit(surface);
@ -202,6 +199,7 @@ impl CompositorHandler for State {
map.layer_for_surface(surface, WindowSurfaceType::ALL)
.is_some()
}) {
let dh = &self.common.display_handle;
layer_map_for_output(output).arrange(dh);
}

View file

@ -3,13 +3,11 @@
use crate::state::State;
use smithay::{
delegate_data_device,
input::Seat,
reexports::wayland_server::protocol::{wl_data_source::WlDataSource, wl_surface::WlSurface},
utils::IsAlive,
wayland::{
data_device::{
ClientDndGrabHandler, DataDeviceHandler, DataDeviceState, ServerDndGrabHandler,
},
seat::Seat,
wayland::data_device::{
ClientDndGrabHandler, DataDeviceHandler, DataDeviceState, ServerDndGrabHandler,
},
};
use std::cell::RefCell;

View file

@ -4,7 +4,6 @@ use crate::state::{BackendData, State};
use smithay::{
backend::{allocator::dmabuf::Dmabuf, renderer::ImportDma},
delegate_dmabuf,
reexports::wayland_server::DisplayHandle,
wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportError},
};
@ -15,13 +14,12 @@ impl DmabufHandler for State {
fn dmabuf_imported(
&mut self,
dh: &DisplayHandle,
global: &DmabufGlobal,
dmabuf: Dmabuf,
) -> Result<(), ImportError> {
match &mut self.backend {
BackendData::Kms(ref mut state) => state
.dmabuf_imported(dh, global, dmabuf)
.dmabuf_imported(global, dmabuf)
.map_err(|_| ImportError::Failed),
BackendData::Winit(ref mut state) => state
.backend

View file

@ -15,13 +15,13 @@ use smithay::{
},
},
desktop::{draw_window, draw_window_popups, space::RenderElement, Kind, Window},
input::pointer::CursorImageStatus,
reexports::wayland_server::{protocol::wl_output::WlOutput, DisplayHandle, Resource},
utils::{IsAlive, Size, Transform},
wayland::{
compositor::{get_children, with_states, SurfaceAttributes},
dmabuf::get_dmabuf,
output::Output,
seat::CursorImageStatus,
},
};
@ -201,7 +201,7 @@ impl ExportDmabufHandler for State {
.get::<RefCell<CursorImageStatus>>()
.map(|cell| {
let mut cursor_status = cell.borrow_mut();
if let CursorImageStatus::Image(ref surface) = *cursor_status {
if let CursorImageStatus::Surface(ref surface) = *cursor_status {
if !surface.alive() {
*cursor_status = CursorImageStatus::Default;
}

View file

@ -4,7 +4,7 @@ use crate::utils::prelude::*;
use smithay::{
delegate_layer_shell,
desktop::{LayerSurface, PopupKind},
reexports::wayland_server::{protocol::wl_output::WlOutput, DisplayHandle},
reexports::wayland_server::protocol::wl_output::WlOutput,
wayland::{
output::Output,
shell::{
@ -23,7 +23,6 @@ impl WlrLayerShellHandler for State {
fn new_layer_surface(
&mut self,
_dh: &DisplayHandle,
surface: WlrLayerSurface,
wl_output: Option<WlOutput>,
_layer: Layer,
@ -42,7 +41,7 @@ impl WlrLayerShellHandler for State {
));
}
fn new_popup(&mut self, _dh: &DisplayHandle, _parent: WlrLayerSurface, popup: PopupSurface) {
fn new_popup(&mut self, _parent: WlrLayerSurface, popup: PopupSurface) {
let positioner = popup.with_pending_state(|state| state.positioner);
self.common.shell.unconstrain_popup(&popup, &positioner);

View file

@ -3,13 +3,44 @@
use crate::state::State;
use smithay::{
delegate_seat,
wayland::seat::{SeatHandler, SeatState},
input::{pointer::CursorImageStatus, SeatHandler, SeatState},
reexports::wayland_server::{protocol::wl_surface::WlSurface, Resource},
wayland::{data_device::set_data_device_focus, primary_selection::set_primary_focus},
};
use std::cell::RefCell;
impl SeatHandler for State {
type KeyboardFocus = WlSurface;
type PointerFocus = WlSurface;
fn seat_state(&mut self) -> &mut SeatState<Self> {
&mut self.common.seat_state
}
fn cursor_image(
&mut self,
seat: &smithay::input::Seat<Self>,
image: smithay::input::pointer::CursorImageStatus,
) {
*seat
.user_data()
.get::<RefCell<CursorImageStatus>>()
.unwrap()
.borrow_mut() = image;
}
fn focus_changed(
&mut self,
seat: &smithay::input::Seat<Self>,
focused: Option<&Self::KeyboardFocus>,
) {
let dh = &self.common.display_handle;
if let Some(client) = focused.and_then(|s| dh.get_client(s.id()).ok()) {
set_data_device_focus(dh, seat, Some(client));
let client2 = focused.and_then(|s| dh.get_client(s.id()).ok()).unwrap();
set_primary_focus(dh, seat, Some(client2))
}
}
}
delegate_seat!(State);

View file

@ -2,8 +2,8 @@
use smithay::{
desktop::{Kind, Window},
input::Seat,
reexports::wayland_server::DisplayHandle,
wayland::seat::Seat,
};
use crate::{
@ -18,7 +18,7 @@ impl ToplevelManagementHandler for State {
&mut self.common.shell.toplevel_management_state
}
fn activate(&mut self, dh: &DisplayHandle, window: &Window, seat: Option<Seat<Self>>) {
fn activate(&mut self, _dh: &DisplayHandle, window: &Window, seat: Option<Seat<Self>>) {
if let Some(idx) = self
.common
.shell
@ -30,8 +30,7 @@ impl ToplevelManagementHandler for State {
if self.common.shell.active_space(&output).idx != idx {
self.common.shell.activate(&seat, &output, idx as usize);
}
self.common
.set_focus(dh, Some(window.toplevel().wl_surface()), &seat, None);
Common::set_focus(self, Some(window.toplevel().wl_surface()), &seat, None);
}
}

View file

@ -7,35 +7,35 @@ use smithay::{
Kind, PopupGrab, PopupKeyboardGrab, PopupKind, PopupPointerGrab, PopupUngrabStrategy,
Window, WindowSurfaceType,
},
input::{
pointer::{Focus, GrabStartData as PointerGrabStartData},
Seat,
},
reexports::{
wayland_protocols::xdg::shell::server::xdg_toplevel,
wayland_server::{
protocol::{wl_output::WlOutput, wl_seat::WlSeat, wl_surface::WlSurface},
DisplayHandle,
},
wayland_server::protocol::{wl_output::WlOutput, wl_seat::WlSeat, wl_surface::WlSurface},
},
utils::Serial,
wayland::{
output::Output,
seat::{Focus, PointerGrabStartData, Seat},
shell::xdg::{
Configure, PopupSurface, PositionerState, ToplevelSurface, XdgShellHandler,
XdgShellState,
},
Serial,
},
};
use std::cell::Cell;
pub mod popup;
pub type PopupGrabData = Cell<Option<PopupGrab>>;
pub type PopupGrabData = Cell<Option<PopupGrab<State>>>;
impl XdgShellHandler for State {
fn xdg_shell_state(&mut self) -> &mut XdgShellState {
&mut self.common.shell.xdg_shell_state
}
fn new_toplevel(&mut self, _dh: &DisplayHandle, surface: ToplevelSurface) {
fn new_toplevel(&mut self, surface: ToplevelSurface) {
super::mark_dirty_on_drop(&self.common, surface.wl_surface());
let seat = &self.common.last_active_seat;
@ -48,12 +48,7 @@ impl XdgShellHandler for State {
// We will position the window after the first commit, when we know its size hints
}
fn new_popup(
&mut self,
_dh: &DisplayHandle,
surface: PopupSurface,
positioner: PositionerState,
) {
fn new_popup(&mut self, surface: PopupSurface, positioner: PositionerState) {
super::mark_dirty_on_drop(&self.common, surface.wl_surface());
surface.with_pending_state(|state| {
@ -75,7 +70,7 @@ impl XdgShellHandler for State {
}
}
fn ack_configure(&mut self, _dh: &DisplayHandle, surface: WlSurface, configure: Configure) {
fn ack_configure(&mut self, surface: WlSurface, configure: Configure) {
if let Configure::Toplevel(configure) = configure {
// If we would re-position the window inside the grab we would get a weird jittery animation.
// We only want to resize once the client has acknoledged & commited the new size,
@ -95,13 +90,14 @@ impl XdgShellHandler for State {
}
}
fn grab(&mut self, dh: &DisplayHandle, surface: PopupSurface, seat: WlSeat, serial: Serial) {
fn grab(&mut self, surface: PopupSurface, seat: WlSeat, serial: Serial) {
let seat = Seat::from_resource(&seat).unwrap();
let ret = self
.common
.shell
.popups
.grab_popup(dh, surface.into(), &seat, serial);
let dh = &self.common.display_handle;
let ret =
self.common
.shell
.popups
.grab_popup(dh, surface.wl_surface().clone(), &seat, serial);
if let Ok(mut grab) = ret {
if let Some(keyboard) = seat.get_keyboard() {
@ -109,11 +105,15 @@ impl XdgShellHandler for State {
&& !(keyboard.has_grab(serial)
|| keyboard.has_grab(grab.previous_serial().unwrap_or(serial)))
{
grab.ungrab(dh, PopupUngrabStrategy::All);
grab.ungrab(PopupUngrabStrategy::All);
return;
}
self.common
.set_focus(dh, grab.current_grab().as_ref(), &seat, Some(serial));
Common::set_focus(
self,
grab.current_grab().as_ref().map(|x| &x.0),
&seat,
Some(serial),
);
keyboard.set_grab(PopupKeyboardGrab::new(&grab), serial);
}
@ -123,10 +123,10 @@ impl XdgShellHandler for State {
|| pointer
.has_grab(grab.previous_serial().unwrap_or_else(|| grab.serial())))
{
grab.ungrab(dh, PopupUngrabStrategy::All);
grab.ungrab(PopupUngrabStrategy::All);
return;
}
pointer.set_grab(PopupPointerGrab::new(&grab), serial, Focus::Keep);
pointer.set_grab(self, PopupPointerGrab::new(&grab), serial, Focus::Keep);
}
seat.user_data()
@ -140,7 +140,6 @@ impl XdgShellHandler for State {
fn reposition_request(
&mut self,
_dh: &DisplayHandle,
surface: PopupSurface,
positioner: PositionerState,
token: u32,
@ -161,13 +160,7 @@ impl XdgShellHandler for State {
}
}
fn move_request(
&mut self,
_dh: &DisplayHandle,
surface: ToplevelSurface,
seat: WlSeat,
serial: Serial,
) {
fn move_request(&mut self, surface: ToplevelSurface, seat: WlSeat, serial: Serial) {
let seat = Seat::from_resource(&seat).unwrap();
if let Some(start_data) = check_grab_preconditions(&seat, surface.wl_surface(), serial) {
let workspace = self
@ -181,15 +174,12 @@ impl XdgShellHandler for State {
.unwrap()
.clone();
self.common
.shell
.move_request(&window, &seat, serial, start_data);
Shell::move_request(self, &window, &seat, serial, start_data);
}
}
fn resize_request(
&mut self,
_dh: &DisplayHandle,
surface: ToplevelSurface,
seat: WlSeat,
serial: Serial,
@ -197,22 +187,11 @@ impl XdgShellHandler for State {
) {
let seat = Seat::from_resource(&seat).unwrap();
if let Some(start_data) = check_grab_preconditions(&seat, surface.wl_surface(), serial) {
let workspace = self
.common
.shell
.space_for_window_mut(surface.wl_surface())
.unwrap();
let window = workspace
.space
.window_for_surface(surface.wl_surface(), WindowSurfaceType::TOPLEVEL)
.unwrap()
.clone();
workspace.resize_request(&window, &seat, serial, start_data, edges);
Workspace::resize_request(self, surface.wl_surface(), &seat, serial, start_data, edges);
}
}
fn maximize_request(&mut self, _dh: &DisplayHandle, surface: ToplevelSurface) {
fn maximize_request(&mut self, surface: ToplevelSurface) {
let surface = surface.wl_surface();
let seat = &self.common.last_active_seat;
let output = active_output(seat, &self.common);
@ -227,7 +206,7 @@ impl XdgShellHandler for State {
}
}
fn unmaximize_request(&mut self, _dh: &DisplayHandle, surface: ToplevelSurface) {
fn unmaximize_request(&mut self, surface: ToplevelSurface) {
let surface = surface.wl_surface();
if let Some(workspace) = self.common.shell.space_for_window_mut(surface) {
@ -240,12 +219,7 @@ impl XdgShellHandler for State {
}
}
fn fullscreen_request(
&mut self,
_dh: &DisplayHandle,
surface: ToplevelSurface,
output: Option<WlOutput>,
) {
fn fullscreen_request(&mut self, surface: ToplevelSurface, output: Option<WlOutput>) {
let output = output
.as_ref()
.and_then(Output::from_resource)
@ -265,7 +239,7 @@ impl XdgShellHandler for State {
}
}
fn unfullscreen_request(&mut self, _dh: &DisplayHandle, surface: ToplevelSurface) {
fn unfullscreen_request(&mut self, surface: ToplevelSurface) {
let surface = surface.wl_surface();
if let Some(workspace) = self.common.shell.space_for_window_mut(surface) {
let window = workspace
@ -282,7 +256,7 @@ fn check_grab_preconditions(
seat: &Seat<State>,
surface: &WlSurface,
serial: Serial,
) -> Option<PointerGrabStartData> {
) -> Option<PointerGrabStartData<State>> {
use smithay::reexports::wayland_server::Resource;
// TODO: touch resize.

View file

@ -106,7 +106,7 @@ where
drm: &wl_drm::WlDrm,
request: wl_drm::Request,
data: &DrmInstanceData,
dh: &DisplayHandle,
_dh: &DisplayHandle,
data_init: &mut DataInit<'_, D>,
) {
match request {
@ -161,7 +161,7 @@ where
dma.add_plane(name, 0, offset0 as u32, stride0 as u32, Modifier::Invalid);
match dma.build() {
Some(dmabuf) => {
match state.dmabuf_imported(dh, &data.dmabuf_global, dmabuf.clone()) {
match state.dmabuf_imported(&data.dmabuf_global, dmabuf.clone()) {
Ok(_) => {
// import was successful
data_init.init(id, dmabuf);

View file

@ -2,13 +2,14 @@
use smithay::{
desktop::Window,
input::{Seat, SeatHandler},
reexports::wayland_server::{
backend::{ClientId, GlobalId, ObjectId},
protocol::wl_surface::WlSurface,
Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource,
},
utils::{Logical, Rectangle},
wayland::{output::Output, seat::Seat},
wayland::output::Output,
};
pub use cosmic_protocols::toplevel_management::v1::server::zcosmic_toplevel_manager_v1::ZcosmicToplelevelManagementCapabilitiesV1 as ManagementCapabilities;
@ -25,7 +26,7 @@ pub struct ToplevelManagementState {
}
#[allow(unused_variables)]
pub trait ToplevelManagementHandler: ToplevelInfoHandler {
pub trait ToplevelManagementHandler: ToplevelInfoHandler + SeatHandler {
fn toplevel_management_state(&mut self) -> &mut ToplevelManagementState;
fn activate(&mut self, dh: &DisplayHandle, window: &Window, seat: Option<Seat<Self>>) {}