From 96ad7bf6cf3ae67bb0bebb18eb6b11d2d8d61c30 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sun, 30 Sep 2018 17:17:51 -0500 Subject: [PATCH] i think i fixed it --- Cargo.lock | 2 +- src/capture.rs | 1 - src/gui.rs | 15 ++++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cbd1c5c..e6746c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -367,7 +367,7 @@ dependencies = [ [[package]] name = "leanshot" -version = "0.3.1" +version = "0.3.2" dependencies = [ "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "gl 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/capture.rs b/src/capture.rs index 662e77f..cd98fa4 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -12,7 +12,6 @@ pub fn capture(opt: &Options) -> Result<(), ScreenshotError> { _ => gui.display.get_default_root_window()?, }; - println!("{}", window_to_capture.as_raw()); let capture = gui.capture_window(&opt, window_to_capture)?; capture.save_image(&opt.outfile)?; diff --git a/src/gui.rs b/src/gui.rs index a8eb183..7ff5f8a 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -23,7 +23,6 @@ impl GUI { let mut height = attr.get_height(); let root = attr.get_root(); let (mut x, mut y, _) = self.display.translate_coordinates(window, 0, 0, root)?; - println!("{} {}", window.as_raw(), root.as_raw()); imlib2::context_set_display(&self.display); let visual = Visual::default(&self.display, 0); @@ -89,7 +88,7 @@ impl GUI { use gl; use glutin::{ self, - dpi::LogicalSize, + dpi::{PhysicalSize, PhysicalPosition}, os::unix::{WindowBuilderExt, WindowExt, XWindowType}, ElementState, Event, EventsLoop, GlContext, GlWindow, KeyboardInput, MouseButton, MouseCursor, VirtualKeyCode, WindowBuilder, WindowEvent, @@ -112,8 +111,9 @@ impl GUI { let wb = WindowBuilder::new() .with_x11_window_type(XWindowType::Splash) .with_decorations(false) + .with_visibility(false) .with_always_on_top(true) - .with_dimensions(LogicalSize::new(width.into(), height.into())) + .with_dimensions(PhysicalSize::new(width.into(), height.into()).to_logical(mon.get_hidpi_factor())) .with_fullscreen(Some(mon)); let ctx = glutin::ContextBuilder::new() .with_vsync(false) @@ -135,20 +135,16 @@ impl GUI { let raw_data; { let _g = x.grab(); - println!("grabbed"); // let img = Image2::create_from_drawable(window, 0, 0, 0, width as i32, height as i32, true)?; imlib2::context_set_image(&capture); - println!("set contexted"); len = (width * height) as usize; // println!("{}", window.as_raw()); raw_data = unsafe { slice::from_raw_parts(imlib2::image_get_data(), len) }; - println!("captured"); unsafe { win.make_current().expect("couldn't make window"); gl::load_with(|sym| win.get_proc_address(sym) as *const _); } - println!("maked"); } mem::forget(x); @@ -193,6 +189,9 @@ impl GUI { let mut recth = 0.0f64; let mut delayed_down = false; let mut redraw = true; + + win.show(); + win.set_position(PhysicalPosition::new(0.0, 0.0).to_logical(f)); while running { if redraw { // let size = win.get_inner_size().unwrap(); @@ -267,6 +266,8 @@ impl GUI { (Some(VirtualKeyCode::Escape), ElementState::Released) => { if down { down = false; + rectw = 0.0; + recth = 0.0; } else { running = false; }