cargo fix

This commit is contained in:
Michael Zhang 2020-06-15 21:10:08 -05:00
parent 5b7e0c98a7
commit f6a1d572f5
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
6 changed files with 24 additions and 19 deletions

2
Cargo.lock generated
View file

@ -1,3 +1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]] [[package]]
name = "adler32" name = "adler32"
version = "1.0.3" version = "1.0.3"

View file

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

View file

@ -1,7 +1,7 @@
#[derive(Debug, Fail)] #[derive(Debug, Fail)]
pub enum ScreenshotError { pub enum ScreenshotError {
#[fail(display = "x11 error")] #[fail(display = "x11 error")]
X11Error(#[cause] ::xlib::X11Error), X11Error(#[cause] crate::xlib::X11Error),
#[fail(display = "imlib2 error")] #[fail(display = "imlib2 error")]
ImlibError(#[cause] ::imlib2::Error), ImlibError(#[cause] ::imlib2::Error),
@ -22,8 +22,8 @@ impl From<::std::io::Error> for ScreenshotError {
} }
} }
impl From<::xlib::X11Error> for ScreenshotError { impl From<crate::xlib::X11Error> for ScreenshotError {
fn from(err: ::xlib::X11Error) -> Self { fn from(err: crate::xlib::X11Error) -> Self {
ScreenshotError::X11Error(err) ScreenshotError::X11Error(err)
} }
} }

View file

@ -1,10 +1,10 @@
use imlib2::{self, Image as Image2}; use imlib2::{self, Image as Image2};
use xlib::{Display, Visual, Window}; use crate::xlib::{Display, Visual, Window};
use errors::ScreenshotError; use crate::errors::ScreenshotError;
use Options; use crate::Options;
use Rectangle; use crate::Rectangle;
use Region; use crate::Region;
pub struct GUI { pub struct GUI {
pub(crate) display: Display, pub(crate) display: Display,
@ -24,6 +24,7 @@ impl GUI {
let root = attr.get_root(); let root = attr.get_root();
let (x, y, _) = self.display.translate_coordinates(window, 0, 0, root)?; let (x, y, _) = self.display.translate_coordinates(window, 0, 0, root)?;
imlib2::context_set_display(&self.display); imlib2::context_set_display(&self.display);
let visual = Visual::default(&self.display, 0); let visual = Visual::default(&self.display, 0);
imlib2::context_set_visual(&visual); imlib2::context_set_visual(&visual);
@ -38,7 +39,8 @@ impl GUI {
region.y, region.y,
region.width, region.width,
region.height, region.height,
).map_err(|err| err.into()); )
.map_err(|err| err.into());
} }
Image2::create_from_drawable(window, 0, x, y, width as i32, height as i32, true) Image2::create_from_drawable(window, 0, x, y, width as i32, height as i32, true)
@ -87,8 +89,8 @@ impl GUI {
MouseCursor, VirtualKeyCode, WindowBuilder, WindowEvent, MouseCursor, VirtualKeyCode, WindowBuilder, WindowEvent,
}; };
use nanovg::{self, Image, ImagePattern, PathOptions, StrokeOptions}; use nanovg::{self, Image, ImagePattern, PathOptions, StrokeOptions};
use x11;
use std::{f32::consts, mem, slice}; use std::{f32::consts, mem, slice};
use x11;
// let attr = window.get_attributes()?; // let attr = window.get_attributes()?;
// let width = attr.get_width(); // let width = attr.get_width();
@ -109,7 +111,8 @@ impl GUI {
.with_always_on_top(true) .with_always_on_top(true)
.with_dimensions( .with_dimensions(
PhysicalSize::new(width.into(), height.into()).to_logical(mon.get_hidpi_factor()), PhysicalSize::new(width.into(), height.into()).to_logical(mon.get_hidpi_factor()),
).with_fullscreen(Some(mon)); )
.with_fullscreen(Some(mon));
let ctx = glutin::ContextBuilder::new() let ctx = glutin::ContextBuilder::new()
.with_vsync(false) .with_vsync(false)
.with_multisampling(4) .with_multisampling(4)

View file

@ -20,12 +20,12 @@ mod errors;
mod gui; mod gui;
mod options; mod options;
use errors::ScreenshotError; use crate::errors::ScreenshotError;
use structopt::StructOpt; use structopt::StructOpt;
use xlib::Rectangle; use crate::xlib::Rectangle;
pub use capture::capture; pub use crate::capture::capture;
pub use options::{Options, Region}; pub use crate::options::{Options, Region};
use failure::Error; use failure::Error;

View file

@ -1,6 +1,6 @@
use std::path::PathBuf; use std::path::PathBuf;
use ScreenshotError; use crate::ScreenshotError;
/// A region option /// A region option
#[allow(missing_docs)] #[allow(missing_docs)]