mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:27:34 +00:00
Demos/CatDog: Introduce inspector & artist states based on open programs
These two new main states are determined by looking at the programs the user has open. The artist state, using the new artist catdog, is triggered by PixelPaint and FontEditor, and the inspector state is triggered by Inspector, Profiler and SystemMonitor. This requires CatDog to unveil /proc/all, and, for some reason, /etc/passwd.
This commit is contained in:
parent
93bb943394
commit
145f983ee1
3 changed files with 43 additions and 3 deletions
|
@ -6,11 +6,34 @@
|
|||
*/
|
||||
|
||||
#include "CatDog.h"
|
||||
#include <LibCore/ProcessStatisticsReader.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/Window.h>
|
||||
|
||||
void CatDog::timer_event(Core::TimerEvent&)
|
||||
{
|
||||
auto maybe_proc_info = Core::ProcessStatisticsReader::get_all(m_proc_all);
|
||||
if (maybe_proc_info.has_value()) {
|
||||
auto proc_info = maybe_proc_info.release_value();
|
||||
|
||||
auto maybe_paint_program = proc_info.processes.first_matching([](auto& process) {
|
||||
return process.name.equals_ignoring_case("pixelpaint") || process.name.equals_ignoring_case("fonteditor");
|
||||
});
|
||||
if (maybe_paint_program.has_value()) {
|
||||
m_main_state = MainState::Artist;
|
||||
} else {
|
||||
auto maybe_inspector_program = proc_info.processes.first_matching([](auto& process) {
|
||||
return process.name.equals_ignoring_case("inspector") || process.name.equals_ignoring_case("systemmonitor") || process.name.equals_ignoring_case("profiler");
|
||||
});
|
||||
|
||||
if (maybe_inspector_program.has_value())
|
||||
m_main_state = MainState::Inspector;
|
||||
// If we currently have an application state but that app isn't open anymore, go back to idle.
|
||||
else if (!is_non_application_state(m_main_state))
|
||||
m_main_state = MainState::Idle;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_roaming)
|
||||
return;
|
||||
if (m_temp_pos.x() > 48) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue