Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "resmon"
version = "2.32.0"
version = "2.33.0"
edition = "2021"
authors = ["Emulsion Labs"]
description = "Ultra-light taskbar resource monitor for Windows 10/11"
Expand Down
2 changes: 1 addition & 1 deletion res/resmon.manifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="ResourceMonitor" version="2.32.0.0"/>
<assemblyIdentity type="win32" name="ResourceMonitor" version="2.33.0.0"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security><requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
Expand Down
2 changes: 1 addition & 1 deletion setup.iss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; Inno Setup script. Build the exe first: cargo build --release
#define MyAppName "Resource Monitor"
#define MyAppVersion "2.32.0"
#define MyAppVersion "2.33.0"
#define MyAppPublisher "Emulsion Labs"
#define MyAppURL "https://github.com/rajhansgithub/Windows_Resource_Monitoring_Tool"
#define MyAppExeName "ResourceMonitor.exe"
Expand Down
89 changes: 86 additions & 3 deletions src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ pub enum Hit {
TileStyle(bool),
/// Icon tile's style menu: 0 memory, 1 GPU, 2 disk, 3 network.
IconPick(u8),
/// "Show in hover" button: puts item `settings::HOVER_*` in the tray hover window or takes it out.
HoverPin(u8),
/// Add-ons page: open / close this add-on's tile (`addons::Addon::idx`).
AddonOpen(u8),
/// Add-ons page: this add-on's on / off switch.
Expand Down Expand Up @@ -387,6 +389,8 @@ pub struct Monitor {
pub speed: bool,
/// Tiles drawn as lit part icons (from the settings each tick).
pub icons: bool,
/// What the tray hover window shows (`Settings::hover_items`, from the settings each tick).
pub hover: u8,
/// Icon picks from the settings: memory, GPU, disk, Ethernet style, Wi-Fi style.
pub icon_picks: [u8; 6],
/// Moving parts of the icons, stepped by the host each frame.
Expand Down Expand Up @@ -457,6 +461,7 @@ impl Monitor {
sp: speedpage::SpeedState::default(),
speed: false,
icons: false,
hover: crate::settings::HOVER_ALL,
icon_picks: [0; 6],
ianim: liticon::Anim::default(),
}
Expand Down Expand Up @@ -539,6 +544,7 @@ impl Monitor {
static FORCE: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
self.icons = a.m.s.tile_icons || *FORCE.get_or_init(|| std::env::var("RESMON_TILES").is_ok_and(|v| v == "icons"));
self.icon_picks = [a.m.s.icon_mem, a.m.s.icon_gpu, a.m.s.icon_disk, a.m.s.icon_eth, a.m.s.icon_wifi, a.m.s.icon_net];
self.hover = a.m.s.hover_items;
if !self.bt_on && self.view == Some(Dev::Bluetooth) {
self.close_dev();
}
Expand Down Expand Up @@ -1017,6 +1023,7 @@ impl Monitor {
let rr = if i as i32 == n - 1 { r } else { x + tw };
let rc = Rect { l: x, t, r: rr, b: t + th };
self.vits.push((*v, rc));
self.push_pin(rc, rc.r - self.sc(6), *v);
if let Some(d) = self.vit_dev(*v) {
self.hits.push((rc, Hit::Open(d)));
}
Expand Down Expand Up @@ -1212,10 +1219,13 @@ impl Monitor {
Vit::Net => Some(3),
_ => None,
};
let b = self.sc(24);
if let Some(k) = pick {
let b = self.sc(24);
self.hits.push((Rect { l: rc.r - b - self.sc(6), t: rc.t + self.sc(6), r: rc.r - self.sc(6), b: rc.t + self.sc(6) + b }, Hit::IconPick(k)));
}
// "Show in hover" sits left of the style button (or in its place).
let pin_r = if pick.is_some() { rc.r - self.sc(6) - b - self.sc(2) } else { rc.r - self.sc(6) };
self.push_pin(rc, pin_r, *v);
if let Some(d) = self.vit_dev(*v) {
self.hits.push((rc, Hit::Open(d)));
}
Expand All @@ -1226,6 +1236,26 @@ impl Monitor {
t
}

/// The hover-window item a tile stands for.
fn vit_hover(v: Vit) -> u8 {
use crate::settings::*;
match v {
Vit::Cpu => HOVER_CPU,
Vit::Mem => HOVER_MEM,
Vit::Gpu | Vit::Vram => HOVER_GPU,
Vit::Disk => HOVER_DISK,
Vit::Net => HOVER_NET,
Vit::Bat => HOVER_BAT,
}
}

/// A tile's "show in hover" button, 24 px, top right of `tile` ending at `right`.
fn push_pin(&mut self, tile: Rect, right: i32, v: Vit) {
let b = self.sc(24);
let t = tile.t + self.sc(6);
self.hits.push((Rect { l: right - b, t, r: right, b: t + b }, Hit::HoverPin(Self::vit_hover(v))));
}

/// Parts of the GPU group in the icon view: load, then VRAM and temperature when known.
fn gpu_parts(&self) -> Vec<u8> {
let mut v = vec![0];
Expand Down Expand Up @@ -1358,7 +1388,15 @@ impl Monitor {
Sec::Cpu => self.hits.push((r, Hit::Open(Dev::Cpu))),
Sec::Mem => self.hits.push((r, Hit::Open(Dev::Mem))),
Sec::Gpu => self.hits.push((r, Hit::Open(Dev::Gpu))),
Sec::Net => self.hits.push((r, Hit::Open(Dev::Net))),
Sec::Net => {
// "Show in hover" for data usage, right of the 14-day bars (see `nets`).
let on = self.det.adapters.iter().filter(|a| a.connected).count();
let off = if on < self.det.adapters.len() { self.sc(26) } else { 0 };
let t = r.t + head + on.max(1) as i32 * self.sc(84) + off + self.sc(24);
let b = self.sc(24);
self.hits.push((Rect { l: r.r - self.sc(12) - b, t, r: r.r - self.sc(12), b: t + b }, Hit::HoverPin(crate::settings::HOVER_USAGE)));
self.hits.push((r, Hit::Open(Dev::Net)));
}
Sec::Bt => self.hits.push((r, Hit::Open(Dev::Bluetooth))),
Sec::Addons => self.hits.push((r, Hit::Open(Dev::Addons))),
Sec::Disk => {
Expand Down Expand Up @@ -1409,6 +1447,7 @@ impl Monitor {
let mut x = r.r - s(16) - tw * SORTS.len() as i32 - s(4);
let t = r.t + s(14);
let pl = x - s(12) - s(84);
self.hits.push((Rect { l: pl - s(8) - s(30) - s(8) - s(24), t: t - s(1), r: pl - s(8) - s(30) - s(8), b: t + s(23) }, Hit::HoverPin(crate::settings::HOVER_TOP)));
self.hits.push((Rect { l: pl - s(8) - s(30), t, r: pl - s(8), b: t + s(22) }, Hit::Grouping));
self.hits.push((Rect { l: pl, t, r: x - s(12), b: t + s(22) }, Hit::Pause));
for i in 0..SORTS.len() as u8 {
Expand Down Expand Up @@ -1469,6 +1508,7 @@ impl Monitor {
let r = self.cur(Key::Vit(*v), *r);
if vis(r) {
d.vital(cv, *v, d.sh(r));
d.pins(cv, d.sh(r));
if self.vit_dev(*v).is_some_and(|dv| d.hot_open(dv, r)) {
d.open_ring(cv, d.sh(r));
}
Expand All @@ -1494,6 +1534,7 @@ impl Monitor {
Sec::Addons => d.addons_card(cv, r),
Sec::Procs => d.procs(cv, r),
}
d.pins(cv, r);
let whole = match sec {
Sec::Bt => Some(Dev::Bluetooth),
Sec::Addons => Some(Dev::Addons),
Expand Down Expand Up @@ -1613,6 +1654,34 @@ impl Draw<'_> {
self.m.hits.iter().find(|x| x.1 == h).map(|x| self.sh(x.0))
}

/// The "show in hover" buttons inside `area`: a small window over a taskbar line.
/// Filled with the accent when the item is in the hover window, an outline when not.
fn pins(&self, cv: &mut Canvas, area: Rect) {
for (i, (hr, h)) in self.m.hits.iter().enumerate() {
let Hit::HoverPin(item) = *h else { continue };
let b = self.sh(*hr);
if !area.contains(b.l, b.t) {
continue;
}
let on = self.m.hover & (1 << item) != 0;
let hot = self.hot == Some(i);
if hot {
cv.fill_round(b, b.h() as f32 / 2.0, self.col.fg.with_a(if self.dark() { 30 } else { 22 }));
}
let (cx, cy) = ((b.l + b.r) / 2, (b.t + b.b) / 2);
let win = Rect { l: cx - self.s(6), t: cy - self.s(6), r: cx + self.s(6), b: cy + self.s(2) };
let bar = Rect { l: cx - self.s(6), t: cy + self.s(4), r: cx + self.s(6), b: cy + self.s(4) + self.s(2).max(1) };
if on {
cv.fill_round(win, self.sf(2.0), self.col.accent);
cv.fill_round(bar, self.sf(1.0), self.col.accent);
} else {
let c = if hot { self.col.fg } else { self.col.dim.with_a(170) };
cv.stroke_round(win, self.sf(2.0), c);
cv.fill_round(bar, self.sf(1.0), c.with_a(110));
}
}
}

/// The pointer is on the `Open(d)` hit that covers exactly `r` (content coordinates).
fn hot_open(&self, d: Dev, r: Rect) -> bool {
self.hot.and_then(|i| self.m.hits.get(i)).is_some_and(|x| x.1 == Hit::Open(d) && x.0 == r)
Expand Down Expand Up @@ -2817,7 +2886,7 @@ impl Draw<'_> {
cv.numeral(self.f.head, &fmt::bytes(today_r + today_s), l, y + self.s(14), self.col.fg);
self.cap(cv, "MONTH", l + self.s(120), y);
cv.numeral(self.f.head, &fmt::bytes(m.month), l + self.s(120), y + self.s(14), self.col.fg);
let br = Rect { l: l + self.s(230), t: y, r: rr, b: y + self.s(58) };
let br = Rect { l: l + self.s(230), t: y, r: rr - self.s(28), b: y + self.s(58) };
if br.w() > self.s(80) && !m.days.is_empty() {
let n = m.days.len() as i32;
let g = self.s(4);
Expand Down Expand Up @@ -3297,6 +3366,20 @@ mod tests {
let pick = m.hits.iter().position(|h| h.1 == Hit::IconPick(1)).unwrap();
let open = m.hits.iter().position(|h| h.1 == Hit::Open(Dev::Gpu)).unwrap();
assert!(pick < open);
// Every tile has a "show in hover" button, inside the tile, clear of the style
// button, and ahead of the tile's own click.
use crate::settings::*;
for (v, item) in [(Vit::Cpu, HOVER_CPU), (Vit::Mem, HOVER_MEM), (Vit::Gpu, HOVER_GPU), (Vit::Disk, HOVER_DISK), (Vit::Net, HOVER_NET), (Vit::Bat, HOVER_BAT)] {
let tile = m.vits.iter().find(|x| x.0 == v).unwrap().1;
let (i, pin) = m.hits.iter().enumerate().find(|(_, h)| h.1 == Hit::HoverPin(item)).map(|(i, h)| (i, h.0)).unwrap();
assert!(pin.l >= tile.l && pin.r <= tile.r && pin.t >= tile.t && pin.b <= tile.b, "{v:?} pin inside its tile");
if let Some(o) = m.vit_dev(v).and_then(|d| m.hits.iter().position(|h| h.1 == Hit::Open(d))) {
assert!(i < o, "{v:?} pin wins over the tile click");
}
if let Some(p) = m.hits.iter().find(|h| matches!(h.1, Hit::IconPick(_)) && tile.contains(h.0.l, h.0.t)) {
assert!(pin.r <= p.0.l, "{v:?} pin left of the style button");
}
}
}
}

Expand Down
67 changes: 57 additions & 10 deletions src/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,49 @@ fn has_space(a: &App) -> bool {
a.snap.disk_used_pct.is_some() && a.snap.disk_total > 0
}

/// The ring gauge picked for the hover window (`Settings::hover_items`). Disk active time takes
/// the GPU's place on a PC without a GPU.
fn gauge_shown(a: &App, m: Metric) -> bool {
use crate::settings::*;
match m {
Metric::Cpu => a.s.hover(HOVER_CPU),
Metric::Ram => a.s.hover(HOVER_MEM),
Metric::Gpu => a.s.hover(HOVER_GPU),
_ => a.s.hover(HOVER_DISK),
}
}

/// Ring gauges the hover window shows, in order.
fn gauge_metrics(a: &App) -> Vec<Metric> {
let s = &a.snap;
let mut v = vec![Metric::Cpu, Metric::Ram];
if s.gpu.is_some() {
v.push(Metric::Gpu);
} else if s.disk_active.is_some() {
v.push(Metric::DiskActive);
}
v.retain(|m| gauge_shown(a, *m));
v
}

fn size(a: &App) -> (i32, i32) {
let mut h = PAD + HEADER + GAP + RINGS + GAP + DIAL_CARD + GAP + DIAL_CARD + GAP + USAGE + GAP + PROCS + PAD;
if has_space(a) {
h += DISK_SPACE;
use crate::settings::*;
let mut h = PAD + HEADER + PAD;
let mut card = |v: f32| h += GAP + v;
if !gauge_metrics(a).is_empty() {
card(RINGS);
}
if a.s.hover(HOVER_NET) {
card(DIAL_CARD);
}
if a.s.hover(HOVER_DISK) {
card(DIAL_CARD + if has_space(a) { DISK_SPACE } else { 0.0 });
}
if a.s.hover(HOVER_USAGE) {
card(USAGE + if a.s.data_cap_gb > 0.0 { CAP } else { 0.0 });
}
if a.s.data_cap_gb > 0.0 {
h += CAP;
if a.s.hover(HOVER_TOP) {
card(PROCS);
}
(sc(a, W), sc(a, h))
}
Expand Down Expand Up @@ -848,7 +884,7 @@ fn draw(a: &App, c: &mut Canvas, f: &Fonts, scale: f32, out: &mut Out) {
x -= w + sc(6.0);
}
}
if let Some(b) = s.battery {
if let (Some(b), true) = (s.battery, a.s.hover(crate::settings::HOVER_BAT)) {
let mut t = format!("Battery {}%", b.percent);
if b.charging {
t.push_str(" \u{2191}");
Expand Down Expand Up @@ -906,13 +942,15 @@ fn draw(a: &App, c: &mut Canvas, f: &Fonts, scale: f32, out: &mut Out) {
hit: PopupHit::ResMon,
});
}
// Only what the Monitor page's "show in hover" buttons picked.
gauges.retain(|g| gauge_shown(a, g.m));
let icons = a.s.tile_icons;
let pk = crate::liticon::resolve([a.s.icon_mem, a.s.icon_gpu, a.s.icon_disk, a.s.icon_eth, a.s.icon_wifi, a.s.icon_net], crate::liticon::detect(a.detail(), s));
let an = crate::liticon::Anim::default();
let live = crate::liticon::Live { warn: a.s.warn_pct, crit: a.s.crit_pct, ..Default::default() };
let n = gauges.len() as i32;
let n = (gauges.len() as i32).max(1);
let gw = (right - pad - gap * (n - 1)) / n;
let gh = sc(RINGS);
let gh = if gauges.is_empty() { -gap } else { sc(RINGS) };
for (i, g) in gauges.iter().enumerate() {
let x = pad + i as i32 * (gw + gap);
let r = Rect { l: x, t: y, r: x + gw, b: y + gh };
Expand Down Expand Up @@ -958,12 +996,14 @@ fn draw(a: &App, c: &mut Canvas, f: &Fonts, scale: f32, out: &mut Out) {
let ix = pad + sc(14.0);

// ---- network: dial (log scale), values, mirror chart
use crate::settings::{HOVER_DISK, HOVER_NET, HOVER_TOP, HOVER_USAGE};
let down_c = accent(Metric::Down, a.dark);
let up_c = accent(Metric::Up, a.dark);
if a.s.hover(HOVER_NET) {
let nh = sc(DIAL_CARD);
let r = Rect { l: pad, t: y, r: right, b: y + nh };
card(c, r, rad, pal, e.hot(r), scale);
out.hits.push((r, PopupHit::NetSettings));
let down_c = accent(Metric::Down, a.dark);
let up_c = accent(Metric::Up, a.dark);
if icons {
let (cx, cy) = ((pad + sc(10.0)) as f32 + dial_d as f32 / 2.0, (y + nh / 2) as f32);
let size = (nh - sc(12.0)) as f32;
Expand Down Expand Up @@ -998,7 +1038,9 @@ fn draw(a: &App, c: &mut Canvas, f: &Fonts, scale: f32, out: &mut Out) {
chart(c, &e, out, cr, Kind::Net, &tr, true);
}
y += nh + gap;
}

if a.s.hover(HOVER_DISK) {
// ---- disk: active-time dial, R/W values, mirror chart, drive cells
let space = has_space(a);
let dh = sc(DIAL_CARD + if space { DISK_SPACE } else { 0.0 });
Expand Down Expand Up @@ -1062,7 +1104,9 @@ fn draw(a: &App, c: &mut Canvas, f: &Fonts, scale: f32, out: &mut Out) {
}
}
y += dh + gap;
}

if a.s.hover(HOVER_USAGE) {
// ---- data usage: today + month figures, 14-day stacked bars
let cap = a.cycle_usage();
let uh = sc(USAGE) + if cap.is_some() { sc(CAP) } else { 0 };
Expand Down Expand Up @@ -1166,7 +1210,9 @@ fn draw(a: &App, c: &mut Canvas, f: &Fonts, scale: f32, out: &mut Out) {
c.text(f.small, &label, right - sc(14.0) - lw, by - sc(4.0), pal.dim);
}
y += uh + gap;
}

if a.s.hover(HOVER_TOP) {
// ---- top processes: one list, CPU / Memory / Disk tabs, bars
let ph = sc(PROCS);
card(c, Rect { l: pad, t: y, r: right, b: y + ph }, rad, pal, false, scale);
Expand Down Expand Up @@ -1252,6 +1298,7 @@ fn draw(a: &App, c: &mut Canvas, f: &Fonts, scale: f32, out: &mut Out) {
}
}

}
if let Some(t) = out.tip.take() {
draw_tip(c, &e, &t);
}
Expand Down
Loading
Loading