mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-25 20:22:18 +03:00
Ladybird: Prohibit GUI interaction of the WebContent process on macOS
The WebContent process behaves a bit awkwardly on macOS. When we launch the process, we have to create a QGuiApplication to access system fonts. But on macOS, doing so creates an entry in the Dock, and also causes the WebContent to be focused. So if you enter cmd+Q without first focusing the Ladybird GUI, WebContent is closed, while the Ladybird process keeps running.
This commit is contained in:
parent
cc86c07f58
commit
4dcdc3bd25
Notes:
sideshowbarker
2024-07-17 06:20:50 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/4dcdc3bd25 Pull-request: https://github.com/SerenityOS/serenity/pull/18525
@ -17,6 +17,10 @@ set(WEBCONTENT_SOURCES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
list(APPEND WEBCONTENT_SOURCES MacOSSetup.mm)
|
||||
endif()
|
||||
|
||||
qt_add_executable(WebContent ${WEBCONTENT_SOURCES})
|
||||
|
||||
target_include_directories(WebContent PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/)
|
||||
|
9
Ladybird/WebContent/MacOSSetup.h
Normal file
9
Ladybird/WebContent/MacOSSetup.h
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
void prohibit_interaction();
|
15
Ladybird/WebContent/MacOSSetup.mm
Normal file
15
Ladybird/WebContent/MacOSSetup.mm
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "MacOSSetup.h"
|
||||
#import <AppKit/NSApplication.h>
|
||||
|
||||
void prohibit_interaction()
|
||||
{
|
||||
// This prevents WebContent from being displayed in the macOS Dock and becoming the focused,
|
||||
// interactable application upon launch.
|
||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited];
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
#include "../Utilities.h"
|
||||
#include "../WebSocketClientManagerLadybird.h"
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/LocalServer.h>
|
||||
@ -31,6 +32,10 @@
|
||||
#include <WebContent/PageHost.h>
|
||||
#include <WebContent/WebDriverConnection.h>
|
||||
|
||||
#if defined(AK_OS_MACOS)
|
||||
# include "MacOSSetup.h"
|
||||
#endif
|
||||
|
||||
static ErrorOr<void> load_content_filters();
|
||||
static ErrorOr<void> load_autoplay_allowlist();
|
||||
|
||||
@ -40,6 +45,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
QGuiApplication app(arguments.argc, arguments.argv);
|
||||
|
||||
#if defined(AK_OS_MACOS)
|
||||
prohibit_interaction();
|
||||
#endif
|
||||
|
||||
Core::EventLoopManager::install(*new Ladybird::EventLoopManagerQt);
|
||||
Core::EventLoop event_loop;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user