From 77393ca68c398e1c02d5789119f8bf386e48b5e4 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Fri, 26 Jun 2020 13:51:31 -0500 Subject: [PATCH] push some restructure --- .editorconfig | 9 + .travis.yml | 44 - Cargo.lock | 1102 ++++-------------------- Cargo.toml | 23 +- LICENSE | 2 +- imlib2/Cargo.toml | 11 - imlib2/imlib2-sys/Cargo.toml | 13 - imlib2/imlib2-sys/build.rs | 20 - imlib2/imlib2-sys/lib.rs | 5 - imlib2/imlib2-sys/wrapper.h | 1 - imlib2/src/errors.rs | 7 - imlib2/src/image.rs | 77 -- imlib2/src/lib.rs | 70 -- src/capture.rs | 22 - src/errors.rs | 41 - src/gui.rs | 367 +------- src/lib.rs | 42 + src/main.rs | 35 +- src/old.rs | 279 ++++++ src/options.rs | 6 +- src/platform/mod.rs | 21 + src/platform/x11.rs | 55 ++ x11/Cargo.toml | 16 + x11/src/errors.rs | 27 + x11/src/lib.rs | 18 + {xlib => x11}/src/rect.rs | 0 {xlib/src => x11/src/xlib}/atom.rs | 22 +- x11/src/xlib/cursor.rs | 13 + {xlib/src => x11/src/xlib}/display.rs | 81 +- {xlib/src => x11/src/xlib}/drawable.rs | 16 +- {xlib/src => x11/src/xlib}/event.rs | 9 +- {xlib/src => x11/src/xlib}/image.rs | 16 +- x11/src/xlib/mod.rs | 23 + {xlib/src => x11/src/xlib}/visual.rs | 10 +- {xlib/src => x11/src/xlib}/window.rs | 73 +- x11/src/xrender/mod.rs | 1 + x11/src/xrender/picture.rs | 7 + xlib/Cargo.toml | 11 - xlib/src/cursor.rs | 13 - xlib/src/cursorfont.rs | 5 - xlib/src/errors.rs | 25 - xlib/src/lib.rs | 35 - 42 files changed, 870 insertions(+), 1803 deletions(-) create mode 100644 .editorconfig delete mode 100644 .travis.yml delete mode 100644 imlib2/Cargo.toml delete mode 100644 imlib2/imlib2-sys/Cargo.toml delete mode 100644 imlib2/imlib2-sys/build.rs delete mode 100644 imlib2/imlib2-sys/lib.rs delete mode 100644 imlib2/imlib2-sys/wrapper.h delete mode 100644 imlib2/src/errors.rs delete mode 100644 imlib2/src/image.rs delete mode 100644 imlib2/src/lib.rs delete mode 100644 src/capture.rs delete mode 100644 src/errors.rs create mode 100644 src/lib.rs create mode 100644 src/old.rs create mode 100644 src/platform/mod.rs create mode 100644 src/platform/x11.rs create mode 100644 x11/Cargo.toml create mode 100644 x11/src/errors.rs create mode 100644 x11/src/lib.rs rename {xlib => x11}/src/rect.rs (100%) rename {xlib/src => x11/src/xlib}/atom.rs (54%) create mode 100644 x11/src/xlib/cursor.rs rename {xlib/src => x11/src/xlib}/display.rs (60%) rename {xlib/src => x11/src/xlib}/drawable.rs (61%) rename {xlib/src => x11/src/xlib}/event.rs (78%) rename {xlib/src => x11/src/xlib}/image.rs (80%) create mode 100644 x11/src/xlib/mod.rs rename {xlib/src => x11/src/xlib}/visual.rs (55%) rename {xlib/src => x11/src/xlib}/window.rs (69%) create mode 100644 x11/src/xrender/mod.rs create mode 100644 x11/src/xrender/picture.rs delete mode 100644 xlib/Cargo.toml delete mode 100644 xlib/src/cursor.rs delete mode 100644 xlib/src/cursorfont.rs delete mode 100644 xlib/src/errors.rs delete mode 100644 xlib/src/lib.rs diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4266da6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_file = lf +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 +indent_style = space +indent_size = 4 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 33ca80a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -language: rust -sudo: false -cache: cargo -dist: trusty - -addons: - apt: - packages: - - libx11-dev - - libimlib2-dev - - build-essential - - mesa-common-dev - -env: - global: - - PROJECT_NAME=leanshot - -matrix: - include: - - os: linux - rust: stable - env: TARGET=x86_64-unknown-linux-gnu - fast_finish: true - -before_script: rustup target add $TARGET || echo ok -script: - - if [ -z "$TRAVIS_TAG" ]; then cargo check --all --target $TARGET; fi - -before_deploy: ./ci/package $TRAVIS_TAG $TARGET - -deploy: - - provider: releases - api_key: - secure: ZCA3+LjTzliSC3m9DjcEYZOsRhaI5r9LAHfuw5HuaLYbprbEVwqLCTV1ioe7F9dLPembqGoGEsVnWAsrAUP0C9BRUuOrZMYvTOS3qTwSX7pPc/fsNUzP9uc6XPIMQ7/QeakmpgVYvObt9/1Wxui715nPmj9h+YIB4P3BUT8VsufzG0LogNSTwkhicM19O9oFhoCg39qQBueBe2SrS35dqvofSoJlEk2wSBBesQ9xuw9goP8ZkTKD3w/ZmPUS9RuWi1FSzsUcnLGCEMwYxLk9CBnG9I0G8kvDF194UYq7YnlaK4sn4AG5UxkMYcWN573vb+KX56VoHa57Z7qNIoUy1Kk0MatIjPIxd2LQJSTl7I5sckfoq61wihRYYj8R1qI4V4mqBX+MHFwyfs7/XT2pVfPHeflvJ4MMZW5t+OYWv8LfwFgufbLyYS79ZkBIjVnk2ligSv8kSPcuTtnSzp6UJlHsEbRDlWcciAYA92d2bggz7BrSG+X1eDAVto+bGdAeAp5zgRPVKwbpA9aD52y2GmlMh4Z+GcjhF6U7z+2AYRalH9X8d4mSdQ7KuhFfigoR/84tO+kC5QeKnf3FfgXPzOimt8xCsd2MFDrg2sPvgFkQGyM0ihB9NnNBfiFrQrRP3+DyTCI3TqOfkz8QKe4h7DxefR1t+YvheNZjGtC8C+E= - file_glob: true - file: - - leanshot-* - on: - condition: $TRAVIS_RUST_VERSION = stable - tags: true - skip_cleanup: true - -notifications: - email: false diff --git a/Cargo.lock b/Cargo.lock index 0de5d7a..990754c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,44 +1,10 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "addr2line" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gimli 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "adler32" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "aho-corasick" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "andrew" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "line_drawing 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rusttype 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "xml-rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "android_glue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "ansi_term" version = "0.11.0" @@ -48,12 +14,9 @@ dependencies = [ ] [[package]] -name = "approx" -version = "0.3.2" +name = "anyhow" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "atty" @@ -65,58 +28,19 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "autocfg" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "backtrace" -version = "0.3.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "addr2line 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "object 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bindgen" -version = "0.47.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cexpr 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "clang-sys 0.26.4 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.33.1 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "bitflags" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "block" -version = "0.1.6" +name = "bytemuck" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -124,43 +48,11 @@ name = "byteorder" version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "cc" -version = "1.0.54" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cexpr" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "cgl" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gleam 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "clang-sys" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "clap" version = "2.33.1" @@ -176,50 +68,60 @@ dependencies = [ ] [[package]] -name = "cloudabi" -version = "0.0.3" +name = "color_quant" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "crc32fast" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "cocoa" -version = "0.18.5" +name = "crossbeam-deque" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", - "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "core-foundation" -version = "0.6.4" +name = "crossbeam-epoch" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "core-foundation-sys" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "core-graphics" -version = "0.17.3" +name = "crossbeam-queue" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -232,143 +134,26 @@ dependencies = [ ] [[package]] -name = "dlib" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libloading 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "downcast-rs" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "env_logger" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace 0.3.49 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "gimli" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "gl" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gl_generator 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "gl_generator" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "khronos_api 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "xml-rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "gl_generator" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "khronos_api 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "xml-rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "gleam" -version = "0.6.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "glob" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "glutin" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cgl 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cocoa 0.18.5 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gl_generator 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-client 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winit 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)", - "x11-dl 2.18.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "hashbrown" -version = "0.1.8" +name = "deflate" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "adler32 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "either" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "gif" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "color_quant 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -388,27 +173,20 @@ dependencies = [ ] [[package]] -name = "humantime" -version = "1.3.0" +name = "image" +version = "0.23.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "imlib2" -version = "0.1.1" -dependencies = [ - "failure 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "imlib2-sys 0.1.0", - "leanshot_xlib 0.2.0", -] - -[[package]] -name = "imlib2-sys" -version = "0.1.0" -dependencies = [ - "bindgen 0.47.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bytemuck 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "gif 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jpeg-decoder 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "num-iter 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-rational 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "png 0.16.5 (registry+https://github.com/rust-lang/crates.io-index)", + "scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tiff 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -420,9 +198,13 @@ dependencies = [ ] [[package]] -name = "khronos_api" -version = "3.1.0" +name = "jpeg-decoder" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "lazy_static" @@ -433,24 +215,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "leanshot" version = "0.4.0" dependencies = [ - "failure 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "gl 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glutin 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", - "imlib2 0.1.1", - "leanshot_xlib 0.2.0", - "nanovg 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", + "image 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)", + "leanshot_x11 0.2.0", "png 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "x11 2.18.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "leanshot_xlib" +name = "leanshot_x11" version = "0.2.0" dependencies = [ - "failure 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", "x11 2.18.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -460,54 +237,9 @@ version = "0.2.71" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "libloading" -version = "0.5.2" +name = "lzw" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.54 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "libloading" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "line_drawing" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lock_api" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "owning_ref 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "malloc_buf" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "maybe-uninit" @@ -515,17 +247,11 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "memchr" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "memmap" -version = "0.7.0" +name = "memoffset" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -536,44 +262,6 @@ dependencies = [ "adler32 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nanovg" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nanovg-sys 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "nanovg-sys" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.54 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "nix" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.54 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "nom" -version = "4.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "num-integer" version = "0.1.43" @@ -593,6 +281,16 @@ dependencies = [ "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "num-rational" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num-traits" version = "0.2.12" @@ -602,73 +300,14 @@ dependencies = [ ] [[package]] -name = "objc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "object" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ordered-float" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "osmesa-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "owning_ref" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot_core" -version = "0.4.0" +name = "num_cpus" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "hermit-abi 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "pkg-config" version = "0.3.17" @@ -685,6 +324,17 @@ dependencies = [ "num-iter 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "png" +version = "0.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "deflate 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "proc-macro2" version = "0.4.30" @@ -701,11 +351,6 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "quote" version = "0.6.13" @@ -723,228 +368,38 @@ dependencies = [ ] [[package]] -name = "rand" -version = "0.6.5" +name = "rayon" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon-core 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "rand_chacha" -version = "0.1.1" +name = "rayon-core" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-queue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "rand_core" -version = "0.3.1" +name = "scoped_threadpool" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex" -version = "1.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex-syntax" -version = "0.6.18" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rusttype" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rusttype 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rusttype" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "approx 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "stb_truetype 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "scopeguard" -version = "0.3.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "shared_library" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "smallvec" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "smithay-client-toolkit" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "andrew 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "dlib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-client 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-commons 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-protocols 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stable_deref_trait" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "stb_truetype" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "strsim" version = "0.8.0" @@ -990,25 +445,6 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "synstructure" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "termcolor" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "textwrap" version = "0.11.0" @@ -1018,20 +454,31 @@ dependencies = [ ] [[package]] -name = "thread_local" -version = "1.0.1" +name = "thiserror" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror-impl 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "time" -version = "0.1.43" +name = "thiserror-impl" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tiff" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1059,89 +506,6 @@ name = "vec_map" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "walkdir" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wayland-client" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "downcast-rs 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-commons 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-scanner 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-sys 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wayland-commons" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-sys 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wayland-protocols" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-client 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-commons 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-scanner 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-sys 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wayland-scanner" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "xml-rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wayland-sys" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "dlib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "which" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "failure 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "winapi" version = "0.3.8" @@ -1156,41 +520,11 @@ name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "winit" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "backtrace 0.3.49 (registry+https://github.com/rust-lang/crates.io-index)", - "cocoa 0.18.5 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "smithay-client-toolkit 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-client 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "x11-dl 2.18.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "x11" version = "2.18.2" @@ -1200,167 +534,69 @@ dependencies = [ "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "x11-dl" -version = "2.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "xdg" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "xml-rs" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [metadata] -"checksum addr2line 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a49806b9dadc843c61e7c97e72490ad7f7220ae249012fbda9ad0609457c0543" "checksum adler32 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d" -"checksum aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada" -"checksum andrew 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e" -"checksum android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum approx 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" +"checksum anyhow 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb70cc08ec97ca5450e6eba421deeea5f172c0fc61f78b5357b2a8e8be195f" "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" -"checksum backtrace 0.3.49 (registry+https://github.com/rust-lang/crates.io-index)" = "05100821de9e028f12ae3d189176b41ee198341eb8f369956407fea2f5cc666c" -"checksum bindgen 0.47.3 (registry+https://github.com/rust-lang/crates.io-index)" = "df683a55b54b41d5ea8ebfaebb5aa7e6b84e3f3006a78f010dadc9ca88469260" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" +"checksum bytemuck 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37fa13df2292ecb479ec23aa06f4507928bef07839be9ef15281411076629431" "checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -"checksum cc 1.0.54 (registry+https://github.com/rust-lang/crates.io-index)" = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" -"checksum cexpr 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fce5b5fb86b0c57c20c834c1b412fd09c77c8a59b9473f86272709e78874cd1d" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cgl 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "55e7ec0b74fe5897894cbc207092c577e87c52f8a59e8ca8d97ef37551f60a49" -"checksum clang-sys 0.26.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ef0c1bcf2e99c649104bd7a7012d8f8802684400e03db0ec0af48583c6fa0e4" "checksum clap 2.33.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129" -"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cocoa 0.18.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1706996401131526e36b3b49f0c4d912639ce110996f3ca144d78946727bce54" -"checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" -"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" -"checksum core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9" +"checksum color_quant 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbb57365263e881e805dc77d94697c9118fd94d8da011240555aa7b23445bd" +"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +"checksum crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +"checksum crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +"checksum crossbeam-queue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" +"checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" "checksum deflate 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "707b6a7b384888a70c8d2e8650b3e60170dfc6a67bb4aa67b6dfca57af4bedb4" -"checksum dlib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76" -"checksum downcast-rs 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52ba6eb47c2131e784a38b726eb54c1e1484904f013e576a25354d0124161af6" -"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" -"checksum failure 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -"checksum failure_derive 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" -"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" -"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -"checksum gimli 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" -"checksum gl 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d7d8c8e25e8ed44d4813809205090162723a866fb4be3a9d8bb983c9a0bf98f1" -"checksum gl_generator 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0ffaf173cf76c73a73e080366bf556b4776ece104b06961766ff11449f38604" -"checksum gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ca98bbde17256e02d17336a6bdb5a50f7d0ccacee502e191d3e3d0ec2f96f84a" -"checksum gleam 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "cae10d7c99d0e77b4766e850a60898a17c1abaf01075531f1066f03dc7dc5fc5" -"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" -"checksum glutin 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "535c6eda58adbb227604b2db10a022ffd6339d7ea3e970f338e7d98aeb24fcc3" -"checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" +"checksum deflate 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e7e5d2a2273fed52a7f947ee55b092c4057025d7a3e04e5ecdbd25d6c3fb1bd7" +"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +"checksum gif 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "471d90201b3b223f3451cd4ad53e34295f16a1df17b1edf3736d47761c3981af" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hermit-abi 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b9586eedd4ce6b3c498bc3b4dd92fc9f11166aa908a914071953768066c67909" -"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +"checksum image 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d534e95ad8b9d5aa614322d02352b4f1bf962254adcf02ac6f2def8be18498e8" "checksum inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff" -"checksum khronos_api 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" +"checksum jpeg-decoder 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "5b47b4c4e017b01abdc5bcc126d2d1002e5a75bbe3ce73f9f4f311a916363704" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)" = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" -"checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -"checksum libloading 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2cadb8e769f070c45df05c78c7520eb4cd17061d4ab262e43cfc68b4d00ac71c" -"checksum line_drawing 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9" -"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +"checksum lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084" "checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" -"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" -"checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +"checksum memoffset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" "checksum miniz_oxide 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435" -"checksum nanovg 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1d9e6da9031cb3f36614160ac7424e65ad5cc86b25ca3b6f17f7053b18905d4" -"checksum nanovg-sys 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2930972e68f3956b728b005ec6995dda334f19c764fdb919fc32462b89ad76e" -"checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" -"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" "checksum num-integer 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" "checksum num-iter 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f" +"checksum num-rational 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" "checksum num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" -"checksum objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -"checksum object 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" -"checksum ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" -"checksum osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b" -"checksum owning_ref 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -"checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" -"checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -"checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +"checksum num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" "checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" "checksum png 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "63daf481fdd0defa2d1d2be15c674fbfa1b0fd71882c303a91f9a79b3252c359" +"checksum png 0.16.5 (registry+https://github.com/rust-lang/crates.io-index)" = "34ccdd66f6fe4b2433b07e4728e9a013e43233120427046e93ceb709c3a439bf" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" -"checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" -"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" -"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" -"checksum regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)" = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" -"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum rusttype 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "310942406a39981bed7e12b09182a221a29e0990f3e7e0c971f131922ed135d5" -"checksum rusttype 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f61411055101f7b60ecf1041d87fb74205fb20b0c7a723f07ef39174cf6b4c0" -"checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" -"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -"checksum smithay-client-toolkit 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2ccb8c57049b2a34d2cc2b203fa785020ba0129d31920ef0d317430adaf748fa" -"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" -"checksum stb_truetype 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f77b6b07e862c66a9f3e62a07588fee67cd90a9135a2b942409f195507b4fb51" +"checksum rayon 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" +"checksum rayon-core 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" +"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" +"checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "16c2cdbf9cc375f15d1b4141bc48aeef444806655cd0e904207edc8d68d86ed7" "checksum structopt-derive 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "53010261a84b37689f9ed7d395165029f9cc7abb9f56bbfe86bee2597ed25107" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum syn 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "b5304cfdf27365b7585c25d4af91b35016ed21ef88f17ced89c7093b43dba8b6" -"checksum synstructure 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" -"checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -"checksum time 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +"checksum thiserror 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" +"checksum thiserror-impl 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" +"checksum tiff 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f3b8a87c4da944c3f27e5943289171ac71a6150a79ff6bacfff06d159dfff2f" "checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" "checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum vec_map 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" -"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" -"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" -"checksum wayland-client 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "49963e5f9eeaf637bfcd1b9f0701c99fd5cd05225eb51035550d4272806f2713" -"checksum wayland-commons 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "40c08896768b667e1df195d88a62a53a2d1351a1ed96188be79c196b35bb32ec" -"checksum wayland-protocols 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "4afde2ea2a428eee6d7d2c8584fdbe8b82eee8b6c353e129a434cd6e07f42145" -"checksum wayland-scanner 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3828c568714507315ee425a9529edc4a4aa9901409e373e9e0027e7622b79e" -"checksum wayland-sys 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "520ab0fd578017a0ee2206623ba9ef4afe5e8f23ca7b42f6acfba2f4e66b1628" -"checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum winit 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c57c15bd4c0ef18dff33e263e452abe32d00e2e05771cacaa410a14cc1c0776" "checksum x11 2.18.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77ecd092546cb16f25783a5451538e73afc8d32e242648d54f4ae5459ba1e773" -"checksum x11-dl 2.18.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2bf981e3a5b3301209754218f962052d4d9ee97e478f4d26d4a6eced34c1fef8" -"checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" -"checksum xml-rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" diff --git a/Cargo.toml b/Cargo.toml index 5daf999..1526a7c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,19 +4,24 @@ description = "Screenshot capture for Linux." version = "0.4.0" repository = "https://github.com/iptq/leanshot" license-file = "LICENSE" +edition = "2018" authors = ["Michael Zhang "] [workspace] -members = [".", "imlib2", "imlib2/imlib2-sys", "xlib"] +members = [".", "x11"] + +[features] +default = ["x11"] +x11 = ["leanshot_x11"] [dependencies] -failure = "0.1" -gl = "0.11" -glutin = "0.19" -imlib2 = { version = "0.1", path = "./imlib2" } -leanshot_xlib = { version = "0.2", path = "./xlib" } -nanovg = { version = "1.0.2", features = ["gl3"] } +# gl = "0.11" +# glutin = "0.19" +# nanovg = { version = "1.0.2", features = ["gl3"] } png = "0.14" structopt = "0.2" -time = "0.1" -x11 = { version = "2.18", features = ["xlib"] } +# time = "0.1" +anyhow = "1.0.31" +image = "0.23.5" + +leanshot_x11 = { version = "0.2", path = "x11", optional = true, features = ["xlib"] } diff --git a/LICENSE b/LICENSE index 15e28e4..0cab0b2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2018 Michael Zhang +Copyright 2018-2020 Michael Zhang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/imlib2/Cargo.toml b/imlib2/Cargo.toml deleted file mode 100644 index 713043c..0000000 --- a/imlib2/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "imlib2" -version = "0.1.1" -description = "imlib2 bindings" -license-file = "../LICENSE" -authors = ["Michael Zhang "] - -[dependencies] -failure = "0.1" -imlib2-sys = { version = "0.1", path = "imlib2-sys" } -leanshot_xlib = { version = "0.2", path = "../xlib" } diff --git a/imlib2/imlib2-sys/Cargo.toml b/imlib2/imlib2-sys/Cargo.toml deleted file mode 100644 index 7ea45fe..0000000 --- a/imlib2/imlib2-sys/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "imlib2-sys" -version = "0.1.0" -description = "ffi for imlib2" -license-file = "../../LICENSE" -authors = ["Michael Zhang "] -build = "build.rs" - -[lib] -path = "lib.rs" - -[build-dependencies] -bindgen = "0.47" diff --git a/imlib2/imlib2-sys/build.rs b/imlib2/imlib2-sys/build.rs deleted file mode 100644 index 1616c77..0000000 --- a/imlib2/imlib2-sys/build.rs +++ /dev/null @@ -1,20 +0,0 @@ -// bindgen build script by remexre - -extern crate bindgen; - -use std::env; -use std::path::PathBuf; - -use bindgen::Builder; - -fn main() { - println!("cargo:rustc-link-lib=Imlib2"); - let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); - Builder::default() - .header("wrapper.h") - .blacklist_type("max_align_t") - .generate() - .expect("Unable to generate bindings") - .write_to_file(out_path.join("bindings.rs")) - .expect("Unable to write bindings"); -} diff --git a/imlib2/imlib2-sys/lib.rs b/imlib2/imlib2-sys/lib.rs deleted file mode 100644 index a38a13a..0000000 --- a/imlib2/imlib2-sys/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![allow(non_upper_case_globals)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] - -include!(concat!(env!("OUT_DIR"), "/bindings.rs")); diff --git a/imlib2/imlib2-sys/wrapper.h b/imlib2/imlib2-sys/wrapper.h deleted file mode 100644 index 4cedea3..0000000 --- a/imlib2/imlib2-sys/wrapper.h +++ /dev/null @@ -1 +0,0 @@ -#include "Imlib2.h" diff --git a/imlib2/src/errors.rs b/imlib2/src/errors.rs deleted file mode 100644 index 33b5674..0000000 --- a/imlib2/src/errors.rs +++ /dev/null @@ -1,7 +0,0 @@ -/// Enumerated error type. -#[allow(missing_docs)] -#[derive(Debug, Fail)] -pub enum Error { - #[fail(display = "error")] - Error, -} diff --git a/imlib2/src/image.rs b/imlib2/src/image.rs deleted file mode 100644 index a236101..0000000 --- a/imlib2/src/image.rs +++ /dev/null @@ -1,77 +0,0 @@ -use std::ffi::CString; -use std::path::Path; - -use imlib2_sys as im; - -use xlib::Drawable; -use Error; - -/// A simple wrapper around Imlib_Image -pub struct Image { - pub(crate) inner: im::Imlib_Image, -} - -impl Image { - /// Creates an Image from a pixmap. - pub fn create_from_drawable( - drawable: impl Drawable, - pixmap: im::Pixmap, - x: i32, - y: i32, - width: i32, - height: i32, - grab_x: bool, - ) -> Result { - unsafe { im::imlib_context_set_drawable(drawable.as_drawable()) }; - let image = unsafe { - im::imlib_create_image_from_drawable( - pixmap, - x, - y, - width, - height, - if grab_x { 1 } else { 0 }, - ) as im::Imlib_Image - }; - unsafe { im::imlib_context_set_image(image) }; - Ok(Image { inner: image }) - } - - /// Get width - pub fn get_width(&self) -> i32 { - unsafe { - im::imlib_context_set_image(self.inner); - im::imlib_image_get_width() - } - } - - /// Get height - pub fn get_height(&self) -> i32 { - unsafe { - im::imlib_context_set_image(self.inner); - im::imlib_image_get_height() - } - } - - /// Save this image - pub fn save_image(&self, file: impl AsRef) -> Result<(), Error> { - let mut error = 0; - let path = CString::new(file.as_ref().to_str().unwrap()).unwrap(); - unsafe { im::imlib_save_image_with_error_return(path.as_ptr(), &mut error) }; - Ok(()) - } - - /// Get raw image - pub fn as_raw(&self) -> im::Imlib_Image { - self.inner - } -} - -impl Drop for Image { - fn drop(&mut self) { - unsafe { - im::imlib_context_set_image(self.inner); - im::imlib_free_image(); - } - } -} diff --git a/imlib2/src/lib.rs b/imlib2/src/lib.rs deleted file mode 100644 index 17501ea..0000000 --- a/imlib2/src/lib.rs +++ /dev/null @@ -1,70 +0,0 @@ -//! Safe-ish bindings to imlib2 (at least the only parts I need). - -#[macro_use] -extern crate failure; -extern crate imlib2_sys; -extern crate leanshot_xlib as xlib; - -mod errors; -mod image; - -pub use errors::Error; -pub use image::Image; -pub use imlib2_sys::{Drawable, Pixmap}; - -use xlib::{Display, Visual}; - -/// Set the display for the imlib context. -pub fn context_set_display(display: &Display) { - unsafe { - imlib2_sys::imlib_context_set_display(display.as_raw() as *mut imlib2_sys::_XDisplay) - }; -} - -/// Set the visual for the imlib context. -pub fn context_set_visual(visual: &Visual) { - unsafe { imlib2_sys::imlib_context_set_visual(visual.as_raw() as *mut imlib2_sys::Visual) }; -} - -/// Set the visual for the imlib context. -pub fn context_set_image(image: &Image) { - unsafe { imlib2_sys::imlib_context_set_image(image.as_raw() as imlib2_sys::Imlib_Image) }; -} - -/// Get a pointer to the raw image data for the current image. -pub fn image_get_data() -> *mut u32 { - unsafe { imlib2_sys::imlib_image_get_data_for_reading_only() } -} - -/// Create cropped image -pub fn create_cropped_image(x: i32, y: i32, width: u32, height: u32) -> Result { - let inner = - unsafe { imlib2_sys::imlib_create_cropped_image(x, y, width as i32, height as i32) }; - if inner.is_null() { - return Err(Error::Error); - } - Ok(Image { inner }) -} - -/// Create scaled cropped image -pub fn create_scaled_cropped_image( - x: i32, - y: i32, - width: u32, - height: u32, -) -> Result { - let inner = unsafe { - imlib2_sys::imlib_create_cropped_scaled_image( - x, - y, - width as i32, - height as i32, - width as i32, - height as i32, - ) - }; - if inner.is_null() { - return Err(Error::Error); - } - Ok(Image { inner }) -} diff --git a/src/capture.rs b/src/capture.rs deleted file mode 100644 index c4c6a8f..0000000 --- a/src/capture.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::errors::ScreenshotError; - -use crate::gui::GUI; -use crate::options::{Options, Region}; -use imlib2; - -/// The main capture routine. -pub fn capture(opt: &Options) -> Result<(), ScreenshotError> { - let gui = GUI::new()?; - - let window_to_capture = match opt.region { - Region::ActiveWindow => gui.get_active_window()?, - _ => gui.display.get_default_root_window()?, - }; - - let capture = gui.capture_window(&opt, window_to_capture)?; - - imlib2::context_set_image(&capture); - capture.save_image(&opt.outfile)?; - - Ok(()) -} diff --git a/src/errors.rs b/src/errors.rs deleted file mode 100644 index f317941..0000000 --- a/src/errors.rs +++ /dev/null @@ -1,41 +0,0 @@ -#[derive(Debug, Fail)] -pub enum ScreenshotError { - #[fail(display = "x11 error")] - X11Error(#[cause] crate::xlib::X11Error), - - #[fail(display = "imlib2 error")] - ImlibError(#[cause] ::imlib2::Error), - - #[fail(display = "io error")] - IOError(#[cause] ::std::io::Error), - - #[fail(display = "png encoding error")] - PngEncodingError(#[cause] ::png::EncodingError), - - #[fail(display = "error")] - Error, -} - -impl From<::std::io::Error> for ScreenshotError { - fn from(err: ::std::io::Error) -> Self { - ScreenshotError::IOError(err) - } -} - -impl From for ScreenshotError { - fn from(err: crate::xlib::X11Error) -> Self { - ScreenshotError::X11Error(err) - } -} - -impl From<::imlib2::Error> for ScreenshotError { - fn from(err: ::imlib2::Error) -> Self { - ScreenshotError::ImlibError(err) - } -} - -impl From<::png::EncodingError> for ScreenshotError { - fn from(err: ::png::EncodingError) -> Self { - ScreenshotError::PngEncodingError(err) - } -} diff --git a/src/gui.rs b/src/gui.rs index aac81c4..c3dcabb 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -1,346 +1,67 @@ -use crate::xlib::{Display, Visual, Window}; -use imlib2::{self, Image as Image2}; +use anyhow::Result; +use image::RgbaImage; +use x11::{ + xlib::{Display, Window}, + Rectangle, +}; -use crate::errors::ScreenshotError; -use crate::Options; -use crate::Rectangle; -use crate::Region; +use crate::platform::{x11::X11, Platform}; +use crate::{Options, Region}; -pub struct GUI { - pub(crate) display: Display, +pub struct GUI { + inner: P, } -impl GUI { - pub fn new() -> Result { - let display = Display::connect(":0")?; - Ok(GUI { display }) +impl GUI { + pub fn new() -> Result { + let x11 = X11::new()?; + Ok(GUI { inner: x11 }) } +} +impl GUI

{ /// Captures the window and produces an Image. - pub fn capture_window(&self, opt: &Options, window: Window) -> Result { + pub fn capture_window(&self, opt: &Options, window: Window) -> Result { let attr = window.get_attributes()?; let width = attr.get_width(); let height = attr.get_height(); 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); + // 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); if let Region::Selection = opt.region { - let capture = - Image2::create_from_drawable(window, 0, x, y, width as i32, height as i32, true)?; - let region = self.interactive_select(&capture)?; - imlib2::context_set_image(&capture); - return imlib2::create_scaled_cropped_image( - region.x, - region.y, - region.width, - region.height, - ) - .map_err(|err| err.into()); + let image = self.inner.capture_full_screen()?; + let rect = self.inner.show_interactive_selection(image)?; + unimplemented!("rect: {:?}", rect); + // let capture = + // Image2::create_from_drawable(window, 0, x, y, width as i32, height as i32, true)?; + // let region = self.interactive_select(&capture)?; + // imlib2::context_set_image(&capture); + // return imlib2::create_scaled_cropped_image( + // region.x, + // region.y, + // region.width, + // region.height, + // ) + // .map_err(|err| err.into()); } - Image2::create_from_drawable(window, 0, x, y, width as i32, height as i32, true) - .map_err(|err| err.into()) + unimplemented!() + // Image2::create_from_drawable(window, 0, x, y, width as i32, height as i32, true) + // .map_err(|err| err.into()) } /// Get the active window. - pub fn get_active_window(&self) -> Result { - self.display - .get_input_focus() - .map(|(window, _)| window) - .map_err(|err| err.into()) + pub fn get_active_window(&self) -> Result { + self.inner.get_active_window() } - /// Brings up an interactive selection GUI. - pub fn interactive_select(&self, capture: &Image2) -> Result { - // let window = SelectWindow::new(&self.display); - // let root = self.display.get_default_root_window()?; - - // let root_im = root.get_image(); - - // let mut done = 0; - // let mut button_press = false; - // while done == 0 && self.display.pending()? > 0 { - // let ev = self.display.next_event()?; - // match ev.kind() { - // EventKind::ButtonPress => { - // button_press = true; - // } - // EventKind::ButtonRelease => { - // if button_press { - // done = 1; - // } - // button_press = false; - // } - // _ => (), - // } - // } - - use glutin::{ - dpi::{PhysicalPosition, PhysicalSize}, - os::unix::{WindowBuilderExt, WindowExt, XWindowType}, - ElementState, Event, EventsLoop, GlContext, GlWindow, KeyboardInput, MouseButton, - MouseCursor, VirtualKeyCode, WindowBuilder, WindowEvent, - }; - use nanovg::{Image, ImagePattern, PathOptions, StrokeOptions}; - use std::{f32::consts, mem, slice}; - - // let attr = window.get_attributes()?; - // let width = attr.get_width(); - // let height = attr.get_height(); - // let root = attr.get_root(); - // let (x, y, _) = self.display.translate_coordinates(window, 0, 0, root)?; - let width = capture.get_width(); - let height = capture.get_height(); - - let mut evl = EventsLoop::new(); - let mon = evl.get_primary_monitor(); - - // TODO: handle error - let wb = WindowBuilder::new() - .with_x11_window_type(XWindowType::Splash) - .with_decorations(false) - .with_visibility(false) - .with_always_on_top(true) - .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) - .with_multisampling(4) - .with_double_buffer(Some(true)) - .with_srgb(true); - let win = GlWindow::new(wb, ctx, &evl).expect("couldn't make window"); - win.set_position((0.0, 0.0).into()); - let f = win.get_hidpi_factor() as f64; - - // crosshair - win.set_cursor(MouseCursor::Crosshair); - // win.set_inner_size((width, height).into()); - // println!("size={:?} pos={:?} outer={:?}", win.get_inner_size(), win.get_inner_position(), win.get_outer_size()); - // println!("{:?}", win.get_hidpi_factor()); - - let x = Display::from_handle(win.get_xlib_display().unwrap() as u64); - let len; - let raw_data; - { - let _g = x.grab(); - // let img = Image2::create_from_drawable(window, 0, 0, 0, width as i32, height as i32, true)?; - imlib2::context_set_image(&capture); - len = (width * height) as usize; - // println!("{}", window.as_raw()); - raw_data = unsafe { slice::from_raw_parts(imlib2::image_get_data(), len) }; - - unsafe { - win.make_current().expect("couldn't make window"); - gl::load_with(|sym| win.get_proc_address(sym) as *const _); - } - } - mem::forget(x); - - // convert ARGB to RGBA - let mut data = vec![0u32; raw_data.len()]; - data.copy_from_slice(raw_data); - for i in &mut data { - // fix the colors - *i = (*i & 0xff00ff00) | ((*i & 0xff) << 16) | ((*i >> 16) & 0xff); - } - - // invert image - let mut inverted = vec![0u32; raw_data.len()]; - inverted.copy_from_slice(raw_data); - for i in &mut inverted { - // fix the colors - *i = (*i & 0xff000000) | !(*i & 0xffffff); - } - - let ctx = nanovg::ContextBuilder::new() - .build() - .expect("couldn't init nanovg"); - - let image = Image::new(&ctx) - .build_from_rgba(width as usize, height as usize, data.as_slice()) - .expect("couldn't create image"); - - let inverted_image = Image::new(&ctx) - .build_from_rgba(width as usize, height as usize, inverted.as_slice()) - .expect("couldn't create image"); - - let mut running = true; - let mut down = false; - // drag start - let mut dx = -1.0f64; - let mut dy = -1.0f64; - // curr mouse - let mut mx = -1.0f64; - let mut my = -1.0f64; - // rect - let mut rectw = 0.0f64; - 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(); - // let (width, height) = (size.width as i32, size.height as i32); - - unsafe { - gl::Viewport(0, 0, width as i32, height as i32); - gl::ClearColor(0.3, 0.3, 0.32, 1.0); - gl::Clear(gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT | gl::STENCIL_BUFFER_BIT); - } - - let (width, height) = (width as f64, height as f64); - ctx.frame((width as f32, height as f32), f as f32, |frame| { - let path_opts = PathOptions::default(); - frame.path( - |path| { - path.rect((0.0, 0.0), ((width * f) as f32, (height * f) as f32)); - // path.fill(Color::from_rgba(200, 200, 200, 255), Default::default()); - path.fill( - ImagePattern { - image: &image, - origin: (0.0, 0.0), - size: (width as f32, height as f32), - angle: 0.0 / 180.0 * consts::PI, - alpha: 1.0, - }, - Default::default(), - ) - }, - path_opts, - ); - if down && rectw.abs() > 0.0 && recth.abs() > 0.0 { - frame.path( - |path| { - path.rect( - ((dx * f) as f32, (dy * f) as f32), - ((rectw * f) as f32, (recth * f) as f32), - ); - path.stroke( - // Color::from_rgba(0, 0, 0, 255), - ImagePattern { - image: &inverted_image, - origin: (0.0, 0.0), - size: (width as f32, height as f32), - angle: 0.0 / 180.0 * consts::PI, - alpha: 1.0, - }, - StrokeOptions { - width: 1.0, - ..Default::default() - }, - ); - }, - path_opts, - ); - } - }); - } - - evl.poll_events(|event| { - if let Event::WindowEvent { event, .. } = event { - match event { - WindowEvent::Destroyed => running = false, - WindowEvent::KeyboardInput { - input: - KeyboardInput { - virtual_keycode, - state, - .. - }, - .. - } => { - if let (Some(VirtualKeyCode::Escape), ElementState::Released) = - (virtual_keycode, state) - { - if down { - down = false; - rectw = 0.0; - recth = 0.0; - } else { - unsafe { - x11::xlib::XDestroyWindow( - self.display.as_raw(), - win.get_xlib_window().unwrap(), - ) - }; - running = false; - } - } - } - WindowEvent::CursorMoved { position, .. } => { - mx = position.x; - my = position.y; - if down { - if delayed_down { - dx = mx; - dy = my; - delayed_down = false; - } else { - redraw = true; - } - rectw = mx - dx; - recth = my - dy; - } - } - WindowEvent::MouseInput { button, state, .. } => { - if let MouseButton::Left = button { - down = match state { - ElementState::Pressed => { - delayed_down = true; - if mx < 0.0 || my < 0.0 { - } else { - dx = mx; - dy = my; - } - true - } - ElementState::Released => { - if down && rectw.abs() > 0.0 && recth.abs() > 0.0 { - unsafe { - x11::xlib::XDestroyWindow( - self.display.as_raw(), - win.get_xlib_window().unwrap(), - ) - }; - running = false; - } - false - } - } - } - } - _ => (), - } - } - }); - win.swap_buffers().expect("couldn't swap buffers"); - } - if rectw.abs() > 0.0 && recth.abs() > 0.0 { - let mut x = dx; - let mut y = dy; - if rectw < 0.0 { - x += rectw; - } - if recth < 0.0 { - y += recth; - } - Ok(Rectangle::new( - (x * f) as i32, - (y * f) as i32, - (rectw.abs() * f) as u32, - (recth.abs() * f) as u32, - )) - } else { - Err(ScreenshotError::Error) - } + /// Get the active window. + pub fn capture_full_screen(&self) -> Result { + self.inner.capture_full_screen() } } diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..8c653b8 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,42 @@ +//! Screenshot capturing utility. + +#![deny(missing_docs)] + +#[macro_use] +extern crate anyhow; +#[macro_use] +extern crate structopt; +extern crate leanshot_x11 as x11; + +mod options; +mod platform; + +use anyhow::Result; + +pub use crate::options::{Options, Region}; +use crate::platform::{x11::X11, Platform}; + +type Rectangle = x11::Rectangle; + +/// The main capture routine +pub fn capture(opt: &Options) -> Result<()> { + let gui = X11::new()?; + + let image = match opt.region { + Region::ActiveWindow => { + let window = gui.get_active_window()?; + let image = gui.capture_window(window); + } + Region::Fullscreen | Region::Selection => { + let mut image = gui.capture_full_screen()?; + if let Region::Fullscreen = opt.region { + let rect = gui.show_interactive_selection(image)?; + // TODO: crop the image + } + } + }; + + unimplemented!("leanshot::capture") + // imlib2::context_set_image(&capture); + // capture.save_image(&opt.outfile)?; +} diff --git a/src/main.rs b/src/main.rs index 460f730..4d9b295 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,36 +1,9 @@ -//! Screenshot capturing utility. - -#![deny(missing_docs)] - -#[macro_use] -extern crate failure; -extern crate gl; -extern crate glutin; -extern crate imlib2; -extern crate nanovg; -extern crate png; -#[macro_use] -extern crate structopt; -extern crate leanshot_xlib as xlib; -extern crate time; -extern crate x11; - -mod capture; -mod errors; -mod gui; -mod options; - -use crate::errors::ScreenshotError; -use crate::xlib::Rectangle; +use anyhow::Result; +use leanshot::{capture, Options}; use structopt::StructOpt; -pub use crate::capture::capture; -pub use crate::options::{Options, Region}; - -use failure::Error; - #[allow(missing_docs)] -pub fn main() -> Result<(), Error> { +pub fn main() -> Result<()> { let opt = Options::from_args(); - capture(&opt).map(|_| ()).map_err(|err| err.into()) + capture(&opt) } diff --git a/src/old.rs b/src/old.rs new file mode 100644 index 0000000..9e47b14 --- /dev/null +++ b/src/old.rs @@ -0,0 +1,279 @@ + + + /// Brings up an interactive selection GUI. + pub fn interactive_select(&self, capture: &Image2) -> Result { + // let window = SelectWindow::new(&self.display); + // let root = self.display.get_default_root_window()?; + + // let root_im = root.get_image(); + + // let mut done = 0; + // let mut button_press = false; + // while done == 0 && self.display.pending()? > 0 { + // let ev = self.display.next_event()?; + // match ev.kind() { + // EventKind::ButtonPress => { + // button_press = true; + // } + // EventKind::ButtonRelease => { + // if button_press { + // done = 1; + // } + // button_press = false; + // } + // _ => (), + // } + // } + + use glutin::{ + dpi::{PhysicalPosition, PhysicalSize}, + os::unix::{WindowBuilderExt, WindowExt, XWindowType}, + ElementState, Event, EventsLoop, GlContext, GlWindow, KeyboardInput, MouseButton, + MouseCursor, VirtualKeyCode, WindowBuilder, WindowEvent, + }; + use nanovg::{Image, ImagePattern, PathOptions, StrokeOptions}; + use std::{f32::consts, mem, slice}; + + // let attr = window.get_attributes()?; + // let width = attr.get_width(); + // let height = attr.get_height(); + // let root = attr.get_root(); + // let (x, y, _) = self.display.translate_coordinates(window, 0, 0, root)?; + let width = capture.get_width(); + let height = capture.get_height(); + + let mut evl = EventsLoop::new(); + let mon = evl.get_primary_monitor(); + + // TODO: handle error + let wb = WindowBuilder::new() + .with_x11_window_type(XWindowType::Splash) + .with_decorations(false) + .with_visibility(false) + .with_always_on_top(true) + .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) + .with_multisampling(4) + .with_double_buffer(Some(true)) + .with_srgb(true); + let win = GlWindow::new(wb, ctx, &evl).expect("couldn't make window"); + win.set_position((0.0, 0.0).into()); + let f = win.get_hidpi_factor() as f64; + + // crosshair + win.set_cursor(MouseCursor::Crosshair); + // win.set_inner_size((width, height).into()); + // println!("size={:?} pos={:?} outer={:?}", win.get_inner_size(), win.get_inner_position(), win.get_outer_size()); + // println!("{:?}", win.get_hidpi_factor()); + + let x = Display::from_handle(win.get_xlib_display().unwrap() as u64); + let len; + let raw_data; + { + let _g = x.grab(); + // let img = Image2::create_from_drawable(window, 0, 0, 0, width as i32, height as i32, true)?; + imlib2::context_set_image(&capture); + len = (width * height) as usize; + // println!("{}", window.as_raw()); + raw_data = unsafe { slice::from_raw_parts(imlib2::image_get_data(), len) }; + + unsafe { + win.make_current().expect("couldn't make window"); + gl::load_with(|sym| win.get_proc_address(sym) as *const _); + } + } + mem::forget(x); + + // convert ARGB to RGBA + let mut data = vec![0u32; raw_data.len()]; + data.copy_from_slice(raw_data); + for i in &mut data { + // fix the colors + *i = (*i & 0xff00ff00) | ((*i & 0xff) << 16) | ((*i >> 16) & 0xff); + } + + // invert image + let mut inverted = vec![0u32; raw_data.len()]; + inverted.copy_from_slice(raw_data); + for i in &mut inverted { + // fix the colors + *i = (*i & 0xff000000) | !(*i & 0xffffff); + } + + let ctx = nanovg::ContextBuilder::new() + .build() + .expect("couldn't init nanovg"); + + let image = Image::new(&ctx) + .build_from_rgba(width as usize, height as usize, data.as_slice()) + .expect("couldn't create image"); + + let inverted_image = Image::new(&ctx) + .build_from_rgba(width as usize, height as usize, inverted.as_slice()) + .expect("couldn't create image"); + + let mut running = true; + let mut down = false; + // drag start + let mut dx = -1.0f64; + let mut dy = -1.0f64; + // curr mouse + let mut mx = -1.0f64; + let mut my = -1.0f64; + // rect + let mut rectw = 0.0f64; + 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(); + // let (width, height) = (size.width as i32, size.height as i32); + + unsafe { + gl::Viewport(0, 0, width as i32, height as i32); + gl::ClearColor(0.3, 0.3, 0.32, 1.0); + gl::Clear(gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT | gl::STENCIL_BUFFER_BIT); + } + + let (width, height) = (width as f64, height as f64); + ctx.frame((width as f32, height as f32), f as f32, |frame| { + let path_opts = PathOptions::default(); + frame.path( + |path| { + path.rect((0.0, 0.0), ((width * f) as f32, (height * f) as f32)); + // path.fill(Color::from_rgba(200, 200, 200, 255), Default::default()); + path.fill( + ImagePattern { + image: &image, + origin: (0.0, 0.0), + size: (width as f32, height as f32), + angle: 0.0 / 180.0 * consts::PI, + alpha: 1.0, + }, + Default::default(), + ) + }, + path_opts, + ); + if down && rectw.abs() > 0.0 && recth.abs() > 0.0 { + frame.path( + |path| { + path.rect( + ((dx * f) as f32, (dy * f) as f32), + ((rectw * f) as f32, (recth * f) as f32), + ); + path.stroke( + // Color::from_rgba(0, 0, 0, 255), + ImagePattern { + image: &inverted_image, + origin: (0.0, 0.0), + size: (width as f32, height as f32), + angle: 0.0 / 180.0 * consts::PI, + alpha: 1.0, + }, + StrokeOptions { + width: 1.0, + ..Default::default() + }, + ); + }, + path_opts, + ); + } + }); + } + + evl.poll_events(|event| { + if let Event::WindowEvent { event, .. } = event { + match event { + WindowEvent::Destroyed => running = false, + WindowEvent::KeyboardInput { + input: + KeyboardInput { + virtual_keycode, + state, + .. + }, + .. + } => { + if let (Some(VirtualKeyCode::Escape), ElementState::Released) = + (virtual_keycode, state) + { + if down { + down = false; + rectw = 0.0; + recth = 0.0; + } else { + running = false; + } + } + } + WindowEvent::CursorMoved { position, .. } => { + mx = position.x; + my = position.y; + if down { + if delayed_down { + dx = mx; + dy = my; + delayed_down = false; + } else { + redraw = true; + } + rectw = mx - dx; + recth = my - dy; + } + } + WindowEvent::MouseInput { button, state, .. } => { + if let MouseButton::Left = button { + down = match state { + ElementState::Pressed => { + delayed_down = true; + if mx < 0.0 || my < 0.0 { + } else { + dx = mx; + dy = my; + } + true + } + ElementState::Released => { + if down && rectw.abs() > 0.0 && recth.abs() > 0.0 { + running = false; + } + false + } + } + } + } + _ => (), + } + } + }); + win.swap_buffers().expect("couldn't swap buffers"); + } + if rectw.abs() > 0.0 && recth.abs() > 0.0 { + let mut x = dx; + let mut y = dy; + if rectw < 0.0 { + x += rectw; + } + if recth < 0.0 { + y += recth; + } + Ok(Rectangle::new( + (x * f) as i32, + (y * f) as i32, + (rectw.abs() * f) as u32, + (recth.abs() * f) as u32, + )) + } else { + Err(ScreenshotError::Error) + } + } diff --git a/src/options.rs b/src/options.rs index 13a59e5..fc6ceef 100644 --- a/src/options.rs +++ b/src/options.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use crate::ScreenshotError; +use anyhow::Result; /// A region option #[allow(missing_docs)] @@ -27,12 +27,12 @@ pub struct Options { } impl Region { - pub(self) fn from_str(x: &str) -> Result { + pub(self) fn from_str(x: &str) -> Result { match x { "fullscreen" => Ok(Region::Fullscreen), "window" => Ok(Region::ActiveWindow), "select" | "selection" => Ok(Region::Selection), - _ => Err(ScreenshotError::Error), + _ => bail!("please choose a region from 'fullscreen', 'window', or 'select'"), } } } diff --git a/src/platform/mod.rs b/src/platform/mod.rs new file mode 100644 index 0000000..f3083d6 --- /dev/null +++ b/src/platform/mod.rs @@ -0,0 +1,21 @@ +#[cfg(feature = "x11")] +pub mod x11; + +use anyhow::Result; +use image::RgbaImage; + +use crate::Rectangle; + +pub trait Platform { + type Window; + type Image: Image; + + fn get_active_window(&self) -> Result; + fn capture_window(&self, window: Self::Window) -> Result; + fn capture_full_screen(&self) -> Result; + fn show_interactive_selection(&self, image: Self::Image) -> Result; +} + +pub trait Image { + fn into_rgba_image(self) -> RgbaImage; +} diff --git a/src/platform/x11.rs b/src/platform/x11.rs new file mode 100644 index 0000000..c4f7250 --- /dev/null +++ b/src/platform/x11.rs @@ -0,0 +1,55 @@ +use anyhow::Result; +use image::RgbaImage; +use x11::xlib::{Display, Window}; + +use crate::platform::{Image as ImageT, Platform}; +use crate::Rectangle; + +pub struct X11 { + inner: Display, +} + +impl X11 { + pub fn new() -> Result { + let display = Display::connect(":0")?; + Ok(X11 { inner: display }) + } +} + +impl Platform for X11 { + type Window = Window; + type Image = Image; + + fn get_active_window(&self) -> Result { + let (window, _) = self.inner.get_input_focus()?; + Ok(window) + } + + fn capture_window(&self, window: Self::Window) -> Result { + let image = window.get_image()?; + Ok(Image(image)) + } + + fn capture_full_screen(&self) -> Result { + let window = self.inner.get_root_window(0); + unimplemented!() + } + + fn show_interactive_selection(&self, image: Self::Image) -> Result { + let window = Window::create(&self.inner, None, Rectangle::new(0, 0, 500, 500))?; + window.map(); + + let mut running = false; + + while running {} + unimplemented!() + } +} + +pub struct Image(x11::xlib::Image); + +impl ImageT for Image { + fn into_rgba_image(self) -> RgbaImage { + todo!() + } +} diff --git a/x11/Cargo.toml b/x11/Cargo.toml new file mode 100644 index 0000000..6e5d6f0 --- /dev/null +++ b/x11/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "leanshot_x11" +version = "0.2.0" +description = "x11 bindings" +license-file = "../LICENSE" +authors = ["Michael Zhang "] + +[features] +default = [] +xlib = ["x11/xlib"] +xrender = ["x11/xrender"] + +[dependencies] +libc = "0.2" +x11 = { version = "2.18" } +thiserror = "1.0.20" diff --git a/x11/src/errors.rs b/x11/src/errors.rs new file mode 100644 index 0000000..a8d5c24 --- /dev/null +++ b/x11/src/errors.rs @@ -0,0 +1,27 @@ +pub type Result = std::result::Result; + +/// Any error that can be raised when using this library. +#[allow(missing_docs)] +#[derive(Debug, Error)] +pub enum Error { + #[error("invalid image byte order")] + InvalidByteOrder(i32), + + #[error("failed to get attributes")] + GetAttributesError, + + #[error("failed to create cursor")] + CreateCursorError, + + #[error("failed to open display")] + DisplayOpenError, + + #[error("failed to get window")] + GetWindowError, + + #[error("failed to translate coordinates")] + TranslateCoordinatesError, + + #[error("error")] + Error, +} diff --git a/x11/src/lib.rs b/x11/src/lib.rs new file mode 100644 index 0000000..d4de88a --- /dev/null +++ b/x11/src/lib.rs @@ -0,0 +1,18 @@ +//! Higher level bindings to x11. + +#[macro_use] +extern crate thiserror; + +pub extern crate x11; + +#[cfg(feature = "xlib")] +pub mod xlib; + +#[cfg(feature = "xrender")] +pub mod xrender; + +mod errors; +mod rect; + +pub use crate::errors::{Error, Result}; +pub use crate::rect::Rectangle; diff --git a/xlib/src/rect.rs b/x11/src/rect.rs similarity index 100% rename from xlib/src/rect.rs rename to x11/src/rect.rs diff --git a/xlib/src/atom.rs b/x11/src/xlib/atom.rs similarity index 54% rename from xlib/src/atom.rs rename to x11/src/xlib/atom.rs index ab6680b..469ab5b 100644 --- a/xlib/src/atom.rs +++ b/x11/src/xlib/atom.rs @@ -1,38 +1,36 @@ use std::ffi::CString; -use x11::xlib as x; -use Display; -use X11Error; +use x11::xlib; + +use crate::errors::Result; + +use super::display::Display; /// A unique string or intger pub struct Atom { - inner: x::Atom, + inner: xlib::Atom, } impl Atom { /// Create a new atom using a string - pub fn new( - display: &Display, - val: impl AsRef, - only_if_exists: bool, - ) -> Result { + pub fn new(display: &Display, val: impl AsRef, only_if_exists: bool) -> Result { let val = { let v = val.as_ref(); let s = CString::new(v).unwrap(); s.as_ptr() }; let inner = - unsafe { x::XInternAtom(display.as_raw(), val, if only_if_exists { 1 } else { 0 }) }; + unsafe { xlib::XInternAtom(display.as_raw(), val, if only_if_exists { 1 } else { 0 }) }; Ok(Atom { inner }) } /// Create a new Atom object from an existing handle - pub fn from(handle: x::Atom) -> Self { + pub fn from(handle: xlib::Atom) -> Self { Atom { inner: handle } } /// Get the handle - pub fn as_raw(&self) -> x::Atom { + pub fn as_raw(&self) -> xlib::Atom { self.inner } } diff --git a/x11/src/xlib/cursor.rs b/x11/src/xlib/cursor.rs new file mode 100644 index 0000000..2133c20 --- /dev/null +++ b/x11/src/xlib/cursor.rs @@ -0,0 +1,13 @@ +use x11::xlib; + +/// Mouse pointer +pub struct Cursor { + pub(crate) display: *mut xlib::Display, + pub(crate) inner: xlib::Cursor, +} + +impl Drop for Cursor { + fn drop(&mut self) { + unsafe { xlib::XFreeCursor(self.display, self.inner) }; + } +} diff --git a/xlib/src/display.rs b/x11/src/xlib/display.rs similarity index 60% rename from xlib/src/display.rs rename to x11/src/xlib/display.rs index 9ae7576..2993652 100644 --- a/xlib/src/display.rs +++ b/x11/src/xlib/display.rs @@ -1,21 +1,25 @@ use std::ffi::CString; -use libc; -use x11::xlib as x; +use x11::xlib; -use {Cursor, Event, Visual, Window, X11Error}; +use crate::errors::{Error, Result}; + +use super::cursor::Cursor; +use super::event::Event; +use super::visual::Visual; +use super::window::Window; /// A connection to an X server. pub struct Display { - inner: *mut x::Display, + inner: *mut xlib::Display, } -pub struct Grab(pub(crate) *mut x::Display); +pub struct Grab(pub(crate) *mut xlib::Display); /// Something that's part of a display. pub trait GetDisplay { /// Get the current display - fn get_display(&self) -> *mut x::Display; + fn get_display(&self) -> *mut xlib::Display; } impl Display { @@ -23,11 +27,11 @@ impl Display { /// /// On POSIX-conformant systems, the display name or DISPLAY environment variable can be a string in the format: /// hostname:number.screen_number - pub fn connect(display_name: impl AsRef) -> Result { + pub fn connect(display_name: impl AsRef) -> Result { let display_name = CString::new(display_name.as_ref()).unwrap(); - let inner = unsafe { x::XOpenDisplay(display_name.as_ptr()) }; + let inner = unsafe { xlib::XOpenDisplay(display_name.as_ptr()) }; if inner.is_null() { - return Err(X11Error::DisplayOpenError); + return Err(Error::DisplayOpenError); } Ok(Display { inner }) } @@ -35,21 +39,21 @@ impl Display { /// Create a Display for an existing connection pub fn from_handle(handle: u64) -> Self { Display { - inner: handle as *mut x::Display, + inner: handle as *mut xlib::Display, } } /// Grab pub fn grab(&self) -> Grab { - unsafe { x::XGrabServer(self.inner) }; + unsafe { xlib::XGrabServer(self.inner) }; Grab(self.inner) } /// Wrapper around XCreateFontCursor - pub fn create_font_cursor(&self, shape: u32) -> Result { - let cursor = unsafe { x::XCreateFontCursor(self.inner, shape) as x::Cursor }; + pub fn create_font_cursor(&self, shape: u32) -> Result { + let cursor = unsafe { xlib::XCreateFontCursor(self.inner, shape) as xlib::Cursor }; if cursor == 0 { - return Err(X11Error::CreateCursorError); + return Err(Error::CreateCursorError); } Ok(Cursor { display: self.inner, @@ -58,33 +62,34 @@ impl Display { } /// Get the next event, blocks until an event is reached. - pub fn next_event(&self) -> Result { - let event = - unsafe { libc::malloc(::std::mem::size_of::()) as *mut x::XAnyEvent }; + pub fn next_event(&self) -> Result { + let event = unsafe { + libc::malloc(::std::mem::size_of::()) as *mut xlib::XAnyEvent + }; Event::from_raw(event) } /// Returns the number of events that are still pending - pub fn pending(&self) -> Result { - Ok(unsafe { x::XPending(self.inner) }) + pub fn pending(&self) -> Result { + Ok(unsafe { xlib::XPending(self.inner) }) } /// Gets the raw X Display handle - pub fn as_raw(&self) -> *mut x::Display { + pub fn as_raw(&self) -> *mut xlib::Display { self.inner } /// Gets the default visual pub fn default_visual(&self, screen: i32) -> Visual { - let visual = unsafe { x::XDefaultVisual(self.inner, screen) }; + let visual = unsafe { xlib::XDefaultVisual(self.inner, screen) }; Visual { inner: visual } } /// Returns the root window for the given screen. - pub fn get_root_window(&self, screen: i32) -> Result { - let inner = unsafe { x::XRootWindow(self.inner, screen) }; + pub fn get_root_window(&self, screen: i32) -> Result { + let inner = unsafe { xlib::XRootWindow(self.inner, screen) }; if inner == 0 { - return Err(X11Error::GetWindowError); + return Err(Error::GetWindowError); } let window = Window { display: self.inner, @@ -94,10 +99,10 @@ impl Display { } /// Returns the root window for the default screen. - pub fn get_default_root_window(&self) -> Result { - let inner = unsafe { x::XDefaultRootWindow(self.inner) }; + pub fn get_default_root_window(&self) -> Result { + let inner = unsafe { xlib::XDefaultRootWindow(self.inner) }; if inner == 0 { - return Err(X11Error::GetWindowError); + return Err(Error::GetWindowError); } let window = Window { display: self.inner, @@ -115,12 +120,12 @@ impl Display { x: i32, y: i32, w2: Window, - ) -> Result<(i32, i32, Option), X11Error> { + ) -> Result<(i32, i32, Option)> { let mut rx = 0; let mut ry = 0; - let mut child_return: x::Window = 0; + let mut child_return: xlib::Window = 0; let status = unsafe { - x::XTranslateCoordinates( + xlib::XTranslateCoordinates( self.inner, w1.inner, w2.inner, @@ -132,7 +137,7 @@ impl Display { ) }; if status == 0 { - return Err(X11Error::TranslateCoordinatesError); + return Err(Error::TranslateCoordinatesError); } let child = match child_return { 0 => None, @@ -146,14 +151,14 @@ impl Display { /// Sync pub fn sync(&self, discard: bool) { - unsafe { x::XSync(self.inner, if discard { 1 } else { 0 }) }; + unsafe { xlib::XSync(self.inner, if discard { 1 } else { 0 }) }; } - /// eturns the focus window and the current focus state. - pub fn get_input_focus(&self) -> Result<(Window, i32), X11Error> { - let mut focus_return: x::Window = 0; + /// Returns the focus window and the current focus state. + pub fn get_input_focus(&self) -> Result<(Window, i32)> { + let mut focus_return: xlib::Window = 0; let mut revert_to_return = 0; - unsafe { x::XGetInputFocus(self.inner, &mut focus_return, &mut revert_to_return) }; + unsafe { xlib::XGetInputFocus(self.inner, &mut focus_return, &mut revert_to_return) }; let window = Window { display: self.inner, inner: focus_return, @@ -164,12 +169,12 @@ impl Display { impl Drop for Display { fn drop(&mut self) { - unsafe { x::XCloseDisplay(self.inner) }; + unsafe { xlib::XCloseDisplay(self.inner) }; } } impl Drop for Grab { fn drop(&mut self) { - unsafe { x::XUngrabServer(self.0) }; + unsafe { xlib::XUngrabServer(self.0) }; } } diff --git a/xlib/src/drawable.rs b/x11/src/xlib/drawable.rs similarity index 61% rename from xlib/src/drawable.rs rename to x11/src/xlib/drawable.rs index 6becc50..60be2cb 100644 --- a/xlib/src/drawable.rs +++ b/x11/src/xlib/drawable.rs @@ -1,16 +1,20 @@ -use x11::xlib as x; +use x11::xlib; -use {GetDisplay, Image, Rectangle, X11Error}; +use crate::errors::Result; +use crate::rect::Rectangle; + +use super::display::GetDisplay; +use super::image::Image; /// Anything that's drawable pub trait Drawable: GetDisplay { /// Get drawable handle - fn as_drawable(&self) -> x::Drawable; + fn as_drawable(&self) -> xlib::Drawable; /// Capture a snapshot of this drawable, clipped by rect. - fn get_image(&self, rect: Rectangle) -> Result { + fn get_image(&self, rect: Rectangle) -> Result { let image = unsafe { - x::XGetImage( + xlib::XGetImage( self.get_display(), self.as_drawable(), rect.x as i32, @@ -18,7 +22,7 @@ pub trait Drawable: GetDisplay { rect.width, rect.height, 0xffffffff, - x::ZPixmap, + xlib::ZPixmap, ) }; Ok(Image { inner: image }) diff --git a/xlib/src/event.rs b/x11/src/xlib/event.rs similarity index 78% rename from xlib/src/event.rs rename to x11/src/xlib/event.rs index 1c382a8..4bc5542 100644 --- a/xlib/src/event.rs +++ b/x11/src/xlib/event.rs @@ -1,11 +1,10 @@ -use libc; -use x11::xlib as x; +use x11::xlib; -use X11Error; +use crate::errors::Result; /// An x11 Event pub struct Event { - inner: *mut x::XAnyEvent, + inner: *mut xlib::XAnyEvent, kind: EventKind, } @@ -27,7 +26,7 @@ impl Event { &self.kind } - pub(super) fn from_raw(event: *mut x::XAnyEvent) -> Result { + pub(super) fn from_raw(event: *mut xlib::XAnyEvent) -> Result { Ok(Event { inner: event, kind: EventKind::None, diff --git a/xlib/src/image.rs b/x11/src/xlib/image.rs similarity index 80% rename from xlib/src/image.rs rename to x11/src/xlib/image.rs index e84c542..42a2d4a 100644 --- a/xlib/src/image.rs +++ b/x11/src/xlib/image.rs @@ -1,10 +1,10 @@ -use x11::xlib as x; +use x11::xlib; -use X11Error; +use crate::errors::{Error, Result}; /// A handle to an XImage. pub struct Image { - pub(super) inner: *mut x::XImage, + pub(super) inner: *mut xlib::XImage, } /// Image byte order @@ -45,12 +45,12 @@ impl Image { } /// Get byte order - pub fn get_byte_order(&self) -> Result { + pub fn get_byte_order(&self) -> Result { let byte_order = unsafe { (*self.inner).byte_order }; match byte_order { - x::LSBFirst => Ok(ImageByteOrder::LSBFirst), - x::MSBFirst => Ok(ImageByteOrder::MSBFirst), - _ => Err(X11Error::InvalidByteOrder), + xlib::LSBFirst => Ok(ImageByteOrder::LSBFirst), + xlib::MSBFirst => Ok(ImageByteOrder::MSBFirst), + order => Err(Error::InvalidByteOrder(order)), } } @@ -64,7 +64,7 @@ impl Image { impl Drop for Image { fn drop(&mut self) { - unsafe { x::XDestroyImage(self.inner) }; + unsafe { xlib::XDestroyImage(self.inner) }; } } diff --git a/x11/src/xlib/mod.rs b/x11/src/xlib/mod.rs new file mode 100644 index 0000000..5ed8e83 --- /dev/null +++ b/x11/src/xlib/mod.rs @@ -0,0 +1,23 @@ +mod atom; +mod cursor; +mod display; +mod drawable; +mod event; +mod image; +mod visual; +mod window; + +pub use self::atom::Atom; +pub use self::cursor::Cursor; +pub use self::display::{Display, GetDisplay}; +pub use self::drawable::Drawable; +pub use self::event::{Event, EventKind}; +pub use self::image::Image; +pub use self::visual::Visual; +pub use self::window::Window; + +pub const XC_crosshair: u32 = 34; +pub const XC_ll_angle: u32 = 76; +pub const XC_lr_angle: u32 = 78; +pub const XC_ul_angle: u32 = 144; +pub const XC_ur_angle: u32 = 148; diff --git a/xlib/src/visual.rs b/x11/src/xlib/visual.rs similarity index 55% rename from xlib/src/visual.rs rename to x11/src/xlib/visual.rs index 264d5e8..5bcf83d 100644 --- a/xlib/src/visual.rs +++ b/x11/src/xlib/visual.rs @@ -1,21 +1,21 @@ -use x11::xlib as x; +use x11::xlib; -use Display; +use super::display::Display; /// A wrapper around a Visual pub struct Visual { - pub(super) inner: *mut x::Visual, + pub(super) inner: *mut xlib::Visual, } impl Visual { /// Gets the raw handle to the x11 Visual - pub fn as_raw(&self) -> *mut x::Visual { + pub fn as_raw(&self) -> *mut xlib::Visual { self.inner } /// Gets the default visual pub fn default(display: &Display, screen: i32) -> Self { - let inner = unsafe { x::XDefaultVisual(display.as_raw(), screen) }; + let inner = unsafe { xlib::XDefaultVisual(display.as_raw(), screen) }; Visual { inner } } } diff --git a/xlib/src/window.rs b/x11/src/xlib/window.rs similarity index 69% rename from xlib/src/window.rs rename to x11/src/xlib/window.rs index 77c3176..80565b0 100644 --- a/xlib/src/window.rs +++ b/x11/src/xlib/window.rs @@ -1,22 +1,20 @@ use std::mem; -// use imlib2::Drawable; -use libc; -use x11::xlib as x; +use x11::xlib; -use {Atom, Display, Drawable, GetDisplay, Image, Rectangle, X11Error}; +use crate::errors::{Error, Result}; +use crate::rect::Rectangle; + +use super::atom::Atom; +use super::display::{Display, GetDisplay}; +use super::drawable::Drawable; +use super::image::Image; /// A wrapper around a window handle. -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Clone, PartialEq, Eq)] pub struct Window { - pub(super) display: *mut x::Display, - pub(super) inner: x::Window, -} - -/// Window Attributes -pub struct WindowAttributes { - pub(super) display: *mut x::Display, - pub(self) inner: *mut x::XWindowAttributes, + pub(super) display: *mut xlib::Display, + pub(super) inner: xlib::Window, } impl Window { @@ -25,14 +23,14 @@ impl Window { display: &Display, parent: Option, location: Rectangle, - ) -> Result { + ) -> Result { let parent = match parent { Some(parent) => parent, None => display.get_default_root_window()?, }; let visual = display.default_visual(0); let window = unsafe { - x::XCreateWindow( + xlib::XCreateWindow( display.as_raw(), parent.as_raw(), location.x as i32, @@ -44,7 +42,7 @@ impl Window { 0, visual.as_raw(), 0, - 0 as *mut x::XSetWindowAttributes, + 0 as *mut xlib::XSetWindowAttributes, ) }; Ok(Window { @@ -54,7 +52,7 @@ impl Window { } /// Create a new Window instance from an existing ID - pub fn create_from_handle(display: &Display, id: u64) -> Result { + pub fn create_from_handle(display: &Display, id: u64) -> Result { Ok(Window { display: display.as_raw(), inner: id, @@ -62,13 +60,13 @@ impl Window { } /// Get window attributes. - pub fn get_attributes(&self) -> Result { + pub fn get_attributes(&self) -> Result { let attr = unsafe { - libc::malloc(mem::size_of::()) as *mut x::XWindowAttributes + libc::malloc(mem::size_of::()) as *mut xlib::XWindowAttributes }; - let result = unsafe { x::XGetWindowAttributes(self.display, self.inner, attr) }; + let result = unsafe { xlib::XGetWindowAttributes(self.display, self.inner, attr) }; match result { - 0 => Err(X11Error::GetAttributesError), + 0 => Err(Error::GetAttributesError), _ => Ok(WindowAttributes { display: self.display, inner: attr, @@ -77,12 +75,12 @@ impl Window { } /// Get the raw window handle - pub fn as_raw(&self) -> x::Window { + pub fn as_raw(&self) -> xlib::Window { self.inner } - /// Get image - pub fn get_image(&self) -> Result { + /// Gets the image from this window using XGetImage. + pub fn get_image(&self) -> Result { let attr = self.get_attributes()?; Drawable::get_image( self, @@ -101,32 +99,49 @@ impl Window { use std::mem::transmute; let v = val.as_raw(); unsafe { - x::XChangeProperty( + xlib::XChangeProperty( self.display, self.inner, key.as_raw(), - x::XA_ATOM, + xlib::XA_ATOM, 32, - x::PropModeReplace, + xlib::PropModeReplace, transmute(&v), 1, ); } } + + /// Map to display + pub fn map(&self) { + unsafe { xlib::XMapWindow(self.display, self.inner) }; + } } impl GetDisplay for Window { - fn get_display(&self) -> *mut x::Display { + fn get_display(&self) -> *mut xlib::Display { self.display } } impl Drawable for Window { - fn as_drawable(&self) -> x::Drawable { + fn as_drawable(&self) -> xlib::Drawable { self.inner } } +impl Drop for Window { + fn drop(&mut self) { + unsafe { xlib::XDestroyWindow(self.display, self.inner) }; + } +} + +/// Window Attributes +pub struct WindowAttributes { + pub(super) display: *mut xlib::Display, + pub(self) inner: *mut xlib::XWindowAttributes, +} + // impl AsRef for Window { // fn as_ref(&self) -> &Drawable { // &self.inner diff --git a/x11/src/xrender/mod.rs b/x11/src/xrender/mod.rs new file mode 100644 index 0000000..d9a70d2 --- /dev/null +++ b/x11/src/xrender/mod.rs @@ -0,0 +1 @@ +mod picture; diff --git a/x11/src/xrender/picture.rs b/x11/src/xrender/picture.rs new file mode 100644 index 0000000..82c0c32 --- /dev/null +++ b/x11/src/xrender/picture.rs @@ -0,0 +1,7 @@ +pub struct Picture {} + +impl Picture {} + +impl Drop for Picture { + fn drop(&self) {} +} diff --git a/xlib/Cargo.toml b/xlib/Cargo.toml deleted file mode 100644 index e04e24f..0000000 --- a/xlib/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "leanshot_xlib" -version = "0.2.0" -description = "xlib bindings" -license-file = "../LICENSE" -authors = ["Michael Zhang "] - -[dependencies] -failure = "0.1" -libc = "0.2" -x11 = { version = "2.18", features = ["xlib"] } diff --git a/xlib/src/cursor.rs b/xlib/src/cursor.rs deleted file mode 100644 index 41bef77..0000000 --- a/xlib/src/cursor.rs +++ /dev/null @@ -1,13 +0,0 @@ -use x11::xlib as x; - -/// Mouse pointer -pub struct Cursor { - pub(crate) display: *mut x::Display, - pub(crate) inner: x::Cursor, -} - -impl Drop for Cursor { - fn drop(&mut self) { - unsafe { x::XFreeCursor(self.display, self.inner) }; - } -} diff --git a/xlib/src/cursorfont.rs b/xlib/src/cursorfont.rs deleted file mode 100644 index 4d96aba..0000000 --- a/xlib/src/cursorfont.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub const XC_crosshair: u32 = 34; -pub const XC_ll_angle: u32 = 76; -pub const XC_lr_angle: u32 = 78; -pub const XC_ul_angle: u32 = 144; -pub const XC_ur_angle: u32 = 148; diff --git a/xlib/src/errors.rs b/xlib/src/errors.rs deleted file mode 100644 index 8978708..0000000 --- a/xlib/src/errors.rs +++ /dev/null @@ -1,25 +0,0 @@ -/// Any error that can be raised when using this library. -#[allow(missing_docs)] -#[derive(Debug, Fail)] -pub enum X11Error { - #[fail(display = "failed to create cursor")] - CreateCursorError, - - #[fail(display = "failed to open display")] - DisplayOpenError, - - #[fail(display = "failed to get attributes")] - GetAttributesError, - - #[fail(display = "failed to get window")] - GetWindowError, - - #[fail(display = "invalid byte order")] - InvalidByteOrder, - - #[fail(display = "failed to translate coordinates")] - TranslateCoordinatesError, - - #[fail(display = "error")] - Error, -} diff --git a/xlib/src/lib.rs b/xlib/src/lib.rs deleted file mode 100644 index e058b3d..0000000 --- a/xlib/src/lib.rs +++ /dev/null @@ -1,35 +0,0 @@ -//! Safe-ish bindings to parts of x11's xlib module. -//! -//! I need this for my project. - -#[macro_use] -extern crate failure; -extern crate libc; -pub extern crate x11; - -mod atom; -mod cursor; -mod display; -mod drawable; -mod errors; -mod event; -mod image; -mod rect; -mod visual; -mod window; - -#[allow(non_upper_case_globals)] -#[allow(missing_docs)] -mod cursorfont; - -pub use atom::Atom; -pub use cursor::Cursor; -pub use cursorfont::*; -pub use display::{Display, GetDisplay, Grab}; -pub use drawable::Drawable; -pub use errors::X11Error; -pub use event::{Event, EventKind}; -pub use image::{Image, ImageByteOrder, PixBuffer}; -pub use rect::Rectangle; -pub use visual::Visual; -pub use window::{Window, WindowAttributes};