Merge pull request #102 from pinnacle-comp/update_deps

Update dependencies
This commit is contained in:
Ottatop 2023-10-12 17:24:33 -05:00 committed by GitHub
commit d443d9e8a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 175 additions and 168 deletions

View file

@ -10,30 +10,31 @@ repository = "https://github.com/pinnacle-comp/pinnacle/"
keywords = ["wayland", "compositor", "smithay", "lua"] keywords = ["wayland", "compositor", "smithay", "lua"]
[dependencies] [dependencies]
tracing = { git = "https://github.com/tokio-rs/tracing", rev = "b8c45cc" } tracing = { git = "https://github.com/tokio-rs/tracing", rev = "84f0a60" }
tracing-subscriber = { git = "https://github.com/tokio-rs/tracing", rev = "b8c45cc", features = ["env-filter"] } tracing-subscriber = { git = "https://github.com/tokio-rs/tracing", rev = "84f0a60", features = ["env-filter"] }
tracing-appender = { git = "https://github.com/tokio-rs/tracing", rev = "b8c45cc" } tracing-appender = { git = "https://github.com/tokio-rs/tracing", rev = "84f0a60" }
smithay = { git = "https://github.com/Smithay/smithay", rev = "1a61e1c", features = ["desktop", "wayland_frontend"] } smithay = { git = "https://github.com/Smithay/smithay", rev = "4e41ab0" }
smithay-drm-extras = { git = "https://github.com/Smithay/smithay", rev = "1a61e1c", optional = true } smithay-drm-extras = { git = "https://github.com/Smithay/smithay", rev = "4e41ab0", optional = true }
thiserror = "1.0.48" thiserror = "1.0.48"
xcursor = { version = "0.3.4", optional = true } xcursor = { version = "0.3.4", optional = true }
image = { version = "0.24.7", default-features = false, optional = true } image = { version = "0.24.7", default-features = false, optional = true }
serde = { version = "1.0.188", features = ["derive"] } serde = { version = "1.0.188", features = ["derive"] }
rmp = { version = "0.8.12" } rmp = { version = "0.8.12" }
rmp-serde = { version = "1.1.2" } rmp-serde = { version = "1.1.2" }
calloop = { version = "0.10.1", features = ["executor", "futures-io"] } calloop = { version = "0.12.2", features = ["executor", "futures-io"] }
futures-lite = { version = "1.13.0" } futures-lite = { version = "1.13.0" }
async-process = { version = "1.7.0" } async-process = { version = "1.7.0" }
async-channel = "1.9.0" async-channel = "1.9.0"
x11rb = { version = "0.12.0", default-features = false, features = ["composite"], optional = true } x11rb = { version = "0.12.0", default-features = false, features = ["composite"], optional = true }
shellexpand = "3.1.0" shellexpand = "3.1.0"
toml = "0.7.7" toml = "0.8.2"
anyhow = { version = "1.0.75", features = ["backtrace"] } anyhow = { version = "1.0.75", features = ["backtrace"] }
clap = { version = "4.4.2", features = ["derive"] } clap = { version = "4.4.2", features = ["derive"] }
xkbcommon = "0.6.0" xkbcommon = "0.6.0"
xdg = "2.5.2" xdg = "2.5.2"
lazy_static = "1.4.0" lazy_static = "1.4.0"
sysinfo = "0.29.10" sysinfo = "0.29.10"
nix = { version = "0.27.1", features = ["user", "resource"] }
[features] [features]
default = ["egl", "winit", "udev", "xwayland"] default = ["egl", "winit", "udev", "xwayland"]

View file

@ -73,10 +73,7 @@ use smithay::{
}, },
}, },
utils::{Clock, DeviceFd, IsAlive, Logical, Monotonic, Point, Transform}, utils::{Clock, DeviceFd, IsAlive, Logical, Monotonic, Point, Transform},
wayland::{ wayland::dmabuf::{DmabufFeedback, DmabufFeedbackBuilder, DmabufGlobal, DmabufState},
dmabuf::{DmabufFeedback, DmabufFeedbackBuilder, DmabufGlobal, DmabufState},
input_method::{InputMethodHandle, InputMethodSeat},
},
xwayland::X11Surface, xwayland::X11Surface,
}; };
use smithay_drm_extras::{ use smithay_drm_extras::{
@ -159,8 +156,8 @@ impl BackendData for Udev {
} }
pub fn run_udev() -> anyhow::Result<()> { pub fn run_udev() -> anyhow::Result<()> {
let mut event_loop = EventLoop::try_new_high_precision()?; let mut event_loop = EventLoop::try_new()?;
let mut display = Display::new()?; let display = Display::new()?;
// Initialize session // Initialize session
let (session, notifier) = LibSeatSession::new()?; let (session, notifier) = LibSeatSession::new()?;
@ -198,9 +195,11 @@ pub fn run_udev() -> anyhow::Result<()> {
pointer_element: PointerElement::default(), pointer_element: PointerElement::default(),
}; };
let display_handle = display.handle();
let mut state = State::init( let mut state = State::init(
Backend::Udev(data), Backend::Udev(data),
&mut display, display,
event_loop.get_signal(), event_loop.get_signal(),
event_loop.handle(), event_loop.handle(),
)?; )?;
@ -377,7 +376,8 @@ pub fn run_udev() -> anyhow::Result<()> {
?primary_gpu, ?primary_gpu,
"Trying to initialize EGL Hardware Acceleration", "Trying to initialize EGL Hardware Acceleration",
); );
match renderer.bind_wl_display(&display.handle()) {
match renderer.bind_wl_display(&display_handle) {
Ok(_) => tracing::info!("EGL hardware-acceleration enabled"), Ok(_) => tracing::info!("EGL hardware-acceleration enabled"),
Err(err) => tracing::error!(?err, "Failed to initialize EGL hardware-acceleration"), Err(err) => tracing::error!(?err, "Failed to initialize EGL hardware-acceleration"),
} }
@ -389,7 +389,7 @@ pub fn run_udev() -> anyhow::Result<()> {
.expect("failed to create dmabuf feedback"); .expect("failed to create dmabuf feedback");
let mut dmabuf_state = DmabufState::new(); let mut dmabuf_state = DmabufState::new();
let global = dmabuf_state let global = dmabuf_state
.create_global_with_default_feedback::<State>(&display.handle(), &default_feedback); .create_global_with_default_feedback::<State>(&display_handle, &default_feedback);
udev.dmabuf_state = Some((dmabuf_state, global)); udev.dmabuf_state = Some((dmabuf_state, global));
let gpu_manager = &mut udev.gpu_manager; let gpu_manager = &mut udev.gpu_manager;
@ -419,11 +419,14 @@ pub fn run_udev() -> anyhow::Result<()> {
event_loop.run( event_loop.run(
Some(Duration::from_micros(((1.0 / 144.0) * 1000000.0) as u64)), Some(Duration::from_micros(((1.0 / 144.0) * 1000000.0) as u64)),
&mut CalloopData { state, display }, &mut CalloopData {
state,
display_handle,
},
|data| { |data| {
data.state.space.refresh(); data.state.space.refresh();
data.state.popup_manager.cleanup(); data.state.popup_manager.cleanup();
data.display data.display_handle
.flush_clients() .flush_clients()
.expect("failed to flush_clients"); .expect("failed to flush_clients");
}, },
@ -1244,7 +1247,7 @@ impl State {
surface, surface,
&mut renderer, &mut renderer,
&output, &output,
self.seat.input_method(), // self.seat.input_method(),
&pointer_image, &pointer_image,
&mut udev.pointer_element, &mut udev.pointer_element,
self.pointer_location, self.pointer_location,
@ -1361,7 +1364,7 @@ fn render_surface<'a>(
surface: &'a mut SurfaceData, surface: &'a mut SurfaceData,
renderer: &mut UdevRenderer<'a, '_>, renderer: &mut UdevRenderer<'a, '_>,
output: &Output, output: &Output,
input_method: &InputMethodHandle, // input_method: &InputMethodHandle,
pointer_image: &TextureBuffer<MultiTexture>, pointer_image: &TextureBuffer<MultiTexture>,
pointer_element: &mut PointerElement<MultiTexture>, pointer_element: &mut PointerElement<MultiTexture>,
pointer_location: Point<f64, Logical>, pointer_location: Point<f64, Logical>,
@ -1416,7 +1419,7 @@ fn render_surface<'a>(
pointer_location, pointer_location,
cursor_status, cursor_status,
dnd_icon, dnd_icon,
input_method, // input_method,
pointer_element, pointer_element,
Some(pointer_image), Some(pointer_image),
); );

View file

@ -27,10 +27,7 @@ use smithay::{
wayland_server::{protocol::wl_surface::WlSurface, Display}, wayland_server::{protocol::wl_surface::WlSurface, Display},
}, },
utils::{IsAlive, Transform}, utils::{IsAlive, Transform},
wayland::{ wayland::dmabuf::{DmabufFeedback, DmabufFeedbackBuilder, DmabufGlobal, DmabufState},
dmabuf::{DmabufFeedback, DmabufFeedbackBuilder, DmabufGlobal, DmabufState},
input_method::InputMethodSeat,
},
}; };
use crate::{ use crate::{
@ -62,9 +59,9 @@ impl BackendData for Winit {
/// Start Pinnacle as a window in a graphical environment. /// Start Pinnacle as a window in a graphical environment.
pub fn run_winit() -> anyhow::Result<()> { pub fn run_winit() -> anyhow::Result<()> {
let mut event_loop: EventLoop<CalloopData> = EventLoop::try_new_high_precision()?; let mut event_loop: EventLoop<CalloopData> = EventLoop::try_new()?;
let mut display: Display<State> = Display::new()?; let display: Display<State> = Display::new()?;
let display_handle = display.handle(); let display_handle = display.handle();
let evt_loop_handle = event_loop.handle(); let evt_loop_handle = event_loop.handle();
@ -84,8 +81,7 @@ pub fn run_winit() -> anyhow::Result<()> {
size: (0, 0).into(), size: (0, 0).into(),
subpixel: Subpixel::Unknown, subpixel: Subpixel::Unknown,
make: "Pinnacle".to_string(), make: "Pinnacle".to_string(),
model: "69LongMonitorNameXQ83VGX Super Ultra Pro Max XTX Ti Plus with Max-Q Design (and Knuckles)" model: "Winit Window".to_string(),
.to_string(),
}; };
let output = Output::new("Pinnacle window".to_string(), physical_properties); let output = Output::new("Pinnacle window".to_string(), physical_properties);
@ -160,7 +156,7 @@ pub fn run_winit() -> anyhow::Result<()> {
dmabuf_state, dmabuf_state,
full_redraw: 0, full_redraw: 0,
}), }),
&mut display, display,
event_loop.get_signal(), event_loop.get_signal(),
evt_loop_handle, evt_loop_handle,
)?; )?;
@ -193,7 +189,7 @@ pub fn run_winit() -> anyhow::Result<()> {
state state
.loop_handle .loop_handle
.insert_source(Timer::immediate(), move |_instant, _metadata, data| { .insert_source(Timer::immediate(), move |_instant, _metadata, data| {
let display = &mut data.display; let display_handle = &mut data.display_handle;
let state = &mut data.state; let state = &mut data.state;
let result = winit_evt_loop.dispatch_new_events(|event| match event { let result = winit_evt_loop.dispatch_new_events(|event| match event {
@ -230,7 +226,7 @@ pub fn run_winit() -> anyhow::Result<()> {
if let CursorImageStatus::Surface(surface) = &state.cursor_status { if let CursorImageStatus::Surface(surface) = &state.cursor_status {
if !surface.alive() { if !surface.alive() {
state.cursor_status = CursorImageStatus::Default; state.cursor_status = CursorImageStatus::default_named();
} }
} }
@ -277,7 +273,7 @@ pub fn run_winit() -> anyhow::Result<()> {
state.space.refresh(); state.space.refresh();
state.popup_manager.cleanup(); state.popup_manager.cleanup();
display display_handle
.flush_clients() .flush_clients()
.expect("failed to flush client buffers"); .expect("failed to flush client buffers");
@ -303,7 +299,7 @@ pub fn run_winit() -> anyhow::Result<()> {
state.pointer_location, state.pointer_location,
&mut state.cursor_status, &mut state.cursor_status,
state.dnd_icon.as_ref(), state.dnd_icon.as_ref(),
state.seat.input_method(), // state.seat.input_method(),
&mut pointer_element, &mut pointer_element,
None, None,
); );
@ -387,7 +383,7 @@ pub fn run_winit() -> anyhow::Result<()> {
state.space.refresh(); state.space.refresh();
state.popup_manager.cleanup(); state.popup_manager.cleanup();
display display_handle
.flush_clients() .flush_clients()
.expect("failed to flush client buffers"); .expect("failed to flush client buffers");
@ -400,7 +396,10 @@ pub fn run_winit() -> anyhow::Result<()> {
event_loop.run( event_loop.run(
Some(Duration::from_micros(((1.0 / 144.0) * 1000000.0) as u64)), Some(Duration::from_micros(((1.0 / 144.0) * 1000000.0) as u64)),
&mut CalloopData { display, state }, &mut CalloopData {
display_handle,
state,
},
|_data| { |_data| {
// println!("{}", _data.state.space.elements().count()); // println!("{}", _data.state.space.elements().count());
}, },

View file

@ -19,6 +19,7 @@ use smithay::{
use toml::Table; use toml::Table;
use api::msg::Modifier; use api::msg::Modifier;
use xkbcommon::xkb::Keysym;
use crate::{ use crate::{
state::{State, WithState}, state::{State, WithState},
@ -286,8 +287,8 @@ impl State {
let reload_mask = ModifierMask::from(reload_keybind.modifiers); let reload_mask = ModifierMask::from(reload_keybind.modifiers);
let kill_mask = ModifierMask::from(kill_keybind.modifiers); let kill_mask = ModifierMask::from(kill_keybind.modifiers);
let reload_keybind = (reload_mask, reload_keybind.key as u32); let reload_keybind = (reload_mask, Keysym::from(reload_keybind.key as u32));
let kill_keybind = (kill_mask, kill_keybind.key as u32); let kill_keybind = (kill_mask, Keysym::from(kill_keybind.key as u32));
let socket_token = self let socket_token = self
.loop_handle .loop_handle

View file

@ -112,6 +112,14 @@ impl TryFrom<FocusTarget> for WlSurface {
} }
impl PointerTarget<State> for FocusTarget { impl PointerTarget<State> for FocusTarget {
fn frame(&self, seat: &Seat<State>, data: &mut State) {
match self {
FocusTarget::Window(window) => window.frame(seat, data),
FocusTarget::Popup(popup) => popup.wl_surface().frame(seat, data),
FocusTarget::LayerSurface(surf) => surf.frame(seat, data),
}
}
fn enter(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) { fn enter(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) {
match self { match self {
FocusTarget::Window(window) => PointerTarget::enter(window, seat, data, event), FocusTarget::Window(window) => PointerTarget::enter(window, seat, data, event),

View file

@ -32,6 +32,10 @@ pub struct MoveSurfaceGrab<S: SeatHandler> {
} }
impl PointerGrab<State> for MoveSurfaceGrab<State> { impl PointerGrab<State> for MoveSurfaceGrab<State> {
fn frame(&mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>) {
handle.frame(data);
}
fn motion( fn motion(
&mut self, &mut self,
state: &mut State, state: &mut State,

View file

@ -83,6 +83,10 @@ impl<S: SeatHandler> ResizeSurfaceGrab<S> {
} }
impl PointerGrab<State> for ResizeSurfaceGrab<State> { impl PointerGrab<State> for ResizeSurfaceGrab<State> {
fn frame(&mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>) {
handle.frame(data);
}
fn motion( fn motion(
&mut self, &mut self,
data: &mut State, data: &mut State,

View file

@ -3,6 +3,8 @@
mod xdg_shell; mod xdg_shell;
mod xwayland; mod xwayland;
use std::os::fd::OwnedFd;
use smithay::{ use smithay::{
backend::renderer::utils, backend::renderer::utils,
delegate_compositor, delegate_data_device, delegate_fractional_scale, delegate_layer_shell, delegate_compositor, delegate_data_device, delegate_fractional_scale, delegate_layer_shell,
@ -13,7 +15,6 @@ use smithay::{
output::Output, output::Output,
reexports::{ reexports::{
calloop::Interest, calloop::Interest,
wayland_protocols::wp::primary_selection::zv1::server::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1,
wayland_server::{ wayland_server::{
protocol::{ protocol::{
wl_buffer::WlBuffer, wl_data_source::WlDataSource, wl_output::WlOutput, wl_buffer::WlBuffer, wl_data_source::WlDataSource, wl_output::WlOutput,
@ -28,23 +29,26 @@ use smithay::{
self, BufferAssignment, CompositorClientState, CompositorHandler, CompositorState, self, BufferAssignment, CompositorClientState, CompositorHandler, CompositorState,
SurfaceAttributes, SurfaceAttributes,
}, },
data_device::{
self, set_data_device_focus, ClientDndGrabHandler, DataDeviceHandler, DataDeviceState,
ServerDndGrabHandler,
},
dmabuf, dmabuf,
fractional_scale::{self, FractionalScaleHandler}, fractional_scale::{self, FractionalScaleHandler},
primary_selection::{
self, set_primary_focus, PrimarySelectionHandler, PrimarySelectionState,
},
seat::WaylandFocus, seat::WaylandFocus,
selection::data_device::{
set_data_device_focus, ClientDndGrabHandler, DataDeviceHandler, DataDeviceState,
ServerDndGrabHandler,
},
selection::{
primary_selection::{
set_primary_focus, PrimarySelectionHandler, PrimarySelectionState,
},
SelectionHandler, SelectionSource, SelectionTarget,
},
shell::{ shell::{
wlr_layer::{self, Layer, LayerSurfaceData, WlrLayerShellHandler, WlrLayerShellState}, wlr_layer::{self, Layer, LayerSurfaceData, WlrLayerShellHandler, WlrLayerShellState},
xdg::{XdgPopupSurfaceData, XdgToplevelSurfaceData}, xdg::{XdgPopupSurfaceData, XdgToplevelSurfaceData},
}, },
shm::{ShmHandler, ShmState}, shm::{ShmHandler, ShmState},
}, },
xwayland::{xwm::SelectionType, X11Wm, XWaylandClientData}, xwayland::{X11Wm, XWaylandClientData},
}; };
use crate::{ use crate::{
@ -83,7 +87,7 @@ impl CompositorHandler for State {
let res = state.loop_handle.insert_source(source, move |_, _, data| { let res = state.loop_handle.insert_source(source, move |_, _, data| {
data.state data.state
.client_compositor_state(&client) .client_compositor_state(&client)
.blocker_cleared(&mut data.state, &data.display.handle()); .blocker_cleared(&mut data.state, &data.display_handle);
Ok(()) Ok(())
}); });
if res.is_ok() { if res.is_ok() {
@ -164,7 +168,7 @@ fn ensure_initial_configure(surface: &WlSurface, state: &mut State) {
} }
if let Some(popup) = state.popup_manager.find_popup(surface) { if let Some(popup) = state.popup_manager.find_popup(surface) {
let PopupKind::Xdg(popup) = &popup; let PopupKind::Xdg(popup) = &popup else { return };
let initial_configure_sent = compositor::with_states(surface, |states| { let initial_configure_sent = compositor::with_states(surface, |states| {
states states
.data_map .data_map
@ -227,87 +231,49 @@ impl ClientDndGrabHandler for State {
impl ServerDndGrabHandler for State {} impl ServerDndGrabHandler for State {}
impl DataDeviceHandler for State { impl SelectionHandler for State {
type SelectionUserData = (); type SelectionUserData = ();
fn data_device_state(&self) -> &DataDeviceState { fn new_selection(
&self.data_device_state &mut self,
} ty: SelectionTarget,
source: Option<SelectionSource>,
fn new_selection(&mut self, source: Option<WlDataSource>, _seat: Seat<Self>) { _seat: Seat<Self>,
) {
if let Some(xwm) = self.xwm.as_mut() { if let Some(xwm) = self.xwm.as_mut() {
if let Some(source) = source { if let Err(err) = xwm.new_selection(ty, source.map(|source| source.mime_types())) {
if let Ok(Err(err)) = data_device::with_source_metadata(&source, |metadata| { tracing::warn!(?err, ?ty, "Failed to set Xwayland selection");
xwm.new_selection(SelectionType::Clipboard, Some(metadata.mime_types.clone()))
}) {
tracing::warn!(?err, "Failed to set Xwayland clipboard selection");
}
} else if let Err(err) = xwm.new_selection(SelectionType::Clipboard, None) {
tracing::warn!(?err, "Failed to clear Xwayland clipboard selection");
} }
} }
} }
fn send_selection( fn send_selection(
&mut self, &mut self,
ty: SelectionTarget,
mime_type: String, mime_type: String,
fd: std::os::fd::OwnedFd, fd: OwnedFd,
_seat: Seat<Self>, _seat: Seat<Self>,
_user_data: &Self::SelectionUserData, _user_data: &(),
) { ) {
if let Some(xwm) = self.xwm.as_mut() { if let Some(xwm) = self.xwm.as_mut() {
if let Err(err) = xwm.send_selection( if let Err(err) = xwm.send_selection(ty, mime_type, fd, self.loop_handle.clone()) {
SelectionType::Clipboard, tracing::warn!(?err, "Failed to send primary (X11 -> Wayland)");
mime_type,
fd,
self.loop_handle.clone(),
) {
tracing::warn!(?err, "Failed to send clipboard (X11 -> Wayland)");
} }
} }
} }
} }
impl DataDeviceHandler for State {
fn data_device_state(&self) -> &DataDeviceState {
&self.data_device_state
}
}
delegate_data_device!(State); delegate_data_device!(State);
impl PrimarySelectionHandler for State { impl PrimarySelectionHandler for State {
type SelectionUserData = ();
fn primary_selection_state(&self) -> &PrimarySelectionState { fn primary_selection_state(&self) -> &PrimarySelectionState {
&self.primary_selection_state &self.primary_selection_state
} }
fn new_selection(&mut self, source: Option<ZwpPrimarySelectionSourceV1>, _seat: Seat<Self>) {
if let Some(xwm) = self.xwm.as_mut() {
if let Some(source) = source {
if let Ok(Err(err)) = primary_selection::with_source_metadata(&source, |metadata| {
xwm.new_selection(SelectionType::Primary, Some(metadata.mime_types.clone()))
}) {
tracing::warn!(?err, "Failed to set Xwayland primary selection");
}
} else if let Err(err) = xwm.new_selection(SelectionType::Primary, None) {
tracing::warn!(?err, "Failed to clear Xwayland primary selection");
}
}
}
fn send_selection(
&mut self,
mime_type: String,
fd: std::os::fd::OwnedFd,
_seat: Seat<Self>,
_user_data: &Self::SelectionUserData,
) {
if let Some(xwm) = self.xwm.as_mut() {
if let Err(err) = xwm.send_selection(
SelectionType::Primary,
mime_type,
fd,
self.loop_handle.clone(),
) {
tracing::warn!(?err, "Failed to send primary (X11 -> Wayland)");
}
}
}
} }
delegate_primary_selection!(State); delegate_primary_selection!(State);

View file

@ -197,7 +197,7 @@ impl XdgShellHandler for State {
if let Some(popup) = self.popup_manager.find_popup(s) { if let Some(popup) = self.popup_manager.find_popup(s) {
// popup.geometry() doesn't return the right location, so we dive into the // popup.geometry() doesn't return the right location, so we dive into the
// PopupSurface's state to grab it. // PopupSurface's state to grab it.
let PopupKind::Xdg(popup_surf) = &popup; let PopupKind::Xdg(popup_surf) = &popup else { return }; // TODO:
let l = popup_surf.with_pending_state(|state| state.geometry.loc); let l = popup_surf.with_pending_state(|state| state.geometry.loc);
tracing::debug!(loc = ?l, "parent is popup"); tracing::debug!(loc = ?l, "parent is popup");
loc += l; loc += l;

View file

@ -3,17 +3,20 @@
use smithay::{ use smithay::{
utils::{Logical, Point, Rectangle, SERIAL_COUNTER}, utils::{Logical, Point, Rectangle, SERIAL_COUNTER},
wayland::{ wayland::{
data_device::{ selection::data_device::{
clear_data_device_selection, current_data_device_selection_userdata, clear_data_device_selection, current_data_device_selection_userdata,
request_data_device_client_selection, set_data_device_selection, request_data_device_client_selection, set_data_device_selection,
}, },
primary_selection::{ selection::{
clear_primary_selection, current_primary_selection_userdata, primary_selection::{
request_primary_client_selection, set_primary_selection, clear_primary_selection, current_primary_selection_userdata,
request_primary_client_selection, set_primary_selection,
},
SelectionTarget,
}, },
}, },
xwayland::{ xwayland::{
xwm::{Reorder, SelectionType, WmWindowType, XwmId}, xwm::{Reorder, WmWindowType, XwmId},
X11Surface, X11Wm, XwmHandler, X11Surface, X11Wm, XwmHandler,
}, },
}; };
@ -403,7 +406,7 @@ impl XwmHandler for CalloopData {
); );
} }
fn allow_selection_access(&mut self, xwm: XwmId, _selection: SelectionType) -> bool { fn allow_selection_access(&mut self, xwm: XwmId, _selection: SelectionTarget) -> bool {
self.state self.state
.seat .seat
.get_keyboard() .get_keyboard()
@ -420,12 +423,12 @@ impl XwmHandler for CalloopData {
fn send_selection( fn send_selection(
&mut self, &mut self,
_xwm: XwmId, _xwm: XwmId,
selection: SelectionType, selection: SelectionTarget,
mime_type: String, mime_type: String,
fd: std::os::fd::OwnedFd, fd: std::os::fd::OwnedFd,
) { ) {
match selection { match selection {
SelectionType::Clipboard => { SelectionTarget::Clipboard => {
if let Err(err) = if let Err(err) =
request_data_device_client_selection(&self.state.seat, mime_type, fd) request_data_device_client_selection(&self.state.seat, mime_type, fd)
{ {
@ -435,7 +438,7 @@ impl XwmHandler for CalloopData {
); );
} }
} }
SelectionType::Primary => { SelectionTarget::Primary => {
if let Err(err) = request_primary_client_selection(&self.state.seat, mime_type, fd) if let Err(err) = request_primary_client_selection(&self.state.seat, mime_type, fd)
{ {
tracing::error!( tracing::error!(
@ -447,9 +450,9 @@ impl XwmHandler for CalloopData {
} }
} }
fn new_selection(&mut self, _xwm: XwmId, selection: SelectionType, mime_types: Vec<String>) { fn new_selection(&mut self, _xwm: XwmId, selection: SelectionTarget, mime_types: Vec<String>) {
match selection { match selection {
SelectionType::Clipboard => { SelectionTarget::Clipboard => {
set_data_device_selection( set_data_device_selection(
&self.state.display_handle, &self.state.display_handle,
&self.state.seat, &self.state.seat,
@ -457,20 +460,20 @@ impl XwmHandler for CalloopData {
(), (),
); );
} }
SelectionType::Primary => { SelectionTarget::Primary => {
set_primary_selection(&self.state.display_handle, &self.state.seat, mime_types, ()); set_primary_selection(&self.state.display_handle, &self.state.seat, mime_types, ());
} }
} }
} }
fn cleared_selection(&mut self, _xwm: XwmId, selection: SelectionType) { fn cleared_selection(&mut self, _xwm: XwmId, selection: SelectionTarget) {
match selection { match selection {
SelectionType::Clipboard => { SelectionTarget::Clipboard => {
if current_data_device_selection_userdata(&self.state.seat).is_some() { if current_data_device_selection_userdata(&self.state.seat).is_some() {
clear_data_device_selection(&self.state.display_handle, &self.state.seat); clear_data_device_selection(&self.state.display_handle, &self.state.seat);
} }
} }
SelectionType::Primary => { SelectionTarget::Primary => {
if current_primary_selection_userdata(&self.state.seat).is_some() { if current_primary_selection_userdata(&self.state.seat).is_some() {
clear_primary_selection(&self.state.display_handle, &self.state.seat); clear_primary_selection(&self.state.display_handle, &self.state.seat);
} }

View file

@ -27,17 +27,18 @@ use smithay::{
utils::{Logical, Point, SERIAL_COUNTER}, utils::{Logical, Point, SERIAL_COUNTER},
wayland::{seat::WaylandFocus, shell::wlr_layer}, wayland::{seat::WaylandFocus, shell::wlr_layer},
}; };
use xkbcommon::xkb::Keysym;
use crate::state::State; use crate::state::State;
#[derive(Default, Debug)] #[derive(Default, Debug)]
pub struct InputState { pub struct InputState {
/// A hashmap of modifier keys and keycodes to callback IDs /// A hashmap of modifier keys and keycodes to callback IDs
pub keybinds: HashMap<(ModifierMask, u32), CallbackId>, pub keybinds: HashMap<(ModifierMask, Keysym), CallbackId>,
/// A hashmap of modifier keys and mouse button codes to callback IDs /// A hashmap of modifier keys and mouse button codes to callback IDs
pub mousebinds: HashMap<(ModifierMask, u32, MouseEdge), CallbackId>, pub mousebinds: HashMap<(ModifierMask, u32, MouseEdge), CallbackId>,
pub reload_keybind: Option<(ModifierMask, u32)>, pub reload_keybind: Option<(ModifierMask, Keysym)>,
pub kill_keybind: Option<(ModifierMask, u32)>, pub kill_keybind: Option<(ModifierMask, Keysym)>,
pub libinput_settings: Vec<LibinputSetting>, pub libinput_settings: Vec<LibinputSetting>,
pub libinput_devices: Vec<input::Device>, pub libinput_devices: Vec<input::Device>,
} }
@ -337,7 +338,7 @@ impl State {
} else if Some((modifier_mask, mod_sym)) == reload_keybind { } else if Some((modifier_mask, mod_sym)) == reload_keybind {
return FilterResult::Intercept(KeyAction::ReloadConfig); return FilterResult::Intercept(KeyAction::ReloadConfig);
} else if let mut vt @ keysyms::KEY_XF86Switch_VT_1 } else if let mut vt @ keysyms::KEY_XF86Switch_VT_1
..=keysyms::KEY_XF86Switch_VT_12 = keysym.modified_sym() ..=keysyms::KEY_XF86Switch_VT_12 = keysym.modified_sym().raw()
{ {
vt = vt - keysyms::KEY_XF86Switch_VT_1 + 1; vt = vt - keysyms::KEY_XF86Switch_VT_1 + 1;
tracing::info!("Switching to vt {vt}"); tracing::info!("Switching to vt {vt}");
@ -345,7 +346,7 @@ impl State {
} }
} }
if keysym.modified_sym() == keysyms::KEY_Control_L { if keysym.modified_sym() == Keysym::Control_L {
match press_state { match press_state {
KeyState::Pressed => { KeyState::Pressed => {
move_mode = true; move_mode = true;

View file

@ -12,7 +12,7 @@ use smithay::{
}, },
desktop::{ desktop::{
layer_map_for_output, layer_map_for_output,
space::{SpaceElement, SpaceRenderElements, SurfaceTree}, space::{SpaceElement, SpaceRenderElements},
utils::{ utils::{
surface_presentation_feedback_flags_from_states, surface_primary_scanout_output, surface_presentation_feedback_flags_from_states, surface_primary_scanout_output,
OutputPresentationFeedback, OutputPresentationFeedback,
@ -27,7 +27,7 @@ use smithay::{
}, },
render_elements, render_elements,
utils::{IsAlive, Logical, Physical, Point, Scale}, utils::{IsAlive, Logical, Physical, Point, Scale},
wayland::{compositor, input_method::InputMethodHandle, shell::wlr_layer}, wayland::{compositor, shell::wlr_layer},
xwayland::X11Surface, xwayland::X11Surface,
}; };
@ -181,7 +181,7 @@ pub fn generate_render_elements<R, T>(
pointer_location: Point<f64, Logical>, pointer_location: Point<f64, Logical>,
cursor_status: &mut CursorImageStatus, cursor_status: &mut CursorImageStatus,
dnd_icon: Option<&WlSurface>, dnd_icon: Option<&WlSurface>,
input_method: &InputMethodHandle, // input_method: &InputMethodHandle,
pointer_element: &mut PointerElement<T>, pointer_element: &mut PointerElement<T>,
pointer_image: Option<&TextureBuffer<T>>, pointer_image: Option<&TextureBuffer<T>>,
) -> Vec<OutputRenderElements<R, WaylandSurfaceRenderElement<R>>> ) -> Vec<OutputRenderElements<R, WaylandSurfaceRenderElement<R>>>
@ -196,21 +196,21 @@ where
let scale = Scale::from(output.current_scale().fractional_scale()); let scale = Scale::from(output.current_scale().fractional_scale());
let mut custom_render_elements: Vec<CustomRenderElements<_, _>> = Vec::new(); let mut custom_render_elements: Vec<CustomRenderElements<_, _>> = Vec::new();
// draw input method surface if any // // draw input method surface if any
let rectangle = input_method.coordinates(); // let rectangle = input_method.coordinates();
let position = Point::from(( // let position = Point::from((
rectangle.loc.x + rectangle.size.w, // rectangle.loc.x + rectangle.size.w,
rectangle.loc.y + rectangle.size.h, // rectangle.loc.y + rectangle.size.h,
)); // ));
input_method.with_surface(|surface| { // input_method.with_surface(|surface| {
custom_render_elements.extend(AsRenderElements::<R>::render_elements( // custom_render_elements.extend(AsRenderElements::<R>::render_elements(
&SurfaceTree::from_surface(surface), // &SurfaceTree::from_surface(surface),
renderer, // renderer,
position.to_physical_precise_round(scale), // position.to_physical_precise_round(scale),
scale, // scale,
1.0, // 1.0,
)); // ));
}); // });
if output_geometry.to_f64().contains(pointer_location) { if output_geometry.to_f64().contains(pointer_location) {
let cursor_hotspot = if let CursorImageStatus::Surface(ref surface) = cursor_status { let cursor_hotspot = if let CursorImageStatus::Surface(ref surface) = cursor_status {
@ -238,7 +238,7 @@ where
// reset the cursor if the surface is no longer alive // reset the cursor if the surface is no longer alive
if let CursorImageStatus::Surface(surface) = &*cursor_status { if let CursorImageStatus::Surface(surface) = &*cursor_status {
if !surface.alive() { if !surface.alive() {
*cursor_status = CursorImageStatus::Default; *cursor_status = CursorImageStatus::default_named();
} }
} }

View file

@ -3,13 +3,14 @@
use smithay::{ use smithay::{
backend::renderer::{ backend::renderer::{
element::{ element::{
self,
surface::{self, WaylandSurfaceRenderElement}, surface::{self, WaylandSurfaceRenderElement},
texture::{TextureBuffer, TextureRenderElement}, texture::{TextureBuffer, TextureRenderElement},
AsRenderElements, AsRenderElements,
}, },
ImportAll, Renderer, Texture, ImportAll, Renderer, Texture,
}, },
input::pointer::CursorImageStatus, input::pointer::{CursorIcon, CursorImageStatus},
render_elements, render_elements,
utils::{Physical, Point, Scale}, utils::{Physical, Point, Scale},
}; };
@ -23,7 +24,7 @@ impl<T: Texture> Default for PointerElement<T> {
fn default() -> Self { fn default() -> Self {
Self { Self {
texture: Default::default(), texture: Default::default(),
status: CursorImageStatus::Default, status: CursorImageStatus::default_named(),
} }
} }
} }
@ -64,7 +65,7 @@ where
) -> Vec<C> { ) -> Vec<C> {
match &self.status { match &self.status {
CursorImageStatus::Hidden => vec![], CursorImageStatus::Hidden => vec![],
CursorImageStatus::Default => { CursorImageStatus::Named(CursorIcon::Default) => {
if let Some(texture) = self.texture.as_ref() { if let Some(texture) = self.texture.as_ref() {
vec![PointerRenderElement::<R>::from( vec![PointerRenderElement::<R>::from(
TextureRenderElement::from_texture_buffer( TextureRenderElement::from_texture_buffer(
@ -73,6 +74,7 @@ where
None, None,
None, None,
None, None,
element::Kind::Cursor,
), ),
) )
.into()] .into()]
@ -80,10 +82,16 @@ where
vec![] vec![]
} }
} }
CursorImageStatus::Named(_) => vec![],
CursorImageStatus::Surface(surface) => { CursorImageStatus::Surface(surface) => {
let elements: Vec<PointerRenderElement<R>> = let elements: Vec<PointerRenderElement<R>> =
surface::render_elements_from_surface_tree( surface::render_elements_from_surface_tree(
renderer, surface, location, scale, alpha, renderer,
surface,
location,
scale,
alpha,
element::Kind::Cursor,
); );
elements.into_iter().map(C::from).collect() elements.into_iter().map(C::from).collect()
} }

View file

@ -2,7 +2,7 @@
mod api_handlers; mod api_handlers;
use std::{cell::RefCell, os::fd::AsRawFd, sync::Arc, time::Duration}; use std::{cell::RefCell, sync::Arc, time::Duration};
use crate::{ use crate::{
backend::Backend, backend::Backend,
@ -33,11 +33,11 @@ use smithay::{
utils::{Clock, Logical, Monotonic, Point, Size}, utils::{Clock, Logical, Monotonic, Point, Size},
wayland::{ wayland::{
compositor::{self, CompositorClientState, CompositorState}, compositor::{self, CompositorClientState, CompositorState},
data_device::DataDeviceState,
dmabuf::DmabufFeedback, dmabuf::DmabufFeedback,
fractional_scale::FractionalScaleManagerState, fractional_scale::FractionalScaleManagerState,
output::OutputManagerState, output::OutputManagerState,
primary_selection::PrimarySelectionState, selection::data_device::DataDeviceState,
selection::primary_selection::PrimarySelectionState,
shell::{wlr_layer::WlrLayerShellState, xdg::XdgShellState}, shell::{wlr_layer::WlrLayerShellState, xdg::XdgShellState},
shm::ShmState, shm::ShmState,
socket::ListeningSocketSource, socket::ListeningSocketSource,
@ -103,7 +103,7 @@ impl State {
/// Creates the central state and starts the config and xwayland /// Creates the central state and starts the config and xwayland
pub fn init( pub fn init(
backend: Backend, backend: Backend,
display: &mut Display<Self>, display: Display<Self>,
loop_signal: LoopSignal, loop_signal: LoopSignal,
loop_handle: LoopHandle<'static, CalloopData>, loop_handle: LoopHandle<'static, CalloopData>,
) -> anyhow::Result<Self> { ) -> anyhow::Result<Self> {
@ -134,20 +134,23 @@ impl State {
} }
loop_handle.insert_source(socket, |stream, _metadata, data| { loop_handle.insert_source(socket, |stream, _metadata, data| {
data.display data.display_handle
.handle()
.insert_client(stream, Arc::new(ClientState::default())) .insert_client(stream, Arc::new(ClientState::default()))
.expect("Could not insert client into loop handle"); .expect("Could not insert client into loop handle");
})?; })?;
let display_handle = display.handle();
loop_handle.insert_source( loop_handle.insert_source(
Generic::new( Generic::new(display, Interest::READ, Mode::Level),
display.backend().poll_fd().as_raw_fd(), |_readiness, display, data| {
Interest::READ, // Safety: we don't drop the display
Mode::Level, unsafe {
), display
|_readiness, _metadata, data| { .get_mut()
data.display.dispatch_clients(&mut data.state)?; .dispatch_clients(&mut data.state)
.expect("failed to dispatch clients");
}
Ok(PostAction::Continue) Ok(PostAction::Continue)
}, },
)?; )?;
@ -166,7 +169,6 @@ impl State {
anyhow::bail!("Failed to insert async executor into event loop: {err}"); anyhow::bail!("Failed to insert async executor into event loop: {err}");
} }
let display_handle = display.handle();
let mut seat_state = SeatState::new(); let mut seat_state = SeatState::new();
let mut seat = seat_state.new_wl_seat(&display_handle, backend.seat_name()); let mut seat = seat_state.new_wl_seat(&display_handle, backend.seat_name());
@ -241,7 +243,7 @@ impl State {
pointer_location: (0.0, 0.0).into(), pointer_location: (0.0, 0.0).into(),
shm_state: ShmState::new::<Self>(&display_handle, vec![]), shm_state: ShmState::new::<Self>(&display_handle, vec![]),
space: Space::<WindowElement>::default(), space: Space::<WindowElement>::default(),
cursor_status: CursorImageStatus::Default, cursor_status: CursorImageStatus::default_named(),
output_manager_state: OutputManagerState::new_with_xdg_output::<Self>(&display_handle), output_manager_state: OutputManagerState::new_with_xdg_output::<Self>(&display_handle),
xdg_shell_state: XdgShellState::new::<Self>(&display_handle), xdg_shell_state: XdgShellState::new::<Self>(&display_handle),
viewporter_state: ViewporterState::new::<Self>(&display_handle), viewporter_state: ViewporterState::new::<Self>(&display_handle),
@ -313,7 +315,7 @@ impl State {
} }
pub struct CalloopData { pub struct CalloopData {
pub display: Display<State>, pub display_handle: DisplayHandle,
pub state: State, pub state: State,
} }

View file

@ -58,7 +58,7 @@ impl State {
self.input_state self.input_state
.keybinds .keybinds
.insert((modifiers.into(), key), callback_id); .insert((modifiers.into(), key.into()), callback_id);
} }
Msg::SetMousebind { Msg::SetMousebind {
modifiers, modifiers,

View file

@ -290,6 +290,13 @@ impl IsAlive for WindowElement {
} }
impl PointerTarget<State> for WindowElement { impl PointerTarget<State> for WindowElement {
fn frame(&self, seat: &Seat<State>, data: &mut State) {
match self {
WindowElement::Wayland(window) => window.frame(seat, data),
WindowElement::X11(surface) => surface.frame(seat, data),
}
}
fn enter(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) { fn enter(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) {
// TODO: ssd // TODO: ssd
match self { match self {