1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +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

@ -442,6 +442,18 @@ int share_buffer_with(int shared_buffer_id, pid_t peer_pid)
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int share_buffer_globally(int shared_buffer_id)
{
int rc = syscall(SC_share_buffer_globally, shared_buffer_id);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int set_process_icon(int icon_id)
{
int rc = syscall(SC_set_process_icon, icon_id);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
void* get_shared_buffer(int shared_buffer_id)
{
int rc = syscall(SC_get_shared_buffer, shared_buffer_id);

View file

@ -24,10 +24,12 @@ int create_thread(int (*)(void*), void*);
void exit_thread(int);
int create_shared_buffer(int, void** buffer);
int share_buffer_with(int, pid_t peer_pid);
int share_buffer_globally(int);
void* get_shared_buffer(int shared_buffer_id);
int release_shared_buffer(int shared_buffer_id);
int seal_shared_buffer(int shared_buffer_id);
int get_shared_buffer_size(int shared_buffer_id);
int set_process_icon(int icon_id);
int read_tsc(unsigned* lsw, unsigned* msw);
inline int getpagesize() { return 4096; }
pid_t fork();

View file

@ -43,6 +43,7 @@ HashMap<pid_t, CProcessStatistics> CProcessStatisticsReader::get_all()
process.ticks = process_object.get("ticks").to_u32();
process.priority = process_object.get("priority").to_string();
process.syscall_count = process_object.get("syscall_count").to_u32();
process.icon_id = process_object.get("icon_id").to_int();
// and synthetic data last
process.username = username_from_uid(process.uid);

View file

@ -24,6 +24,7 @@ struct CProcessStatistics {
unsigned ticks;
String priority;
unsigned syscall_count;
int icon_id;
// synthetic
String username;

View file

@ -635,6 +635,16 @@ void GWindow::set_icon(const GraphicsBitmap* icon)
painter.blit({ 0, 0 }, *icon, icon->rect());
}
int rc = seal_shared_buffer(m_icon->shared_buffer_id());
ASSERT(rc == 0);
rc = share_buffer_globally(m_icon->shared_buffer_id());
ASSERT(rc == 0);
static bool has_set_process_icon;
if (!has_set_process_icon)
set_process_icon(m_icon->shared_buffer_id());
WSAPI_ClientMessage message;
message.type = WSAPI_ClientMessage::Type::SetWindowIconBitmap;
message.window_id = m_window_id;