mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:22:46 +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:
		
							parent
							
								
									7356fd389f
								
							
						
					
					
						commit
						5ded77df39
					
				
					 14 changed files with 97 additions and 2 deletions
				
			
		|  | @ -2452,6 +2452,19 @@ int Process::sys$share_buffer_with(int shared_buffer_id, pid_t peer_pid) | |||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| int Process::sys$share_buffer_globally(int shared_buffer_id) | ||||
| { | ||||
|     LOCKER(shared_buffers().lock()); | ||||
|     auto it = shared_buffers().resource().find(shared_buffer_id); | ||||
|     if (it == shared_buffers().resource().end()) | ||||
|         return -EINVAL; | ||||
|     auto& shared_buffer = *(*it).value; | ||||
|     if (!shared_buffer.is_shared_with(m_pid)) | ||||
|         return -EPERM; | ||||
|     shared_buffer.share_globally(); | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| int Process::sys$release_shared_buffer(int shared_buffer_id) | ||||
| { | ||||
|     LOCKER(shared_buffers().lock()); | ||||
|  | @ -2773,3 +2786,16 @@ String Process::backtrace(ProcessInspectionHandle& handle) const | |||
|     }); | ||||
|     return builder.to_string(); | ||||
| } | ||||
| 
 | ||||
| int Process::sys$set_process_icon(int icon_id) | ||||
| { | ||||
|     LOCKER(shared_buffers().lock()); | ||||
|     auto it = shared_buffers().resource().find(icon_id); | ||||
|     if (it == shared_buffers().resource().end()) | ||||
|         return -EINVAL; | ||||
|     auto& shared_buffer = *(*it).value; | ||||
|     if (!shared_buffer.is_shared_with(m_pid)) | ||||
|         return -EPERM; | ||||
|     m_icon_id = icon_id; | ||||
|     return 0; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling