mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +00:00
Taskbar: Set chdir to the home directory when opening applications
Although the chdir was set up for the applications opened from the quick launch, the regular application list hadn't do this. This meant that you could open a Terminal or HackStudio project in the root directory, which isn't so bad, but it's better to stick to the user home directory.
This commit is contained in:
parent
4181c0330c
commit
49ae73022c
Notes:
sideshowbarker
2024-07-19 17:20:59 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/49ae73022c9 Pull-request: https://github.com/SerenityOS/serenity/pull/9179
|
@ -12,6 +12,7 @@
|
|||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibDesktop/AppFile.h>
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
#include <LibGUI/Application.h>
|
||||
|
@ -190,13 +191,20 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
|
|||
} else {
|
||||
argv[0] = app.executable.characters();
|
||||
}
|
||||
|
||||
posix_spawn_file_actions_t spawn_actions;
|
||||
posix_spawn_file_actions_init(&spawn_actions);
|
||||
auto home_directory = Core::StandardPaths::home_directory();
|
||||
posix_spawn_file_actions_addchdir(&spawn_actions, home_directory.characters());
|
||||
|
||||
pid_t child_pid;
|
||||
if ((errno = posix_spawn(&child_pid, argv[0], nullptr, nullptr, const_cast<char**>(argv), environ))) {
|
||||
if ((errno = posix_spawn(&child_pid, argv[0], &spawn_actions, nullptr, const_cast<char**>(argv), environ))) {
|
||||
perror("posix_spawn");
|
||||
} else {
|
||||
if (disown(child_pid) < 0)
|
||||
perror("disown");
|
||||
}
|
||||
posix_spawn_file_actions_destroy(&spawn_actions);
|
||||
}));
|
||||
++app_identifier;
|
||||
}
|
||||
|
@ -261,14 +269,21 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
|
|||
}
|
||||
}));
|
||||
system_menu->add_action(GUI::Action::create("Run...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-run.png"), [](auto&) {
|
||||
posix_spawn_file_actions_t spawn_actions;
|
||||
posix_spawn_file_actions_init(&spawn_actions);
|
||||
auto home_directory = Core::StandardPaths::home_directory();
|
||||
posix_spawn_file_actions_addchdir(&spawn_actions, home_directory.characters());
|
||||
|
||||
pid_t child_pid;
|
||||
const char* argv[] = { "/bin/Run", nullptr };
|
||||
if ((errno = posix_spawn(&child_pid, "/bin/Run", nullptr, nullptr, const_cast<char**>(argv), environ))) {
|
||||
if ((errno = posix_spawn(&child_pid, "/bin/Run", &spawn_actions, nullptr, const_cast<char**>(argv), environ))) {
|
||||
perror("posix_spawn");
|
||||
} else {
|
||||
if (disown(child_pid) < 0)
|
||||
perror("disown");
|
||||
}
|
||||
|
||||
posix_spawn_file_actions_destroy(&spawn_actions);
|
||||
}));
|
||||
system_menu->add_separator();
|
||||
system_menu->add_action(GUI::Action::create("Exit...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/power.png"), [](auto&) {
|
||||
|
|
Loading…
Reference in a new issue