cargo clippy + cargo fmt

This commit is contained in:
Michael Zhang 2020-06-15 21:25:28 -05:00
parent f6a1d572f5
commit 15220bed4b
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
8 changed files with 601 additions and 558 deletions

996
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
[package]
name = "leanshot"
description = "Screenshot capture for Linux."
version = "0.3.3"
version = "0.4.0"
repository = "https://github.com/iptq/leanshot"
license-file = "LICENSE"
authors = ["Michael Zhang <failed.down@gmail.com>"]
@ -14,7 +14,7 @@ failure = "0.1"
gl = "0.11"
glutin = "0.19"
imlib2 = { version = "0.1", path = "./imlib2" }
leanshot_xlib = { version = "0.1", path = "./xlib" }
leanshot_xlib = { version = "0.2", path = "./xlib" }
nanovg = { version = "1.0.2", features = ["gl3"] }
png = "0.14"
structopt = "0.2"

View file

@ -8,4 +8,4 @@ authors = ["Michael Zhang <failed.down@gmail.com>"]
[dependencies]
failure = "0.1"
imlib2-sys = { version = "0.1", path = "imlib2-sys" }
leanshot_xlib = { version = "0.1", path = "../xlib" }
leanshot_xlib = { version = "0.2", path = "../xlib" }

View file

@ -1,8 +1,8 @@
use crate::errors::ScreenshotError;
use crate::gui::GUI;
use imlib2;
use crate::options::{Options, Region};
use imlib2;
/// The main capture routine.
pub fn capture(opt: &Options) -> Result<(), ScreenshotError> {

View file

@ -1,5 +1,5 @@
use imlib2::{self, Image as Image2};
use crate::xlib::{Display, Visual, Window};
use imlib2::{self, Image as Image2};
use crate::errors::ScreenshotError;
use crate::Options;
@ -24,7 +24,6 @@ impl GUI {
let root = attr.get_root();
let (x, y, _) = self.display.translate_coordinates(window, 0, 0, root)?;
imlib2::context_set_display(&self.display);
let visual = Visual::default(&self.display, 0);
imlib2::context_set_visual(&visual);
@ -80,17 +79,14 @@ impl GUI {
// }
// }
use gl;
use glutin::{
self,
dpi::{PhysicalPosition, PhysicalSize},
os::unix::{WindowBuilderExt, WindowExt, XWindowType},
ElementState, Event, EventsLoop, GlContext, GlWindow, KeyboardInput, MouseButton,
MouseCursor, VirtualKeyCode, WindowBuilder, WindowEvent,
};
use nanovg::{self, Image, ImagePattern, PathOptions, StrokeOptions};
use nanovg::{Image, ImagePattern, PathOptions, StrokeOptions};
use std::{f32::consts, mem, slice};
use x11;
// let attr = window.get_attributes()?;
// let width = attr.get_width();
@ -249,8 +245,9 @@ impl GUI {
});
}
evl.poll_events(|event| match event {
Event::WindowEvent { event, .. } => match event {
evl.poll_events(|event| {
if let Event::WindowEvent { event, .. } = event {
match event {
WindowEvent::Destroyed => running = false,
WindowEvent::KeyboardInput {
input:
@ -260,8 +257,10 @@ impl GUI {
..
},
..
} => match (virtual_keycode, state) {
(Some(VirtualKeyCode::Escape), ElementState::Released) => {
} => {
if let (Some(VirtualKeyCode::Escape), ElementState::Released) =
(virtual_keycode, state)
{
if down {
down = false;
rectw = 0.0;
@ -276,8 +275,7 @@ impl GUI {
running = false;
}
}
_ => (),
},
}
WindowEvent::CursorMoved { position, .. } => {
mx = position.x;
my = position.y;
@ -293,8 +291,8 @@ impl GUI {
recth = my - dy;
}
}
WindowEvent::MouseInput { button, state, .. } => match button {
MouseButton::Left => {
WindowEvent::MouseInput { button, state, .. } => {
if let MouseButton::Left = button {
down = match state {
ElementState::Pressed => {
delayed_down = true;
@ -317,13 +315,12 @@ impl GUI {
}
false
}
};
}
}
}
_ => (),
},
_ => (),
},
_ => (),
}
}
});
win.swap_buffers().expect("couldn't swap buffers");
}

View file

@ -21,8 +21,8 @@ mod gui;
mod options;
use crate::errors::ScreenshotError;
use structopt::StructOpt;
use crate::xlib::Rectangle;
use structopt::StructOpt;
pub use crate::capture::capture;
pub use crate::options::{Options, Region};

View file

@ -10,7 +10,7 @@ pub enum Region {
Selection,
}
/// Optiosn for screenshot
/// Options for screenshot
#[derive(StructOpt)]
pub struct Options {
/// The region to select (fullscreen | window | select)

View file

@ -1,6 +1,6 @@
[package]
name = "leanshot_xlib"
version = "0.1.1"
version = "0.2.0"
description = "xlib bindings"
license-file = "../LICENSE"
authors = ["Michael Zhang <failed.down@gmail.com>"]