mirror of
https://github.com/marcoallegretti/WEFT_OS.git
synced 2026-03-27 01:13:09 +00:00
style(compositor): apply rustfmt formatting
This commit is contained in:
parent
e981044c43
commit
fcd4a3bacd
4 changed files with 52 additions and 72 deletions
|
|
@ -13,17 +13,16 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::{
|
backend::{
|
||||||
session::{libseat::LibSeatSession, Session},
|
session::{Session, libseat::LibSeatSession},
|
||||||
udev::{UdevBackend, UdevEvent},
|
udev::{UdevBackend, UdevEvent},
|
||||||
},
|
},
|
||||||
reexports::calloop::{generic::Generic, EventLoop, Interest, Mode, PostAction},
|
reexports::calloop::{EventLoop, Interest, Mode, PostAction, generic::Generic},
|
||||||
wayland::socket::ListeningSocketSource,
|
wayland::socket::ListeningSocketSource,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::state::{WeftClientState, WeftCompositorState};
|
use crate::state::{WeftClientState, WeftCompositorState};
|
||||||
|
|
||||||
let mut display =
|
let mut display = smithay::reexports::wayland_server::Display::<WeftCompositorState>::new()?;
|
||||||
smithay::reexports::wayland_server::Display::<WeftCompositorState>::new()?;
|
|
||||||
let display_handle = display.handle();
|
let display_handle = display.handle();
|
||||||
|
|
||||||
let mut event_loop: EventLoop<'static, WeftCompositorState> = EventLoop::try_new()?;
|
let mut event_loop: EventLoop<'static, WeftCompositorState> = EventLoop::try_new()?;
|
||||||
|
|
@ -31,8 +30,8 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
let loop_signal = event_loop.get_signal();
|
let loop_signal = event_loop.get_signal();
|
||||||
|
|
||||||
// Gain DRM device access without root via libseat.
|
// Gain DRM device access without root via libseat.
|
||||||
let (session, _notifier) = LibSeatSession::new()
|
let (session, _notifier) =
|
||||||
.map_err(|e| anyhow::anyhow!("libseat session failed: {e}"))?;
|
LibSeatSession::new().map_err(|e| anyhow::anyhow!("libseat session failed: {e}"))?;
|
||||||
|
|
||||||
let listening_socket = ListeningSocketSource::new_auto()
|
let listening_socket = ListeningSocketSource::new_auto()
|
||||||
.map_err(|e| anyhow::anyhow!("Wayland socket creation failed: {e}"))?;
|
.map_err(|e| anyhow::anyhow!("Wayland socket creation failed: {e}"))?;
|
||||||
|
|
@ -79,12 +78,8 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
})
|
})
|
||||||
.map_err(|e| anyhow::anyhow!("udev source insertion failed: {e}"))?;
|
.map_err(|e| anyhow::anyhow!("udev source insertion failed: {e}"))?;
|
||||||
|
|
||||||
let mut state = WeftCompositorState::new(
|
let mut state =
|
||||||
display_handle,
|
WeftCompositorState::new(display_handle, loop_signal, loop_handle, session.seat());
|
||||||
loop_signal,
|
|
||||||
loop_handle,
|
|
||||||
session.seat(),
|
|
||||||
);
|
|
||||||
|
|
||||||
tracing::info!("DRM/KMS backend initialised; entering event loop");
|
tracing::info!("DRM/KMS backend initialised; entering event loop");
|
||||||
event_loop.run(None, &mut state, |_| {})?;
|
event_loop.run(None, &mut state, |_| {})?;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use smithay::{
|
||||||
winit::{self, WinitEvent},
|
winit::{self, WinitEvent},
|
||||||
},
|
},
|
||||||
output::{Mode as OutputMode, Output, PhysicalProperties, Subpixel},
|
output::{Mode as OutputMode, Output, PhysicalProperties, Subpixel},
|
||||||
reexports::calloop::{generic::Generic, EventLoop, Interest, Mode, PostAction},
|
reexports::calloop::{EventLoop, Interest, Mode, PostAction, generic::Generic},
|
||||||
utils::{Rectangle, Transform},
|
utils::{Rectangle, Transform},
|
||||||
wayland::socket::ListeningSocketSource,
|
wayland::socket::ListeningSocketSource,
|
||||||
};
|
};
|
||||||
|
|
@ -20,16 +20,15 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn run() -> anyhow::Result<()> {
|
pub fn run() -> anyhow::Result<()> {
|
||||||
let mut display =
|
let mut display = smithay::reexports::wayland_server::Display::<WeftCompositorState>::new()?;
|
||||||
smithay::reexports::wayland_server::Display::<WeftCompositorState>::new()?;
|
|
||||||
let display_handle = display.handle();
|
let display_handle = display.handle();
|
||||||
|
|
||||||
let mut event_loop: EventLoop<'static, WeftCompositorState> = EventLoop::try_new()?;
|
let mut event_loop: EventLoop<'static, WeftCompositorState> = EventLoop::try_new()?;
|
||||||
let loop_handle = event_loop.handle();
|
let loop_handle = event_loop.handle();
|
||||||
let loop_signal = event_loop.get_signal();
|
let loop_signal = event_loop.get_signal();
|
||||||
|
|
||||||
let (mut backend, winit) = winit::init()
|
let (mut backend, winit) =
|
||||||
.map_err(|e| anyhow::anyhow!("winit init failed: {e}"))?;
|
winit::init().map_err(|e| anyhow::anyhow!("winit init failed: {e}"))?;
|
||||||
|
|
||||||
let mode = OutputMode {
|
let mode = OutputMode {
|
||||||
size: backend.window_size(),
|
size: backend.window_size(),
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,26 @@
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::input::{
|
backend::input::{
|
||||||
AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, GestureHoldBeginEvent,
|
AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, GestureHoldBeginEvent,
|
||||||
GestureHoldEndEvent, GesturePinchBeginEvent, GesturePinchEndEvent,
|
GestureHoldEndEvent, GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||||
GesturePinchUpdateEvent, GestureSwipeBeginEvent, GestureSwipeEndEvent,
|
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, InputBackend,
|
||||||
GestureSwipeUpdateEvent, InputBackend, InputEvent, KeyState, KeyboardKeyEvent,
|
InputEvent, KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent,
|
||||||
PointerAxisEvent, PointerButtonEvent, PointerMotionAbsoluteEvent, PointerMotionEvent,
|
PointerMotionAbsoluteEvent, PointerMotionEvent, TouchCancelEvent, TouchDownEvent,
|
||||||
TouchCancelEvent, TouchDownEvent, TouchFrameEvent, TouchMotionEvent, TouchUpEvent,
|
TouchFrameEvent, TouchMotionEvent, TouchUpEvent,
|
||||||
},
|
},
|
||||||
input::{
|
input::{
|
||||||
keyboard::FilterResult,
|
keyboard::FilterResult,
|
||||||
pointer::{AxisFrame, ButtonEvent, MotionEvent},
|
pointer::{AxisFrame, ButtonEvent, MotionEvent},
|
||||||
},
|
},
|
||||||
utils::{Logical, Point, Serial, SERIAL_COUNTER},
|
utils::{Logical, Point, SERIAL_COUNTER, Serial},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::state::WeftCompositorState;
|
use crate::state::WeftCompositorState;
|
||||||
|
|
||||||
pub fn process_input_event<B: InputBackend>(
|
pub fn process_input_event<B: InputBackend>(state: &mut WeftCompositorState, event: InputEvent<B>) {
|
||||||
state: &mut WeftCompositorState,
|
|
||||||
event: InputEvent<B>,
|
|
||||||
) {
|
|
||||||
match event {
|
match event {
|
||||||
InputEvent::Keyboard { event } => handle_keyboard(state, event),
|
InputEvent::Keyboard { event } => handle_keyboard(state, event),
|
||||||
InputEvent::PointerMotion { event } => handle_pointer_motion(state, event),
|
InputEvent::PointerMotion { event } => handle_pointer_motion(state, event),
|
||||||
InputEvent::PointerMotionAbsolute { event } => {
|
InputEvent::PointerMotionAbsolute { event } => handle_pointer_motion_absolute(state, event),
|
||||||
handle_pointer_motion_absolute(state, event)
|
|
||||||
}
|
|
||||||
InputEvent::PointerButton { event } => handle_pointer_button(state, event),
|
InputEvent::PointerButton { event } => handle_pointer_button(state, event),
|
||||||
InputEvent::PointerAxis { event } => handle_pointer_axis(state, event),
|
InputEvent::PointerAxis { event } => handle_pointer_axis(state, event),
|
||||||
InputEvent::TouchDown { event } => handle_touch_down(state, event),
|
InputEvent::TouchDown { event } => handle_touch_down(state, event),
|
||||||
|
|
@ -47,10 +42,7 @@ pub fn process_input_event<B: InputBackend>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_keyboard<B: InputBackend>(
|
fn handle_keyboard<B: InputBackend>(state: &mut WeftCompositorState, event: B::KeyboardKeyEvent) {
|
||||||
state: &mut WeftCompositorState,
|
|
||||||
event: B::KeyboardKeyEvent,
|
|
||||||
) {
|
|
||||||
let serial = SERIAL_COUNTER.next_serial();
|
let serial = SERIAL_COUNTER.next_serial();
|
||||||
let time = event.time_msec();
|
let time = event.time_msec();
|
||||||
let key_state = event.state();
|
let key_state = event.state();
|
||||||
|
|
@ -99,10 +91,7 @@ fn handle_pointer_motion_absolute<B: InputBackend>(
|
||||||
) {
|
) {
|
||||||
let output = state.space.outputs().next().cloned();
|
let output = state.space.outputs().next().cloned();
|
||||||
if let Some(output) = output {
|
if let Some(output) = output {
|
||||||
let output_geo = state
|
let output_geo = state.space.output_geometry(&output).unwrap_or_default();
|
||||||
.space
|
|
||||||
.output_geometry(&output)
|
|
||||||
.unwrap_or_default();
|
|
||||||
let pos = event.position_transformed(output_geo.size);
|
let pos = event.position_transformed(output_geo.size);
|
||||||
state.pointer_location = output_geo.loc.to_f64() + pos;
|
state.pointer_location = output_geo.loc.to_f64() + pos;
|
||||||
}
|
}
|
||||||
|
|
@ -203,10 +192,7 @@ fn handle_pointer_axis<B: InputBackend>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_touch_down<B: InputBackend>(
|
fn handle_touch_down<B: InputBackend>(state: &mut WeftCompositorState, event: B::TouchDownEvent) {
|
||||||
state: &mut WeftCompositorState,
|
|
||||||
event: B::TouchDownEvent,
|
|
||||||
) {
|
|
||||||
let serial = SERIAL_COUNTER.next_serial();
|
let serial = SERIAL_COUNTER.next_serial();
|
||||||
let output = state.space.outputs().next().cloned();
|
let output = state.space.outputs().next().cloned();
|
||||||
if let Some(output) = output {
|
if let Some(output) = output {
|
||||||
|
|
@ -230,10 +216,7 @@ fn handle_touch_down<B: InputBackend>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_touch_up<B: InputBackend>(
|
fn handle_touch_up<B: InputBackend>(state: &mut WeftCompositorState, event: B::TouchUpEvent) {
|
||||||
state: &mut WeftCompositorState,
|
|
||||||
event: B::TouchUpEvent,
|
|
||||||
) {
|
|
||||||
let serial = SERIAL_COUNTER.next_serial();
|
let serial = SERIAL_COUNTER.next_serial();
|
||||||
if let Some(touch) = state.seat.get_touch() {
|
if let Some(touch) = state.seat.get_touch() {
|
||||||
touch.up(
|
touch.up(
|
||||||
|
|
@ -428,15 +411,18 @@ fn handle_gesture_hold_end<B: InputBackend>(
|
||||||
pub fn surface_under(
|
pub fn surface_under(
|
||||||
state: &WeftCompositorState,
|
state: &WeftCompositorState,
|
||||||
point: Point<f64, Logical>,
|
point: Point<f64, Logical>,
|
||||||
) -> Option<(smithay::reexports::wayland_server::protocol::wl_surface::WlSurface, Point<f64, Logical>)> {
|
) -> Option<(
|
||||||
state
|
smithay::reexports::wayland_server::protocol::wl_surface::WlSurface,
|
||||||
.space
|
Point<f64, Logical>,
|
||||||
.element_under(point)
|
)> {
|
||||||
.and_then(|(window, loc)| {
|
state.space.element_under(point).and_then(|(window, loc)| {
|
||||||
window
|
window
|
||||||
.surface_under(point - loc.to_f64(), smithay::desktop::WindowSurfaceType::ALL)
|
.surface_under(
|
||||||
.map(|(surface, surface_loc)| (surface, (loc.to_f64() + surface_loc.to_f64())))
|
point - loc.to_f64(),
|
||||||
})
|
smithay::desktop::WindowSurfaceType::ALL,
|
||||||
|
)
|
||||||
|
.map(|(surface, surface_loc)| (surface, (loc.to_f64() + surface_loc.to_f64())))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clamp_pointer_to_output_space(state: &mut WeftCompositorState) {
|
fn clamp_pointer_to_output_space(state: &mut WeftCompositorState) {
|
||||||
|
|
|
||||||
|
|
@ -2,33 +2,27 @@ use smithay::{
|
||||||
backend::{input::TabletToolDescriptor, renderer::utils::on_commit_buffer_handler},
|
backend::{input::TabletToolDescriptor, renderer::utils::on_commit_buffer_handler},
|
||||||
delegate_compositor, delegate_cursor_shape, delegate_dmabuf, delegate_input_method_manager,
|
delegate_compositor, delegate_cursor_shape, delegate_dmabuf, delegate_input_method_manager,
|
||||||
delegate_layer_shell, delegate_output, delegate_pointer_constraints, delegate_presentation,
|
delegate_layer_shell, delegate_output, delegate_pointer_constraints, delegate_presentation,
|
||||||
delegate_seat, delegate_shm, delegate_text_input_manager,
|
delegate_seat, delegate_shm, delegate_text_input_manager, delegate_xdg_shell,
|
||||||
delegate_xdg_shell,
|
desktop::{PopupKind, PopupManager, Space, Window, WindowSurfaceType, layer_map_for_output},
|
||||||
desktop::{
|
input::{Seat, SeatHandler, SeatState, keyboard::XkbConfig, pointer::CursorImageStatus},
|
||||||
layer_map_for_output, PopupKind, PopupManager, Space, Window, WindowSurfaceType,
|
|
||||||
},
|
|
||||||
input::{
|
|
||||||
keyboard::XkbConfig,
|
|
||||||
pointer::CursorImageStatus,
|
|
||||||
Seat, SeatHandler, SeatState,
|
|
||||||
},
|
|
||||||
output::Output,
|
output::Output,
|
||||||
reexports::{
|
reexports::{
|
||||||
calloop::{LoopHandle, LoopSignal},
|
calloop::{LoopHandle, LoopSignal},
|
||||||
wayland_server::{
|
wayland_server::{
|
||||||
|
Client, DisplayHandle,
|
||||||
backend::{ClientData, ClientId, DisconnectReason},
|
backend::{ClientData, ClientId, DisconnectReason},
|
||||||
protocol::{wl_buffer::WlBuffer, wl_output::WlOutput, wl_surface::WlSurface},
|
protocol::{wl_buffer::WlBuffer, wl_output::WlOutput, wl_surface::WlSurface},
|
||||||
Client, DisplayHandle,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
utils::{Logical, Point, Rectangle},
|
utils::{Logical, Point, Rectangle},
|
||||||
wayland::{
|
wayland::{
|
||||||
compositor::{CompositorClientState, CompositorHandler, CompositorState},
|
|
||||||
buffer::BufferHandler,
|
buffer::BufferHandler,
|
||||||
|
compositor::{CompositorClientState, CompositorHandler, CompositorState},
|
||||||
cursor_shape::CursorShapeManagerState,
|
cursor_shape::CursorShapeManagerState,
|
||||||
dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportNotifier},
|
dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportNotifier},
|
||||||
input_method::{InputMethodHandler, InputMethodManagerState, PopupSurface as ImPopupSurface},
|
input_method::{
|
||||||
tablet_manager::TabletSeatHandler,
|
InputMethodHandler, InputMethodManagerState, PopupSurface as ImPopupSurface,
|
||||||
|
},
|
||||||
output::OutputManagerState,
|
output::OutputManagerState,
|
||||||
pointer_constraints::{PointerConstraintsHandler, PointerConstraintsState},
|
pointer_constraints::{PointerConstraintsHandler, PointerConstraintsState},
|
||||||
presentation::{PresentationHandler, PresentationState},
|
presentation::{PresentationHandler, PresentationState},
|
||||||
|
|
@ -38,6 +32,7 @@ use smithay::{
|
||||||
xdg::{PopupSurface, PositionerState, ToplevelSurface, XdgShellHandler, XdgShellState},
|
xdg::{PopupSurface, PositionerState, ToplevelSurface, XdgShellHandler, XdgShellState},
|
||||||
},
|
},
|
||||||
shm::{ShmHandler, ShmState},
|
shm::{ShmHandler, ShmState},
|
||||||
|
tablet_manager::TabletSeatHandler,
|
||||||
text_input::TextInputManagerState,
|
text_input::TextInputManagerState,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -100,8 +95,7 @@ impl WeftCompositorState {
|
||||||
let layer_shell_state = WlrLayerShellState::new::<Self>(&display_handle);
|
let layer_shell_state = WlrLayerShellState::new::<Self>(&display_handle);
|
||||||
let shm_state = ShmState::new::<Self>(&display_handle, vec![]);
|
let shm_state = ShmState::new::<Self>(&display_handle, vec![]);
|
||||||
let dmabuf_state = DmabufState::new();
|
let dmabuf_state = DmabufState::new();
|
||||||
let output_manager_state =
|
let output_manager_state = OutputManagerState::new_with_xdg_output::<Self>(&display_handle);
|
||||||
OutputManagerState::new_with_xdg_output::<Self>(&display_handle);
|
|
||||||
// Clock ID 1 = CLOCK_MONOTONIC
|
// Clock ID 1 = CLOCK_MONOTONIC
|
||||||
let presentation_state = PresentationState::new::<Self>(&display_handle, 1);
|
let presentation_state = PresentationState::new::<Self>(&display_handle, 1);
|
||||||
let text_input_state = TextInputManagerState::new::<Self>(&display_handle);
|
let text_input_state = TextInputManagerState::new::<Self>(&display_handle);
|
||||||
|
|
@ -223,7 +217,13 @@ impl XdgShellHandler for WeftCompositorState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn grab(&mut self, _surface: PopupSurface, _seat: smithay::reexports::wayland_server::protocol::wl_seat::WlSeat, _serial: smithay::utils::Serial) {}
|
fn grab(
|
||||||
|
&mut self,
|
||||||
|
_surface: PopupSurface,
|
||||||
|
_seat: smithay::reexports::wayland_server::protocol::wl_seat::WlSeat,
|
||||||
|
_serial: smithay::utils::Serial,
|
||||||
|
) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate_xdg_shell!(WeftCompositorState);
|
delegate_xdg_shell!(WeftCompositorState);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue