Merge pull request #71 from Smithay/feature/evlh_wayland
Don't required EventLoop for wayland object creation
This commit is contained in:
commit
3f99cdc76f
|
@ -93,7 +93,7 @@ use self::roles::{Role, RoleType, WrongRole};
|
||||||
use self::tree::SurfaceData;
|
use self::tree::SurfaceData;
|
||||||
pub use self::tree::TraversalAction;
|
pub use self::tree::TraversalAction;
|
||||||
use utils::Rectangle;
|
use utils::Rectangle;
|
||||||
use wayland_server::{resource_is_registered, EventLoop, EventLoopHandle, Global};
|
use wayland_server::{resource_is_registered, EventLoopHandle, Global};
|
||||||
use wayland_server::protocol::{wl_buffer, wl_callback, wl_compositor, wl_output, wl_region,
|
use wayland_server::protocol::{wl_buffer, wl_callback, wl_compositor, wl_output, wl_region,
|
||||||
wl_subcompositor, wl_surface};
|
wl_subcompositor, wl_surface};
|
||||||
|
|
||||||
|
@ -529,7 +529,7 @@ impl<U: 'static, R: RoleType + 'static, ID: 'static> CompositorToken<U, R, ID> {
|
||||||
/// It also returns the two global handles, in case you whish to remove these
|
/// It also returns the two global handles, in case you whish to remove these
|
||||||
/// globals from the event loop in the future.
|
/// globals from the event loop in the future.
|
||||||
pub fn compositor_init<U, R, ID, L>(
|
pub fn compositor_init<U, R, ID, L>(
|
||||||
evl: &mut EventLoop, implem: SurfaceUserImplementation<U, R, ID>, idata: ID, logger: L
|
evlh: &mut EventLoopHandle, implem: SurfaceUserImplementation<U, R, ID>, idata: ID, logger: L
|
||||||
) -> (
|
) -> (
|
||||||
CompositorToken<U, R, ID>,
|
CompositorToken<U, R, ID>,
|
||||||
Global<wl_compositor::WlCompositor, self::handlers::SurfaceIData<U, R, ID>>,
|
Global<wl_compositor::WlCompositor, self::handlers::SurfaceIData<U, R, ID>>,
|
||||||
|
@ -548,8 +548,8 @@ where
|
||||||
idata,
|
idata,
|
||||||
);
|
);
|
||||||
let compositor_global_token =
|
let compositor_global_token =
|
||||||
evl.register_global::<wl_compositor::WlCompositor, _>(4, self::handlers::compositor_bind, idata);
|
evlh.register_global::<wl_compositor::WlCompositor, _>(4, self::handlers::compositor_bind, idata);
|
||||||
let subcompositor_global_token = evl.register_global::<wl_subcompositor::WlSubcompositor, _>(
|
let subcompositor_global_token = evlh.register_global::<wl_subcompositor::WlSubcompositor, _>(
|
||||||
1,
|
1,
|
||||||
self::handlers::subcompositor_bind::<U, R>,
|
self::handlers::subcompositor_bind::<U, R>,
|
||||||
(),
|
(),
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use wayland_server::{Client, EventLoop, EventLoopHandle, Global, Liveness, Resource, StateToken};
|
use wayland_server::{Client, EventLoopHandle, Global, Liveness, Resource, StateToken};
|
||||||
use wayland_server::protocol::wl_output;
|
use wayland_server::protocol::wl_output;
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
|
@ -113,7 +113,7 @@ impl Output {
|
||||||
/// returns the state token allowing you to access it, as well as the global handle,
|
/// returns the state token allowing you to access it, as well as the global handle,
|
||||||
/// in case you whish to remove this global in the future.
|
/// in case you whish to remove this global in the future.
|
||||||
pub fn new<L>(
|
pub fn new<L>(
|
||||||
evl: &mut EventLoop, name: String, physical: PhysicalProperties, logger: L
|
evlh: &mut EventLoopHandle, name: String, physical: PhysicalProperties, logger: L
|
||||||
) -> (
|
) -> (
|
||||||
StateToken<Output>,
|
StateToken<Output>,
|
||||||
Global<wl_output::WlOutput, StateToken<Output>>,
|
Global<wl_output::WlOutput, StateToken<Output>>,
|
||||||
|
@ -125,7 +125,7 @@ impl Output {
|
||||||
|
|
||||||
info!(log, "Creating new wl_output"; "name" => &name);
|
info!(log, "Creating new wl_output"; "name" => &name);
|
||||||
|
|
||||||
let token = evl.state().insert(Output {
|
let token = evlh.state().insert(Output {
|
||||||
name: name,
|
name: name,
|
||||||
log: log,
|
log: log,
|
||||||
instances: Vec::new(),
|
instances: Vec::new(),
|
||||||
|
@ -138,7 +138,7 @@ impl Output {
|
||||||
preferred_mode: None,
|
preferred_mode: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
let global = evl.register_global(3, output_bind, token.clone());
|
let global = evlh.register_global(3, output_bind, token.clone());
|
||||||
|
|
||||||
(token, global)
|
(token, global)
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ mod pointer;
|
||||||
|
|
||||||
pub use self::keyboard::{Error as KeyboardError, KeyboardHandle};
|
pub use self::keyboard::{Error as KeyboardError, KeyboardHandle};
|
||||||
pub use self::pointer::PointerHandle;
|
pub use self::pointer::PointerHandle;
|
||||||
use wayland_server::{Client, EventLoop, EventLoopHandle, Global, Liveness, Resource, StateToken};
|
use wayland_server::{Client, EventLoopHandle, Global, Liveness, Resource, StateToken};
|
||||||
use wayland_server::protocol::{wl_keyboard, wl_pointer, wl_seat};
|
use wayland_server::protocol::{wl_keyboard, wl_pointer, wl_seat};
|
||||||
|
|
||||||
/// Internal data of a seat global
|
/// Internal data of a seat global
|
||||||
|
@ -88,7 +88,7 @@ impl Seat {
|
||||||
/// you to add or remove capabilities from it), and the global handle,
|
/// you to add or remove capabilities from it), and the global handle,
|
||||||
/// in case you want to remove it.
|
/// in case you want to remove it.
|
||||||
pub fn new<L>(
|
pub fn new<L>(
|
||||||
evl: &mut EventLoop, name: String, logger: L
|
evlh: &mut EventLoopHandle, name: String, logger: L
|
||||||
) -> (StateToken<Seat>, Global<wl_seat::WlSeat, StateToken<Seat>>)
|
) -> (StateToken<Seat>, Global<wl_seat::WlSeat, StateToken<Seat>>)
|
||||||
where
|
where
|
||||||
L: Into<Option<::slog::Logger>>,
|
L: Into<Option<::slog::Logger>>,
|
||||||
|
@ -101,9 +101,9 @@ impl Seat {
|
||||||
keyboard: None,
|
keyboard: None,
|
||||||
known_seats: Vec::new(),
|
known_seats: Vec::new(),
|
||||||
};
|
};
|
||||||
let token = evl.state().insert(seat);
|
let token = evlh.state().insert(seat);
|
||||||
// TODO: support version 5 (axis)
|
// TODO: support version 5 (axis)
|
||||||
let global = evl.register_global(4, seat_global_bind, token.clone());
|
let global = evlh.register_global(4, seat_global_bind, token.clone());
|
||||||
(token, global)
|
(token, global)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ use wayland::compositor::roles::Role;
|
||||||
use wayland_protocols::unstable::xdg_shell::v6::server::{zxdg_popup_v6,
|
use wayland_protocols::unstable::xdg_shell::v6::server::{zxdg_popup_v6,
|
||||||
zxdg_positioner_v6 as xdg_positioner,
|
zxdg_positioner_v6 as xdg_positioner,
|
||||||
zxdg_shell_v6, zxdg_surface_v6, zxdg_toplevel_v6};
|
zxdg_shell_v6, zxdg_surface_v6, zxdg_toplevel_v6};
|
||||||
use wayland_server::{EventLoop, EventLoopHandle, EventResult, Global, Liveness, Resource, StateToken};
|
use wayland_server::{EventLoopHandle, EventResult, Global, Liveness, Resource, StateToken};
|
||||||
use wayland_server::protocol::{wl_output, wl_seat, wl_shell, wl_shell_surface, wl_surface};
|
use wayland_server::protocol::{wl_output, wl_seat, wl_shell, wl_shell_surface, wl_surface};
|
||||||
|
|
||||||
mod wl_handlers;
|
mod wl_handlers;
|
||||||
|
@ -301,7 +301,7 @@ impl<U, R, CID, SID, SD> Clone for ShellSurfaceIData<U, R, CID, SID, SD> {
|
||||||
/// It also returns the two global handles, in case you whish to remove these
|
/// It also returns the two global handles, in case you whish to remove these
|
||||||
/// globals from the event loop in the future.
|
/// globals from the event loop in the future.
|
||||||
pub fn shell_init<U, R, CID, SID, SD, L>(
|
pub fn shell_init<U, R, CID, SID, SD, L>(
|
||||||
evl: &mut EventLoop, token: CompositorToken<U, R, CID>,
|
evlh: &mut EventLoopHandle, token: CompositorToken<U, R, CID>,
|
||||||
implementation: ShellSurfaceUserImplementation<U, R, CID, SID, SD>, idata: SID, logger: L,
|
implementation: ShellSurfaceUserImplementation<U, R, CID, SID, SD>, idata: SID, logger: L,
|
||||||
) -> (
|
) -> (
|
||||||
StateToken<ShellState<U, R, CID, SD>>,
|
StateToken<ShellState<U, R, CID, SD>>,
|
||||||
|
@ -321,7 +321,7 @@ where
|
||||||
known_toplevels: Vec::new(),
|
known_toplevels: Vec::new(),
|
||||||
known_popups: Vec::new(),
|
known_popups: Vec::new(),
|
||||||
};
|
};
|
||||||
let shell_state_token = evl.state().insert(shell_state);
|
let shell_state_token = evlh.state().insert(shell_state);
|
||||||
|
|
||||||
let shell_surface_idata = ShellSurfaceIData {
|
let shell_surface_idata = ShellSurfaceIData {
|
||||||
log: log.new(o!("smithay_module" => "shell_handler")),
|
log: log.new(o!("smithay_module" => "shell_handler")),
|
||||||
|
@ -332,12 +332,12 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: init globals
|
// TODO: init globals
|
||||||
let wl_shell_global = evl.register_global(
|
let wl_shell_global = evlh.register_global(
|
||||||
1,
|
1,
|
||||||
self::wl_handlers::wl_shell_bind::<U, R, CID, SID, SD>,
|
self::wl_handlers::wl_shell_bind::<U, R, CID, SID, SD>,
|
||||||
shell_surface_idata.clone(),
|
shell_surface_idata.clone(),
|
||||||
);
|
);
|
||||||
let xdg_shell_global = evl.register_global(
|
let xdg_shell_global = evlh.register_global(
|
||||||
1,
|
1,
|
||||||
self::xdg_handlers::xdg_shell_bind::<U, R, CID, SID, SD>,
|
self::xdg_handlers::xdg_shell_bind::<U, R, CID, SID, SD>,
|
||||||
shell_surface_idata.clone(),
|
shell_surface_idata.clone(),
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
use self::pool::{Pool, ResizeError};
|
use self::pool::{Pool, ResizeError};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wayland_server::{resource_is_registered, Client, EventLoop, EventLoopHandle, Global, Resource};
|
use wayland_server::{resource_is_registered, Client, EventLoopHandle, Global, Resource};
|
||||||
use wayland_server::protocol::{wl_buffer, wl_shm, wl_shm_pool};
|
use wayland_server::protocol::{wl_buffer, wl_shm, wl_shm_pool};
|
||||||
|
|
||||||
mod pool;
|
mod pool;
|
||||||
|
@ -89,7 +89,7 @@ pub struct ShmGlobalData {
|
||||||
/// returns the global handle, in case you whish to remove this global in
|
/// returns the global handle, in case you whish to remove this global in
|
||||||
/// the future.
|
/// the future.
|
||||||
pub fn init_shm_global<L>(
|
pub fn init_shm_global<L>(
|
||||||
evl: &mut EventLoop, mut formats: Vec<wl_shm::Format>, logger: L
|
evlh: &mut EventLoopHandle, mut formats: Vec<wl_shm::Format>, logger: L
|
||||||
) -> Global<wl_shm::WlShm, ShmGlobalData>
|
) -> Global<wl_shm::WlShm, ShmGlobalData>
|
||||||
where
|
where
|
||||||
L: Into<Option<::slog::Logger>>,
|
L: Into<Option<::slog::Logger>>,
|
||||||
|
@ -104,7 +104,7 @@ where
|
||||||
log: log.new(o!("smithay_module" => "shm_handler")),
|
log: log.new(o!("smithay_module" => "shm_handler")),
|
||||||
};
|
};
|
||||||
|
|
||||||
evl.register_global::<wl_shm::WlShm, _>(1, shm_global_bind, data)
|
evlh.register_global::<wl_shm::WlShm, _>(1, shm_global_bind, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error that can occur when accessing an SHM buffer
|
/// Error that can occur when accessing an SHM buffer
|
||||||
|
|
Loading…
Reference in New Issue