From 78f389beaae39d011e49a87d5d44dba9ffb762a9 Mon Sep 17 00:00:00 2001 From: Richard Acayan Date: Wed, 24 Jul 2024 22:21:30 -0400 Subject: [PATCH] treewide: use Rust 2018 import paths Rust 2018 is required for D-Bus support with tokio/zbus. --- Cargo.toml | 1 + src/core/button.rs | 12 +++---- src/core/graphics.rs | 23 +++++++------- src/core/layout.rs | 6 ++-- src/core/mod.rs | 6 ---- src/main.rs | 12 +++---- src/wayland/buffer.rs | 25 +++++++-------- src/wayland/dispatcher.rs | 66 +++++++++++++++++++-------------------- src/wayland/keyboard.rs | 20 ++++++------ src/wayland/mod.rs | 13 +++----- src/wayland/protocols.rs | 14 ++++----- src/wayland/seat.rs | 22 ++++++------- src/wayland/surface.rs | 34 ++++++++++---------- 13 files changed, 119 insertions(+), 135 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5c2689e..1998f76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "rusted-fetter" version = "0.1.0" +edition = "2018" [dependencies] fontconfig = "0.9.0" diff --git a/src/core/button.rs b/src/core/button.rs index 2c8a365..dd0a499 100644 --- a/src/core/button.rs +++ b/src/core/button.rs @@ -3,12 +3,11 @@ * Copyright (c) 2024, Richard Acayan. All rights reserved. */ -use core::Display; -use core::Graphics; -use core::Layout; -use core::layout::Key; -use core::layout::MODIFIERS_MAX; -use core::xkeysym::Keysym; +use crate::core::Display; +use crate::core::Graphics; +use crate::core::Layout; +use crate::core::layout::Key; +use crate::core::layout::MODIFIERS_MAX; use std::collections::VecDeque; use std::convert::TryInto; use std::iter; @@ -17,6 +16,7 @@ use std::sync::Arc; use std::sync::Mutex; use std::time::Duration; use std::time::Instant; +use xkeysym::Keysym; /* * The available states for the modifier keys. diff --git a/src/core/graphics.rs b/src/core/graphics.rs index 68370eb..90d4117 100644 --- a/src/core/graphics.rs +++ b/src/core/graphics.rs @@ -3,23 +3,22 @@ * Copyright (c) 2024, Richard Acayan. All rights reserved. */ -use core::button::ModState; -use core::fontconfig; -use core::freetype::freetype; -use core::imgref::ImgRefMut; -use core::imgref::ImgRef; -use core::imgref::ImgVec; -use core::Layout; -use core::layout::Key; -use core::layout::Part; -use core::rgb::alt::BGR; -use core::rgb::alt::BGRA; -use core::xkeysym::Keysym; +use crate::core::Layout; +use crate::core::button::ModState; +use crate::core::layout::Key; +use crate::core::layout::Part; +use freetype::freetype; +use imgref::ImgRef; +use imgref::ImgRefMut; +use imgref::ImgVec; +use rgb::alt::BGR; +use rgb::alt::BGRA; use std::collections::HashMap; use std::fs::File; use std::io::Read; use std::iter; use std::ptr; +use xkeysym::Keysym; fn convert_gray_to_bgrx(mut dest: ImgRefMut>, src: ImgRef, fg_color: BGR) { diff --git a/src/core/layout.rs b/src/core/layout.rs index 39f9447..8ec7418 100644 --- a/src/core/layout.rs +++ b/src/core/layout.rs @@ -3,9 +3,8 @@ * Copyright (c) 2024, Richard Acayan. All rights reserved. */ -use core::button::ModState; -use core::expat; -use core::xkeysym::Keysym; +use crate::core::button::ModState; +use crate::core::expat; use std::cmp::Ordering; use std::collections::HashMap; use std::str::FromStr; @@ -18,6 +17,7 @@ use std::os::raw::c_char; use std::os::raw::c_void; use std::path::Path; use std::ptr; +use xkeysym::Keysym; unsafe extern "C" fn start_elem(data: *mut c_void, c_name: *const expat::XML_Char, diff --git a/src/core/mod.rs b/src/core/mod.rs index 168b670..01acac1 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -3,12 +3,6 @@ * Copyright (c) 2024, Richard Acayan. All rights reserved. */ -pub extern crate fontconfig; -pub extern crate freetype; -pub extern crate imgref; -pub extern crate rgb; -pub extern crate xkeysym; - mod button; mod expat; mod graphics; diff --git a/src/main.rs b/src/main.rs index e9a80ed..9079f17 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,20 +3,18 @@ * Copyright (c) 2024, Richard Acayan. All rights reserved. */ -extern crate polling; - -mod wayland; mod core; +mod wayland; -use core::Layout; +use crate::core::Layout; +use crate::wayland::Dispatcher; use polling::Event; use polling::Events; use polling::Poller; use std::path::Path; use std::time::Instant; -use wayland::Dispatcher; -use wayland::wayland_client::Connection; -use wayland::wayland_client::globals; +use wayland_client::Connection; +use wayland_client::globals; fn main() { diff --git a/src/wayland/buffer.rs b/src/wayland/buffer.rs index 47fab85..3cf52aa 100644 --- a/src/wayland/buffer.rs +++ b/src/wayland/buffer.rs @@ -3,14 +3,11 @@ * Copyright (c) 2024, Richard Acayan. All rights reserved. */ -extern crate libc; -extern crate memmap2; - -use core::imgref::ImgRef; -use core::imgref::ImgRefMut; -use core::rgb::alt::BGRA; -use core::rgb::FromSlice; -use self::memmap2::MmapMut; +use imgref::ImgRef; +use imgref::ImgRefMut; +use memmap2::MmapMut; +use rgb::alt::BGRA; +use rgb::FromSlice; use std::ffi::CString; use std::fs::File; use std::io::Error; @@ -19,12 +16,12 @@ use std::iter; use std::os::fd::FromRawFd; use std::os::fd::AsFd; use std::process; -use wayland::wayland_client::protocol::wl_buffer::WlBuffer; -use wayland::wayland_client::protocol::wl_shm_pool::WlShmPool; -use wayland::wayland_client::protocol::wl_shm; -use wayland::wayland_client::protocol::wl_surface::WlSurface; -use wayland::wayland_client::Dispatch; -use wayland::wayland_client::QueueHandle; +use wayland_client::protocol::wl_buffer::WlBuffer; +use wayland_client::protocol::wl_shm_pool::WlShmPool; +use wayland_client::protocol::wl_shm; +use wayland_client::protocol::wl_surface::WlSurface; +use wayland_client::Dispatch; +use wayland_client::QueueHandle; pub struct Buffer { file: File, diff --git a/src/wayland/dispatcher.rs b/src/wayland/dispatcher.rs index 83077e8..1858738 100644 --- a/src/wayland/dispatcher.rs +++ b/src/wayland/dispatcher.rs @@ -3,42 +3,42 @@ * Copyright (c) 2024, Richard Acayan. All rights reserved. */ -use core::Button; -use core::Display; -use core::Graphics; -use core::Layout; +use crate::core::Button; +use crate::core::Display; +use crate::core::Graphics; +use crate::core::Layout; +use crate::wayland::Seat; +use crate::wayland::Surface; +use crate::wayland::VirtualKeyboard; +use crate::wayland::wlr_layer_shell_unstable_v1::zwlr_layer_shell_v1; +use crate::wayland::wlr_layer_shell_unstable_v1::zwlr_layer_surface_v1; +use crate::wayland::fractional_scale_v1::wp_fractional_scale_manager_v1; +use crate::wayland::fractional_scale_v1::wp_fractional_scale_v1; +use crate::wayland::input_method_unstable_v2::zwp_input_method_manager_v2; +use crate::wayland::input_method_unstable_v2::zwp_input_method_v2; +use crate::wayland::viewporter::wp_viewporter; +use crate::wayland::viewporter::wp_viewport; +use crate::wayland::virtual_keyboard_unstable_v1::zwp_virtual_keyboard_manager_v1; +use crate::wayland::virtual_keyboard_unstable_v1::zwp_virtual_keyboard_v1; use std::io::Error; use std::sync::Arc; use std::sync::Mutex; -use wayland::Seat; -use wayland::Surface; -use wayland::wayland_client::globals::GlobalList; -use wayland::wayland_client::globals::GlobalListContents; -use wayland::wayland_client::protocol::wl_buffer; -use wayland::wayland_client::protocol::wl_compositor; -use wayland::wayland_client::protocol::wl_pointer; -use wayland::wayland_client::protocol::wl_registry; -use wayland::wayland_client::protocol::wl_seat; -use wayland::wayland_client::protocol::wl_shm; -use wayland::wayland_client::protocol::wl_shm_pool; -use wayland::wayland_client::protocol::wl_surface; -use wayland::wayland_client::protocol::wl_touch; -use wayland::wayland_client::Connection; -use wayland::wayland_client::Dispatch; -use wayland::wayland_client::Proxy; -use wayland::wayland_client::QueueHandle; -use wayland::wayland_client::WEnum; -use wayland::wlr_layer_shell_unstable_v1::zwlr_layer_shell_v1; -use wayland::wlr_layer_shell_unstable_v1::zwlr_layer_surface_v1; -use wayland::fractional_scale_v1::wp_fractional_scale_manager_v1; -use wayland::fractional_scale_v1::wp_fractional_scale_v1; -use wayland::input_method_unstable_v2::zwp_input_method_manager_v2; -use wayland::input_method_unstable_v2::zwp_input_method_v2; -use wayland::viewporter::wp_viewporter; -use wayland::viewporter::wp_viewport; -use wayland::virtual_keyboard_unstable_v1::zwp_virtual_keyboard_manager_v1; -use wayland::virtual_keyboard_unstable_v1::zwp_virtual_keyboard_v1; -use wayland::VirtualKeyboard; +use wayland_client::Connection; +use wayland_client::Dispatch; +use wayland_client::Proxy; +use wayland_client::QueueHandle; +use wayland_client::WEnum; +use wayland_client::globals::GlobalList; +use wayland_client::globals::GlobalListContents; +use wayland_client::protocol::wl_buffer; +use wayland_client::protocol::wl_compositor; +use wayland_client::protocol::wl_pointer; +use wayland_client::protocol::wl_registry; +use wayland_client::protocol::wl_seat; +use wayland_client::protocol::wl_shm; +use wayland_client::protocol::wl_shm_pool; +use wayland_client::protocol::wl_surface; +use wayland_client::protocol::wl_touch; pub struct Dispatcher { seat: Seat, VirtualKeyboard, Self>, diff --git a/src/wayland/keyboard.rs b/src/wayland/keyboard.rs index 9dbc424..8478508 100644 --- a/src/wayland/keyboard.rs +++ b/src/wayland/keyboard.rs @@ -3,10 +3,11 @@ * Copyright (c) 2024, Richard Acayan. All rights reserved. */ -use core::Keyboard; -use core::Layout; -use core::Part; -use core::xkeysym::Keysym; +use crate::core::Keyboard; +use crate::core::Layout; +use crate::core::Part; +use crate::wayland::virtual_keyboard_unstable_v1::zwp_virtual_keyboard_manager_v1::ZwpVirtualKeyboardManagerV1; +use crate::wayland::virtual_keyboard_unstable_v1::zwp_virtual_keyboard_v1::ZwpVirtualKeyboardV1; use std::collections::HashMap; use std::fs::File; use std::fs::OpenOptions; @@ -14,12 +15,11 @@ use std::io::Seek; use std::io::Write; use std::os::fd::AsFd; use std::process; -use wayland::wayland_client::Dispatch; -use wayland::wayland_client::QueueHandle; -use wayland::wayland_client::protocol::wl_seat::WlSeat; -use wayland::wayland_client::protocol::wl_keyboard::KeymapFormat; -use wayland::virtual_keyboard_unstable_v1::zwp_virtual_keyboard_manager_v1::ZwpVirtualKeyboardManagerV1; -use wayland::virtual_keyboard_unstable_v1::zwp_virtual_keyboard_v1::ZwpVirtualKeyboardV1; +use wayland_client::Dispatch; +use wayland_client::QueueHandle; +use wayland_client::protocol::wl_seat::WlSeat; +use wayland_client::protocol::wl_keyboard::KeymapFormat; +use xkeysym::Keysym; pub struct VirtualKeyboard { vk: ZwpVirtualKeyboardV1, diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index 11fd815..cb0424b 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -3,11 +3,6 @@ * Copyright (c) 2024, Richard Acayan. All rights reserved. */ -pub extern crate wayland_client; -pub extern crate wayland_protocols; -pub extern crate wayland_protocols_wlr; -pub extern crate wayland_scanner; - mod buffer; mod dispatcher; mod keyboard; @@ -21,10 +16,10 @@ pub use self::keyboard::VirtualKeyboard; pub use self::seat::Seat; pub use self::surface::Surface; -pub use self::wayland_protocols_wlr::layer_shell::v1::client as wlr_layer_shell_unstable_v1; -pub use self::wayland_protocols::wp::fractional_scale::v1::client as fractional_scale_v1; -pub use self::wayland_protocols::wp::text_input::zv3::client as text_input_unstable_v3; -pub use self::wayland_protocols::wp::viewporter::client as viewporter; +pub use wayland_protocols_wlr::layer_shell::v1::client as wlr_layer_shell_unstable_v1; +pub use wayland_protocols::wp::fractional_scale::v1::client as fractional_scale_v1; +pub use wayland_protocols::wp::text_input::zv3::client as text_input_unstable_v3; +pub use wayland_protocols::wp::viewporter::client as viewporter; pub use self::protocols::input_method_unstable_v2; pub use self::protocols::virtual_keyboard_unstable_v1; diff --git a/src/wayland/protocols.rs b/src/wayland/protocols.rs index bc96c25..3996309 100644 --- a/src/wayland/protocols.rs +++ b/src/wayland/protocols.rs @@ -4,12 +4,12 @@ */ pub mod input_method_unstable_v2 { - use wayland::wayland_client; - use wayland::wayland_client::protocol::*; - use wayland::text_input_unstable_v3::*; + use wayland_client; + use wayland_client::protocol::*; + use crate::wayland::text_input_unstable_v3::*; pub mod __interfaces { - use wayland::wayland_client::protocol::__interfaces::*; + use wayland_client::protocol::__interfaces::*; wayland_scanner::generate_interfaces!("wayland-protocols/input-method-unstable-v2.xml"); } @@ -20,11 +20,11 @@ pub mod input_method_unstable_v2 { } pub mod virtual_keyboard_unstable_v1 { - use wayland::wayland_client; - use wayland::wayland_client::protocol::*; + use wayland_client; + use wayland_client::protocol::*; pub mod __interfaces { - use wayland::wayland_client::protocol::__interfaces::*; + use wayland_client::protocol::__interfaces::*; wayland_scanner::generate_interfaces!("wayland-protocols/virtual-keyboard-unstable-v1.xml"); } diff --git a/src/wayland/seat.rs b/src/wayland/seat.rs index 9cf566e..4159d83 100644 --- a/src/wayland/seat.rs +++ b/src/wayland/seat.rs @@ -3,19 +3,19 @@ * Copyright (c) 2024, Richard Acayan. All rights reserved. */ -use core::Button; -use core::ModState; -use core::Display; -use core::Graphics; -use core::Keyboard; -use core::Layout; +use crate::core::Button; +use crate::core::Display; +use crate::core::Graphics; +use crate::core::Keyboard; +use crate::core::Layout; +use crate::core::ModState; use std::sync::Arc; use std::sync::Mutex; -use wayland::wayland_client::protocol::wl_pointer; -use wayland::wayland_client::protocol::wl_seat; -use wayland::wayland_client::protocol::wl_touch::WlTouch; -use wayland::wayland_client::Dispatch; -use wayland::wayland_client::QueueHandle; +use wayland_client::protocol::wl_pointer; +use wayland_client::protocol::wl_seat; +use wayland_client::protocol::wl_touch::WlTouch; +use wayland_client::Dispatch; +use wayland_client::QueueHandle; enum PressAction { Pos(f64, f64), diff --git a/src/wayland/surface.rs b/src/wayland/surface.rs index bf8bc3d..d3867ec 100644 --- a/src/wayland/surface.rs +++ b/src/wayland/surface.rs @@ -3,24 +3,24 @@ * Copyright (c) 2024, Richard Acayan. All rights reserved. */ -use core::Display; -use core::imgref::ImgRefMut; -use core::rgb::alt::BGRA; +use crate::core::Display; +use crate::wayland::Buffer; +use crate::wayland::fractional_scale_v1::wp_fractional_scale_manager_v1::WpFractionalScaleManagerV1; +use crate::wayland::fractional_scale_v1::wp_fractional_scale_v1::WpFractionalScaleV1; +use crate::wayland::viewporter::wp_viewporter::WpViewporter; +use crate::wayland::viewporter::wp_viewport::WpViewport; +use crate::wayland::wlr_layer_shell_unstable_v1::zwlr_layer_shell_v1; +use crate::wayland::wlr_layer_shell_unstable_v1::zwlr_layer_surface_v1; +use imgref::ImgRefMut; +use rgb::alt::BGRA; use std::io::Error; -use wayland::Buffer; -use wayland::wayland_client::protocol::wl_buffer::WlBuffer; -use wayland::wayland_client::protocol::wl_compositor::WlCompositor; -use wayland::wayland_client::protocol::wl_shm_pool::WlShmPool; -use wayland::wayland_client::protocol::wl_shm::WlShm; -use wayland::wayland_client::protocol::wl_surface::WlSurface; -use wayland::wayland_client::Dispatch; -use wayland::wayland_client::QueueHandle; -use wayland::wlr_layer_shell_unstable_v1::zwlr_layer_shell_v1; -use wayland::wlr_layer_shell_unstable_v1::zwlr_layer_surface_v1; -use wayland::fractional_scale_v1::wp_fractional_scale_manager_v1::WpFractionalScaleManagerV1; -use wayland::fractional_scale_v1::wp_fractional_scale_v1::WpFractionalScaleV1; -use wayland::viewporter::wp_viewporter::WpViewporter; -use wayland::viewporter::wp_viewport::WpViewport; +use wayland_client::protocol::wl_buffer::WlBuffer; +use wayland_client::protocol::wl_compositor::WlCompositor; +use wayland_client::protocol::wl_shm_pool::WlShmPool; +use wayland_client::protocol::wl_shm::WlShm; +use wayland_client::protocol::wl_surface::WlSurface; +use wayland_client::Dispatch; +use wayland_client::QueueHandle; pub struct Surface { bufs: [Buffer; 2],