mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
CPUGraph.MenuApplet: execute SystemMonitor on left mousebutton click
This commit is contained in:
parent
1d2c9dbc3a
commit
bb89eaf950
Notes:
sideshowbarker
2024-07-19 09:45:22 +09:00
Author: https://github.com/okraits Commit: https://github.com/SerenityOS/serenity/commit/bb89eaf9507 Pull-request: https://github.com/SerenityOS/serenity/pull/1148
1 changed files with 21 additions and 2 deletions
|
@ -74,6 +74,20 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void mousedown_event(GMouseEvent& event) override
|
||||
{
|
||||
if (event.button() != GMouseButton::Left)
|
||||
return;
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
perror("fork");
|
||||
} else if (pid == 0) {
|
||||
execl("/bin/SystemMonitor", "SystemMonitor", nullptr);
|
||||
perror("execl");
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
static void get_cpu_usage(unsigned& busy, unsigned& idle)
|
||||
{
|
||||
busy = 0;
|
||||
|
@ -98,14 +112,14 @@ private:
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (pledge("stdio shared_buffer accept rpath unix cpath fattr", nullptr) < 0) {
|
||||
if (pledge("stdio shared_buffer accept proc exec rpath unix cpath fattr", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
GApplication app(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer accept rpath", nullptr) < 0) {
|
||||
if (pledge("stdio shared_buffer accept proc exec rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
@ -135,6 +149,11 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/bin/SystemMonitor", "x") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
unveil(nullptr, nullptr);
|
||||
|
||||
return app.exec();
|
||||
|
|
Loading…
Reference in a new issue