anvil: address some clippy warnings
This commit is contained in:
parent
ad038b4a07
commit
73ff30b0ee
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue