From f6a1d572f5ccda41d263531ea4cf755c006e94f4 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Mon, 15 Jun 2020 21:10:08 -0500 Subject: [PATCH] cargo fix --- Cargo.lock | 2 ++ src/capture.rs | 6 +++--- src/errors.rs | 6 +++--- src/gui.rs | 19 +++++++++++-------- src/main.rs | 8 ++++---- src/options.rs | 2 +- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 960d3be..dba527e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "adler32" version = "1.0.3" diff --git a/src/capture.rs b/src/capture.rs index 1a56446..fb04491 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -1,8 +1,8 @@ -use errors::ScreenshotError; +use crate::errors::ScreenshotError; -use gui::GUI; +use crate::gui::GUI; use imlib2; -use options::{Options, Region}; +use crate::options::{Options, Region}; /// The main capture routine. pub fn capture(opt: &Options) -> Result<(), ScreenshotError> { diff --git a/src/errors.rs b/src/errors.rs index 4454c95..f317941 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,7 +1,7 @@ #[derive(Debug, Fail)] pub enum ScreenshotError { #[fail(display = "x11 error")] - X11Error(#[cause] ::xlib::X11Error), + X11Error(#[cause] crate::xlib::X11Error), #[fail(display = "imlib2 error")] ImlibError(#[cause] ::imlib2::Error), @@ -22,8 +22,8 @@ impl From<::std::io::Error> for ScreenshotError { } } -impl From<::xlib::X11Error> for ScreenshotError { - fn from(err: ::xlib::X11Error) -> Self { +impl From for ScreenshotError { + fn from(err: crate::xlib::X11Error) -> Self { ScreenshotError::X11Error(err) } } diff --git a/src/gui.rs b/src/gui.rs index 669deac..0a9f12d 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -1,10 +1,10 @@ use imlib2::{self, Image as Image2}; -use xlib::{Display, Visual, Window}; +use crate::xlib::{Display, Visual, Window}; -use errors::ScreenshotError; -use Options; -use Rectangle; -use Region; +use crate::errors::ScreenshotError; +use crate::Options; +use crate::Rectangle; +use crate::Region; pub struct GUI { pub(crate) display: Display, @@ -24,6 +24,7 @@ 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); @@ -38,7 +39,8 @@ impl GUI { region.y, region.width, 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) @@ -87,8 +89,8 @@ impl GUI { MouseCursor, VirtualKeyCode, WindowBuilder, WindowEvent, }; use nanovg::{self, Image, ImagePattern, PathOptions, StrokeOptions}; - use x11; use std::{f32::consts, mem, slice}; + use x11; // let attr = window.get_attributes()?; // let width = attr.get_width(); @@ -109,7 +111,8 @@ impl GUI { .with_always_on_top(true) .with_dimensions( 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() .with_vsync(false) .with_multisampling(4) diff --git a/src/main.rs b/src/main.rs index 4bcca40..d9a9c03 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,12 +20,12 @@ mod errors; mod gui; mod options; -use errors::ScreenshotError; +use crate::errors::ScreenshotError; use structopt::StructOpt; -use xlib::Rectangle; +use crate::xlib::Rectangle; -pub use capture::capture; -pub use options::{Options, Region}; +pub use crate::capture::capture; +pub use crate::options::{Options, Region}; use failure::Error; diff --git a/src/options.rs b/src/options.rs index d558028..092dba1 100644 --- a/src/options.rs +++ b/src/options.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use ScreenshotError; +use crate::ScreenshotError; /// A region option #[allow(missing_docs)]