ltk/platform/wayland/
window.rsuse smithay_client_toolkit::reexports::protocols::xdg::shell::client::xdg_toplevel;
use smithay_client_toolkit::shell::xdg::window::Window;
use crate::app::App;
use crate::event_loop::SurfaceFocus;
use crate::event_loop::cursor_shape::ResizeEdge;
use super::{ SurfaceKind, WaylandPlatform, WaylandSurfaceState };
pub( super ) fn window( surface: &WaylandSurfaceState ) -> Option<&Window>
{
match surface.surface
{
SurfaceKind::Window( ref window ) => Some( window ),
_ => None,
}
}
pub( super ) fn begin_move<A: App>( platform: &WaylandPlatform<A>, main: &WaylandSurfaceState )
{
let Some( window ) = window( main ) else { return };
let Some( seat ) = platform.seat_state.seats().next() else { return };
window.move_( &seat, platform.last_pointer_serial );
}
pub( super ) fn begin_resize<A: App>( platform: &WaylandPlatform<A>, main: &WaylandSurfaceState, edge: ResizeEdge )
{
let Some( window ) = window( main ) else { return };
let Some( seat ) = platform.seat_state.seats().next() else { return };
window.resize( &seat, platform.last_pointer_serial, xdg_edge( edge ) );
}
pub( super ) fn set_fullscreen( main: &WaylandSurfaceState, fullscreen: bool ) -> bool
{
let Some( window ) = window( main ) else { return false };
if fullscreen
{
window.set_fullscreen( None );
} else {
window.unset_fullscreen();
}
true
}
pub( super ) fn request_frame<A: App>( platform: &WaylandPlatform<A>, surface: &WaylandSurfaceState, focus: SurfaceFocus ) -> bool
{
let Some( wl ) = surface.surface.try_wl_surface() else { return false };
let _ = wl.frame( &platform.qh, focus );
wl.commit();
true
}
fn xdg_edge( edge: ResizeEdge ) -> xdg_toplevel::ResizeEdge
{
match edge
{
ResizeEdge::Top => xdg_toplevel::ResizeEdge::Top,
ResizeEdge::Bottom => xdg_toplevel::ResizeEdge::Bottom,
ResizeEdge::Left => xdg_toplevel::ResizeEdge::Left,
ResizeEdge::Right => xdg_toplevel::ResizeEdge::Right,
ResizeEdge::TopLeft => xdg_toplevel::ResizeEdge::TopLeft,
ResizeEdge::TopRight => xdg_toplevel::ResizeEdge::TopRight,
ResizeEdge::BottomLeft => xdg_toplevel::ResizeEdge::BottomLeft,
ResizeEdge::BottomRight => xdg_toplevel::ResizeEdge::BottomRight,
}
}