mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:28:11 +00:00
Assistant: Only open one Assistant at once
I found myself accidentally opening two assistants at once with the Window+Space shortcut. Since only one assistant window is usable at the same time, I made assistant only spawn 1 instance at most.
This commit is contained in:
parent
fdcfd2816e
commit
bf16591c07
1 changed files with 15 additions and 1 deletions
|
@ -7,6 +7,7 @@
|
|||
#include "Providers.h"
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/LockFile.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Event.h>
|
||||
|
@ -17,6 +18,7 @@
|
|||
#include <LibGUI/TextBox.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace Assistant {
|
||||
|
@ -191,11 +193,23 @@ static constexpr size_t MAX_SEARCH_RESULTS = 6;
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (pledge("stdio recvfd sendfd rpath unix proc exec thread", nullptr) < 0) {
|
||||
if (pledge("stdio recvfd sendfd rpath cpath unix proc exec thread", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Core::LockFile lockfile("/tmp/lock/assistant.lock");
|
||||
|
||||
if (!lockfile.is_held()) {
|
||||
if (lockfile.error_code()) {
|
||||
warnln("Core::LockFile: {}", strerror(lockfile.error_code()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Another assistant is open, so exit silently.
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_minimizable(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue