Merge pull request #100 from yzhs/clippy-warnings
Address some more clippy warnings
This commit is contained in:
commit
824ef5c186
|
@ -303,10 +303,9 @@ enum KeyAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_keyboard_shortcut(modifiers: &ModifiersState, keysym: Keysym) -> KeyAction {
|
fn process_keyboard_shortcut(modifiers: &ModifiersState, keysym: Keysym) -> KeyAction {
|
||||||
if modifiers.ctrl && modifiers.alt && keysym == xkb::KEY_BackSpace {
|
if modifiers.ctrl && modifiers.alt && keysym == xkb::KEY_BackSpace
|
||||||
|
|| modifiers.logo && keysym == xkb::KEY_q {
|
||||||
// ctrl+alt+backspace = quit
|
// ctrl+alt+backspace = quit
|
||||||
KeyAction::Quit
|
|
||||||
} else if modifiers.logo && keysym == xkb::KEY_q {
|
|
||||||
// logo + q = quit
|
// logo + q = quit
|
||||||
KeyAction::Quit
|
KeyAction::Quit
|
||||||
} else if keysym >= xkb::KEY_XF86Switch_VT_1 && keysym <= xkb::KEY_XF86Switch_VT_12 {
|
} else if keysym >= xkb::KEY_XF86Switch_VT_1 && keysym <= xkb::KEY_XF86Switch_VT_12 {
|
||||||
|
|
|
@ -44,7 +44,7 @@ fn main() {
|
||||||
|
|
||||||
let (mut display, mut event_loop) = Display::new();
|
let (mut display, mut event_loop) = Display::new();
|
||||||
|
|
||||||
let arg = ::std::env::args().skip(1).next();
|
let arg = ::std::env::args().nth(1);
|
||||||
match arg.as_ref().map(|s| &s[..]) {
|
match arg.as_ref().map(|s| &s[..]) {
|
||||||
#[cfg(feature = "winit")]
|
#[cfg(feature = "winit")]
|
||||||
Some("--winit") => {
|
Some("--winit") => {
|
||||||
|
@ -69,7 +69,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
println!("USAGE: anvil --backend");
|
println!("USAGE: anvil --backend");
|
||||||
println!("");
|
println!();
|
||||||
println!("Possible backends are:");
|
println!("Possible backends are:");
|
||||||
for b in POSSIBLE_BACKENDS {
|
for b in POSSIBLE_BACKENDS {
|
||||||
println!("\t{}", b);
|
println!("\t{}", b);
|
||||||
|
|
|
@ -36,7 +36,7 @@ macro_rules! opengl_programs(
|
||||||
* OpenGL Shaders
|
* OpenGL Shaders
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pub const VERTEX_SHADER: &'static str = r#"
|
pub const VERTEX_SHADER: &str = r#"
|
||||||
#version 100
|
#version 100
|
||||||
uniform lowp mat4 matrix;
|
uniform lowp mat4 matrix;
|
||||||
attribute lowp vec2 position;
|
attribute lowp vec2 position;
|
||||||
|
@ -50,7 +50,7 @@ void main() {
|
||||||
pub const FRAGMENT_COUNT: usize = 5;
|
pub const FRAGMENT_COUNT: usize = 5;
|
||||||
|
|
||||||
pub const BUFFER_RGBA: usize = 0;
|
pub const BUFFER_RGBA: usize = 0;
|
||||||
pub const FRAGMENT_SHADER_RGBA: &'static str = r#"
|
pub const FRAGMENT_SHADER_RGBA: &str = r#"
|
||||||
#version 100
|
#version 100
|
||||||
uniform lowp sampler2D tex;
|
uniform lowp sampler2D tex;
|
||||||
varying lowp vec2 v_tex_coords;
|
varying lowp vec2 v_tex_coords;
|
||||||
|
@ -64,7 +64,7 @@ void main() {
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
pub const BUFFER_ABGR: usize = 1;
|
pub const BUFFER_ABGR: usize = 1;
|
||||||
pub const FRAGMENT_SHADER_ABGR: &'static str = r#"
|
pub const FRAGMENT_SHADER_ABGR: &str = r#"
|
||||||
#version 100
|
#version 100
|
||||||
uniform lowp sampler2D tex;
|
uniform lowp sampler2D tex;
|
||||||
varying lowp vec2 v_tex_coords;
|
varying lowp vec2 v_tex_coords;
|
||||||
|
@ -78,7 +78,7 @@ void main() {
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
pub const BUFFER_XBGR: usize = 2;
|
pub const BUFFER_XBGR: usize = 2;
|
||||||
pub const FRAGMENT_SHADER_XBGR: &'static str = r#"
|
pub const FRAGMENT_SHADER_XBGR: &str = r#"
|
||||||
#version 100
|
#version 100
|
||||||
uniform lowp sampler2D tex;
|
uniform lowp sampler2D tex;
|
||||||
varying lowp vec2 v_tex_coords;
|
varying lowp vec2 v_tex_coords;
|
||||||
|
@ -92,7 +92,7 @@ void main() {
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
pub const BUFFER_BGRA: usize = 3;
|
pub const BUFFER_BGRA: usize = 3;
|
||||||
pub const FRAGMENT_SHADER_BGRA: &'static str = r#"
|
pub const FRAGMENT_SHADER_BGRA: &str = r#"
|
||||||
#version 100
|
#version 100
|
||||||
uniform lowp sampler2D tex;
|
uniform lowp sampler2D tex;
|
||||||
varying lowp vec2 v_tex_coords;
|
varying lowp vec2 v_tex_coords;
|
||||||
|
@ -106,7 +106,7 @@ void main() {
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
pub const BUFFER_BGRX: usize = 4;
|
pub const BUFFER_BGRX: usize = 4;
|
||||||
pub const FRAGMENT_SHADER_BGRX: &'static str = r#"
|
pub const FRAGMENT_SHADER_BGRX: &str = r#"
|
||||||
#version 100
|
#version 100
|
||||||
uniform lowp sampler2D tex;
|
uniform lowp sampler2D tex;
|
||||||
varying lowp vec2 v_tex_coords;
|
varying lowp vec2 v_tex_coords;
|
||||||
|
|
|
@ -55,7 +55,7 @@ pub fn init_shell(
|
||||||
let (xdg_shell_state, _, _) = xdg_shell_init(
|
let (xdg_shell_state, _, _) = xdg_shell_init(
|
||||||
display,
|
display,
|
||||||
looptoken.clone(),
|
looptoken.clone(),
|
||||||
compositor_token.clone(),
|
compositor_token,
|
||||||
move |shell_event, ()| match shell_event {
|
move |shell_event, ()| match shell_event {
|
||||||
XdgRequest::NewToplevel { surface } => {
|
XdgRequest::NewToplevel { surface } => {
|
||||||
// place the window at a random location in the [0;300]x[0;300] square
|
// place the window at a random location in the [0;300]x[0;300] square
|
||||||
|
@ -88,12 +88,12 @@ pub fn init_shell(
|
||||||
let (wl_shell_state, _) = wl_shell_init(
|
let (wl_shell_state, _) = wl_shell_init(
|
||||||
display,
|
display,
|
||||||
looptoken,
|
looptoken,
|
||||||
compositor_token.clone(),
|
compositor_token,
|
||||||
move |req: ShellRequest<_, _, ()>, ()| match req {
|
move |req: ShellRequest<_, _, ()>, ()|
|
||||||
ShellRequest::SetKind {
|
if let ShellRequest::SetKind {
|
||||||
surface,
|
surface,
|
||||||
kind: ShellSurfaceKind::Toplevel,
|
kind: ShellSurfaceKind::Toplevel,
|
||||||
} => {
|
} = req {
|
||||||
// place the window at a random location in the [0;300]x[0;300] square
|
// place the window at a random location in the [0;300]x[0;300] square
|
||||||
use rand::distributions::{IndependentSample, Range};
|
use rand::distributions::{IndependentSample, Range};
|
||||||
let range = Range::new(0, 300);
|
let range = Range::new(0, 300);
|
||||||
|
@ -104,8 +104,6 @@ pub fn init_shell(
|
||||||
shell_window_map
|
shell_window_map
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.insert(SurfaceKind::Wl(surface), (x, y));
|
.insert(SurfaceKind::Wl(surface), (x, y));
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
},
|
},
|
||||||
log.clone(),
|
log.clone(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -5,7 +5,7 @@ use smithay::wayland_server::protocol::wl_shm::Format;
|
||||||
|
|
||||||
use glium::texture::{ClientFormat, RawImage2d};
|
use glium::texture::{ClientFormat, RawImage2d};
|
||||||
|
|
||||||
pub fn load_shm_buffer<'a>(data: BufferData, pool: &'a [u8]) -> Result<(RawImage2d<'a, u8>, usize), Format> {
|
pub fn load_shm_buffer(data: BufferData, pool: &[u8]) -> Result<(RawImage2d<u8>, usize), Format> {
|
||||||
let offset = data.offset as usize;
|
let offset = data.offset as usize;
|
||||||
let width = data.width as usize;
|
let width = data.width as usize;
|
||||||
let height = data.height as usize;
|
let height = data.height as usize;
|
||||||
|
|
|
@ -105,7 +105,7 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop, log: Logger) ->
|
||||||
let (mut w_seat, _) = Seat::new(
|
let (mut w_seat, _) = Seat::new(
|
||||||
&mut display.borrow_mut(),
|
&mut display.borrow_mut(),
|
||||||
event_loop.token(),
|
event_loop.token(),
|
||||||
session.seat().into(),
|
session.seat(),
|
||||||
log.clone(),
|
log.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop, log: Logger) ->
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
while running.load(Ordering::SeqCst) {
|
while running.load(Ordering::SeqCst) {
|
||||||
if let Err(_) = event_loop.dispatch(Some(16)) {
|
if event_loop.dispatch(Some(16)).is_err() {
|
||||||
running.store(false, Ordering::SeqCst);
|
running.store(false, Ordering::SeqCst);
|
||||||
} else {
|
} else {
|
||||||
display.borrow_mut().flush_clients();
|
display.borrow_mut().flush_clients();
|
||||||
|
@ -288,7 +288,7 @@ impl UdevHandler<DrmHandlerImpl> for UdevHandlerImpl {
|
||||||
self.backends.insert(device.device_id(), backends.clone());
|
self.backends.insert(device.device_id(), backends.clone());
|
||||||
|
|
||||||
Some(DrmHandlerImpl {
|
Some(DrmHandlerImpl {
|
||||||
compositor_token: self.compositor_token.clone(),
|
compositor_token: self.compositor_token,
|
||||||
backends,
|
backends,
|
||||||
window_map: self.window_map.clone(),
|
window_map: self.window_map.clone(),
|
||||||
pointer_location: self.pointer_location.clone(),
|
pointer_location: self.pointer_location.clone(),
|
||||||
|
@ -298,7 +298,7 @@ impl UdevHandler<DrmHandlerImpl> for UdevHandlerImpl {
|
||||||
|
|
||||||
fn device_changed(&mut self, device: &mut DrmDevice<SessionFdDrmDevice>) {
|
fn device_changed(&mut self, device: &mut DrmDevice<SessionFdDrmDevice>) {
|
||||||
//quick and dirt, just re-init all backends
|
//quick and dirt, just re-init all backends
|
||||||
let backends = self.backends.get(&device.device_id()).unwrap();
|
let backends = &self.backends[&device.device_id()];
|
||||||
*backends.borrow_mut() = self.scan_connectors(device, self.active_egl_context.clone());
|
*backends.borrow_mut() = self.scan_connectors(device, self.active_egl_context.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,22 +155,22 @@ where
|
||||||
{
|
{
|
||||||
pub fn new(ctoken: CompositorToken<U, R>, get_size: F) -> WindowMap<U, R, D, SD, F> {
|
pub fn new(ctoken: CompositorToken<U, R>, get_size: F) -> WindowMap<U, R, D, SD, F> {
|
||||||
WindowMap {
|
WindowMap {
|
||||||
ctoken: ctoken,
|
ctoken,
|
||||||
windows: Vec::new(),
|
windows: Vec::new(),
|
||||||
get_size: get_size,
|
get_size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert(&mut self, toplevel: Kind<U, R, SD, D>, location: (i32, i32)) {
|
pub fn insert(&mut self, toplevel: Kind<U, R, SD, D>, location: (i32, i32)) {
|
||||||
let mut window = Window {
|
let mut window = Window {
|
||||||
location: location,
|
location,
|
||||||
surface: Rectangle {
|
surface: Rectangle {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
width: 0,
|
width: 0,
|
||||||
height: 0,
|
height: 0,
|
||||||
},
|
},
|
||||||
toplevel: toplevel,
|
toplevel,
|
||||||
};
|
};
|
||||||
window.self_update(self.ctoken, &self.get_size);
|
window.self_update(self.ctoken, &self.get_size);
|
||||||
self.windows.insert(0, window);
|
self.windows.insert(0, window);
|
||||||
|
@ -219,7 +219,7 @@ where
|
||||||
|
|
||||||
pub fn refresh(&mut self) {
|
pub fn refresh(&mut self) {
|
||||||
self.windows.retain(|w| w.toplevel.alive());
|
self.windows.retain(|w| w.toplevel.alive());
|
||||||
for w in self.windows.iter_mut() {
|
for w in &mut self.windows {
|
||||||
w.self_update(self.ctoken, &self.get_size);
|
w.self_update(self.ctoken, &self.get_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,11 +171,11 @@ impl<A: Device + 'static> DrmBackend<A> {
|
||||||
if !encoders
|
if !encoders
|
||||||
.iter()
|
.iter()
|
||||||
.map(|encoder| encoder.possible_crtcs())
|
.map(|encoder| encoder.possible_crtcs())
|
||||||
.all(|crtc_list| {
|
.all(|crtc_list|
|
||||||
resource_handles
|
resource_handles
|
||||||
.filter_crtcs(crtc_list)
|
.filter_crtcs(crtc_list)
|
||||||
.contains(&self.backend.crtc)
|
.contains(&self.backend.crtc)
|
||||||
}) {
|
) {
|
||||||
bail!(ErrorKind::NoSuitableEncoder(info, self.backend.crtc));
|
bail!(ErrorKind::NoSuitableEncoder(info, self.backend.crtc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,12 +473,13 @@ impl<A: Device + 'static> GraphicsBackend for DrmBackend<A> {
|
||||||
|
|
||||||
impl<A: Device + 'static> EGLGraphicsBackend for DrmBackend<A> {
|
impl<A: Device + 'static> EGLGraphicsBackend for DrmBackend<A> {
|
||||||
fn swap_buffers(&self) -> ::std::result::Result<(), SwapBuffersError> {
|
fn swap_buffers(&self) -> ::std::result::Result<(), SwapBuffersError> {
|
||||||
if {
|
let res = {
|
||||||
let nb = self.backend.next_buffer.take();
|
let nb = self.backend.next_buffer.take();
|
||||||
let res = nb.is_some();
|
let res = nb.is_some();
|
||||||
self.backend.next_buffer.set(nb);
|
self.backend.next_buffer.set(nb);
|
||||||
res
|
res
|
||||||
} {
|
};
|
||||||
|
if res {
|
||||||
// We cannot call lock_front_buffer anymore without releasing the previous buffer, which will happen when the page flip is done
|
// We cannot call lock_front_buffer anymore without releasing the previous buffer, which will happen when the page flip is done
|
||||||
warn!(
|
warn!(
|
||||||
self.backend.logger,
|
self.backend.logger,
|
||||||
|
|
|
@ -328,7 +328,7 @@ impl<A: ControlDevice + 'static> DrmDevice<A> {
|
||||||
info!(log, "DrmDevice initializing");
|
info!(log, "DrmDevice initializing");
|
||||||
|
|
||||||
// we want to mode-set, so we better be the master, if we run via a tty session
|
// we want to mode-set, so we better be the master, if we run via a tty session
|
||||||
if let Err(_) = drm.set_master() {
|
if drm.set_master().is_err() {
|
||||||
warn!(
|
warn!(
|
||||||
log,
|
log,
|
||||||
"Unable to become drm master, assuming unpriviledged mode"
|
"Unable to become drm master, assuming unpriviledged mode"
|
||||||
|
@ -594,7 +594,7 @@ where
|
||||||
fn receive(&mut self, event: FdEvent, (): ()) {
|
fn receive(&mut self, event: FdEvent, (): ()) {
|
||||||
let mut device = self.device.borrow_mut();
|
let mut device = self.device.borrow_mut();
|
||||||
match event {
|
match event {
|
||||||
FdEvent::Ready { .. } => match crtc::receive_events(&mut *device) {
|
FdEvent::Ready { .. } => match crtc::receive_events(&*device) {
|
||||||
Ok(events) => for event in events {
|
Ok(events) => for event in events {
|
||||||
if let crtc::Event::PageFlip(event) = event {
|
if let crtc::Event::PageFlip(event) = event {
|
||||||
if device.active.load(Ordering::SeqCst) {
|
if device.active.load(Ordering::SeqCst) {
|
||||||
|
@ -643,7 +643,7 @@ impl<A: ControlDevice + 'static> AsSessionObserver<DrmDeviceObserver<A>> for Drm
|
||||||
fn observer(&mut self) -> DrmDeviceObserver<A> {
|
fn observer(&mut self) -> DrmDeviceObserver<A> {
|
||||||
DrmDeviceObserver {
|
DrmDeviceObserver {
|
||||||
context: Rc::downgrade(&self.context),
|
context: Rc::downgrade(&self.context),
|
||||||
device_id: self.device_id.clone(),
|
device_id: self.device_id,
|
||||||
backends: self.backends.clone(),
|
backends: self.backends.clone(),
|
||||||
old_state: self.old_state.clone(),
|
old_state: self.old_state.clone(),
|
||||||
active: self.active.clone(),
|
active: self.active.clone(),
|
||||||
|
@ -662,7 +662,7 @@ impl<A: ControlDevice + 'static> SessionObserver for DrmDeviceObserver<A> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(device) = self.context.upgrade() {
|
if let Some(device) = self.context.upgrade() {
|
||||||
for (handle, &(ref info, ref connectors)) in self.old_state.iter() {
|
for (handle, &(ref info, ref connectors)) in &self.old_state {
|
||||||
if let Err(err) = crtc::set(
|
if let Err(err) = crtc::set(
|
||||||
&*device,
|
&*device,
|
||||||
*handle,
|
*handle,
|
||||||
|
|
|
@ -179,7 +179,7 @@ unsafe impl NativeDisplay<X11> for WinitWindow {
|
||||||
|
|
||||||
fn create_surface(&self, _args: ()) -> Result<XlibWindow> {
|
fn create_surface(&self, _args: ()) -> Result<XlibWindow> {
|
||||||
self.get_xlib_window()
|
self.get_xlib_window()
|
||||||
.map(|ptr| XlibWindow(ptr))
|
.map(XlibWindow)
|
||||||
.ok_or(ErrorKind::NonMatchingBackend("X11").into())
|
.ok_or(ErrorKind::NonMatchingBackend("X11").into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,9 @@ pub struct Seat {
|
||||||
impl Seat {
|
impl Seat {
|
||||||
pub(crate) fn new<S: ToString>(id: u64, name: S, capabilities: SeatCapabilities) -> Seat {
|
pub(crate) fn new<S: ToString>(id: u64, name: S, capabilities: SeatCapabilities) -> Seat {
|
||||||
Seat {
|
Seat {
|
||||||
id: id,
|
id,
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
capabilities: capabilities,
|
capabilities,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ pub struct TouchSlot {
|
||||||
|
|
||||||
impl TouchSlot {
|
impl TouchSlot {
|
||||||
pub(crate) fn new(id: u64) -> Self {
|
pub(crate) fn new(id: u64) -> Self {
|
||||||
TouchSlot { id: id }
|
TouchSlot { id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl LibinputInputBackend {
|
||||||
let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_libinput"));
|
let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_libinput"));
|
||||||
info!(log, "Initializing a libinput backend");
|
info!(log, "Initializing a libinput backend");
|
||||||
LibinputInputBackend {
|
LibinputInputBackend {
|
||||||
context: context,
|
context,
|
||||||
devices: Vec::new(),
|
devices: Vec::new(),
|
||||||
seats: HashMap::new(),
|
seats: HashMap::new(),
|
||||||
handler: None,
|
handler: None,
|
||||||
|
@ -404,7 +404,7 @@ impl backend::InputBackend for LibinputInputBackend {
|
||||||
use input::event::touch::*;
|
use input::event::touch::*;
|
||||||
if let Some(ref mut handler) = self.handler {
|
if let Some(ref mut handler) = self.handler {
|
||||||
let device_seat = touch_event.device().seat();
|
let device_seat = touch_event.device().seat();
|
||||||
if let &Some(ref seat) = &self.seats.get(&device_seat) {
|
if let Some(ref seat) = self.seats.get(&device_seat) {
|
||||||
match touch_event {
|
match touch_event {
|
||||||
TouchEvent::Down(down_event) => {
|
TouchEvent::Down(down_event) => {
|
||||||
trace!(self.logger, "Calling on_touch_down with {:?}", down_event);
|
trace!(self.logger, "Calling on_touch_down with {:?}", down_event);
|
||||||
|
@ -446,7 +446,7 @@ impl backend::InputBackend for LibinputInputBackend {
|
||||||
match keyboard_event {
|
match keyboard_event {
|
||||||
KeyboardEvent::Key(key_event) => if let Some(ref mut handler) = self.handler {
|
KeyboardEvent::Key(key_event) => if let Some(ref mut handler) = self.handler {
|
||||||
let device_seat = key_event.device().seat();
|
let device_seat = key_event.device().seat();
|
||||||
if let &Some(ref seat) = &self.seats.get(&device_seat) {
|
if let Some(ref seat) = self.seats.get(&device_seat) {
|
||||||
trace!(self.logger, "Calling on_keyboard_key with {:?}", key_event);
|
trace!(self.logger, "Calling on_keyboard_key with {:?}", key_event);
|
||||||
handler.on_keyboard_key(seat, key_event);
|
handler.on_keyboard_key(seat, key_event);
|
||||||
} else {
|
} else {
|
||||||
|
@ -460,7 +460,7 @@ impl backend::InputBackend for LibinputInputBackend {
|
||||||
use input::event::pointer::*;
|
use input::event::pointer::*;
|
||||||
if let Some(ref mut handler) = self.handler {
|
if let Some(ref mut handler) = self.handler {
|
||||||
let device_seat = pointer_event.device().seat();
|
let device_seat = pointer_event.device().seat();
|
||||||
if let &Some(ref seat) = &self.seats.get(&device_seat) {
|
if let Some(ref seat) = self.seats.get(&device_seat) {
|
||||||
match pointer_event {
|
match pointer_event {
|
||||||
PointerEvent::Motion(motion_event) => {
|
PointerEvent::Motion(motion_event) => {
|
||||||
trace!(
|
trace!(
|
||||||
|
|
|
@ -170,40 +170,40 @@ impl Session for AutoSession {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn open(&mut self, path: &Path, flags: OFlag) -> Result<RawFd> {
|
fn open(&mut self, path: &Path, flags: OFlag) -> Result<RawFd> {
|
||||||
match self {
|
match *self {
|
||||||
#[cfg(feature = "backend_session_logind")]
|
#[cfg(feature = "backend_session_logind")]
|
||||||
&mut AutoSession::Logind(ref mut logind) => logind.open(path, flags).map_err(|e| e.into()),
|
AutoSession::Logind(ref mut logind) => logind.open(path, flags).map_err(|e| e.into()),
|
||||||
&mut AutoSession::Direct(ref mut direct) => direct.open(path, flags).map_err(|e| e.into()),
|
AutoSession::Direct(ref mut direct) => direct.open(path, flags).map_err(|e| e.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn close(&mut self, fd: RawFd) -> Result<()> {
|
fn close(&mut self, fd: RawFd) -> Result<()> {
|
||||||
match self {
|
match *self {
|
||||||
#[cfg(feature = "backend_session_logind")]
|
#[cfg(feature = "backend_session_logind")]
|
||||||
&mut AutoSession::Logind(ref mut logind) => logind.close(fd).map_err(|e| e.into()),
|
AutoSession::Logind(ref mut logind) => logind.close(fd).map_err(|e| e.into()),
|
||||||
&mut AutoSession::Direct(ref mut direct) => direct.close(fd).map_err(|e| e.into()),
|
AutoSession::Direct(ref mut direct) => direct.close(fd).map_err(|e| e.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn change_vt(&mut self, vt: i32) -> Result<()> {
|
fn change_vt(&mut self, vt: i32) -> Result<()> {
|
||||||
match self {
|
match *self {
|
||||||
#[cfg(feature = "backend_session_logind")]
|
#[cfg(feature = "backend_session_logind")]
|
||||||
&mut AutoSession::Logind(ref mut logind) => logind.change_vt(vt).map_err(|e| e.into()),
|
AutoSession::Logind(ref mut logind) => logind.change_vt(vt).map_err(|e| e.into()),
|
||||||
&mut AutoSession::Direct(ref mut direct) => direct.change_vt(vt).map_err(|e| e.into()),
|
AutoSession::Direct(ref mut direct) => direct.change_vt(vt).map_err(|e| e.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_active(&self) -> bool {
|
fn is_active(&self) -> bool {
|
||||||
match self {
|
match *self {
|
||||||
#[cfg(feature = "backend_session_logind")]
|
#[cfg(feature = "backend_session_logind")]
|
||||||
&AutoSession::Logind(ref logind) => logind.is_active(),
|
AutoSession::Logind(ref logind) => logind.is_active(),
|
||||||
&AutoSession::Direct(ref direct) => direct.is_active(),
|
AutoSession::Direct(ref direct) => direct.is_active(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn seat(&self) -> String {
|
fn seat(&self) -> String {
|
||||||
match self {
|
match *self {
|
||||||
#[cfg(feature = "backend_session_logind")]
|
#[cfg(feature = "backend_session_logind")]
|
||||||
&AutoSession::Logind(ref logind) => logind.seat(),
|
AutoSession::Logind(ref logind) => logind.seat(),
|
||||||
&AutoSession::Direct(ref direct) => direct.seat(),
|
AutoSession::Direct(ref direct) => direct.seat(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,12 +215,12 @@ impl SessionNotifier for AutoSessionNotifier {
|
||||||
&mut self,
|
&mut self,
|
||||||
signal: &mut A,
|
signal: &mut A,
|
||||||
) -> Self::Id {
|
) -> Self::Id {
|
||||||
match self {
|
match *self {
|
||||||
#[cfg(feature = "backend_session_logind")]
|
#[cfg(feature = "backend_session_logind")]
|
||||||
&mut AutoSessionNotifier::Logind(ref mut logind) => {
|
AutoSessionNotifier::Logind(ref mut logind) => {
|
||||||
AutoId(AutoIdInternal::Logind(logind.register(signal)))
|
AutoId(AutoIdInternal::Logind(logind.register(signal)))
|
||||||
}
|
}
|
||||||
&mut AutoSessionNotifier::Direct(ref mut direct) => {
|
AutoSessionNotifier::Direct(ref mut direct) => {
|
||||||
AutoId(AutoIdInternal::Direct(direct.register(signal)))
|
AutoId(AutoIdInternal::Direct(direct.register(signal)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,17 +239,17 @@ impl SessionNotifier for AutoSessionNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_active(&self) -> bool {
|
fn is_active(&self) -> bool {
|
||||||
match self {
|
match *self {
|
||||||
#[cfg(feature = "backend_session_logind")]
|
#[cfg(feature = "backend_session_logind")]
|
||||||
&AutoSessionNotifier::Logind(ref logind) => logind.is_active(),
|
AutoSessionNotifier::Logind(ref logind) => logind.is_active(),
|
||||||
&AutoSessionNotifier::Direct(ref direct) => direct.is_active(),
|
AutoSessionNotifier::Direct(ref direct) => direct.is_active(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn seat(&self) -> &str {
|
fn seat(&self) -> &str {
|
||||||
match self {
|
match *self {
|
||||||
#[cfg(feature = "backend_session_logind")]
|
#[cfg(feature = "backend_session_logind")]
|
||||||
&AutoSessionNotifier::Logind(ref logind) => logind.seat(),
|
AutoSessionNotifier::Logind(ref logind) => logind.seat(),
|
||||||
&AutoSessionNotifier::Direct(ref direct) => direct.seat(),
|
AutoSessionNotifier::Direct(ref direct) => direct.seat(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ impl DirectSession {
|
||||||
fcntl::OFlag::O_RDWR | fcntl::OFlag::O_CLOEXEC,
|
fcntl::OFlag::O_RDWR | fcntl::OFlag::O_CLOEXEC,
|
||||||
Mode::empty(),
|
Mode::empty(),
|
||||||
).chain_err(|| ErrorKind::FailedToOpenTTY(String::from(path.to_string_lossy())))
|
).chain_err(|| ErrorKind::FailedToOpenTTY(String::from(path.to_string_lossy())))
|
||||||
}).unwrap_or(dup(0 /*stdin*/).chain_err(|| ErrorKind::FailedToOpenTTY(String::from("<stdin>"))))?;
|
}).unwrap_or_else(|| dup(0 /*stdin*/).chain_err(|| ErrorKind::FailedToOpenTTY(String::from("<stdin>"))))?;
|
||||||
|
|
||||||
let active = Arc::new(AtomicBool::new(true));
|
let active = Arc::new(AtomicBool::new(true));
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ impl Implementation<(), SignalEvent> for DirectSessionNotifier {
|
||||||
if self.is_active() {
|
if self.is_active() {
|
||||||
info!(self.logger, "Session shall become inactive.");
|
info!(self.logger, "Session shall become inactive.");
|
||||||
for signal in &mut self.signals {
|
for signal in &mut self.signals {
|
||||||
if let &mut Some(ref mut signal) = signal {
|
if let Some(ref mut signal) = *signal {
|
||||||
signal.pause(None);
|
signal.pause(None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,7 +387,7 @@ impl Implementation<(), SignalEvent> for DirectSessionNotifier {
|
||||||
tty::vt_rel_disp(self.tty, tty::VT_ACKACQ).expect("Unable to acquire tty lock");
|
tty::vt_rel_disp(self.tty, tty::VT_ACKACQ).expect("Unable to acquire tty lock");
|
||||||
}
|
}
|
||||||
for signal in &mut self.signals {
|
for signal in &mut self.signals {
|
||||||
if let &mut Some(ref mut signal) = signal {
|
if let Some(ref mut signal) = *signal {
|
||||||
signal.activate(None);
|
signal.activate(None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ impl<H: DrmHandler<SessionFdDrmDevice> + 'static, S: Session + 'static, T: UdevH
|
||||||
/// `session` - A session used to open and close devices as they become available
|
/// `session` - A session used to open and close devices as they become available
|
||||||
/// `handler` - User-provided handler to respond to any detected changes
|
/// `handler` - User-provided handler to respond to any detected changes
|
||||||
/// `logger` - slog Logger to be used by the backend and its `DrmDevices`.
|
/// `logger` - slog Logger to be used by the backend and its `DrmDevices`.
|
||||||
pub fn new<'a, L>(
|
pub fn new<L>(
|
||||||
token: LoopToken,
|
token: LoopToken,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
mut session: S,
|
mut session: S,
|
||||||
|
@ -195,7 +195,7 @@ impl<
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SessionObserver for UdevBackendObserver {
|
impl SessionObserver for UdevBackendObserver {
|
||||||
fn pause<'a>(&mut self, devnum: Option<(u32, u32)>) {
|
fn pause(&mut self, devnum: Option<(u32, u32)>) {
|
||||||
if let Some(devices) = self.devices.upgrade() {
|
if let Some(devices) = self.devices.upgrade() {
|
||||||
for &mut (_, ref device) in devices.borrow_mut().values_mut() {
|
for &mut (_, ref device) in devices.borrow_mut().values_mut() {
|
||||||
info!(self.logger, "changed successful");
|
info!(self.logger, "changed successful");
|
||||||
|
@ -204,7 +204,7 @@ impl SessionObserver for UdevBackendObserver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn activate<'a>(&mut self, devnum: Option<(u32, u32, Option<RawFd>)>) {
|
fn activate(&mut self, devnum: Option<(u32, u32, Option<RawFd>)>) {
|
||||||
if let Some(devices) = self.devices.upgrade() {
|
if let Some(devices) = self.devices.upgrade() {
|
||||||
for &mut (_, ref device) in devices.borrow_mut().values_mut() {
|
for &mut (_, ref device) in devices.borrow_mut().values_mut() {
|
||||||
info!(self.logger, "changed successful");
|
info!(self.logger, "changed successful");
|
||||||
|
|
|
@ -53,9 +53,9 @@ enum Window {
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
fn window(&self) -> &WinitWindow {
|
fn window(&self) -> &WinitWindow {
|
||||||
match self {
|
match *self {
|
||||||
&Window::Wayland { ref context, .. } => &**context,
|
Window::Wayland { ref context, .. } => &**context,
|
||||||
&Window::X11 { ref context, .. } => &**context,
|
Window::X11 { ref context, .. } => &**context,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -697,12 +697,9 @@ impl InputBackend for WinitInputBackend {
|
||||||
(WindowEvent::Resized(w, h), _, events_handler) => {
|
(WindowEvent::Resized(w, h), _, events_handler) => {
|
||||||
trace!(logger, "Resizing window to {:?}", (w, h));
|
trace!(logger, "Resizing window to {:?}", (w, h));
|
||||||
window.window().set_inner_size(w, h);
|
window.window().set_inner_size(w, h);
|
||||||
match **window {
|
if let Window::Wayland { ref surface, .. } = **window {
|
||||||
Window::Wayland { ref surface, .. } => {
|
surface.resize(w as i32, h as i32, 0, 0);
|
||||||
surface.resize(w as i32, h as i32, 0, 0)
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
};
|
|
||||||
if let Some(events_handler) = events_handler {
|
if let Some(events_handler) = events_handler {
|
||||||
events_handler.resized(w, h);
|
events_handler.resized(w, h);
|
||||||
}
|
}
|
||||||
|
@ -743,7 +740,7 @@ impl InputBackend for WinitInputBackend {
|
||||||
time,
|
time,
|
||||||
key: scancode,
|
key: scancode,
|
||||||
count: *key_counter,
|
count: *key_counter,
|
||||||
state: state,
|
state,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -760,8 +757,8 @@ impl InputBackend for WinitInputBackend {
|
||||||
WinitMouseMovedEvent {
|
WinitMouseMovedEvent {
|
||||||
window: window.clone(),
|
window: window.clone(),
|
||||||
time,
|
time,
|
||||||
x: x,
|
x,
|
||||||
y: y,
|
y,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -780,8 +777,8 @@ impl InputBackend for WinitInputBackend {
|
||||||
seat,
|
seat,
|
||||||
WinitMouseInputEvent {
|
WinitMouseInputEvent {
|
||||||
time,
|
time,
|
||||||
button: button,
|
button,
|
||||||
state: state,
|
state,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -802,7 +799,7 @@ impl InputBackend for WinitInputBackend {
|
||||||
window: window.clone(),
|
window: window.clone(),
|
||||||
time,
|
time,
|
||||||
location: (x, y),
|
location: (x, y),
|
||||||
id: id,
|
id,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -823,7 +820,7 @@ impl InputBackend for WinitInputBackend {
|
||||||
window: window.clone(),
|
window: window.clone(),
|
||||||
time,
|
time,
|
||||||
location: (x, y),
|
location: (x, y),
|
||||||
id: id,
|
id,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -844,11 +841,11 @@ impl InputBackend for WinitInputBackend {
|
||||||
window: window.clone(),
|
window: window.clone(),
|
||||||
time,
|
time,
|
||||||
location: (x, y),
|
location: (x, y),
|
||||||
id: id,
|
id,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
trace!(logger, "Calling on_touch_up");
|
trace!(logger, "Calling on_touch_up");
|
||||||
handler.on_touch_up(seat, WinitTouchEndedEvent { time, id: id });
|
handler.on_touch_up(seat, WinitTouchEndedEvent { time, id });
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
WindowEvent::Touch(Touch {
|
WindowEvent::Touch(Touch {
|
||||||
|
@ -860,7 +857,7 @@ impl InputBackend for WinitInputBackend {
|
||||||
_,
|
_,
|
||||||
) => {
|
) => {
|
||||||
trace!(logger, "Calling on_touch_cancel");
|
trace!(logger, "Calling on_touch_cancel");
|
||||||
handler.on_touch_cancel(seat, WinitTouchCancelledEvent { time, id: id })
|
handler.on_touch_cancel(seat, WinitTouchCancelledEvent { time, id })
|
||||||
}
|
}
|
||||||
(WindowEvent::CloseRequested, _, _) | (WindowEvent::Destroyed, _, _) => {
|
(WindowEvent::CloseRequested, _, _) | (WindowEvent::Destroyed, _, _) => {
|
||||||
warn!(logger, "Window closed");
|
warn!(logger, "Window closed");
|
||||||
|
|
|
@ -57,8 +57,8 @@ impl<U, R> SurfaceImplem<U, R> {
|
||||||
+ 'static,
|
+ 'static,
|
||||||
{
|
{
|
||||||
SurfaceImplem {
|
SurfaceImplem {
|
||||||
log: log,
|
log,
|
||||||
implem: implem,
|
implem,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,14 +229,14 @@ impl<U: 'static, R: RoleType + Role<SubsurfaceRole> + 'static> SurfaceData<U, R>
|
||||||
pub unsafe fn get_parent(child: &Resource<WlSurface>) -> Option<Resource<WlSurface>> {
|
pub unsafe fn get_parent(child: &Resource<WlSurface>) -> Option<Resource<WlSurface>> {
|
||||||
let child_mutex = Self::get_data(child);
|
let child_mutex = Self::get_data(child);
|
||||||
let child_guard = child_mutex.lock().unwrap();
|
let child_guard = child_mutex.lock().unwrap();
|
||||||
child_guard.parent.as_ref().map(|p| p.clone())
|
child_guard.parent.as_ref().cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve the parent surface (if any) of this surface
|
/// Retrieve the parent surface (if any) of this surface
|
||||||
pub unsafe fn get_children(child: &Resource<WlSurface>) -> Vec<Resource<WlSurface>> {
|
pub unsafe fn get_children(child: &Resource<WlSurface>) -> Vec<Resource<WlSurface>> {
|
||||||
let child_mutex = Self::get_data(child);
|
let child_mutex = Self::get_data(child);
|
||||||
let child_guard = child_mutex.lock().unwrap();
|
let child_guard = child_mutex.lock().unwrap();
|
||||||
child_guard.children.iter().map(|p| p.clone()).collect()
|
child_guard.children.to_vec()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reorders a surface relative to one of its sibling
|
/// Reorders a surface relative to one of its sibling
|
||||||
|
@ -250,7 +250,7 @@ impl<U: 'static, R: RoleType + Role<SubsurfaceRole> + 'static> SurfaceData<U, R>
|
||||||
let parent = {
|
let parent = {
|
||||||
let data_mutex = Self::get_data(surface);
|
let data_mutex = Self::get_data(surface);
|
||||||
let data_guard = data_mutex.lock().unwrap();
|
let data_guard = data_mutex.lock().unwrap();
|
||||||
data_guard.parent.as_ref().map(|p| p.clone()).unwrap()
|
data_guard.parent.as_ref().cloned().unwrap()
|
||||||
};
|
};
|
||||||
if parent.equals(relative_to) {
|
if parent.equals(relative_to) {
|
||||||
// TODO: handle positioning relative to parent
|
// TODO: handle positioning relative to parent
|
||||||
|
|
|
@ -127,7 +127,7 @@ impl Inner {
|
||||||
flags |= WMode::Preferred;
|
flags |= WMode::Preferred;
|
||||||
}
|
}
|
||||||
output.send(Event::Mode {
|
output.send(Event::Mode {
|
||||||
flags: flags,
|
flags,
|
||||||
width: mode.width,
|
width: mode.width,
|
||||||
height: mode.height,
|
height: mode.height,
|
||||||
refresh: mode.refresh,
|
refresh: mode.refresh,
|
||||||
|
@ -198,10 +198,10 @@ impl Output {
|
||||||
info!(log, "Creating new wl_output"; "name" => &name);
|
info!(log, "Creating new wl_output"; "name" => &name);
|
||||||
|
|
||||||
let inner = Arc::new(Mutex::new(Inner {
|
let inner = Arc::new(Mutex::new(Inner {
|
||||||
name: name,
|
name,
|
||||||
log: log,
|
log,
|
||||||
instances: Vec::new(),
|
instances: Vec::new(),
|
||||||
physical: physical,
|
physical,
|
||||||
location: (0, 0),
|
location: (0, 0),
|
||||||
transform: Transform::Normal,
|
transform: Transform::Normal,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
|
@ -306,7 +306,7 @@ impl Output {
|
||||||
for output in &inner.instances {
|
for output in &inner.instances {
|
||||||
if let Some(mode) = new_mode {
|
if let Some(mode) = new_mode {
|
||||||
output.send(Event::Mode {
|
output.send(Event::Mode {
|
||||||
flags: flags,
|
flags,
|
||||||
width: mode.width,
|
width: mode.width,
|
||||||
height: mode.height,
|
height: mode.height,
|
||||||
refresh: mode.refresh,
|
refresh: mode.refresh,
|
||||||
|
|
|
@ -102,10 +102,10 @@ impl KbdInternal {
|
||||||
focus: None,
|
focus: None,
|
||||||
pressed_keys: Vec::new(),
|
pressed_keys: Vec::new(),
|
||||||
mods_state: ModifiersState::new(),
|
mods_state: ModifiersState::new(),
|
||||||
keymap: keymap,
|
keymap,
|
||||||
state: state,
|
state,
|
||||||
repeat_rate: repeat_rate,
|
repeat_rate,
|
||||||
repeat_delay: repeat_delay,
|
repeat_delay,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ pub(crate) fn create_keyboard_handler(
|
||||||
Ok(KeyboardHandle {
|
Ok(KeyboardHandle {
|
||||||
arc: Arc::new(KbdArc {
|
arc: Arc::new(KbdArc {
|
||||||
internal: Mutex::new(internal),
|
internal: Mutex::new(internal),
|
||||||
keymap_file: keymap_file,
|
keymap_file,
|
||||||
keymap_len: keymap_data.as_bytes().len() as u32,
|
keymap_len: keymap_data.as_bytes().len() as u32,
|
||||||
logger: log,
|
logger: log,
|
||||||
}),
|
}),
|
||||||
|
@ -349,7 +349,7 @@ impl KeyboardHandle {
|
||||||
});
|
});
|
||||||
|
|
||||||
// set new focus
|
// set new focus
|
||||||
guard.focus = focus.map(|s| s.clone());
|
guard.focus = focus.cloned();
|
||||||
let (dep, la, lo, gr) = guard.serialize_modifiers();
|
let (dep, la, lo, gr) = guard.serialize_modifiers();
|
||||||
let keys = guard.serialize_pressed_keys();
|
let keys = guard.serialize_pressed_keys();
|
||||||
guard.with_focused_kbds(|kbd, surface| {
|
guard.with_focused_kbds(|kbd, surface| {
|
||||||
|
|
|
@ -125,7 +125,7 @@ impl Seat {
|
||||||
let log = ::slog_or_stdlog(logger);
|
let log = ::slog_or_stdlog(logger);
|
||||||
let inner = Arc::new(Mutex::new(Inner {
|
let inner = Arc::new(Mutex::new(Inner {
|
||||||
log: log.new(o!("smithay_module" => "seat_handler", "seat_name" => name.clone())),
|
log: log.new(o!("smithay_module" => "seat_handler", "seat_name" => name.clone())),
|
||||||
name: name,
|
name,
|
||||||
pointer: None,
|
pointer: None,
|
||||||
keyboard: None,
|
keyboard: None,
|
||||||
known_seats: Vec::new(),
|
known_seats: Vec::new(),
|
||||||
|
|
|
@ -138,7 +138,7 @@ impl PointerHandle {
|
||||||
///
|
///
|
||||||
/// A single frame will group multiple scroll events as if they happended in the same instance.
|
/// A single frame will group multiple scroll events as if they happended in the same instance.
|
||||||
/// Dropping the returned `PointerAxisHandle` will group the events together.
|
/// Dropping the returned `PointerAxisHandle` will group the events together.
|
||||||
pub fn axis<'a>(&'a self) -> PointerAxisHandle<'a> {
|
pub fn axis(& self) -> PointerAxisHandle {
|
||||||
PointerAxisHandle {
|
PointerAxisHandle {
|
||||||
inner: self.inner.lock().unwrap(),
|
inner: self.inner.lock().unwrap(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,7 +345,7 @@ where
|
||||||
self::wl_handlers::implement_shell(
|
self::wl_handlers::implement_shell(
|
||||||
shell,
|
shell,
|
||||||
ltoken.clone(),
|
ltoken.clone(),
|
||||||
ctoken.clone(),
|
ctoken,
|
||||||
implementation.clone(),
|
implementation.clone(),
|
||||||
state2.clone(),
|
state2.clone(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -45,17 +45,17 @@ pub(crate) fn implement_shell<U, R, D, Impl>(
|
||||||
surface,
|
surface,
|
||||||
implementation.clone(),
|
implementation.clone(),
|
||||||
ltoken.clone(),
|
ltoken.clone(),
|
||||||
ctoken.clone(),
|
ctoken,
|
||||||
state.clone(),
|
state.clone(),
|
||||||
);
|
);
|
||||||
state
|
state
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.known_surfaces
|
.known_surfaces
|
||||||
.push(make_handle(&shell_surface, ctoken.clone()));
|
.push(make_handle(&shell_surface, ctoken));
|
||||||
implementation.borrow_mut().receive(
|
implementation.borrow_mut().receive(
|
||||||
ShellRequest::NewShellSurface {
|
ShellRequest::NewShellSurface {
|
||||||
surface: make_handle(&shell_surface, ctoken.clone()),
|
surface: make_handle(&shell_surface, ctoken),
|
||||||
},
|
},
|
||||||
(),
|
(),
|
||||||
);
|
);
|
||||||
|
@ -117,7 +117,7 @@ where
|
||||||
if valid {
|
if valid {
|
||||||
user_impl.receive(
|
user_impl.receive(
|
||||||
ShellRequest::Pong {
|
ShellRequest::Pong {
|
||||||
surface: make_handle(&shell_surface, ctoken.clone()),
|
surface: make_handle(&shell_surface, ctoken),
|
||||||
},
|
},
|
||||||
(),
|
(),
|
||||||
);
|
);
|
||||||
|
@ -125,7 +125,7 @@ where
|
||||||
}
|
}
|
||||||
Request::Move { seat, serial } => user_impl.receive(
|
Request::Move { seat, serial } => user_impl.receive(
|
||||||
ShellRequest::Move {
|
ShellRequest::Move {
|
||||||
surface: make_handle(&shell_surface, ctoken.clone()),
|
surface: make_handle(&shell_surface, ctoken),
|
||||||
serial,
|
serial,
|
||||||
seat,
|
seat,
|
||||||
},
|
},
|
||||||
|
@ -137,7 +137,7 @@ where
|
||||||
edges,
|
edges,
|
||||||
} => user_impl.receive(
|
} => user_impl.receive(
|
||||||
ShellRequest::Resize {
|
ShellRequest::Resize {
|
||||||
surface: make_handle(&shell_surface, ctoken.clone()),
|
surface: make_handle(&shell_surface, ctoken),
|
||||||
serial,
|
serial,
|
||||||
seat,
|
seat,
|
||||||
edges,
|
edges,
|
||||||
|
@ -146,7 +146,7 @@ where
|
||||||
),
|
),
|
||||||
Request::SetToplevel => user_impl.receive(
|
Request::SetToplevel => user_impl.receive(
|
||||||
ShellRequest::SetKind {
|
ShellRequest::SetKind {
|
||||||
surface: make_handle(&shell_surface, ctoken.clone()),
|
surface: make_handle(&shell_surface, ctoken),
|
||||||
kind: ShellSurfaceKind::Toplevel,
|
kind: ShellSurfaceKind::Toplevel,
|
||||||
},
|
},
|
||||||
(),
|
(),
|
||||||
|
@ -158,7 +158,7 @@ where
|
||||||
flags,
|
flags,
|
||||||
} => user_impl.receive(
|
} => user_impl.receive(
|
||||||
ShellRequest::SetKind {
|
ShellRequest::SetKind {
|
||||||
surface: make_handle(&shell_surface, ctoken.clone()),
|
surface: make_handle(&shell_surface, ctoken),
|
||||||
kind: ShellSurfaceKind::Transient {
|
kind: ShellSurfaceKind::Transient {
|
||||||
parent,
|
parent,
|
||||||
location: (x, y),
|
location: (x, y),
|
||||||
|
@ -173,7 +173,7 @@ where
|
||||||
output,
|
output,
|
||||||
} => user_impl.receive(
|
} => user_impl.receive(
|
||||||
ShellRequest::SetKind {
|
ShellRequest::SetKind {
|
||||||
surface: make_handle(&shell_surface, ctoken.clone()),
|
surface: make_handle(&shell_surface, ctoken),
|
||||||
kind: ShellSurfaceKind::Fullscreen {
|
kind: ShellSurfaceKind::Fullscreen {
|
||||||
method,
|
method,
|
||||||
framerate,
|
framerate,
|
||||||
|
@ -191,7 +191,7 @@ where
|
||||||
flags,
|
flags,
|
||||||
} => user_impl.receive(
|
} => user_impl.receive(
|
||||||
ShellRequest::SetKind {
|
ShellRequest::SetKind {
|
||||||
surface: make_handle(&shell_surface, ctoken.clone()),
|
surface: make_handle(&shell_surface, ctoken),
|
||||||
kind: ShellSurfaceKind::Popup {
|
kind: ShellSurfaceKind::Popup {
|
||||||
parent,
|
parent,
|
||||||
serial,
|
serial,
|
||||||
|
@ -204,7 +204,7 @@ where
|
||||||
),
|
),
|
||||||
Request::SetMaximized { output } => user_impl.receive(
|
Request::SetMaximized { output } => user_impl.receive(
|
||||||
ShellRequest::SetKind {
|
ShellRequest::SetKind {
|
||||||
surface: make_handle(&shell_surface, ctoken.clone()),
|
surface: make_handle(&shell_surface, ctoken),
|
||||||
kind: ShellSurfaceKind::Maximized { output },
|
kind: ShellSurfaceKind::Maximized { output },
|
||||||
},
|
},
|
||||||
(),
|
(),
|
||||||
|
|
|
@ -221,7 +221,7 @@ pub struct ToplevelState {
|
||||||
impl Clone for ToplevelState {
|
impl Clone for ToplevelState {
|
||||||
fn clone(&self) -> ToplevelState {
|
fn clone(&self) -> ToplevelState {
|
||||||
ToplevelState {
|
ToplevelState {
|
||||||
parent: self.parent.as_ref().map(|p| p.clone()),
|
parent: self.parent.as_ref().cloned(),
|
||||||
title: self.title.clone(),
|
title: self.title.clone(),
|
||||||
app_id: self.app_id.clone(),
|
app_id: self.app_id.clone(),
|
||||||
min_size: self.min_size,
|
min_size: self.min_size,
|
||||||
|
@ -242,7 +242,7 @@ pub struct PopupState {
|
||||||
impl Clone for PopupState {
|
impl Clone for PopupState {
|
||||||
fn clone(&self) -> PopupState {
|
fn clone(&self) -> PopupState {
|
||||||
PopupState {
|
PopupState {
|
||||||
parent: self.parent.as_ref().map(|p| p.clone()),
|
parent: self.parent.as_ref().cloned(),
|
||||||
positioner: self.positioner.clone(),
|
positioner: self.positioner.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ impl<U, R, SD> Clone for ShellImplementation<U, R, SD> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
ShellImplementation {
|
ShellImplementation {
|
||||||
log: self.log.clone(),
|
log: self.log.clone(),
|
||||||
compositor_token: self.compositor_token.clone(),
|
compositor_token: self.compositor_token,
|
||||||
loop_token: self.loop_token.clone(),
|
loop_token: self.loop_token.clone(),
|
||||||
user_impl: self.user_impl.clone(),
|
user_impl: self.user_impl.clone(),
|
||||||
shell_state: self.shell_state.clone(),
|
shell_state: self.shell_state.clone(),
|
||||||
|
|
|
@ -449,7 +449,7 @@ fn make_toplevel_handle<U, R, SD>(
|
||||||
super::ToplevelSurface {
|
super::ToplevelSurface {
|
||||||
wl_surface: wl_surface.clone(),
|
wl_surface: wl_surface.clone(),
|
||||||
shell_surface: ToplevelKind::Xdg(resource.clone()),
|
shell_surface: ToplevelKind::Xdg(resource.clone()),
|
||||||
token: token,
|
token,
|
||||||
_shell_data: ::std::marker::PhantomData,
|
_shell_data: ::std::marker::PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -650,7 +650,7 @@ fn make_popup_handle<U, R, SD>(
|
||||||
super::PopupSurface {
|
super::PopupSurface {
|
||||||
wl_surface: wl_surface.clone(),
|
wl_surface: wl_surface.clone(),
|
||||||
shell_surface: PopupKind::Xdg(resource.clone()),
|
shell_surface: PopupKind::Xdg(resource.clone()),
|
||||||
token: token,
|
token,
|
||||||
_shell_data: ::std::marker::PhantomData,
|
_shell_data: ::std::marker::PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -466,7 +466,7 @@ fn make_toplevel_handle<U, R, SD>(
|
||||||
super::ToplevelSurface {
|
super::ToplevelSurface {
|
||||||
wl_surface: wl_surface.clone(),
|
wl_surface: wl_surface.clone(),
|
||||||
shell_surface: ToplevelKind::ZxdgV6(resource.clone()),
|
shell_surface: ToplevelKind::ZxdgV6(resource.clone()),
|
||||||
token: token,
|
token,
|
||||||
_shell_data: ::std::marker::PhantomData,
|
_shell_data: ::std::marker::PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -671,7 +671,7 @@ fn make_popup_handle<U, R, SD>(
|
||||||
super::PopupSurface {
|
super::PopupSurface {
|
||||||
wl_surface: wl_surface.clone(),
|
wl_surface: wl_surface.clone(),
|
||||||
shell_surface: PopupKind::ZxdgV6(resource.clone()),
|
shell_surface: PopupKind::ZxdgV6(resource.clone()),
|
||||||
token: token,
|
token,
|
||||||
_shell_data: ::std::marker::PhantomData,
|
_shell_data: ::std::marker::PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,11 +249,11 @@ impl Implementation<Resource<wl_shm_pool::WlShmPool>, wl_shm_pool::Request> for
|
||||||
let data = Box::into_raw(Box::new(InternalBufferData {
|
let data = Box::into_raw(Box::new(InternalBufferData {
|
||||||
pool: arc_pool.clone(),
|
pool: arc_pool.clone(),
|
||||||
data: BufferData {
|
data: BufferData {
|
||||||
offset: offset,
|
offset,
|
||||||
width: width,
|
width,
|
||||||
height: height,
|
height,
|
||||||
stride: stride,
|
stride,
|
||||||
format: format,
|
format,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
let buffer = buffer.implement_nonsend(
|
let buffer = buffer.implement_nonsend(
|
||||||
|
|
|
@ -28,8 +28,8 @@ impl Pool {
|
||||||
trace!(log, "Creating new shm pool"; "fd" => fd as i32, "size" => size);
|
trace!(log, "Creating new shm pool"; "fd" => fd as i32, "size" => size);
|
||||||
Ok(Pool {
|
Ok(Pool {
|
||||||
map: RwLock::new(memmap),
|
map: RwLock::new(memmap),
|
||||||
fd: fd,
|
fd,
|
||||||
log: log,
|
log,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +100,8 @@ impl MemMap {
|
||||||
fn new(fd: RawFd, size: usize) -> Result<MemMap, ()> {
|
fn new(fd: RawFd, size: usize) -> Result<MemMap, ()> {
|
||||||
Ok(MemMap {
|
Ok(MemMap {
|
||||||
ptr: unsafe { map(fd, size) }?,
|
ptr: unsafe { map(fd, size) }?,
|
||||||
fd: fd,
|
fd,
|
||||||
size: size,
|
size,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub(crate) fn prepare_x11_sockets(log: ::slog::Logger) -> Result<(X11Lock, [Unix
|
||||||
}
|
}
|
||||||
// If we reach here, all values from 0 to 32 failed
|
// If we reach here, all values from 0 to 32 failed
|
||||||
// we need to stop trying at some point
|
// we need to stop trying at some point
|
||||||
return Err(());
|
Err(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct X11Lock {
|
pub(crate) struct X11Lock {
|
||||||
|
@ -40,15 +40,15 @@ impl X11Lock {
|
||||||
Ok(mut file) => {
|
Ok(mut file) => {
|
||||||
// we got it, write our PID in it and we're good
|
// we got it, write our PID in it and we're good
|
||||||
let ret = file.write_fmt(format_args!("{:>10}", ::nix::unistd::Pid::this()));
|
let ret = file.write_fmt(format_args!("{:>10}", ::nix::unistd::Pid::this()));
|
||||||
if let Err(_) = ret {
|
if ret.is_err() {
|
||||||
// write to the file failed ? we abandon
|
// write to the file failed ? we abandon
|
||||||
::std::mem::drop(file);
|
::std::mem::drop(file);
|
||||||
let _ = ::std::fs::remove_file(&filename);
|
let _ = ::std::fs::remove_file(&filename);
|
||||||
return Err(());
|
Err(())
|
||||||
} else {
|
} else {
|
||||||
debug!(log, "X11 lock aquired"; "D" => display);
|
debug!(log, "X11 lock aquired"; "D" => display);
|
||||||
// we got the lockfile and wrote our pid to it, all is good
|
// we got the lockfile and wrote our pid to it, all is good
|
||||||
return Ok(X11Lock { display, log });
|
Ok(X11Lock { display, log })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
@ -79,7 +79,7 @@ impl X11Lock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if we reach here, this lockfile exists and is probably in use, give up
|
// if we reach here, this lockfile exists and is probably in use, give up
|
||||||
return Err(());
|
Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue