V1.1 #2

Merged
stjet merged 7 commits from v1.1 into master 2025-05-04 18:10:46 +01:00
31 changed files with 87 additions and 71 deletions
Showing only changes of commit 667b4cd2d9 - Show all commits

View File

@@ -9,7 +9,7 @@ default-run = "ming"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[workspace]
members = [ "linux" ]
members = [ "wm", "wm/linux" ]
[build-dependencies]
bmp-rust = "0.5.0"
@@ -17,20 +17,16 @@ blake2 = { version = "0.10.6", default-features = false }
[dependencies]
ming-wm-lib = { path = "ming-wm-lib" }
blake2 = { version = "0.10.6", default-features = false }
linux = { path = "linux" }
termion = { version = "4.0.3", optional = true }
wm = { path = "wm", optional = true }
rodio = { version = "0.19.0", default-features = false, features = [ "flac", "mp3", "symphonia-vorbis", "wav" ], optional = true }
rand = { version = "0.9.0", default-features = false, features = [ "small_rng" ], optional = true }
id3 = { version = "1.10.0", optional = true }
mp4ameta = { version = "0.11.0", optional = true }
metaflac = { version = "0.2.5", optional = true }
bmp-rust = "0.5.0"
pty-process = { version = "0.5.1", optional = true }
[features]
default = [ "main", "terminal" ]
main = [ "termion" ]
default = [ "wm", "terminal" ]
terminal = [ "pty-process" ]
audio_player = [ "id3", "mp4ameta", "metaflac", "rand", "rodio" ]
@@ -39,8 +35,8 @@ lto = true
[[bin]]
name = "ming"
path = "src/bin/main.rs"
required-features = [ "main" ]
path = "src/bin/wm.rs"
required-features = [ "wm" ]
[[bin]]
name = "mingFiles_Audio_Player"

View File

@@ -1,6 +1,6 @@
[package]
name = "ming-wm-lib"
version = "0.1.6"
version = "0.1.7"
repository = "https://github.com/stjet/ming-wm"
description = "library for building windows for ming-wm in rust"
readme = "README.md"

View File

@@ -2,10 +2,10 @@ use std::vec;
use std::vec::Vec;
use crate::components::Component;
use ming_wm_lib::framebuffer_types::{ Dimensions, Point };
use ming_wm_lib::themes::ThemeInfo;
use ming_wm_lib::messages::WindowMessage;
use ming_wm_lib::window_manager_types::DrawInstructions;
use crate::framebuffer_types::{ Dimensions, Point };
use crate::themes::ThemeInfo;
use crate::messages::WindowMessage;
use crate::window_manager_types::DrawInstructions;
pub struct HighlightButton<T> {
name_: String,

View File

@@ -1,8 +1,8 @@
use std::vec::Vec;
use ming_wm_lib::themes::ThemeInfo;
use ming_wm_lib::messages::WindowMessage;
use ming_wm_lib::window_manager_types::DrawInstructions;
use crate::themes::ThemeInfo;
use crate::messages::WindowMessage;
use crate::window_manager_types::DrawInstructions;
pub mod toggle_button;
pub mod highlight_button;

View File

@@ -1,12 +1,11 @@
use std::vec;
use std::vec::Vec;
use ming_wm_lib::framebuffer_types::{ Dimensions, Point };
use ming_wm_lib::themes::ThemeInfo;
use ming_wm_lib::messages::WindowMessage;
use ming_wm_lib::window_manager_types::DrawInstructions;
use ming_wm_lib::utils::calc_actual_lines;
use crate::framebuffer_types::{ Dimensions, Point };
use crate::themes::ThemeInfo;
use crate::messages::WindowMessage;
use crate::window_manager_types::DrawInstructions;
use crate::utils::calc_actual_lines;
use crate::components::Component;
const MONO_WIDTH: u8 = 10;

View File

@@ -2,10 +2,10 @@ use std::vec;
use std::vec::Vec;
use crate::components::Component;
use ming_wm_lib::framebuffer_types::{ Dimensions, Point };
use ming_wm_lib::themes::ThemeInfo;
use ming_wm_lib::messages::WindowMessage;
use ming_wm_lib::window_manager_types::DrawInstructions;
use crate::framebuffer_types::{ Dimensions, Point };
use crate::themes::ThemeInfo;
use crate::messages::WindowMessage;
use crate::window_manager_types::DrawInstructions;
const MONO_WIDTH: u8 = 10;

View File

@@ -2,10 +2,10 @@ use std::vec;
use std::vec::Vec;
use crate::components::Component;
use ming_wm_lib::framebuffer_types::{ Dimensions, Point };
use ming_wm_lib::themes::ThemeInfo;
use ming_wm_lib::messages::WindowMessage;
use ming_wm_lib::window_manager_types::DrawInstructions;
use crate::framebuffer_types::{ Dimensions, Point };
use crate::themes::ThemeInfo;
use crate::messages::WindowMessage;
use crate::window_manager_types::DrawInstructions;
pub struct ToggleButton<T> {
name_: String,

View File

@@ -4,6 +4,7 @@ pub mod themes;
pub mod serialize;
pub mod messages;
pub mod ipc;
pub mod components;
pub mod dirs;
pub mod utils;
pub mod logging;

View File

@@ -214,3 +214,16 @@ pub fn path_autocomplete(current_path: &str, partial_path: &str) -> Option<Strin
None
}
}
pub fn get_all_files(dir: PathBuf) -> Vec<PathBuf> {
let mut files = Vec::new();
for entry in read_dir(dir).unwrap() {
let path = entry.unwrap().path();
if path.is_dir() {
files.extend(get_all_files(path));
} else {
files.push(path);
}
}
files
}

View File

@@ -17,10 +17,9 @@ use ming_wm_lib::window_manager_types::{ DrawInstructions, WindowLike, WindowLik
use ming_wm_lib::messages::{ WindowMessage, WindowMessageResponse };
use ming_wm_lib::framebuffer_types::Dimensions;
use ming_wm_lib::themes::ThemeInfo;
use ming_wm_lib::utils::{ concat_paths, path_autocomplete, format_seconds, Substring };
use ming_wm_lib::utils::{ concat_paths, get_all_files, path_autocomplete, format_seconds, Substring };
use ming_wm_lib::dirs::home;
use ming_wm_lib::ipc::listen;
use ming_wm::fs::get_all_files;
fn get_artist(path: &PathBuf) -> Option<String> {
let ext = path.extension().unwrap();

View File

@@ -6,15 +6,19 @@ use std::io::{ stdin, stdout, BufReader, BufRead, Write };
use std::process::exit;
use std::env;
use linux::fb::Framebuffer;
use linux::raw::RawStdout;
use termion::input::TermRead;
use termion::event::Key;
//termion is an external dep, will be removed eventually
use wm::termion::input::TermRead;
use wm::termion::event::Key;
use wm::linux::fb::Framebuffer;
use wm::linux::raw::RawStdout;
use wm::framebuffer::{ FramebufferWriter, FramebufferInfo };
use wm::window_manager::WindowManager;
use ming_wm_lib::window_manager_types::KeyChar;
use ming_wm_lib::messages::*;
use ming_wm::framebuffer::{ FramebufferWriter, FramebufferInfo };
use ming_wm::window_manager::WindowManager;
include!(concat!(env!("OUT_DIR"), "/password.rs"));
const CLEAR_ALL: &'static str = "\x1b[2J";
const HIDE_CURSOR: &'static str = "\x1b[?25l";
@@ -71,7 +75,7 @@ fn init(framebuffer: Framebuffer, framebuffer_info: FramebufferInfo) {
writer.init(framebuffer_info.clone());
let mut wm: WindowManager = WindowManager::new(writer, framebuffer, dimensions, rotate, grayscale);
let mut wm: WindowManager = WindowManager::new(writer, framebuffer, dimensions, rotate, grayscale, PASSWORD_HASH);
let mut stdout = RawStdout::new(stdout());
stdout.enter_raw_mode().unwrap();

14
wm/Cargo.toml Normal file
View File

@@ -0,0 +1,14 @@
[package]
name = "wm"
version = "1.0.3"
repository = "https://github.com/stjet/ming-wm"
license = "GPL-3.0-or-later"
edition = "2021"
[dependencies]
ming-wm-lib = { path = "../ming-wm-lib" }
linux = { path = "linux" }
blake2 = { version = "0.10.6", default-features = false }
termion = { version = "4.0.3" }
bmp-rust = "0.5.0"

View File

@@ -7,8 +7,8 @@ use ming_wm_lib::messages::{ WindowMessage, WindowMessageResponse };
use ming_wm_lib::framebuffer_types::Dimensions;
use ming_wm_lib::themes::ThemeInfo;
use ming_wm_lib::dirs::exe_dir;
use crate::components::Component;
use crate::components::paragraph::Paragraph;
use ming_wm_lib::components::Component;
use ming_wm_lib::components::paragraph::Paragraph;
pub struct About {
dimensions: Dimensions,

View File

@@ -8,8 +8,8 @@ use ming_wm_lib::messages::{ WindowMessage, WindowMessageResponse };
use ming_wm_lib::dirs::exe_dir;
use ming_wm_lib::framebuffer_types::Dimensions;
use ming_wm_lib::themes::ThemeInfo;
use crate::components::paragraph::Paragraph;
use crate::components::Component;
use ming_wm_lib::components::paragraph::Paragraph;
use ming_wm_lib::components::Component;
pub struct Help {
dimensions: Dimensions,

View File

@@ -7,13 +7,12 @@ use ming_wm_lib::messages::{ WindowMessage, WindowMessageResponse, WindowManager
use ming_wm_lib::window_manager_types::{ DrawInstructions, WindowLike, WindowLikeType };
use blake2::{ Blake2b512, Digest };
include!(concat!(env!("OUT_DIR"), "/password.rs"));
//const PASSWORD_HASH: [u8; 64] = [220, 88, 183, 188, 240, 27, 107, 181, 58, 191, 198, 170, 114, 38, 7, 148, 6, 179, 75, 128, 231, 171, 172, 220, 85, 38, 36, 113, 116, 146, 70, 197, 163, 179, 158, 192, 130, 53, 247, 48, 47, 209, 95, 96, 179, 211, 4, 122, 254, 127, 21, 165, 139, 199, 151, 226, 216, 176, 123, 41, 194, 221, 58, 69];
pub struct LockScreen {
dimensions: Dimensions,
input_password: String,
password_hash: [u8; 64],
}
impl WindowLike for LockScreen {
@@ -28,7 +27,7 @@ impl WindowLike for LockScreen {
//check password
let mut hasher = Blake2b512::new();
hasher.update((self.input_password.clone() + "salt?sorrycryptographers").as_bytes());
if hasher.finalize() == PASSWORD_HASH.into() {
if hasher.finalize() == self.password_hash.into() {
WindowMessageResponse::Request(WindowManagerRequest::Unlock)
} else {
self.input_password = String::new();
@@ -73,10 +72,11 @@ impl WindowLike for LockScreen {
}
impl LockScreen {
pub fn new() -> Self {
pub fn new(password_hash: [u8; 64]) -> Self {
Self {
dimensions: [0, 0],
input_password: String::new(),
password_hash,
}
}
}

View File

@@ -7,8 +7,8 @@ use ming_wm_lib::messages::{ WindowMessage, WindowMessageResponse, WindowManager
use ming_wm_lib::framebuffer_types::Dimensions;
use ming_wm_lib::themes::ThemeInfo;
use ming_wm_lib::utils::point_inside;
use crate::components::Component;
use crate::components::press_button::PressButton;
use ming_wm_lib::components::Component;
use ming_wm_lib::components::press_button::PressButton;
//seems like framebuffer only updates if (real) key is pressed...
//on mobile, volume down button seems to work but is annoying

View File

@@ -7,9 +7,9 @@ use ming_wm_lib::messages::{ WindowMessage, WindowMessageResponse, WindowManager
use ming_wm_lib::framebuffer_types::Dimensions;
use ming_wm_lib::themes::ThemeInfo;
use ming_wm_lib::dirs::exe_dir;
use ming_wm_lib::components::Component;
use ming_wm_lib::components::highlight_button::HighlightButton;
use crate::fs::{ ExeWindowInfos, get_all_executable_windows };
use crate::components::Component;
use crate::components::highlight_button::HighlightButton;
static CATEGORIES: [&'static str; 9] = ["About", "Utils", "Games", "Editing", "Files", "Internet", "Misc", "Help", "Lock"];

View File

@@ -6,8 +6,8 @@ use ming_wm_lib::window_manager_types::{ DrawInstructions, WindowLike, WindowLik
use ming_wm_lib::messages::{ WindowMessage, WindowMessageResponse, WindowManagerRequest, ShortcutType, InfoType, WindowsVec };
use ming_wm_lib::framebuffer_types::Dimensions;
use ming_wm_lib::themes::ThemeInfo;
use crate::components::Component;
use crate::components::toggle_button::ToggleButton;
use ming_wm_lib::components::Component;
use ming_wm_lib::components::toggle_button::ToggleButton;
const PADDING: usize = 4;
const META_WIDTH: usize = 175; //of the window button

View File

@@ -1,5 +1,4 @@
use std::fs::{ read_dir, File };
use std::path::PathBuf;
use std::io::Read;
use std::collections::HashMap;
@@ -34,19 +33,6 @@ pub fn get_font_char_from_fonts(fonts: &[String], c: char) -> (char, Vec<Vec<u8>
get_font_char(&p, '?').unwrap_or(('?', vec![vec![0]], 0))
}
pub fn get_all_files(dir: PathBuf) -> Vec<PathBuf> {
let mut files = Vec::new();
for entry in read_dir(dir).unwrap() {
let path = entry.unwrap().path();
if path.is_dir() {
files.extend(get_all_files(path));
} else {
files.push(path);
}
}
files
}
//Category, Vec<Display name, file name>
pub type ExeWindowInfos = HashMap<String, Vec<(String, String)>>;

View File

@@ -1,6 +1,8 @@
pub use linux;
pub use termion;
pub mod framebuffer;
pub mod window_manager;
pub mod components;
pub mod fs;
mod proxy_window_like;
mod essential;

View File

@@ -65,12 +65,13 @@ pub struct WindowManager {
current_workspace: u8,
framebuffer: Framebuffer,
clipboard: Option<String>,
password_hash: [u8; 64],
}
//1 is up, 2 is down
impl WindowManager {
pub fn new(writer: FramebufferWriter, framebuffer: Framebuffer, dimensions: Dimensions, rotate: bool, grayscale: bool) -> Self {
pub fn new(writer: FramebufferWriter, framebuffer: Framebuffer, dimensions: Dimensions, rotate: bool, grayscale: bool, password_hash: [u8; 64]) -> Self {
//println!("bg: {}x{}", dimensions[0], dimensions[1] - TASKBAR_HEIGHT - INDICATOR_HEIGHT);
let mut wm = WindowManager {
writer: RefCell::new(writer),
@@ -86,6 +87,7 @@ impl WindowManager {
current_workspace: 0,
framebuffer,
clipboard: None,
password_hash,
};
wm.lock();
wm.change_theme();
@@ -136,7 +138,7 @@ impl WindowManager {
fn lock(&mut self) {
self.locked = true;
self.window_infos = Vec::new();
self.add_window_like(Box::new(LockScreen::new()), [0, 0], None);
self.add_window_like(Box::new(LockScreen::new(self.password_hash)), [0, 0], None);
}
fn unlock(&mut self) {