Skip to content

Commit

Permalink
Merge pull request #376 from nokyan/multiple-processes-selection
Browse files Browse the repository at this point in the history
Allow for multiple processes to be selected in the Processes view
  • Loading branch information
nokyan authored Oct 19, 2024
2 parents 5583d7d + 0082309 commit 6bf4c06
Show file tree
Hide file tree
Showing 15 changed files with 818 additions and 453 deletions.
2 changes: 1 addition & 1 deletion data/resources/ui/pages/applications.ui
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</section>
<section>
<item>
<attribute name="label" translatable="yes">Show App Information</attribute>
<attribute name="label" translatable="yes">Information</attribute>
<attribute name="action">applications.context-information</attribute>
</item>
</section>
Expand Down
42 changes: 41 additions & 1 deletion data/resources/ui/pages/processes.ui
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@
</item>
</section>
</menu>
<menu id="end_process_menu_multiple">
<section>
<item>
<attribute name="label" translatable="yes">Kill Processes</attribute>
<attribute name="action">processes.kill-process</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Halt Processes</attribute>
<attribute name="action">processes.halt-process</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Continue Processes</attribute>
<attribute name="action">processes.continue-process</attribute>
</item>
</section>
</menu>
<menu id="process_context_menu">
<section>
<item>
Expand Down Expand Up @@ -43,16 +59,40 @@
</section>
<section>
<item>
<attribute name="label" translatable="yes">Show Process Information</attribute>
<attribute name="label" translatable="yes">Information</attribute>
<attribute name="action">processes.context-information</attribute>
</item>
</section>
</menu>
<menu id="process_context_menu_multiple">
<section>
<item>
<attribute name="label" translatable="yes">End Processes</attribute>
<attribute name="action">processes.end-process</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Kill Processes</attribute>
<attribute name="action">processes.kill-process</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Halt Processes</attribute>
<attribute name="action">processes.halt-process</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Continue Processes</attribute>
<attribute name="action">processes.continue-process</attribute>
</item>
</section>
</menu>
<template class="ResProcesses" parent="AdwBin">
<object class="GtkPopoverMenu" id="popover_menu">
<property name="name">popover_menu</property>
<property name="menu-model">process_context_menu</property>
</object>
<object class="GtkPopoverMenu" id="popover_menu_multiple">
<property name="name">popover_menu_multiple</property>
<property name="menu-model">process_context_menu_multiple</property>
</object>
<property name="child">
<object class="AdwToolbarView">
<property name="content">
Expand Down
17 changes: 11 additions & 6 deletions lib/process_data/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ impl ProcessData {
});
});

let memory_usage = (statm[1].parse::<usize>()? - statm[2].parse::<usize>()?) * *PAGESIZE;
let memory_usage =
(statm[1].parse::<usize>()? - statm[2].parse::<usize>()?).saturating_mul(*PAGESIZE);

let starttime = stat[21 - 2].parse()?;

Expand Down Expand Up @@ -498,17 +499,17 @@ impl ProcessData {
.and_then(|captures| captures.get(1))
.and_then(|capture| capture.as_str().parse::<u64>().ok())
.unwrap_or_default()
* 1024;
.saturating_mul(1024);

let gtt = RE_DRM_MEMORY_GTT
.captures(&content)
.and_then(|captures| captures.get(1))
.and_then(|capture| capture.as_str().parse::<u64>().ok())
.unwrap_or_default()
* 1024;
.saturating_mul(1024);

let stats = GpuUsageStats {
gfx: gfx + compute,
gfx: gfx.saturating_add(compute),
mem: vram.saturating_add(gtt),
enc,
dec,
Expand Down Expand Up @@ -586,8 +587,12 @@ impl ProcessData {
for (pci_slot, gpu) in NVML_DEVICES.iter() {
return_map.insert(
pci_slot.to_owned(),
gpu.process_utilization_stats(unix_as_millis() * 1000 - 5_000_000)
.unwrap_or_default(),
gpu.process_utilization_stats(
unix_as_millis()
.saturating_mul(1000)
.saturating_sub(5_000_000),
)
.unwrap_or_default(),
);
}

Expand Down
Loading

0 comments on commit 6bf4c06

Please sign in to comment.