1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 04:07:35 +00:00

Kernel+ProcessManager: Let processes have an icon and show it in the table.

Processes can now have an icon assigned, which is essentially a 16x16 RGBA32
bitmap exposed as a shared buffer ID.

You set the icon ID by calling set_process_icon(int) and the icon ID will be
exposed through /proc/all.

To make this work, I added a mechanism for making shared buffers globally
accessible. For safety reasons, each app seals the icon buffer before making
it global.

Right now the first call to GWindow::set_icon() is what determines the
process icon. We'll probably change this in the future. :^)
This commit is contained in:
Andreas Kling 2019-07-29 07:26:01 +02:00
parent 7356fd389f
commit 5ded77df39
14 changed files with 97 additions and 2 deletions

View file

@ -1,5 +1,5 @@
#include <Kernel/SharedBuffer.h>
#include <Kernel/Process.h>
#include <Kernel/SharedBuffer.h>
Lockable<HashMap<int, NonnullOwnPtr<SharedBuffer>>>& shared_buffers()
{
@ -29,6 +29,8 @@ void SharedBuffer::sanity_check(const char* what)
bool SharedBuffer::is_shared_with(pid_t peer_pid)
{
LOCKER(shared_buffers().lock());
if (m_global)
return true;
for (auto& ref : m_refs) {
if (ref.pid == peer_pid) {
return true;
@ -42,6 +44,18 @@ void* SharedBuffer::ref_for_process_and_get_address(Process& process)
{
LOCKER(shared_buffers().lock());
ASSERT(is_shared_with(process.pid()));
if (m_global) {
bool found = false;
for (auto& ref : m_refs) {
if (ref.pid == process.pid()) {
found = true;
break;
}
}
if (!found)
m_refs.append(Reference(process.pid()));
}
for (auto& ref : m_refs) {
if (ref.pid == process.pid()) {
ref.count++;
@ -93,6 +107,7 @@ void SharedBuffer::deref_for_process(Process& process)
destroy_if_unused();
return;
}
return;
}
}