Compare commits
11 Commits
18bc607d93
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b7596674ab | |||
| ce92b3841f | |||
| 659d1530b0 | |||
| 302753cd3d | |||
| bbba5b2927 | |||
| 29908646ea | |||
| 8cf9b50690 | |||
| d6f15c5dce | |||
| b4d93f24cd | |||
| c514e4faec | |||
| e51594a010 |
@@ -0,0 +1,17 @@
|
|||||||
|
# clangd configuration for Nebula Browser
|
||||||
|
#
|
||||||
|
# Full diagnostics require:
|
||||||
|
# 1. CEF binary distribution unpacked to thirdparty/cef/
|
||||||
|
# 2. Running: cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||||
|
# 3. Symlink or copy: ln -s build/compile_commands.json .
|
||||||
|
#
|
||||||
|
# Without compile_commands.json, clangd uses fallback flags below.
|
||||||
|
|
||||||
|
CompileFlags:
|
||||||
|
Add:
|
||||||
|
- -std=c++20
|
||||||
|
- -xobjective-c++
|
||||||
|
- -Isrc
|
||||||
|
- -Ithirdparty/cef
|
||||||
|
- -Ithirdparty/cef/include
|
||||||
|
- -Wno-c++17-extensions
|
||||||
@@ -18,3 +18,4 @@ CMakeFiles/
|
|||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
*.log
|
*.log
|
||||||
|
/.cache
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Nebula Browser Asset License
|
||||||
|
|
||||||
|
The source code of Nebula Browser is licensed under the Mozilla Public License 2.0, as described in the LICENSE file.
|
||||||
|
|
||||||
|
However, the Nebula Browser name, logo, icons, artwork, screenshots, visual identity, branding materials, and other non-code assets are not automatically covered by the MPL-2.0 license.
|
||||||
|
|
||||||
|
Unless otherwise stated, these assets are All Rights Reserved.
|
||||||
|
|
||||||
|
You may not use the Nebula Browser name, logo, or branding in a way that suggests endorsement, official status, or affiliation with the Nebula Project without permission.
|
||||||
|
|
||||||
|
Community forks are welcome, but they should use their own name and branding unless permission is granted.
|
||||||
+204
-71
@@ -1,6 +1,11 @@
|
|||||||
cmake_minimum_required(VERSION 3.21)
|
cmake_minimum_required(VERSION 3.21)
|
||||||
|
|
||||||
project(NebulaBrowser LANGUAGES CXX)
|
# Enable OBJCXX early on macOS for Cocoa integration
|
||||||
|
if(APPLE)
|
||||||
|
project(NebulaBrowser LANGUAGES CXX OBJCXX)
|
||||||
|
else()
|
||||||
|
project(NebulaBrowser LANGUAGES CXX)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
@@ -16,16 +21,11 @@ if(NOT EXISTS "${CEF_ROOT}/cmake/FindCEF.cmake")
|
|||||||
"CEF was not found.\n"
|
"CEF was not found.\n"
|
||||||
"Expected CEF here:\n"
|
"Expected CEF here:\n"
|
||||||
" ${CEF_ROOT}\n\n"
|
" ${CEF_ROOT}\n\n"
|
||||||
"Make sure the contents of the CEF binary distribution are inside thirdparty/cef."
|
"Unpack the CEF binary distribution for your OS into thirdparty/cef."
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
|
||||||
# CEF setup
|
|
||||||
# ------------------------------------------------------------
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CEF_ROOT}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${CEF_ROOT}/cmake")
|
||||||
|
|
||||||
find_package(CEF REQUIRED)
|
find_package(CEF REQUIRED)
|
||||||
|
|
||||||
add_subdirectory(
|
add_subdirectory(
|
||||||
@@ -33,12 +33,14 @@ add_subdirectory(
|
|||||||
"${CMAKE_BINARY_DIR}/libcef_dll_wrapper"
|
"${CMAKE_BINARY_DIR}/libcef_dll_wrapper"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SET_CEF_TARGET_OUT_DIR()
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# Nebula source files
|
# Sources
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
set(NEBULA_SOURCES
|
set(NEBULA_COMMON_SOURCES
|
||||||
app/main.cpp
|
src/app/first_run_state.cpp
|
||||||
src/app/nebula_controller.cpp
|
src/app/nebula_controller.cpp
|
||||||
src/app/run.cpp
|
src/app/run.cpp
|
||||||
src/browser/session_state.cpp
|
src/browser/session_state.cpp
|
||||||
@@ -48,78 +50,209 @@ set(NEBULA_SOURCES
|
|||||||
src/cef/browser_client.cpp
|
src/cef/browser_client.cpp
|
||||||
src/cef/nebula_app.cpp
|
src/cef/nebula_app.cpp
|
||||||
src/ui/paths.cpp
|
src/ui/paths.cpp
|
||||||
src/window/nebula_window.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(NebulaBrowser WIN32
|
if(OS_WINDOWS)
|
||||||
${NEBULA_SOURCES}
|
set(NEBULA_PLATFORM_SOURCES
|
||||||
)
|
src/platform/win/default_browser_win.cpp
|
||||||
|
src/platform/win/paths_win.cpp
|
||||||
SET_EXECUTABLE_TARGET_PROPERTIES(NebulaBrowser)
|
src/platform/win/startup_win.cpp
|
||||||
|
src/platform/win/browser_host_win.cpp
|
||||||
if(MSVC)
|
src/platform/win/nebula_window_win.cpp
|
||||||
set_property(TARGET NebulaBrowser PROPERTY
|
|
||||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
|
|
||||||
)
|
)
|
||||||
|
elseif(OS_MACOSX)
|
||||||
|
set(NEBULA_PLATFORM_SOURCES
|
||||||
|
src/platform/mac/default_browser_mac.mm
|
||||||
|
src/platform/mac/paths_mac.cpp
|
||||||
|
src/platform/mac/startup_mac.mm
|
||||||
|
src/platform/mac/browser_host_mac.mm
|
||||||
|
src/platform/mac/nebula_window_mac.mm
|
||||||
|
)
|
||||||
|
set_source_files_properties(
|
||||||
|
src/platform/mac/startup_mac.mm
|
||||||
|
src/platform/mac/browser_host_mac.mm
|
||||||
|
src/platform/mac/nebula_window_mac.mm
|
||||||
|
PROPERTIES
|
||||||
|
COMPILE_FLAGS "-fobjc-arc"
|
||||||
|
)
|
||||||
|
elseif(OS_LINUX)
|
||||||
|
set(NEBULA_PLATFORM_SOURCES
|
||||||
|
src/platform/linux/default_browser_linux.cpp
|
||||||
|
src/platform/linux/paths_linux.cpp
|
||||||
|
src/platform/linux/startup_linux.cpp
|
||||||
|
src/platform/linux/browser_host_linux.cpp
|
||||||
|
src/platform/linux/nebula_window_linux.cpp
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Unsupported platform.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(NebulaBrowser PRIVATE
|
# On macOS, CEF is a framework linked via CEF_STANDARD_LIBS.
|
||||||
"${CMAKE_SOURCE_DIR}/src"
|
# On Windows/Linux, we create a logical target for libcef.
|
||||||
"${CEF_ROOT}"
|
if(NOT OS_MACOSX)
|
||||||
"${CEF_ROOT}/include"
|
ADD_LOGICAL_TARGET("libcef_lib" "${CEF_LIB_RELEASE}" "${CEF_LIB_DEBUG}")
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(NebulaBrowser PRIVATE
|
|
||||||
libcef_dll_wrapper
|
|
||||||
${CEF_STANDARD_LIBS}
|
|
||||||
)
|
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
|
||||||
# Platform-specific CEF linking
|
|
||||||
# ------------------------------------------------------------
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
target_link_libraries(NebulaBrowser PRIVATE
|
|
||||||
"${CEF_ROOT}/Release/libcef.lib"
|
|
||||||
dwmapi
|
|
||||||
)
|
|
||||||
|
|
||||||
target_compile_definitions(NebulaBrowser PRIVATE
|
|
||||||
NOMINMAX
|
|
||||||
WIN32_LEAN_AND_MEAN
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
if(OS_LINUX)
|
||||||
# Copy CEF runtime files after build
|
FIND_LINUX_LIBRARIES("X11")
|
||||||
# ------------------------------------------------------------
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
function(add_nebula_app_target nebula_target entry_source)
|
||||||
add_custom_command(TARGET NebulaBrowser POST_BUILD
|
if(OS_WINDOWS)
|
||||||
|
add_executable(${nebula_target} WIN32
|
||||||
|
${entry_source}
|
||||||
|
${NEBULA_COMMON_SOURCES}
|
||||||
|
${NEBULA_PLATFORM_SOURCES}
|
||||||
|
)
|
||||||
|
elseif(OS_MACOSX)
|
||||||
|
add_executable(${nebula_target} MACOSX_BUNDLE
|
||||||
|
${entry_source}
|
||||||
|
${NEBULA_COMMON_SOURCES}
|
||||||
|
${NEBULA_PLATFORM_SOURCES}
|
||||||
|
)
|
||||||
|
elseif(OS_LINUX)
|
||||||
|
add_executable(${nebula_target}
|
||||||
|
${entry_source}
|
||||||
|
${NEBULA_COMMON_SOURCES}
|
||||||
|
${NEBULA_PLATFORM_SOURCES}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
SET_EXECUTABLE_TARGET_PROPERTIES(${nebula_target})
|
||||||
|
add_dependencies(${nebula_target} libcef_dll_wrapper)
|
||||||
|
|
||||||
|
target_include_directories(${nebula_target} PRIVATE
|
||||||
|
"${CMAKE_SOURCE_DIR}/src"
|
||||||
|
"${CEF_ROOT}"
|
||||||
|
"${CEF_ROOT}/include"
|
||||||
|
)
|
||||||
|
|
||||||
|
if(OS_MACOSX)
|
||||||
|
# On macOS, CEF is a framework; don't link libcef_lib
|
||||||
|
target_link_libraries(${nebula_target} PRIVATE
|
||||||
|
libcef_dll_wrapper
|
||||||
|
${CEF_STANDARD_LIBS}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
target_link_libraries(${nebula_target} PRIVATE
|
||||||
|
libcef_lib
|
||||||
|
libcef_dll_wrapper
|
||||||
|
${CEF_STANDARD_LIBS}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
set_property(TARGET ${nebula_target} PROPERTY
|
||||||
|
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# Platform-specific CEF runtime deployment
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
if(OS_WINDOWS)
|
||||||
|
target_link_libraries(${nebula_target} PRIVATE dwmapi)
|
||||||
|
target_compile_definitions(${nebula_target} PRIVATE
|
||||||
|
NOMINMAX
|
||||||
|
WIN32_LEAN_AND_MEAN
|
||||||
|
)
|
||||||
|
COPY_FILES("${nebula_target}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR_RELEASE}" "${CEF_TARGET_OUT_DIR}")
|
||||||
|
COPY_FILES("${nebula_target}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}")
|
||||||
|
elseif(OS_LINUX)
|
||||||
|
COPY_FILES("${nebula_target}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR_RELEASE}" "${CEF_TARGET_OUT_DIR}")
|
||||||
|
COPY_FILES("${nebula_target}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}")
|
||||||
|
elseif(OS_MACOSX)
|
||||||
|
target_link_libraries(${nebula_target} PRIVATE
|
||||||
|
"-framework Cocoa"
|
||||||
|
"-framework ApplicationServices"
|
||||||
|
)
|
||||||
|
set(NEBULA_APP "${CEF_TARGET_OUT_DIR}/${nebula_target}.app")
|
||||||
|
set(NEBULA_HELPER_TARGET "${nebula_target}_Helper")
|
||||||
|
set(NEBULA_HELPER_OUTPUT_NAME "${nebula_target} Helper")
|
||||||
|
string(TOLOWER "${nebula_target}" NEBULA_HELPER_BUNDLE_NAME)
|
||||||
|
|
||||||
|
COPY_MAC_FRAMEWORK(
|
||||||
|
"${nebula_target}"
|
||||||
|
"${CEF_BINARY_DIR_RELEASE}"
|
||||||
|
"${NEBULA_APP}"
|
||||||
|
)
|
||||||
|
COPY_FILES(
|
||||||
|
"${nebula_target}"
|
||||||
|
"${CEF_BINARY_FILES}"
|
||||||
|
"${CEF_BINARY_DIR_RELEASE}"
|
||||||
|
"${NEBULA_APP}/Contents/Frameworks"
|
||||||
|
)
|
||||||
|
COPY_FILES(
|
||||||
|
"${nebula_target}"
|
||||||
|
"${CEF_RESOURCE_FILES}"
|
||||||
|
"${CEF_RESOURCE_DIR}"
|
||||||
|
"${NEBULA_APP}/Contents/Resources"
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(_suffix_list ${CEF_HELPER_APP_SUFFIXES})
|
||||||
|
string(REPLACE ":" ";" _suffix_list ${_suffix_list})
|
||||||
|
list(GET _suffix_list 0 _name_suffix)
|
||||||
|
list(GET _suffix_list 1 _target_suffix)
|
||||||
|
list(GET _suffix_list 2 _plist_suffix)
|
||||||
|
|
||||||
|
set(_helper_target "${NEBULA_HELPER_TARGET}${_target_suffix}")
|
||||||
|
set(_helper_output_name "${NEBULA_HELPER_OUTPUT_NAME}${_name_suffix}")
|
||||||
|
set(_helper_info_plist "${CMAKE_CURRENT_BINARY_DIR}/${_helper_target}-Info.plist")
|
||||||
|
|
||||||
|
file(READ "${CMAKE_SOURCE_DIR}/cmake/mac-helper-Info.plist.in" _plist_contents)
|
||||||
|
string(REPLACE "\${EXECUTABLE_NAME}" "${_helper_output_name}" _plist_contents "${_plist_contents}")
|
||||||
|
string(REPLACE "\${PRODUCT_NAME}" "${_helper_output_name}" _plist_contents "${_plist_contents}")
|
||||||
|
string(REPLACE "\${HELPER_BUNDLE_NAME}" "${NEBULA_HELPER_BUNDLE_NAME}" _plist_contents "${_plist_contents}")
|
||||||
|
string(REPLACE "\${BUNDLE_ID_SUFFIX}" "${_plist_suffix}" _plist_contents "${_plist_contents}")
|
||||||
|
file(WRITE "${_helper_info_plist}" "${_plist_contents}")
|
||||||
|
|
||||||
|
add_executable(${_helper_target} MACOSX_BUNDLE
|
||||||
|
app/process_helper_mac.cc
|
||||||
|
src/cef/nebula_app.cpp
|
||||||
|
)
|
||||||
|
SET_EXECUTABLE_TARGET_PROPERTIES(${_helper_target})
|
||||||
|
add_dependencies(${_helper_target} libcef_dll_wrapper)
|
||||||
|
target_include_directories(${_helper_target} PRIVATE
|
||||||
|
"${CMAKE_SOURCE_DIR}/src"
|
||||||
|
"${CEF_ROOT}"
|
||||||
|
"${CEF_ROOT}/include"
|
||||||
|
)
|
||||||
|
target_link_libraries(${_helper_target} PRIVATE
|
||||||
|
libcef_dll_wrapper
|
||||||
|
${CEF_STANDARD_LIBS}
|
||||||
|
)
|
||||||
|
set_target_properties(${_helper_target} PROPERTIES
|
||||||
|
MACOSX_BUNDLE_INFO_PLIST "${_helper_info_plist}"
|
||||||
|
OUTPUT_NAME "${_helper_output_name}"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_dependencies(${nebula_target} "${_helper_target}")
|
||||||
|
add_custom_command(TARGET ${nebula_target} POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||||
|
"${CEF_TARGET_OUT_DIR}/${_helper_output_name}.app"
|
||||||
|
"${NEBULA_APP}/Contents/Frameworks/${_helper_output_name}.app"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# Copy Nebula UI files after build
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
add_custom_command(TARGET ${nebula_target} POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||||
"${CEF_ROOT}/Release"
|
"${CMAKE_SOURCE_DIR}/ui"
|
||||||
"$<TARGET_FILE_DIR:NebulaBrowser>"
|
"$<TARGET_FILE_DIR:${nebula_target}>/ui"
|
||||||
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||||
"${CEF_ROOT}/Resources"
|
"${CMAKE_SOURCE_DIR}/assets"
|
||||||
"$<TARGET_FILE_DIR:NebulaBrowser>"
|
"$<TARGET_FILE_DIR:${nebula_target}>/ui/assets"
|
||||||
|
|
||||||
COMMENT "Copying CEF runtime files..."
|
COMMENT "Copying Nebula UI files and assets for ${nebula_target}..."
|
||||||
)
|
)
|
||||||
endif()
|
endfunction()
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
add_nebula_app_target(NebulaBrowser app/main.cpp)
|
||||||
# Copy Nebula UI files after build
|
add_nebula_app_target(NebulaBigPicture app/main_bigpicture.cpp)
|
||||||
# ------------------------------------------------------------
|
|
||||||
|
|
||||||
add_custom_command(TARGET NebulaBrowser POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
||||||
"${CMAKE_SOURCE_DIR}/ui"
|
|
||||||
"$<TARGET_FILE_DIR:NebulaBrowser>/ui"
|
|
||||||
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
||||||
"${CMAKE_SOURCE_DIR}/assets"
|
|
||||||
"$<TARGET_FILE_DIR:NebulaBrowser>/ui/assets"
|
|
||||||
|
|
||||||
COMMENT "Copying Nebula UI files and assets..."
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -0,0 +1,373 @@
|
|||||||
|
Mozilla Public License Version 2.0
|
||||||
|
==================================
|
||||||
|
|
||||||
|
1. Definitions
|
||||||
|
--------------
|
||||||
|
|
||||||
|
1.1. "Contributor"
|
||||||
|
means each individual or legal entity that creates, contributes to
|
||||||
|
the creation of, or owns Covered Software.
|
||||||
|
|
||||||
|
1.2. "Contributor Version"
|
||||||
|
means the combination of the Contributions of others (if any) used
|
||||||
|
by a Contributor and that particular Contributor's Contribution.
|
||||||
|
|
||||||
|
1.3. "Contribution"
|
||||||
|
means Covered Software of a particular Contributor.
|
||||||
|
|
||||||
|
1.4. "Covered Software"
|
||||||
|
means Source Code Form to which the initial Contributor has attached
|
||||||
|
the notice in Exhibit A, the Executable Form of such Source Code
|
||||||
|
Form, and Modifications of such Source Code Form, in each case
|
||||||
|
including portions thereof.
|
||||||
|
|
||||||
|
1.5. "Incompatible With Secondary Licenses"
|
||||||
|
means
|
||||||
|
|
||||||
|
(a) that the initial Contributor has attached the notice described
|
||||||
|
in Exhibit B to the Covered Software; or
|
||||||
|
|
||||||
|
(b) that the Covered Software was made available under the terms of
|
||||||
|
version 1.1 or earlier of the License, but not also under the
|
||||||
|
terms of a Secondary License.
|
||||||
|
|
||||||
|
1.6. "Executable Form"
|
||||||
|
means any form of the work other than Source Code Form.
|
||||||
|
|
||||||
|
1.7. "Larger Work"
|
||||||
|
means a work that combines Covered Software with other material, in
|
||||||
|
a separate file or files, that is not Covered Software.
|
||||||
|
|
||||||
|
1.8. "License"
|
||||||
|
means this document.
|
||||||
|
|
||||||
|
1.9. "Licensable"
|
||||||
|
means having the right to grant, to the maximum extent possible,
|
||||||
|
whether at the time of the initial grant or subsequently, any and
|
||||||
|
all of the rights conveyed by this License.
|
||||||
|
|
||||||
|
1.10. "Modifications"
|
||||||
|
means any of the following:
|
||||||
|
|
||||||
|
(a) any file in Source Code Form that results from an addition to,
|
||||||
|
deletion from, or modification of the contents of Covered
|
||||||
|
Software; or
|
||||||
|
|
||||||
|
(b) any new file in Source Code Form that contains any Covered
|
||||||
|
Software.
|
||||||
|
|
||||||
|
1.11. "Patent Claims" of a Contributor
|
||||||
|
means any patent claim(s), including without limitation, method,
|
||||||
|
process, and apparatus claims, in any patent Licensable by such
|
||||||
|
Contributor that would be infringed, but for the grant of the
|
||||||
|
License, by the making, using, selling, offering for sale, having
|
||||||
|
made, import, or transfer of either its Contributions or its
|
||||||
|
Contributor Version.
|
||||||
|
|
||||||
|
1.12. "Secondary License"
|
||||||
|
means either the GNU General Public License, Version 2.0, the GNU
|
||||||
|
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||||
|
Public License, Version 3.0, or any later versions of those
|
||||||
|
licenses.
|
||||||
|
|
||||||
|
1.13. "Source Code Form"
|
||||||
|
means the form of the work preferred for making modifications.
|
||||||
|
|
||||||
|
1.14. "You" (or "Your")
|
||||||
|
means an individual or a legal entity exercising rights under this
|
||||||
|
License. For legal entities, "You" includes any entity that
|
||||||
|
controls, is controlled by, or is under common control with You. For
|
||||||
|
purposes of this definition, "control" means (a) the power, direct
|
||||||
|
or indirect, to cause the direction or management of such entity,
|
||||||
|
whether by contract or otherwise, or (b) ownership of more than
|
||||||
|
fifty percent (50%) of the outstanding shares or beneficial
|
||||||
|
ownership of such entity.
|
||||||
|
|
||||||
|
2. License Grants and Conditions
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
2.1. Grants
|
||||||
|
|
||||||
|
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||||
|
non-exclusive license:
|
||||||
|
|
||||||
|
(a) under intellectual property rights (other than patent or trademark)
|
||||||
|
Licensable by such Contributor to use, reproduce, make available,
|
||||||
|
modify, display, perform, distribute, and otherwise exploit its
|
||||||
|
Contributions, either on an unmodified basis, with Modifications, or
|
||||||
|
as part of a Larger Work; and
|
||||||
|
|
||||||
|
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||||
|
for sale, have made, import, and otherwise transfer either its
|
||||||
|
Contributions or its Contributor Version.
|
||||||
|
|
||||||
|
2.2. Effective Date
|
||||||
|
|
||||||
|
The licenses granted in Section 2.1 with respect to any Contribution
|
||||||
|
become effective for each Contribution on the date the Contributor first
|
||||||
|
distributes such Contribution.
|
||||||
|
|
||||||
|
2.3. Limitations on Grant Scope
|
||||||
|
|
||||||
|
The licenses granted in this Section 2 are the only rights granted under
|
||||||
|
this License. No additional rights or licenses will be implied from the
|
||||||
|
distribution or licensing of Covered Software under this License.
|
||||||
|
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||||
|
Contributor:
|
||||||
|
|
||||||
|
(a) for any code that a Contributor has removed from Covered Software;
|
||||||
|
or
|
||||||
|
|
||||||
|
(b) for infringements caused by: (i) Your and any other third party's
|
||||||
|
modifications of Covered Software, or (ii) the combination of its
|
||||||
|
Contributions with other software (except as part of its Contributor
|
||||||
|
Version); or
|
||||||
|
|
||||||
|
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||||
|
its Contributions.
|
||||||
|
|
||||||
|
This License does not grant any rights in the trademarks, service marks,
|
||||||
|
or logos of any Contributor (except as may be necessary to comply with
|
||||||
|
the notice requirements in Section 3.4).
|
||||||
|
|
||||||
|
2.4. Subsequent Licenses
|
||||||
|
|
||||||
|
No Contributor makes additional grants as a result of Your choice to
|
||||||
|
distribute the Covered Software under a subsequent version of this
|
||||||
|
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||||
|
permitted under the terms of Section 3.3).
|
||||||
|
|
||||||
|
2.5. Representation
|
||||||
|
|
||||||
|
Each Contributor represents that the Contributor believes its
|
||||||
|
Contributions are its original creation(s) or it has sufficient rights
|
||||||
|
to grant the rights to its Contributions conveyed by this License.
|
||||||
|
|
||||||
|
2.6. Fair Use
|
||||||
|
|
||||||
|
This License is not intended to limit any rights You have under
|
||||||
|
applicable copyright doctrines of fair use, fair dealing, or other
|
||||||
|
equivalents.
|
||||||
|
|
||||||
|
2.7. Conditions
|
||||||
|
|
||||||
|
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||||
|
in Section 2.1.
|
||||||
|
|
||||||
|
3. Responsibilities
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
3.1. Distribution of Source Form
|
||||||
|
|
||||||
|
All distribution of Covered Software in Source Code Form, including any
|
||||||
|
Modifications that You create or to which You contribute, must be under
|
||||||
|
the terms of this License. You must inform recipients that the Source
|
||||||
|
Code Form of the Covered Software is governed by the terms of this
|
||||||
|
License, and how they can obtain a copy of this License. You may not
|
||||||
|
attempt to alter or restrict the recipients' rights in the Source Code
|
||||||
|
Form.
|
||||||
|
|
||||||
|
3.2. Distribution of Executable Form
|
||||||
|
|
||||||
|
If You distribute Covered Software in Executable Form then:
|
||||||
|
|
||||||
|
(a) such Covered Software must also be made available in Source Code
|
||||||
|
Form, as described in Section 3.1, and You must inform recipients of
|
||||||
|
the Executable Form how they can obtain a copy of such Source Code
|
||||||
|
Form by reasonable means in a timely manner, at a charge no more
|
||||||
|
than the cost of distribution to the recipient; and
|
||||||
|
|
||||||
|
(b) You may distribute such Executable Form under the terms of this
|
||||||
|
License, or sublicense it under different terms, provided that the
|
||||||
|
license for the Executable Form does not attempt to limit or alter
|
||||||
|
the recipients' rights in the Source Code Form under this License.
|
||||||
|
|
||||||
|
3.3. Distribution of a Larger Work
|
||||||
|
|
||||||
|
You may create and distribute a Larger Work under terms of Your choice,
|
||||||
|
provided that You also comply with the requirements of this License for
|
||||||
|
the Covered Software. If the Larger Work is a combination of Covered
|
||||||
|
Software with a work governed by one or more Secondary Licenses, and the
|
||||||
|
Covered Software is not Incompatible With Secondary Licenses, this
|
||||||
|
License permits You to additionally distribute such Covered Software
|
||||||
|
under the terms of such Secondary License(s), so that the recipient of
|
||||||
|
the Larger Work may, at their option, further distribute the Covered
|
||||||
|
Software under the terms of either this License or such Secondary
|
||||||
|
License(s).
|
||||||
|
|
||||||
|
3.4. Notices
|
||||||
|
|
||||||
|
You may not remove or alter the substance of any license notices
|
||||||
|
(including copyright notices, patent notices, disclaimers of warranty,
|
||||||
|
or limitations of liability) contained within the Source Code Form of
|
||||||
|
the Covered Software, except that You may alter any license notices to
|
||||||
|
the extent required to remedy known factual inaccuracies.
|
||||||
|
|
||||||
|
3.5. Application of Additional Terms
|
||||||
|
|
||||||
|
You may choose to offer, and to charge a fee for, warranty, support,
|
||||||
|
indemnity or liability obligations to one or more recipients of Covered
|
||||||
|
Software. However, You may do so only on Your own behalf, and not on
|
||||||
|
behalf of any Contributor. You must make it absolutely clear that any
|
||||||
|
such warranty, support, indemnity, or liability obligation is offered by
|
||||||
|
You alone, and You hereby agree to indemnify every Contributor for any
|
||||||
|
liability incurred by such Contributor as a result of warranty, support,
|
||||||
|
indemnity or liability terms You offer. You may include additional
|
||||||
|
disclaimers of warranty and limitations of liability specific to any
|
||||||
|
jurisdiction.
|
||||||
|
|
||||||
|
4. Inability to Comply Due to Statute or Regulation
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
If it is impossible for You to comply with any of the terms of this
|
||||||
|
License with respect to some or all of the Covered Software due to
|
||||||
|
statute, judicial order, or regulation then You must: (a) comply with
|
||||||
|
the terms of this License to the maximum extent possible; and (b)
|
||||||
|
describe the limitations and the code they affect. Such description must
|
||||||
|
be placed in a text file included with all distributions of the Covered
|
||||||
|
Software under this License. Except to the extent prohibited by statute
|
||||||
|
or regulation, such description must be sufficiently detailed for a
|
||||||
|
recipient of ordinary skill to be able to understand it.
|
||||||
|
|
||||||
|
5. Termination
|
||||||
|
--------------
|
||||||
|
|
||||||
|
5.1. The rights granted under this License will terminate automatically
|
||||||
|
if You fail to comply with any of its terms. However, if You become
|
||||||
|
compliant, then the rights granted under this License from a particular
|
||||||
|
Contributor are reinstated (a) provisionally, unless and until such
|
||||||
|
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||||
|
ongoing basis, if such Contributor fails to notify You of the
|
||||||
|
non-compliance by some reasonable means prior to 60 days after You have
|
||||||
|
come back into compliance. Moreover, Your grants from a particular
|
||||||
|
Contributor are reinstated on an ongoing basis if such Contributor
|
||||||
|
notifies You of the non-compliance by some reasonable means, this is the
|
||||||
|
first time You have received notice of non-compliance with this License
|
||||||
|
from such Contributor, and You become compliant prior to 30 days after
|
||||||
|
Your receipt of the notice.
|
||||||
|
|
||||||
|
5.2. If You initiate litigation against any entity by asserting a patent
|
||||||
|
infringement claim (excluding declaratory judgment actions,
|
||||||
|
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||||
|
directly or indirectly infringes any patent, then the rights granted to
|
||||||
|
You by any and all Contributors for the Covered Software under Section
|
||||||
|
2.1 of this License shall terminate.
|
||||||
|
|
||||||
|
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||||
|
end user license agreements (excluding distributors and resellers) which
|
||||||
|
have been validly granted by You or Your distributors under this License
|
||||||
|
prior to termination shall survive termination.
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 6. Disclaimer of Warranty *
|
||||||
|
* ------------------------- *
|
||||||
|
* *
|
||||||
|
* Covered Software is provided under this License on an "as is" *
|
||||||
|
* basis, without warranty of any kind, either expressed, implied, or *
|
||||||
|
* statutory, including, without limitation, warranties that the *
|
||||||
|
* Covered Software is free of defects, merchantable, fit for a *
|
||||||
|
* particular purpose or non-infringing. The entire risk as to the *
|
||||||
|
* quality and performance of the Covered Software is with You. *
|
||||||
|
* Should any Covered Software prove defective in any respect, You *
|
||||||
|
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||||
|
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||||
|
* essential part of this License. No use of any Covered Software is *
|
||||||
|
* authorized under this License except under this disclaimer. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 7. Limitation of Liability *
|
||||||
|
* -------------------------- *
|
||||||
|
* *
|
||||||
|
* Under no circumstances and under no legal theory, whether tort *
|
||||||
|
* (including negligence), contract, or otherwise, shall any *
|
||||||
|
* Contributor, or anyone who distributes Covered Software as *
|
||||||
|
* permitted above, be liable to You for any direct, indirect, *
|
||||||
|
* special, incidental, or consequential damages of any character *
|
||||||
|
* including, without limitation, damages for lost profits, loss of *
|
||||||
|
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||||
|
* and all other commercial damages or losses, even if such party *
|
||||||
|
* shall have been informed of the possibility of such damages. This *
|
||||||
|
* limitation of liability shall not apply to liability for death or *
|
||||||
|
* personal injury resulting from such party's negligence to the *
|
||||||
|
* extent applicable law prohibits such limitation. Some *
|
||||||
|
* jurisdictions do not allow the exclusion or limitation of *
|
||||||
|
* incidental or consequential damages, so this exclusion and *
|
||||||
|
* limitation may not apply to You. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
8. Litigation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Any litigation relating to this License may be brought only in the
|
||||||
|
courts of a jurisdiction where the defendant maintains its principal
|
||||||
|
place of business and such litigation shall be governed by laws of that
|
||||||
|
jurisdiction, without reference to its conflict-of-law provisions.
|
||||||
|
Nothing in this Section shall prevent a party's ability to bring
|
||||||
|
cross-claims or counter-claims.
|
||||||
|
|
||||||
|
9. Miscellaneous
|
||||||
|
----------------
|
||||||
|
|
||||||
|
This License represents the complete agreement concerning the subject
|
||||||
|
matter hereof. If any provision of this License is held to be
|
||||||
|
unenforceable, such provision shall be reformed only to the extent
|
||||||
|
necessary to make it enforceable. Any law or regulation which provides
|
||||||
|
that the language of a contract shall be construed against the drafter
|
||||||
|
shall not be used to construe this License against a Contributor.
|
||||||
|
|
||||||
|
10. Versions of the License
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
10.1. New Versions
|
||||||
|
|
||||||
|
Mozilla Foundation is the license steward. Except as provided in Section
|
||||||
|
10.3, no one other than the license steward has the right to modify or
|
||||||
|
publish new versions of this License. Each version will be given a
|
||||||
|
distinguishing version number.
|
||||||
|
|
||||||
|
10.2. Effect of New Versions
|
||||||
|
|
||||||
|
You may distribute the Covered Software under the terms of the version
|
||||||
|
of the License under which You originally received the Covered Software,
|
||||||
|
or under the terms of any subsequent version published by the license
|
||||||
|
steward.
|
||||||
|
|
||||||
|
10.3. Modified Versions
|
||||||
|
|
||||||
|
If you create software not governed by this License, and you want to
|
||||||
|
create a new license for such software, you may create and use a
|
||||||
|
modified version of this License if you rename the license and remove
|
||||||
|
any references to the name of the license steward (except to note that
|
||||||
|
such modified license differs from this License).
|
||||||
|
|
||||||
|
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||||
|
Licenses
|
||||||
|
|
||||||
|
If You choose to distribute Source Code Form that is Incompatible With
|
||||||
|
Secondary Licenses under the terms of this version of the License, the
|
||||||
|
notice described in Exhibit B of this License must be attached.
|
||||||
|
|
||||||
|
Exhibit A - Source Code Form License Notice
|
||||||
|
-------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
If it is not possible or desirable to put the notice in a particular
|
||||||
|
file, then You may include the notice in a location (such as a LICENSE
|
||||||
|
file in a relevant directory) where a recipient would be likely to look
|
||||||
|
for such a notice.
|
||||||
|
|
||||||
|
You may add additional accurate notices of copyright ownership.
|
||||||
|
|
||||||
|
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||||
|
---------------------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
defined by the Mozilla Public License, v. 2.0.
|
||||||
@@ -0,0 +1,351 @@
|
|||||||
|
# Nebula Browser
|
||||||
|
|
||||||
|
A Chromium Embedded Framework (CEF) browser with a custom HTML chrome UI.
|
||||||
|
|
||||||
|
**Nebula Browser** is a controller-first web browser designed for Steam Deck, SteamOS-style systems, handheld PCs, living room setups, and gamepad-driven desktop environments.
|
||||||
|
|
||||||
|
Originally developed as an Electron-based browser for SteamOS users, Nebula Browser is now being rebuilt with **CEF / Chromium Embedded Framework** to provide deeper control over the browser experience, improved native integration, and a cleaner long-term foundation for custom UI, controller navigation, and platform-specific builds.
|
||||||
|
|
||||||
|
Development on Nebula Browser has somewhat resumed, with the project now moving toward a more native custom browser architecture.
|
||||||
|
|
||||||
|
Nebula Browser is intended to remain open source. The browser source code is licensed under MPL-2.0, while Nebula branding and visual assets are protected separately.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
- **[Cross-platform build & architecture](docs/cross-platform.md)** — how to use one repo for Windows, macOS, and Linux; CEF setup; source layout; porting status.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Project Status
|
||||||
|
|
||||||
|
Nebula Browser is currently in early active redevelopment.
|
||||||
|
|
||||||
|
The original Electron version proved the core idea: a browser built around controller use, large-screen navigation, and a UI that does not feel like a standard desktop browser awkwardly placed on a handheld gaming device.
|
||||||
|
|
||||||
|
The new CEF version is the next major step.
|
||||||
|
|
||||||
|
Current focus areas include:
|
||||||
|
|
||||||
|
* Rebuilding the browser around CEF
|
||||||
|
* Creating a fully custom browser interface
|
||||||
|
* Moving away from default Chromium UI elements
|
||||||
|
* Reusing and adapting existing Nebula UI concepts where possible
|
||||||
|
* Supporting controller-first navigation
|
||||||
|
* Preparing for cross-platform builds across Windows, Linux, and macOS
|
||||||
|
* Creating a stronger foundation for future NebulaOS integration
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Why CEF?
|
||||||
|
|
||||||
|
Nebula Browser originally used Electron because it was fast to prototype, easy to package, and allowed the project to move quickly. However, Electron also comes with limits when building a browser that is meant to feel fully custom and deeply integrated with the operating system.
|
||||||
|
|
||||||
|
The move to **CEF** allows Nebula Browser to become more than a web app wrapped in a browser shell.
|
||||||
|
|
||||||
|
CEF gives the project:
|
||||||
|
|
||||||
|
* More control over the native window and browser lifecycle
|
||||||
|
* Better separation between the browser engine and the custom UI
|
||||||
|
* Greater flexibility for building a non-Chrome-like interface
|
||||||
|
* A more suitable foundation for SteamOS, Linux, and future NebulaOS use
|
||||||
|
* The ability to build a browser that feels purpose-built rather than wrapped
|
||||||
|
|
||||||
|
The goal is not to create another Chromium clone. The goal is to create a browser interface designed around how people actually use handhelds, controllers, TVs, and gaming-first systems.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Distribution Direction
|
||||||
|
|
||||||
|
Nebula Browser was originally aimed at Steam. However, after exploring Steam as a release platform, it became clear that Steam may not be the best fit for this kind of application.
|
||||||
|
|
||||||
|
The current distribution direction is:
|
||||||
|
|
||||||
|
### Primary Target
|
||||||
|
|
||||||
|
* **Itch.io**
|
||||||
|
|
||||||
|
Itch.io is currently the most practical and flexible platform for distributing Nebula Browser. It allows the project to be released as a utility-style app without needing to fit into a traditional game store category.
|
||||||
|
|
||||||
|
### Potential Future Targets
|
||||||
|
|
||||||
|
* **Epic Games Store**
|
||||||
|
* **GOG**
|
||||||
|
* **Flatpak / Linux package distribution**
|
||||||
|
* **Direct downloads from the Nebula website**
|
||||||
|
|
||||||
|
Epic Games and GOG are being considered as possible future distribution platforms, especially if Nebula Browser grows into a more polished desktop or gaming utility. These are not confirmed release platforms yet, but they remain possible options.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Open Source Direction
|
||||||
|
|
||||||
|
Nebula Browser is intended to remain open source because browsers are privacy-sensitive software. Users should be able to inspect how the browser works, verify that it is not doing anything suspicious, and contribute fixes or improvements when they find problems.
|
||||||
|
|
||||||
|
Open source is especially important for:
|
||||||
|
|
||||||
|
* User trust
|
||||||
|
* Privacy transparency
|
||||||
|
* Linux and Steam Deck community adoption
|
||||||
|
* Cross-platform testing
|
||||||
|
* Community contributions
|
||||||
|
* Long-term sustainability
|
||||||
|
|
||||||
|
The core Nebula Browser project should remain open source, including:
|
||||||
|
|
||||||
|
* Browser shell
|
||||||
|
* CEF integration code
|
||||||
|
* Custom browser UI
|
||||||
|
* Controller navigation systems
|
||||||
|
* Settings and theme systems
|
||||||
|
* Build scripts and documentation
|
||||||
|
|
||||||
|
Not every Nebula-related component has to be open source. Some future or external components may remain private or be licensed separately, such as:
|
||||||
|
|
||||||
|
* NebulaOS-specific services
|
||||||
|
* Account systems
|
||||||
|
* Cloud sync
|
||||||
|
* Hosted backend services
|
||||||
|
* Internal analytics or crash reporting infrastructure
|
||||||
|
* Private distribution tooling
|
||||||
|
* Experimental unreleased features
|
||||||
|
* Protected branding assets
|
||||||
|
|
||||||
|
Suggested openness model:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Nebula Browser: open source
|
||||||
|
Nebula Core: open source or source-available
|
||||||
|
NebulaOS: potentially partially open source
|
||||||
|
Nebula online services/backend: private
|
||||||
|
Branding assets: protected
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Core Vision
|
||||||
|
|
||||||
|
Nebula Browser is built around one simple idea:
|
||||||
|
|
||||||
|
> The web should be comfortable to use from a couch, handheld, controller, or gaming-focused operating system.
|
||||||
|
|
||||||
|
Most browsers are designed around keyboards, mice, and desktop workflows. Nebula Browser is designed around a different experience.
|
||||||
|
|
||||||
|
Nebula Browser aims to support:
|
||||||
|
|
||||||
|
* Controller-first navigation
|
||||||
|
* Large, readable interface elements
|
||||||
|
* Gamepad-friendly menus and shortcuts
|
||||||
|
* Steam Deck and handheld PC usability
|
||||||
|
* Custom home pages and launcher-style navigation
|
||||||
|
* Better integration with gaming-focused environments
|
||||||
|
* A UI that feels closer to a console app than a traditional browser
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Planned Features
|
||||||
|
|
||||||
|
The CEF rebuild is still early, but the intended feature set includes:
|
||||||
|
|
||||||
|
* Fully custom browser chrome
|
||||||
|
* Custom tab bar
|
||||||
|
* Custom address bar
|
||||||
|
* Controller-friendly navigation system
|
||||||
|
* On-screen keyboard support
|
||||||
|
* Bookmarks and quick access tiles
|
||||||
|
* Custom home page
|
||||||
|
* Desktop mode and controller mode
|
||||||
|
* Fullscreen and couch-friendly browsing
|
||||||
|
* Custom context menus
|
||||||
|
* Download management
|
||||||
|
* Settings system
|
||||||
|
* Theme support
|
||||||
|
* Steam Deck / handheld-focused layout options
|
||||||
|
* Optional integration with NebulaOS
|
||||||
|
|
||||||
|
Some features may be ported or adapted from the earlier Electron version where it makes sense.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Nebula Core
|
||||||
|
|
||||||
|
Nebula Browser may also make use of **Nebula Core**, a shared package system for Nebula-related projects.
|
||||||
|
|
||||||
|
Nebula Core is intended to provide reusable systems such as:
|
||||||
|
|
||||||
|
* Controller input handling
|
||||||
|
* Navigation helpers
|
||||||
|
* UI components
|
||||||
|
* Glyphs and button prompts
|
||||||
|
* Theming utilities
|
||||||
|
* On-screen keyboard systems
|
||||||
|
* Shared Nebula project logic
|
||||||
|
|
||||||
|
Because the new browser is CEF-based rather than Electron-based, some Nebula Core modules may need to be adapted for native integration or used through the browser UI layer rather than directly inside the C++ application layer.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Relationship to NebulaOS
|
||||||
|
|
||||||
|
Nebula Browser is part of the wider **Nebula Project** ecosystem.
|
||||||
|
|
||||||
|
NebulaOS is a controller-focused operating system / shell concept designed around gaming, handheld PCs, and living room devices. Nebula Browser is intended to become one of the key built-in applications for that ecosystem.
|
||||||
|
|
||||||
|
While Nebula Browser can exist as a standalone app, its long-term role is to provide a web browsing experience that feels native inside NebulaOS.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Technology Stack
|
||||||
|
|
||||||
|
The current redevelopment direction uses:
|
||||||
|
|
||||||
|
* **C++** for the native browser shell
|
||||||
|
* **CEF / Chromium Embedded Framework** for web rendering
|
||||||
|
* **HTML, CSS, and JavaScript** for the custom browser UI
|
||||||
|
* **CMake** for project configuration
|
||||||
|
* Platform-specific CEF builds for Windows, Linux, and macOS
|
||||||
|
|
||||||
|
The previous version used Electron, but the current direction is focused on CEF.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Repository Structure
|
||||||
|
|
||||||
|
The repository structure may change as the CEF rebuild develops, but the project is expected to follow a layout similar to:
|
||||||
|
|
||||||
|
```text
|
||||||
|
NebulaBrowser/
|
||||||
|
├── app/
|
||||||
|
│ ├── browser/
|
||||||
|
│ ├── ui/
|
||||||
|
│ └── platform/
|
||||||
|
├── cef/
|
||||||
|
│ └── README.md
|
||||||
|
├── resources/
|
||||||
|
│ ├── icons/
|
||||||
|
│ ├── themes/
|
||||||
|
│ └── pages/
|
||||||
|
├── scripts/
|
||||||
|
├── third_party/
|
||||||
|
├── CMakeLists.txt
|
||||||
|
└── README.md
|
||||||
|
```
|
||||||
|
|
||||||
|
CEF itself should generally not be committed directly into the repository. Instead, platform-specific CEF builds should be downloaded separately and placed into the expected local folder during development.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Development Notes
|
||||||
|
|
||||||
|
Nebula Browser is still experimental and in transition from the original Electron version to the new CEF version.
|
||||||
|
|
||||||
|
Expect changes in:
|
||||||
|
|
||||||
|
* Build setup
|
||||||
|
* File structure
|
||||||
|
* UI architecture
|
||||||
|
* Controller input systems
|
||||||
|
* Platform support
|
||||||
|
* Packaging and distribution
|
||||||
|
|
||||||
|
The project is not yet considered production-ready.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
Build instructions will be expanded as the CEF version becomes more stable.
|
||||||
|
|
||||||
|
At a high level, development requires:
|
||||||
|
|
||||||
|
1. A supported C++ compiler
|
||||||
|
2. CMake
|
||||||
|
3. A downloaded CEF binary distribution for your operating system
|
||||||
|
4. The Nebula Browser source code
|
||||||
|
5. A local build folder
|
||||||
|
|
||||||
|
Example build flow:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cmake -S . -B build
|
||||||
|
cmake --build build
|
||||||
|
```
|
||||||
|
|
||||||
|
More detailed platform-specific instructions will be added later. For macOS/Linux prerequisites, directory structure, and current port status, see [docs/cross-platform.md](docs/cross-platform.md).
|
||||||
|
|
||||||
|
### Quick start (Windows)
|
||||||
|
|
||||||
|
1. Download the [CEF standard binary distribution](https://cef-builds.spotifycdn.com/index.html) for Windows 64-bit.
|
||||||
|
2. Extract into `thirdparty/cef/` so `thirdparty/cef/cmake/FindCEF.cmake` exists.
|
||||||
|
3. Build:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
cmake -B build
|
||||||
|
cmake --build build --config Release
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Run `build\Release\NebulaBrowser.exe`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Platform Goals
|
||||||
|
|
||||||
|
Nebula Browser is being designed with cross-platform support in mind.
|
||||||
|
|
||||||
|
Target platforms include:
|
||||||
|
|
||||||
|
* Windows
|
||||||
|
* Linux
|
||||||
|
* SteamOS / Steam Deck
|
||||||
|
* macOS
|
||||||
|
|
||||||
|
Linux and SteamOS are especially important because Nebula Browser was originally created to solve a gap in the handheld and couch-browsing experience.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Release Plans
|
||||||
|
|
||||||
|
Nebula Browser does not currently have a fixed release date.
|
||||||
|
|
||||||
|
The current release plan is:
|
||||||
|
|
||||||
|
1. Rebuild the core browser shell in CEF
|
||||||
|
2. Replace default Chromium UI with a custom Nebula interface
|
||||||
|
3. Restore core browser functionality
|
||||||
|
4. Add controller-first navigation
|
||||||
|
5. Prepare an early public build
|
||||||
|
6. Release through Itch.io first
|
||||||
|
7. Explore additional distribution options later
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Nebula Browser is currently a personal / experimental project and is still finding its new technical direction.
|
||||||
|
|
||||||
|
Contributions, ideas, testing, and feedback may become more open once the CEF rebuild has a more stable foundation.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Licensing
|
||||||
|
|
||||||
|
Nebula Browser separates source code licensing from branding and visual assets.
|
||||||
|
|
||||||
|
The preferred licensing direction is:
|
||||||
|
|
||||||
|
* **Source code:** Mozilla Public License 2.0
|
||||||
|
* **Documentation:** CC BY 4.0, unless otherwise specified
|
||||||
|
* **Branding, logos, icons, names, and visual identity:** All Rights Reserved, unless explicitly stated otherwise
|
||||||
|
|
||||||
|
MPL-2.0 is being used because it is a practical open-source license for a browser-style project. It allows people to use, modify, and contribute to the code while requiring changes to MPL-licensed files to remain open under the same license.
|
||||||
|
|
||||||
|
The Nebula name, logo, and brand identity are not automatically granted for reuse just because the code is open source. See [ASSETS-LICENSE.md](ASSETS-LICENSE.md) for the separate asset and branding terms.
|
||||||
|
|
||||||
|
See the CEF distribution and Chromium license terms for third-party runtime components.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
Nebula Browser is created as part of the wider Nebula Project, a collection of software experiments focused on controller-first computing, gaming-focused interfaces, and custom desktop experiences.
|
||||||
|
|
||||||
|
The project began as a browser for SteamOS and Steam Deck users, but is now evolving into a more flexible, native, and custom browser experience built around CEF.
|
||||||
+25
-5
@@ -1,13 +1,33 @@
|
|||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include "app/run.h"
|
#include "app/run.h"
|
||||||
|
#include "platform/types.h"
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include <windows.h>
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include "include/wrapper/cef_library_loader.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
int APIENTRY wWinMain(HINSTANCE instance,
|
int APIENTRY wWinMain(HINSTANCE instance,
|
||||||
HINSTANCE previous_instance,
|
HINSTANCE previous_instance,
|
||||||
LPWSTR command_line,
|
LPWSTR command_line,
|
||||||
int show_command) {
|
int show_command) {
|
||||||
UNREFERENCED_PARAMETER(previous_instance);
|
NEBULA_UNUSED(previous_instance);
|
||||||
UNREFERENCED_PARAMETER(command_line);
|
NEBULA_UNUSED(command_line);
|
||||||
|
|
||||||
return nebula::app::RunNebula(instance, show_command);
|
const nebula::platform::AppStartup startup{instance, show_command};
|
||||||
|
return nebula::app::RunNebula(startup, {nebula::app::AppMode::Desktop});
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
CefScopedLibraryLoader library_loader;
|
||||||
|
if (!library_loader.LoadInMain()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const nebula::platform::AppStartup startup{argc, argv};
|
||||||
|
return nebula::app::RunNebula(startup, {nebula::app::AppMode::Desktop});
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#include "app/run.h"
|
||||||
|
#include "platform/types.h"
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include <windows.h>
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include "include/wrapper/cef_library_loader.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
int APIENTRY wWinMain(HINSTANCE instance,
|
||||||
|
HINSTANCE previous_instance,
|
||||||
|
LPWSTR command_line,
|
||||||
|
int show_command) {
|
||||||
|
NEBULA_UNUSED(previous_instance);
|
||||||
|
NEBULA_UNUSED(command_line);
|
||||||
|
|
||||||
|
const nebula::platform::AppStartup startup{instance, show_command};
|
||||||
|
return nebula::app::RunNebula(startup, {nebula::app::AppMode::BigPicture});
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
CefScopedLibraryLoader library_loader;
|
||||||
|
if (!library_loader.LoadInMain()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const nebula::platform::AppStartup startup{argc, argv};
|
||||||
|
return nebula::app::RunNebula(startup, {nebula::app::AppMode::BigPicture});
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#include "cef/nebula_app.h"
|
||||||
|
#include "include/cef_app.h"
|
||||||
|
#include "include/wrapper/cef_library_loader.h"
|
||||||
|
|
||||||
|
#if defined(CEF_USE_SANDBOX)
|
||||||
|
#include "include/cef_sandbox_mac.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
#if defined(CEF_USE_SANDBOX)
|
||||||
|
CefScopedSandboxContext sandbox_context;
|
||||||
|
if (!sandbox_context.Initialize(argc, argv)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CefScopedLibraryLoader library_loader;
|
||||||
|
if (!library_loader.LoadInHelper()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CefMainArgs main_args(argc, argv);
|
||||||
|
CefRefPtr<nebula::cef::NebulaApp> app(new nebula::cef::NebulaApp);
|
||||||
|
return CefExecuteProcess(main_args, app, nullptr);
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>en</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>${EXECUTABLE_NAME}</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>${EXECUTABLE_NAME}</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.nebula.browser.${HELPER_BUNDLE_NAME}.helper${BUNDLE_ID_SUFFIX}</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>${PRODUCT_NAME}</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>LSEnvironment</key>
|
||||||
|
<dict>
|
||||||
|
<key>MallocNanoZone</key>
|
||||||
|
<string>0</string>
|
||||||
|
</dict>
|
||||||
|
<key>LSFileQuarantineEnabled</key>
|
||||||
|
<true/>
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>12.0</string>
|
||||||
|
<key>LSUIElement</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>NSSupportsAutomaticGraphicsSwitching</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
build/compile_commands.json
|
||||||
@@ -0,0 +1,215 @@
|
|||||||
|
# Cross-platform build guide
|
||||||
|
|
||||||
|
Nebula Browser uses a **single codebase** and **one git branch** for Windows, macOS, and Linux. You do not maintain separate platform branches. Instead, each machine unpacks the correct [CEF](https://bitbucket.org/chromiumembedded/cef) binary distribution into `thirdparty/cef/` and builds with CMake.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
| Layer | Location | Platform-specific? |
|
||||||
|
|-------|----------|-------------------|
|
||||||
|
| CEF binaries | `thirdparty/cef/` (gitignored) | Yes — one distribution per OS |
|
||||||
|
| CMake / deploy | `CMakeLists.txt` | Yes — uses CEF’s `COPY_FILES`, `COPY_MAC_FRAMEWORK`, etc. |
|
||||||
|
| App entry & CEF init | `src/app/run.cpp`, `src/platform/*/startup_*.cpp` | Partly |
|
||||||
|
| Native window shell | `src/platform/win\|mac\|linux/` | Yes |
|
||||||
|
| Browser embedding | `src/platform/*/browser_host_*.cpp` | Partly |
|
||||||
|
| Tabs, URLs, UI routing | `src/browser/`, `src/ui/`, `src/cef/` | No (shared) |
|
||||||
|
|
||||||
|
**Windows** has a full native shell (custom frame, DWM, embedded CEF views).
|
||||||
|
|
||||||
|
**macOS** has a Cocoa native shell (`NSWindow` / `NSView`) with CEF child-view embedding.
|
||||||
|
|
||||||
|
**Linux** compiles and links today, but `NebulaWindow::Create()` is still a stub that returns `false` until a real X11 (or GTK) host is implemented.
|
||||||
|
|
||||||
|
## Directory layout
|
||||||
|
|
||||||
|
```
|
||||||
|
thirdparty/cef/ # CEF standard distribution for your OS (not in git)
|
||||||
|
|
||||||
|
src/platform/
|
||||||
|
types.h # Rect, BrowserLayout, NativeWindow, AppStartup
|
||||||
|
startup.h # PrepareApp, single-instance, CefMainArgs, CefSettings paths
|
||||||
|
browser_host.h # CefWindowInfo helpers, resize/show/destroy browser HWNDs
|
||||||
|
paths_platform.h # ExecutableDirectory, DefaultUserDataRoot, PathToUtf8
|
||||||
|
|
||||||
|
win/ # Windows implementation
|
||||||
|
mac/ # macOS Cocoa implementation
|
||||||
|
linux/ # Linux stubs + partial CEF glue
|
||||||
|
|
||||||
|
src/window/
|
||||||
|
nebula_window.h # Platform-agnostic window API (PIMPL)
|
||||||
|
|
||||||
|
src/app/ # Shared controller and run loop
|
||||||
|
src/browser/ # Shared tab/session logic
|
||||||
|
src/cef/ # Shared CEF app and browser client
|
||||||
|
src/ui/ # Shared nebula:// URLs and path helpers
|
||||||
|
ui/ # HTML/JS UI (copied next to the binary at build time)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- **CMake** 3.21+
|
||||||
|
- **C++20** compiler
|
||||||
|
- Windows: Visual Studio 2022
|
||||||
|
- macOS: Xcode 16+ (Clang)
|
||||||
|
- Linux: GCC 10+ or Clang, plus development packages for X11 (CEF’s CMake runs `pkg-config` for X11 on Linux)
|
||||||
|
- **CEF standard binary distribution** for your OS and CPU architecture from the [CEF builds](https://cef-builds.spotifycdn.com/index.html) page (or your usual CEF source)
|
||||||
|
|
||||||
|
## CEF setup
|
||||||
|
|
||||||
|
1. Download the **standard distribution** for your platform (e.g. `cef_binary_*_windows64`, `*_macos*`, `*_linux64`).
|
||||||
|
2. Extract so that this path exists:
|
||||||
|
|
||||||
|
```
|
||||||
|
thirdparty/cef/cmake/FindCEF.cmake
|
||||||
|
```
|
||||||
|
|
||||||
|
3. The rest of the distribution (`Release/`, `Resources/`, `libcef_dll/`, etc.) should sit directly under `thirdparty/cef/` as shipped by CEF.
|
||||||
|
|
||||||
|
`thirdparty/cef/` is listed in `.gitignore` so binaries are never committed. Each developer and CI machine supplies its own copy.
|
||||||
|
|
||||||
|
## IDE / clangd setup
|
||||||
|
|
||||||
|
Without CEF headers, clangd will show many errors (unknown types like `CefWindowInfo`, `CefMainArgs`, etc.). To get full IDE support:
|
||||||
|
|
||||||
|
1. Unpack CEF into `thirdparty/cef/` as described above
|
||||||
|
2. Generate `compile_commands.json`:
|
||||||
|
```bash
|
||||||
|
cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||||
|
```
|
||||||
|
3. Symlink it to the project root:
|
||||||
|
```bash
|
||||||
|
ln -s build/compile_commands.json .
|
||||||
|
```
|
||||||
|
|
||||||
|
The included `.clangd` file provides fallback flags, but full diagnostics require the compile database.
|
||||||
|
|
||||||
|
Optional: override the location at configure time:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cmake -B build -DCEF_ROOT=/path/to/cef_binary
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
cmake -B build
|
||||||
|
cmake --build build --config Release
|
||||||
|
```
|
||||||
|
|
||||||
|
Output: `build/Release/NebulaBrowser.exe` (plus CEF DLLs and `ui/` copied beside it).
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cmake -B build -DPROJECT_ARCH=x86_64 # or arm64 on Apple Silicon
|
||||||
|
cmake --build build --config Release
|
||||||
|
```
|
||||||
|
|
||||||
|
CMake builds a `NebulaBrowser.app` bundle and copies the Chromium Embedded Framework into `Contents/Frameworks`. The macOS port includes a Cocoa `NSWindow` / `NSView` host and child-view embedding for CEF browsers.
|
||||||
|
|
||||||
|
CEF **helper app** subprocess targets may still need to be added if the selected CEF distribution does not provide a compatible default subprocess layout. Use CEF’s `cefsimple` sample as the reference for the complete Mac bundle layout.
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cmake -B build
|
||||||
|
cmake --build build
|
||||||
|
```
|
||||||
|
|
||||||
|
Output: `build/NebulaBrowser` (or `build/<Config>/NebulaBrowser` depending on generator). CEF `.so` files and resources are copied next to the executable.
|
||||||
|
|
||||||
|
You may need to set **SUID** on `chrome-sandbox` as printed by CMake post-build (CEF documents this in its Linux README).
|
||||||
|
|
||||||
|
Until a Linux host window exists, the binary will not show a UI for the same reason as macOS.
|
||||||
|
|
||||||
|
## How CMake picks a platform
|
||||||
|
|
||||||
|
`find_package(CEF)` loads CEF’s `cef_variables.cmake`, which sets:
|
||||||
|
|
||||||
|
- `OS_WINDOWS`
|
||||||
|
- `OS_MACOSX`
|
||||||
|
- `OS_LINUX`
|
||||||
|
|
||||||
|
`CMakeLists.txt` then:
|
||||||
|
|
||||||
|
1. Adds the matching `src/platform/{win,mac,linux}/*.cpp` sources
|
||||||
|
2. Sets the executable type (`WIN32`, `MACOSX_BUNDLE`, or plain executable)
|
||||||
|
3. Links `libcef_dll_wrapper`, `libcef_lib`, and `${CEF_STANDARD_LIBS}`
|
||||||
|
4. Runs CEF’s copy macros so runtime files land beside the app
|
||||||
|
|
||||||
|
Shared sources are always compiled; only the `src/platform/...` tree changes per OS.
|
||||||
|
|
||||||
|
## Application flow
|
||||||
|
|
||||||
|
```
|
||||||
|
main (app/main.cpp)
|
||||||
|
└─ RunNebula(AppStartup) src/app/run.cpp
|
||||||
|
├─ platform::PrepareApp()
|
||||||
|
├─ CefExecuteProcess() (subprocesses)
|
||||||
|
├─ platform::TryAcquireSingleInstance()
|
||||||
|
├─ CefInitialize()
|
||||||
|
├─ NebulaController::Create()
|
||||||
|
│ └─ NebulaWindow::Create() platform-specific
|
||||||
|
└─ CefRunMessageLoop()
|
||||||
|
```
|
||||||
|
|
||||||
|
`AppStartup` carries platform entry data:
|
||||||
|
|
||||||
|
- **Windows:** `HINSTANCE` + show command (`wWinMain`)
|
||||||
|
- **macOS / Linux:** `argc` / `argv` (`main`)
|
||||||
|
|
||||||
|
## User data and profile paths
|
||||||
|
|
||||||
|
Shared logic in `src/ui/paths.cpp` writes under:
|
||||||
|
|
||||||
|
| OS | Default root |
|
||||||
|
|----|----------------|
|
||||||
|
| Windows | `%LOCALAPPDATA%\Nebula\User Data` (falls back to exe directory) |
|
||||||
|
| macOS | `~/Library/Application Support/Nebula/User Data` |
|
||||||
|
| Linux | `$XDG_DATA_HOME/Nebula/User Data` or `~/.local/share/Nebula/User Data` |
|
||||||
|
|
||||||
|
Platform-specific discovery lives in `src/platform/*/paths_*.cpp`.
|
||||||
|
|
||||||
|
## GPU / Chromium flags
|
||||||
|
|
||||||
|
`src/cef/nebula_app.cpp` applies shared switches (`no-sandbox`, `ignore-gpu-blocklist`, etc.) and platform graphics backends:
|
||||||
|
|
||||||
|
| OS | Backend |
|
||||||
|
|----|---------|
|
||||||
|
| Windows | ANGLE + D3D11 |
|
||||||
|
| macOS | ANGLE + Metal |
|
||||||
|
| Linux | EGL |
|
||||||
|
|
||||||
|
## Adding or changing platform code
|
||||||
|
|
||||||
|
1. **Shared behavior** (tabs, `nebula://` URLs, CEF clients) → edit under `src/browser/`, `src/ui/`, `src/cef/`, `src/app/` only if it is truly cross-platform.
|
||||||
|
2. **Native window or OS API** → edit `src/platform/<os>/` and keep `src/window/nebula_window.h` free of `#include <windows.h>` (or Cocoa/X11 headers).
|
||||||
|
3. **CEF child window embedding** → `src/platform/<os>/browser_host_*.cpp` (`MakeChildWindowInfo`, resize, visibility).
|
||||||
|
4. **Startup / paths** → `startup_*.cpp` and `paths_*.cpp` in the same folder.
|
||||||
|
5. **New OS** → add `src/platform/<os>/`, extend the `if(OS_...)` blocks in `CMakeLists.txt`, and document CEF distribution layout here.
|
||||||
|
|
||||||
|
## Porting checklist (macOS / Linux)
|
||||||
|
|
||||||
|
- [x] macOS: implement `NebulaWindow` in `nebula_window_mac.mm`
|
||||||
|
- [x] macOS: wire `browser_host_mac.mm` resize/show/raise to Cocoa views
|
||||||
|
- [ ] Linux: implement `NebulaWindow` in `nebula_window_linux.cpp`
|
||||||
|
- [ ] Linux: wire `browser_host_linux.cpp` resize/show/raise to the real toolkit
|
||||||
|
- [ ] macOS: add CEF helper app targets and bundle layout (copy from `cefsimple`)
|
||||||
|
- [ ] Linux: confirm X11 (or chosen toolkit) parent handle for `CefWindowInfo::SetAsChild`
|
||||||
|
- [ ] Test GPU diagnostics page and hardware acceleration on target hardware
|
||||||
|
- [ ] Package or script runtime layout (`ui/`, CEF frameworks/libs, ICU locales, etc.)
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
**Do I need a separate git branch per OS?**
|
||||||
|
No. Use one branch; swap `thirdparty/cef` and rebuild on each machine.
|
||||||
|
|
||||||
|
**Can I commit CEF into the repo?**
|
||||||
|
Not recommended (size, licensing, per-arch binaries). Keeping `thirdparty/cef/` gitignored is intentional.
|
||||||
|
|
||||||
|
**Why does Linux build but not run?**
|
||||||
|
The Linux window stub intentionally returns `false` from `Create()` until a native shell exists. Shared CEF and browser code are ready; the missing piece is the host window.
|
||||||
|
|
||||||
|
**Where is the Windows UI code?**
|
||||||
|
`src/platform/win/nebula_window_win.cpp` — custom chrome, hit-testing, fullscreen, and child browser placement.
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
#include "app/first_run_state.h"
|
||||||
|
|
||||||
|
#include <cctype>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
#include <system_error>
|
||||||
|
|
||||||
|
#include "ui/paths.h"
|
||||||
|
|
||||||
|
namespace nebula::app {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
std::string ReadFile(const std::filesystem::path& path) {
|
||||||
|
std::ifstream input(path, std::ios::binary);
|
||||||
|
if (!input) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostringstream buffer;
|
||||||
|
buffer << input.rdbuf();
|
||||||
|
return buffer.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReadFirstStartValue(const std::string& json, bool& first_start) {
|
||||||
|
constexpr std::string_view key = "\"first-start\"";
|
||||||
|
const size_t key_pos = json.find(key);
|
||||||
|
if (key_pos == std::string::npos) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t colon = json.find(':', key_pos + key.size());
|
||||||
|
if (colon == std::string::npos) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
++colon;
|
||||||
|
while (colon < json.size() && std::isspace(static_cast<unsigned char>(json[colon]))) {
|
||||||
|
++colon;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json.compare(colon, 4, "true") == 0) {
|
||||||
|
first_start = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (json.compare(colon, 5, "false") == 0) {
|
||||||
|
first_start = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
bool ShouldShowFirstRunSetup() {
|
||||||
|
const auto path = nebula::ui::GetFirstRunStatePath();
|
||||||
|
if (path.empty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string json = ReadFile(path);
|
||||||
|
if (json.empty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool first_start = true;
|
||||||
|
return ReadFirstStartValue(json, first_start) ? first_start : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WriteFirstRunState(bool first_start) {
|
||||||
|
const auto path = nebula::ui::GetFirstRunStatePath();
|
||||||
|
if (path.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::path temp_path = path;
|
||||||
|
temp_path += L".tmp";
|
||||||
|
{
|
||||||
|
std::ofstream output(temp_path, std::ios::binary | std::ios::trunc);
|
||||||
|
if (!output) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
output << "{\n \"first-start\": " << (first_start ? "true" : "false") << "\n}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::error_code ec;
|
||||||
|
std::filesystem::remove(path, ec);
|
||||||
|
ec.clear();
|
||||||
|
std::filesystem::rename(temp_path, path, ec);
|
||||||
|
return !ec;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::app
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace nebula::app {
|
||||||
|
|
||||||
|
bool ShouldShowFirstRunSetup();
|
||||||
|
bool WriteFirstRunState(bool first_start);
|
||||||
|
|
||||||
|
} // namespace nebula::app
|
||||||
+748
-135
File diff suppressed because it is too large
Load Diff
@@ -5,8 +5,10 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "app/run.h"
|
||||||
#include "browser/tab_manager.h"
|
#include "browser/tab_manager.h"
|
||||||
#include "cef/browser_client.h"
|
#include "cef/browser_client.h"
|
||||||
|
#include "platform/types.h"
|
||||||
#include "window/nebula_window.h"
|
#include "window/nebula_window.h"
|
||||||
|
|
||||||
namespace nebula::app {
|
namespace nebula::app {
|
||||||
@@ -15,7 +17,9 @@ class NebulaController final : public nebula::window::WindowDelegate,
|
|||||||
public nebula::browser::TabObserver,
|
public nebula::browser::TabObserver,
|
||||||
public nebula::cef::BrowserClientDelegate {
|
public nebula::cef::BrowserClientDelegate {
|
||||||
public:
|
public:
|
||||||
NebulaController(HINSTANCE instance, std::string initial_url, int show_command);
|
NebulaController(nebula::platform::AppStartup startup,
|
||||||
|
std::string initial_url,
|
||||||
|
LaunchOptions launch_options = {});
|
||||||
~NebulaController() override;
|
~NebulaController() override;
|
||||||
|
|
||||||
bool Create();
|
bool Create();
|
||||||
@@ -23,6 +27,7 @@ public:
|
|||||||
void OnWindowCreated() override;
|
void OnWindowCreated() override;
|
||||||
void OnWindowResized(const nebula::window::BrowserLayout& layout) override;
|
void OnWindowResized(const nebula::window::BrowserLayout& layout) override;
|
||||||
void OnWindowCloseRequested() override;
|
void OnWindowCloseRequested() override;
|
||||||
|
void OnExternalOpenRequested(const std::string& target) override;
|
||||||
|
|
||||||
void OnActiveTabChanged(const nebula::browser::NebulaTab& tab) override;
|
void OnActiveTabChanged(const nebula::browser::NebulaTab& tab) override;
|
||||||
|
|
||||||
@@ -40,40 +45,71 @@ public:
|
|||||||
bool ShouldBypassInsecureWarning(CefRefPtr<CefBrowser> browser, const std::string& target_url) override;
|
bool ShouldBypassInsecureWarning(CefRefPtr<CefBrowser> browser, const std::string& target_url) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateNewTab();
|
void CreateNewTab(std::string url = {});
|
||||||
void ActivateTab(int tab_id);
|
void ActivateTab(int tab_id);
|
||||||
void CloseTab(int tab_id);
|
void CloseTab(int tab_id);
|
||||||
void CreateChromeBrowser();
|
void CreateChromeBrowser();
|
||||||
|
void CreateBigPictureBrowser();
|
||||||
void CreateContentBrowser();
|
void CreateContentBrowser();
|
||||||
|
void EnterBigPictureMode();
|
||||||
|
void ExitBigPictureMode();
|
||||||
|
nebula::window::BrowserLayout CurrentBrowserLayout() const;
|
||||||
void ToggleMenuPopup();
|
void ToggleMenuPopup();
|
||||||
void CloseMenuPopup();
|
void CloseMenuPopup();
|
||||||
void CreateMenuPopupBrowser();
|
void CreateMenuPopupBrowser();
|
||||||
void PositionMenuPopup();
|
void PositionMenuPopup();
|
||||||
|
void SendMenuPopupZoom();
|
||||||
|
void SendThemeToChromeSurfaces(const std::string& theme_json);
|
||||||
void ToggleDevTools();
|
void ToggleDevTools();
|
||||||
void AdjustZoom(double delta);
|
void AdjustZoom(double delta);
|
||||||
void FreshReload();
|
void FreshReload();
|
||||||
|
void SendBigPictureMouseMove(const std::string& payload);
|
||||||
|
void SendBigPictureMouseClick(const std::string& payload, bool right_click);
|
||||||
|
void SendBigPictureMouseWheel(const std::string& payload);
|
||||||
|
void SendBigPictureText(const std::string& payload);
|
||||||
|
void SetBigPictureBrowseVisible(bool visible);
|
||||||
void SetContentFullscreen(bool fullscreen);
|
void SetContentFullscreen(bool fullscreen);
|
||||||
|
void CompleteFirstRunSetup();
|
||||||
|
void SendDefaultBrowserResult(const std::string& request_id,
|
||||||
|
bool success,
|
||||||
|
bool needs_user_action,
|
||||||
|
const std::string& error = {});
|
||||||
void ResizeBrowsers();
|
void ResizeBrowsers();
|
||||||
void SendChromeState(const nebula::browser::NebulaTab& tab);
|
void SendChromeState(const nebula::browser::NebulaTab& tab);
|
||||||
|
void SendBigPictureState(const nebula::browser::NebulaTab& tab);
|
||||||
void RecordSiteHistory(const std::string& url);
|
void RecordSiteHistory(const std::string& url);
|
||||||
void InjectSettingsHistory(CefRefPtr<CefBrowser> browser);
|
void InjectSettingsHistory(CefRefPtr<CefBrowser> browser);
|
||||||
|
void InjectBigPictureCursor(CefRefPtr<CefBrowser> browser);
|
||||||
|
void RemoveBigPictureCursor(CefRefPtr<CefBrowser> browser);
|
||||||
void PersistSession() const;
|
void PersistSession() const;
|
||||||
|
void BeginShutdown();
|
||||||
void MaybeFinishShutdown();
|
void MaybeFinishShutdown();
|
||||||
|
bool ForgetClosingTabBrowser(CefRefPtr<CefBrowser> browser);
|
||||||
|
void LoadPendingNavigationDelayed();
|
||||||
|
|
||||||
HINSTANCE instance_ = nullptr;
|
nebula::platform::AppStartup startup_;
|
||||||
std::string initial_url_;
|
std::string initial_url_;
|
||||||
int show_command_ = SW_SHOWDEFAULT;
|
std::string pending_initial_navigation_;
|
||||||
|
LaunchOptions launch_options_;
|
||||||
bool closing_ = false;
|
bool closing_ = false;
|
||||||
bool chrome_ready_ = false;
|
bool chrome_ready_ = false;
|
||||||
|
bool big_picture_ready_ = false;
|
||||||
|
bool big_picture_mode_ = false;
|
||||||
|
bool big_picture_browse_visible_ = false;
|
||||||
bool content_fullscreen_ = false;
|
bool content_fullscreen_ = false;
|
||||||
|
bool first_run_setup_active_ = false;
|
||||||
|
bool menu_popup_visible_ = false;
|
||||||
|
|
||||||
std::unique_ptr<nebula::window::NebulaWindow> window_;
|
std::unique_ptr<nebula::window::NebulaWindow> window_;
|
||||||
nebula::browser::TabManager tabs_;
|
nebula::browser::TabManager tabs_;
|
||||||
CefRefPtr<CefBrowser> chrome_browser_;
|
CefRefPtr<CefBrowser> chrome_browser_;
|
||||||
|
CefRefPtr<CefBrowser> big_picture_browser_;
|
||||||
CefRefPtr<CefBrowser> menu_popup_browser_;
|
CefRefPtr<CefBrowser> menu_popup_browser_;
|
||||||
CefRefPtr<nebula::cef::NebulaBrowserClient> chrome_client_;
|
CefRefPtr<nebula::cef::NebulaBrowserClient> chrome_client_;
|
||||||
|
CefRefPtr<nebula::cef::NebulaBrowserClient> big_picture_client_;
|
||||||
CefRefPtr<nebula::cef::NebulaBrowserClient> content_client_;
|
CefRefPtr<nebula::cef::NebulaBrowserClient> content_client_;
|
||||||
CefRefPtr<nebula::cef::NebulaBrowserClient> menu_popup_client_;
|
CefRefPtr<nebula::cef::NebulaBrowserClient> menu_popup_client_;
|
||||||
|
std::vector<CefRefPtr<CefBrowser>> closing_tab_browsers_;
|
||||||
std::unordered_set<std::string> insecure_warning_bypasses_;
|
std::unordered_set<std::string> insecure_warning_bypasses_;
|
||||||
std::vector<std::string> site_history_;
|
std::vector<std::string> site_history_;
|
||||||
};
|
};
|
||||||
|
|||||||
+105
-45
@@ -1,44 +1,120 @@
|
|||||||
#include "app/run.h"
|
#include "app/run.h"
|
||||||
|
|
||||||
#include "app/nebula_controller.h"
|
#include "app/nebula_controller.h"
|
||||||
|
#include "browser/url_utils.h"
|
||||||
#include "cef/nebula_app.h"
|
#include "cef/nebula_app.h"
|
||||||
#include "include/cef_app.h"
|
#include "include/cef_app.h"
|
||||||
#include "include/cef_command_line.h"
|
#include "include/cef_command_line.h"
|
||||||
|
#include "platform/default_browser.h"
|
||||||
|
#include "platform/startup.h"
|
||||||
#include "ui/paths.h"
|
#include "ui/paths.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cctype>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <system_error>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace nebula::app {
|
namespace nebula::app {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr wchar_t kMainInstanceMutexName[] = L"Local\\NebulaBrowserMainInstance";
|
std::string Trim(std::string value) {
|
||||||
|
while (!value.empty() && std::isspace(static_cast<unsigned char>(value.front()))) {
|
||||||
void EnableDpiAwareness() {
|
value.erase(value.begin());
|
||||||
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
}
|
||||||
|
while (!value.empty() && std::isspace(static_cast<unsigned char>(value.back()))) {
|
||||||
|
value.pop_back();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ScopedHandle {
|
std::string ToLowerAscii(std::string value) {
|
||||||
public:
|
std::transform(value.begin(), value.end(), value.begin(), [](unsigned char ch) {
|
||||||
explicit ScopedHandle(HANDLE handle) : handle_(handle) {}
|
return static_cast<char>(std::tolower(ch));
|
||||||
~ScopedHandle() {
|
});
|
||||||
if (handle_) {
|
return value;
|
||||||
CloseHandle(handle_);
|
}
|
||||||
|
|
||||||
|
bool StartsWithKnownScheme(const std::string& value) {
|
||||||
|
const std::string lower = ToLowerAscii(value);
|
||||||
|
return lower.starts_with("http://") ||
|
||||||
|
lower.starts_with("https://") ||
|
||||||
|
lower.starts_with("file:") ||
|
||||||
|
lower.starts_with("data:") ||
|
||||||
|
lower.starts_with("blob:") ||
|
||||||
|
lower.starts_with("chrome:") ||
|
||||||
|
lower.starts_with("nebula://");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::path PathFromUtf8(const std::string& value) {
|
||||||
|
#if defined(_WIN32)
|
||||||
|
const int size = MultiByteToWideChar(
|
||||||
|
CP_UTF8, 0, value.data(), static_cast<int>(value.size()), nullptr, 0);
|
||||||
|
if (size <= 0) {
|
||||||
|
return std::filesystem::path(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring wide(size, L'\0');
|
||||||
|
MultiByteToWideChar(
|
||||||
|
CP_UTF8, 0, value.data(), static_cast<int>(value.size()), wide.data(), size);
|
||||||
|
return std::filesystem::path(wide);
|
||||||
|
#else
|
||||||
|
return std::filesystem::path(value);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string NormalizeLaunchTarget(std::string target) {
|
||||||
|
target = Trim(std::move(target));
|
||||||
|
if (target.empty() || nebula::ui::IsChromiumNewTabUrl(target)) {
|
||||||
|
return target.empty() ? std::string{} : nebula::ui::GetHomeUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StartsWithKnownScheme(target)) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::filesystem::path path = PathFromUtf8(target);
|
||||||
|
std::error_code ec;
|
||||||
|
if (!path.empty() && std::filesystem::exists(path, ec) && !ec) {
|
||||||
|
const std::filesystem::path absolute_path = std::filesystem::absolute(path, ec);
|
||||||
|
return nebula::ui::FilePathToUrl(ec ? path : absolute_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nebula::browser::NormalizeNavigationInput(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetLaunchTarget(CefRefPtr<CefCommandLine> command_line) {
|
||||||
|
if (!command_line) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string target = command_line->GetSwitchValue("url");
|
||||||
|
if (!target.empty()) {
|
||||||
|
return NormalizeLaunchTarget(std::move(target));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<CefString> arguments;
|
||||||
|
command_line->GetArguments(arguments);
|
||||||
|
for (const auto& argument : arguments) {
|
||||||
|
target = argument.ToString();
|
||||||
|
if (!Trim(target).empty()) {
|
||||||
|
return NormalizeLaunchTarget(std::move(target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedHandle(const ScopedHandle&) = delete;
|
return {};
|
||||||
ScopedHandle& operator=(const ScopedHandle&) = delete;
|
}
|
||||||
|
|
||||||
bool valid() const { return handle_ != nullptr; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
HANDLE handle_ = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int RunNebula(HINSTANCE instance, int show_command) {
|
int RunNebula(const nebula::platform::AppStartup& startup, LaunchOptions options) {
|
||||||
EnableDpiAwareness();
|
nebula::platform::PrepareApp();
|
||||||
|
|
||||||
CefMainArgs main_args(instance);
|
const CefMainArgs main_args = nebula::platform::MakeMainArgs(startup);
|
||||||
CefRefPtr<nebula::cef::NebulaApp> app(new nebula::cef::NebulaApp);
|
CefRefPtr<nebula::cef::NebulaApp> app(new nebula::cef::NebulaApp);
|
||||||
|
|
||||||
const int subprocess_exit_code = CefExecuteProcess(main_args, app, nullptr);
|
const int subprocess_exit_code = CefExecuteProcess(main_args, app, nullptr);
|
||||||
@@ -46,41 +122,25 @@ int RunNebula(HINSTANCE instance, int show_command) {
|
|||||||
return subprocess_exit_code;
|
return subprocess_exit_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedHandle main_instance_mutex(CreateMutexW(nullptr, TRUE, kMainInstanceMutexName));
|
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
|
||||||
if (main_instance_mutex.valid() && GetLastError() == ERROR_ALREADY_EXISTS) {
|
nebula::platform::InitCommandLine(command_line, startup);
|
||||||
|
std::string initial_url = GetLaunchTarget(command_line);
|
||||||
|
|
||||||
|
if (!nebula::platform::TryAcquireSingleInstance(initial_url)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
nebula::platform::EnsureDefaultBrowserRegistration();
|
||||||
|
|
||||||
CefSettings settings;
|
CefSettings settings;
|
||||||
settings.no_sandbox = true;
|
settings.no_sandbox = true;
|
||||||
settings.persist_session_cookies = true;
|
settings.persist_session_cookies = true;
|
||||||
|
nebula::platform::ConfigureCefSettings(settings);
|
||||||
// A persistent profile is required for the GPU shader cache and several
|
|
||||||
// hardware acceleration features. Without these Chromium silently falls
|
|
||||||
// back to software rendering, which causes choppy video and disables
|
|
||||||
// WebGL/WebGL2 in the GPU diagnostics page.
|
|
||||||
const std::wstring user_data_dir = nebula::ui::GetUserDataDirectory().wstring();
|
|
||||||
const std::wstring cache_dir = nebula::ui::GetCacheDirectory().wstring();
|
|
||||||
if (!user_data_dir.empty()) {
|
|
||||||
CefString(&settings.root_cache_path).FromWString(user_data_dir);
|
|
||||||
}
|
|
||||||
if (!cache_dir.empty()) {
|
|
||||||
CefString(&settings.cache_path).FromWString(cache_dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CefInitialize(main_args, settings, app, nullptr)) {
|
if (!CefInitialize(main_args, settings, app, nullptr)) {
|
||||||
return CefGetExitCode();
|
return CefGetExitCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
|
NebulaController controller(startup, std::move(initial_url), options);
|
||||||
command_line->InitFromString(GetCommandLineW());
|
|
||||||
|
|
||||||
std::string initial_url = command_line->GetSwitchValue("url");
|
|
||||||
if (!initial_url.empty() && nebula::ui::IsChromiumNewTabUrl(initial_url)) {
|
|
||||||
initial_url = nebula::ui::GetHomeUrl();
|
|
||||||
}
|
|
||||||
|
|
||||||
NebulaController controller(instance, initial_url, show_command);
|
|
||||||
const bool created = controller.Create();
|
const bool created = controller.Create();
|
||||||
if (created) {
|
if (created) {
|
||||||
CefRunMessageLoop();
|
CefRunMessageLoop();
|
||||||
|
|||||||
+11
-2
@@ -1,9 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <windows.h>
|
#include "platform/types.h"
|
||||||
|
|
||||||
namespace nebula::app {
|
namespace nebula::app {
|
||||||
|
|
||||||
int RunNebula(HINSTANCE instance, int show_command);
|
enum class AppMode {
|
||||||
|
Desktop,
|
||||||
|
BigPicture,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LaunchOptions {
|
||||||
|
AppMode mode = AppMode::Desktop;
|
||||||
|
};
|
||||||
|
|
||||||
|
int RunNebula(const nebula::platform::AppStartup& startup, LaunchOptions options = {});
|
||||||
|
|
||||||
} // namespace nebula::app
|
} // namespace nebula::app
|
||||||
|
|||||||
+85
-25
@@ -1,6 +1,7 @@
|
|||||||
#include "cef/browser_client.h"
|
#include "cef/browser_client.h"
|
||||||
|
|
||||||
#include "include/cef_request.h"
|
#include "include/cef_request.h"
|
||||||
|
#include "platform/types.h"
|
||||||
#include "include/wrapper/cef_helpers.h"
|
#include "include/wrapper/cef_helpers.h"
|
||||||
#include "ui/paths.h"
|
#include "ui/paths.h"
|
||||||
|
|
||||||
@@ -25,6 +26,51 @@ bool IsSettingsFrame(CefRefPtr<CefFrame> frame) {
|
|||||||
return nebula::ui::ToInternalUrl(frame->GetURL().ToString()).starts_with("nebula://settings");
|
return nebula::ui::ToInternalUrl(frame->GetURL().ToString()).starts_with("nebula://settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsSetupFrame(CefRefPtr<CefFrame> frame) {
|
||||||
|
if (!frame) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nebula::ui::ToInternalUrl(frame->GetURL().ToString()).starts_with("nebula://setup");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsBigPictureFrame(CefRefPtr<CefFrame> frame) {
|
||||||
|
if (!frame) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string url = nebula::ui::ToInternalUrl(frame->GetURL().ToString());
|
||||||
|
return url.starts_with("nebula://bigpicture") ||
|
||||||
|
url.starts_with("nebula://big-picture");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsBigPictureCommand(const std::string& command) {
|
||||||
|
return command == "navigate" ||
|
||||||
|
command == "new-tab" ||
|
||||||
|
command == "activate-tab" ||
|
||||||
|
command == "close-tab" ||
|
||||||
|
command == "back" ||
|
||||||
|
command == "forward" ||
|
||||||
|
command == "reload" ||
|
||||||
|
command == "stop" ||
|
||||||
|
command == "home" ||
|
||||||
|
command == "settings" ||
|
||||||
|
command == "open-settings" ||
|
||||||
|
command == "big-picture" ||
|
||||||
|
command == "exit-bigpicture" ||
|
||||||
|
command == "gpu-diagnostics" ||
|
||||||
|
command == "zoom-out" ||
|
||||||
|
command == "zoom-in" ||
|
||||||
|
command == "clear-site-history" ||
|
||||||
|
command == "clear-search-history" ||
|
||||||
|
command == "bigpicture-mouse-move" ||
|
||||||
|
command == "bigpicture-click" ||
|
||||||
|
command == "bigpicture-right-click" ||
|
||||||
|
command == "bigpicture-scroll" ||
|
||||||
|
command == "bigpicture-text" ||
|
||||||
|
command == "bigpicture-browse-visible";
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> ToStringVector(const std::vector<CefString>& values) {
|
std::vector<std::string> ToStringVector(const std::vector<CefString>& values) {
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
result.reserve(values.size());
|
result.reserve(values.size());
|
||||||
@@ -44,15 +90,15 @@ bool NebulaBrowserClient::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser
|
|||||||
CefProcessId source_process,
|
CefProcessId source_process,
|
||||||
CefRefPtr<CefProcessMessage> message) {
|
CefRefPtr<CefProcessMessage> message) {
|
||||||
CEF_REQUIRE_UI_THREAD();
|
CEF_REQUIRE_UI_THREAD();
|
||||||
UNREFERENCED_PARAMETER(browser);
|
NEBULA_UNUSED(browser);
|
||||||
UNREFERENCED_PARAMETER(source_process);
|
NEBULA_UNUSED(source_process);
|
||||||
|
|
||||||
if (!message || message->GetName().ToString() != kChromeCommandMessage) {
|
if (!message || message->GetName().ToString() != kChromeCommandMessage) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role_ != BrowserRole::Chrome && role_ != BrowserRole::MenuPopup &&
|
if (role_ != BrowserRole::Chrome && role_ != BrowserRole::Content &&
|
||||||
role_ != BrowserRole::Content) {
|
role_ != BrowserRole::BigPicture && role_ != BrowserRole::MenuPopup) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,9 +110,23 @@ bool NebulaBrowserClient::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser
|
|||||||
command == "navigate-insecure" && IsInsecureInterstitialFrame(frame);
|
command == "navigate-insecure" && IsInsecureInterstitialFrame(frame);
|
||||||
const bool allowed_settings_command =
|
const bool allowed_settings_command =
|
||||||
IsSettingsFrame(frame) && (command == "navigate" ||
|
IsSettingsFrame(frame) && (command == "navigate" ||
|
||||||
|
command == "new-tab" ||
|
||||||
|
command == "check-default-browser" ||
|
||||||
|
command == "set-default-browser" ||
|
||||||
command == "clear-site-history" ||
|
command == "clear-site-history" ||
|
||||||
command == "clear-search-history");
|
command == "clear-search-history");
|
||||||
if (!allowed_insecure_command && !allowed_settings_command) {
|
const bool allowed_setup_command =
|
||||||
|
IsSetupFrame(frame) && (command == "complete-first-run" ||
|
||||||
|
command == "check-default-browser" ||
|
||||||
|
command == "set-default-browser");
|
||||||
|
const bool allowed_big_picture_command =
|
||||||
|
IsBigPictureFrame(frame) && command == "exit-bigpicture";
|
||||||
|
if (!allowed_insecure_command && !allowed_settings_command &&
|
||||||
|
!allowed_setup_command && !allowed_big_picture_command) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (role_ == BrowserRole::BigPicture) {
|
||||||
|
if (!IsBigPictureFrame(frame) || !IsBigPictureCommand(command)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +176,7 @@ bool NebulaBrowserClient::OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
|
|||||||
CefEventHandle os_event,
|
CefEventHandle os_event,
|
||||||
bool* is_keyboard_shortcut) {
|
bool* is_keyboard_shortcut) {
|
||||||
CEF_REQUIRE_UI_THREAD();
|
CEF_REQUIRE_UI_THREAD();
|
||||||
UNREFERENCED_PARAMETER(os_event);
|
NEBULA_UNUSED(os_event);
|
||||||
|
|
||||||
if (role_ == BrowserRole::Content &&
|
if (role_ == BrowserRole::Content &&
|
||||||
event.type == KEYEVENT_RAWKEYDOWN &&
|
event.type == KEYEVENT_RAWKEYDOWN &&
|
||||||
@@ -148,17 +208,17 @@ bool NebulaBrowserClient::OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
|||||||
CefRefPtr<CefDictionaryValue>& extra_info,
|
CefRefPtr<CefDictionaryValue>& extra_info,
|
||||||
bool* no_javascript_access) {
|
bool* no_javascript_access) {
|
||||||
CEF_REQUIRE_UI_THREAD();
|
CEF_REQUIRE_UI_THREAD();
|
||||||
UNREFERENCED_PARAMETER(frame);
|
NEBULA_UNUSED(frame);
|
||||||
UNREFERENCED_PARAMETER(popup_id);
|
NEBULA_UNUSED(popup_id);
|
||||||
UNREFERENCED_PARAMETER(target_frame_name);
|
NEBULA_UNUSED(target_frame_name);
|
||||||
UNREFERENCED_PARAMETER(target_disposition);
|
NEBULA_UNUSED(target_disposition);
|
||||||
UNREFERENCED_PARAMETER(user_gesture);
|
NEBULA_UNUSED(user_gesture);
|
||||||
UNREFERENCED_PARAMETER(popupFeatures);
|
NEBULA_UNUSED(popupFeatures);
|
||||||
UNREFERENCED_PARAMETER(windowInfo);
|
NEBULA_UNUSED(windowInfo);
|
||||||
UNREFERENCED_PARAMETER(client);
|
NEBULA_UNUSED(client);
|
||||||
UNREFERENCED_PARAMETER(settings);
|
NEBULA_UNUSED(settings);
|
||||||
UNREFERENCED_PARAMETER(extra_info);
|
NEBULA_UNUSED(extra_info);
|
||||||
UNREFERENCED_PARAMETER(no_javascript_access);
|
NEBULA_UNUSED(no_javascript_access);
|
||||||
|
|
||||||
if (role_ == BrowserRole::Content && delegate_) {
|
if (role_ == BrowserRole::Content && delegate_) {
|
||||||
delegate_->OnPopupRequested(browser, target_url.ToString());
|
delegate_->OnPopupRequested(browser, target_url.ToString());
|
||||||
@@ -187,8 +247,8 @@ void NebulaBrowserClient::OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
|
|||||||
bool canGoBack,
|
bool canGoBack,
|
||||||
bool canGoForward) {
|
bool canGoForward) {
|
||||||
CEF_REQUIRE_UI_THREAD();
|
CEF_REQUIRE_UI_THREAD();
|
||||||
UNREFERENCED_PARAMETER(canGoBack);
|
NEBULA_UNUSED(canGoBack);
|
||||||
UNREFERENCED_PARAMETER(canGoForward);
|
NEBULA_UNUSED(canGoForward);
|
||||||
|
|
||||||
if (role_ == BrowserRole::Content && delegate_) {
|
if (role_ == BrowserRole::Content && delegate_) {
|
||||||
delegate_->OnContentLoadingStateChanged(browser, isLoading);
|
delegate_->OnContentLoadingStateChanged(browser, isLoading);
|
||||||
@@ -199,7 +259,7 @@ void NebulaBrowserClient::OnLoadStart(CefRefPtr<CefBrowser> browser,
|
|||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
TransitionType transition_type) {
|
TransitionType transition_type) {
|
||||||
CEF_REQUIRE_UI_THREAD();
|
CEF_REQUIRE_UI_THREAD();
|
||||||
UNREFERENCED_PARAMETER(transition_type);
|
NEBULA_UNUSED(transition_type);
|
||||||
|
|
||||||
if (role_ == BrowserRole::Content && delegate_ && frame && frame->IsMain()) {
|
if (role_ == BrowserRole::Content && delegate_ && frame && frame->IsMain()) {
|
||||||
delegate_->OnContentLoadProgressChanged(browser, 0.12);
|
delegate_->OnContentLoadProgressChanged(browser, 0.12);
|
||||||
@@ -229,9 +289,9 @@ bool NebulaBrowserClient::OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
|
|||||||
bool user_gesture,
|
bool user_gesture,
|
||||||
bool is_redirect) {
|
bool is_redirect) {
|
||||||
CEF_REQUIRE_UI_THREAD();
|
CEF_REQUIRE_UI_THREAD();
|
||||||
UNREFERENCED_PARAMETER(browser);
|
NEBULA_UNUSED(browser);
|
||||||
UNREFERENCED_PARAMETER(user_gesture);
|
NEBULA_UNUSED(user_gesture);
|
||||||
UNREFERENCED_PARAMETER(is_redirect);
|
NEBULA_UNUSED(is_redirect);
|
||||||
|
|
||||||
if (role_ == BrowserRole::Content && frame && frame->IsMain() && request) {
|
if (role_ == BrowserRole::Content && frame && frame->IsMain() && request) {
|
||||||
const std::string url = request->GetURL().ToString();
|
const std::string url = request->GetURL().ToString();
|
||||||
@@ -263,8 +323,8 @@ bool NebulaBrowserClient::OnShowPermissionPrompt(
|
|||||||
uint32_t requested_permissions,
|
uint32_t requested_permissions,
|
||||||
CefRefPtr<CefPermissionPromptCallback> callback) {
|
CefRefPtr<CefPermissionPromptCallback> callback) {
|
||||||
CEF_REQUIRE_UI_THREAD();
|
CEF_REQUIRE_UI_THREAD();
|
||||||
UNREFERENCED_PARAMETER(prompt_id);
|
NEBULA_UNUSED(prompt_id);
|
||||||
UNREFERENCED_PARAMETER(requesting_origin);
|
NEBULA_UNUSED(requesting_origin);
|
||||||
|
|
||||||
if (role_ == BrowserRole::Content &&
|
if (role_ == BrowserRole::Content &&
|
||||||
(requested_permissions & CEF_PERMISSION_TYPE_GEOLOCATION) != 0 &&
|
(requested_permissions & CEF_PERMISSION_TYPE_GEOLOCATION) != 0 &&
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace nebula::cef {
|
|||||||
enum class BrowserRole {
|
enum class BrowserRole {
|
||||||
Chrome,
|
Chrome,
|
||||||
Content,
|
Content,
|
||||||
|
BigPicture,
|
||||||
MenuPopup,
|
MenuPopup,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+13
-5
@@ -1,6 +1,7 @@
|
|||||||
#include "cef/nebula_app.h"
|
#include "cef/nebula_app.h"
|
||||||
|
|
||||||
#include "include/cef_process_message.h"
|
#include "include/cef_process_message.h"
|
||||||
|
#include "platform/types.h"
|
||||||
#include "include/wrapper/cef_helpers.h"
|
#include "include/wrapper/cef_helpers.h"
|
||||||
|
|
||||||
namespace nebula::cef {
|
namespace nebula::cef {
|
||||||
@@ -15,8 +16,8 @@ public:
|
|||||||
const CefV8ValueList& arguments,
|
const CefV8ValueList& arguments,
|
||||||
CefRefPtr<CefV8Value>& retval,
|
CefRefPtr<CefV8Value>& retval,
|
||||||
CefString& exception) override {
|
CefString& exception) override {
|
||||||
UNREFERENCED_PARAMETER(object);
|
NEBULA_UNUSED(object);
|
||||||
UNREFERENCED_PARAMETER(retval);
|
NEBULA_UNUSED(retval);
|
||||||
|
|
||||||
if (name != "postMessage" && name != "sendToHost" && name != "send") {
|
if (name != "postMessage" && name != "sendToHost" && name != "send") {
|
||||||
return false;
|
return false;
|
||||||
@@ -54,7 +55,7 @@ private:
|
|||||||
|
|
||||||
void NebulaApp::OnBeforeCommandLineProcessing(const CefString& process_type,
|
void NebulaApp::OnBeforeCommandLineProcessing(const CefString& process_type,
|
||||||
CefRefPtr<CefCommandLine> command_line) {
|
CefRefPtr<CefCommandLine> command_line) {
|
||||||
UNREFERENCED_PARAMETER(process_type);
|
NEBULA_UNUSED(process_type);
|
||||||
|
|
||||||
// The bundled UI is loaded from file:// and uses ES modules.
|
// The bundled UI is loaded from file:// and uses ES modules.
|
||||||
command_line->AppendSwitch("allow-file-access-from-files");
|
command_line->AppendSwitch("allow-file-access-from-files");
|
||||||
@@ -76,16 +77,23 @@ void NebulaApp::OnBeforeCommandLineProcessing(const CefString& process_type,
|
|||||||
// can prevent WebGL shared contexts from initializing on some drivers.
|
// can prevent WebGL shared contexts from initializing on some drivers.
|
||||||
command_line->AppendSwitch("ignore-gpu-blocklist");
|
command_line->AppendSwitch("ignore-gpu-blocklist");
|
||||||
command_line->AppendSwitch("enable-accelerated-video-decode");
|
command_line->AppendSwitch("enable-accelerated-video-decode");
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
command_line->AppendSwitchWithValue("use-gl", "angle");
|
command_line->AppendSwitchWithValue("use-gl", "angle");
|
||||||
command_line->AppendSwitchWithValue("use-angle", "d3d11");
|
command_line->AppendSwitchWithValue("use-angle", "d3d11");
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
command_line->AppendSwitchWithValue("use-angle", "metal");
|
||||||
|
#else
|
||||||
|
command_line->AppendSwitchWithValue("use-gl", "egl");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void NebulaApp::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
void NebulaApp::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
CefRefPtr<CefV8Context> context) {
|
CefRefPtr<CefV8Context> context) {
|
||||||
CEF_REQUIRE_RENDERER_THREAD();
|
CEF_REQUIRE_RENDERER_THREAD();
|
||||||
UNREFERENCED_PARAMETER(browser);
|
NEBULA_UNUSED(browser);
|
||||||
UNREFERENCED_PARAMETER(frame);
|
NEBULA_UNUSED(frame);
|
||||||
|
|
||||||
CefRefPtr<CefV8Value> global = context->GetGlobal();
|
CefRefPtr<CefV8Value> global = context->GetGlobal();
|
||||||
CefRefPtr<NativeBridgeHandler> handler = new NativeBridgeHandler();
|
CefRefPtr<NativeBridgeHandler> handler = new NativeBridgeHandler();
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "include/cef_browser.h"
|
||||||
|
#include "platform/types.h"
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
|
||||||
|
CefWindowInfo MakeChildWindowInfo(NativeWindow parent, const Rect& rect);
|
||||||
|
CefWindowInfo MakeDevToolsPopup(NativeWindow parent, const char* title);
|
||||||
|
void ResizeBrowserWindow(NativeWindow browser_window, const Rect& rect);
|
||||||
|
void SetBrowserVisible(NativeWindow browser_window, bool visible);
|
||||||
|
void RaiseBrowserWindow(NativeWindow browser_window);
|
||||||
|
void MoveCursorToBrowserPoint(NativeWindow browser_window, int x, int y);
|
||||||
|
Rect MenuPopupRect(NativeWindow parent, const BrowserLayout& layout);
|
||||||
|
std::string CacheBusterToken();
|
||||||
|
void DestroyTopLevelWindow(NativeWindow window);
|
||||||
|
int ScaleForParentWindow(NativeWindow parent, int value);
|
||||||
|
std::pair<int, int> ParentClientSize(NativeWindow parent);
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
|
||||||
|
bool IsDefaultBrowser();
|
||||||
|
bool EnsureDefaultBrowserRegistration();
|
||||||
|
bool RequestDefaultBrowser();
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
#include "platform/browser_host.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
|
||||||
|
CefWindowInfo MakeChildWindowInfo(NativeWindow parent, const Rect& rect) {
|
||||||
|
CefWindowInfo info;
|
||||||
|
info.SetAsChild(
|
||||||
|
reinterpret_cast<CefWindowHandle>(parent),
|
||||||
|
CefRect(rect.x, rect.y, rect.width, rect.height));
|
||||||
|
info.runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefWindowInfo MakeDevToolsPopup(NativeWindow parent, const char* title) {
|
||||||
|
CefWindowInfo info;
|
||||||
|
info.SetAsPopup(reinterpret_cast<CefWindowHandle>(parent), title);
|
||||||
|
info.runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResizeBrowserWindow(NativeWindow browser_window, const Rect& rect) {
|
||||||
|
NEBULA_UNUSED(browser_window);
|
||||||
|
NEBULA_UNUSED(rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetBrowserVisible(NativeWindow browser_window, bool visible) {
|
||||||
|
NEBULA_UNUSED(browser_window);
|
||||||
|
NEBULA_UNUSED(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RaiseBrowserWindow(NativeWindow browser_window) {
|
||||||
|
NEBULA_UNUSED(browser_window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MoveCursorToBrowserPoint(NativeWindow browser_window, int x, int y) {
|
||||||
|
NEBULA_UNUSED(browser_window);
|
||||||
|
NEBULA_UNUSED(x);
|
||||||
|
NEBULA_UNUSED(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ScaleForParentWindow(NativeWindow parent, int value) {
|
||||||
|
NEBULA_UNUSED(parent);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<int, int> ParentClientSize(NativeWindow parent) {
|
||||||
|
NEBULA_UNUSED(parent);
|
||||||
|
return {1280, 720};
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect MenuPopupRect(NativeWindow parent, const BrowserLayout& layout) {
|
||||||
|
const auto client_size = ParentClientSize(parent);
|
||||||
|
const int width = 260;
|
||||||
|
const int height = 258;
|
||||||
|
const int margin = 12;
|
||||||
|
const int overlap = 2;
|
||||||
|
const int x = std::max(0, client_size.first - width - margin);
|
||||||
|
const int y = std::max(0, layout.chrome.y + layout.chrome.height - overlap);
|
||||||
|
return {
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
std::min(client_size.first, x + width) - x,
|
||||||
|
std::min(client_size.second, y + height) - y,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CacheBusterToken() {
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
void DestroyTopLevelWindow(NativeWindow window) {
|
||||||
|
NEBULA_UNUSED(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#include "platform/default_browser.h"
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
|
||||||
|
bool IsDefaultBrowser() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EnsureDefaultBrowserRegistration() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RequestDefaultBrowser() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#include "window/nebula_window.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace nebula::window {
|
||||||
|
|
||||||
|
struct nebula::window::NebulaWindowImpl {
|
||||||
|
WindowDelegate* delegate = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
NebulaWindow::NebulaWindow(WindowDelegate* delegate)
|
||||||
|
: impl_(std::make_unique<NebulaWindowImpl>()) {
|
||||||
|
impl_->delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
NebulaWindow::~NebulaWindow() = default;
|
||||||
|
|
||||||
|
bool NebulaWindow::Create(const platform::AppStartup& startup) {
|
||||||
|
NEBULA_UNUSED(startup);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
platform::NativeWindow NebulaWindow::native_handle() const {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
BrowserLayout NebulaWindow::CurrentLayout(bool show_chrome) const {
|
||||||
|
NEBULA_UNUSED(show_chrome);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::ResizeChild(platform::NativeWindow child, const platform::Rect& rect) const {
|
||||||
|
NEBULA_UNUSED(child);
|
||||||
|
NEBULA_UNUSED(rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::Minimize() {}
|
||||||
|
void NebulaWindow::ToggleMaximize() {}
|
||||||
|
void NebulaWindow::SetFullscreen(bool fullscreen) { NEBULA_UNUSED(fullscreen); }
|
||||||
|
void NebulaWindow::Close() {}
|
||||||
|
void NebulaWindow::BeginDrag() {}
|
||||||
|
void NebulaWindow::SetTitle(const std::string& title) { NEBULA_UNUSED(title); }
|
||||||
|
void NebulaWindow::EnableFrameHitTest(platform::NativeWindow child) const { NEBULA_UNUSED(child); }
|
||||||
|
|
||||||
|
} // namespace nebula::window
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#include "platform/paths_platform.h"
|
||||||
|
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
|
||||||
|
std::filesystem::path ExecutableDirectory() {
|
||||||
|
char buffer[4096] = {};
|
||||||
|
const ssize_t length = readlink("/proc/self/exe", buffer, sizeof(buffer) - 1);
|
||||||
|
if (length <= 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[length] = '\0';
|
||||||
|
return std::filesystem::path(buffer).parent_path();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::path DefaultUserDataRoot() {
|
||||||
|
if (const char* xdg_data = std::getenv("XDG_DATA_HOME"); xdg_data && *xdg_data) {
|
||||||
|
return std::filesystem::path(xdg_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const char* home = std::getenv("HOME")) {
|
||||||
|
return std::filesystem::path(home) / ".local" / "share";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (passwd* pw = getpwuid(getuid())) {
|
||||||
|
return std::filesystem::path(pw->pw_dir) / ".local" / "share";
|
||||||
|
}
|
||||||
|
|
||||||
|
return ExecutableDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string PathToUtf8(const std::filesystem::path& path) {
|
||||||
|
return path.string();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#include "platform/startup.h"
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <system_error>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "include/cef_command_line.h"
|
||||||
|
#include "ui/paths.h"
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
int g_single_instance_lock = -1;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void PrepareApp() {}
|
||||||
|
|
||||||
|
bool TryAcquireSingleInstance(const std::string& launch_target) {
|
||||||
|
NEBULA_UNUSED(launch_target);
|
||||||
|
|
||||||
|
const auto lock_path = nebula::ui::GetUserDataDirectory() / ".nebula_instance.lock";
|
||||||
|
std::error_code ec;
|
||||||
|
std::filesystem::create_directories(lock_path.parent_path(), ec);
|
||||||
|
|
||||||
|
g_single_instance_lock = open(lock_path.c_str(), O_CREAT | O_RDWR, 0644);
|
||||||
|
if (g_single_instance_lock < 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return flock(g_single_instance_lock, LOCK_EX | LOCK_NB) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefMainArgs MakeMainArgs(const AppStartup& startup) {
|
||||||
|
return CefMainArgs(startup.argc, startup.argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitCommandLine(CefRefPtr<CefCommandLine> command_line, const AppStartup& startup) {
|
||||||
|
command_line->InitFromArgv(startup.argc, startup.argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigureCefSettings(CefSettings& settings) {
|
||||||
|
const std::string user_data_dir = nebula::ui::GetUserDataDirectory().string();
|
||||||
|
const std::string cache_dir = nebula::ui::GetCacheDirectory().string();
|
||||||
|
if (!user_data_dir.empty()) {
|
||||||
|
CefString(&settings.root_cache_path).FromString(user_data_dir);
|
||||||
|
}
|
||||||
|
if (!cache_dir.empty()) {
|
||||||
|
CefString(&settings.cache_path).FromString(cache_dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
#include "platform/browser_host.h"
|
||||||
|
|
||||||
|
#import <ApplicationServices/ApplicationServices.h>
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
NSView* AsView(NativeWindow window) {
|
||||||
|
return (__bridge NSView*)window;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSRect ToNativeRect(const Rect& rect) {
|
||||||
|
return NSMakeRect(rect.x, rect.y, std::max(0, rect.width), std::max(0, rect.height));
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect ToPlatformRect(NSRect rect) {
|
||||||
|
return {
|
||||||
|
static_cast<int>(std::round(NSMinX(rect))),
|
||||||
|
static_cast<int>(std::round(NSMinY(rect))),
|
||||||
|
std::max(0, static_cast<int>(std::round(NSWidth(rect)))),
|
||||||
|
std::max(0, static_cast<int>(std::round(NSHeight(rect)))),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
CefWindowInfo MakeChildWindowInfo(NativeWindow parent, const Rect& rect) {
|
||||||
|
CefWindowInfo info;
|
||||||
|
info.SetAsChild((__bridge CefWindowHandle)AsView(parent),
|
||||||
|
CefRect(rect.x, rect.y, rect.width, rect.height));
|
||||||
|
info.runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefWindowInfo MakeDevToolsPopup(NativeWindow parent, const char* title) {
|
||||||
|
(void)title;
|
||||||
|
CefWindowInfo info;
|
||||||
|
info.SetAsChild((__bridge CefWindowHandle)AsView(parent), CefRect(0, 0, 800, 600));
|
||||||
|
info.runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResizeBrowserWindow(NativeWindow browser_window, const Rect& rect) {
|
||||||
|
NSView* view = AsView(browser_window);
|
||||||
|
if (!view) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[view setFrame:ToNativeRect(rect)];
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetBrowserVisible(NativeWindow browser_window, bool visible) {
|
||||||
|
NSView* view = AsView(browser_window);
|
||||||
|
if (!view) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[view setHidden:!visible];
|
||||||
|
if (visible && [view superview]) {
|
||||||
|
[[view superview] addSubview:view positioned:NSWindowAbove relativeTo:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RaiseBrowserWindow(NativeWindow browser_window) {
|
||||||
|
NSView* view = AsView(browser_window);
|
||||||
|
if (view && [view superview]) {
|
||||||
|
[[view superview] addSubview:view positioned:NSWindowAbove relativeTo:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MoveCursorToBrowserPoint(NativeWindow browser_window, int x, int y) {
|
||||||
|
NSView* view = AsView(browser_window);
|
||||||
|
if (!view || ![view window]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NSPoint window_point = [view convertPoint:NSMakePoint(x, y) toView:nil];
|
||||||
|
const NSPoint screen_point = [[view window] convertPointToScreen:window_point];
|
||||||
|
const CGFloat screen_height = NSMaxY([[NSScreen mainScreen] frame]);
|
||||||
|
CGWarpMouseCursorPosition(CGPointMake(screen_point.x, screen_height - screen_point.y));
|
||||||
|
}
|
||||||
|
|
||||||
|
int ScaleForParentWindow(NativeWindow parent, int value) {
|
||||||
|
(void)parent;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<int, int> ParentClientSize(NativeWindow parent) {
|
||||||
|
NSView* view = AsView(parent);
|
||||||
|
if (!view) {
|
||||||
|
return {0, 0};
|
||||||
|
}
|
||||||
|
|
||||||
|
const Rect rect = ToPlatformRect([view bounds]);
|
||||||
|
return {rect.width, rect.height};
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect MenuPopupRect(NativeWindow parent, const BrowserLayout& layout) {
|
||||||
|
const auto client_size = ParentClientSize(parent);
|
||||||
|
const int width = 260;
|
||||||
|
const int height = 258;
|
||||||
|
const int margin = 12;
|
||||||
|
const int overlap = 2;
|
||||||
|
const int x = std::max(0, client_size.first - width - margin);
|
||||||
|
const int y = std::max(0, layout.chrome.y + layout.chrome.height - overlap);
|
||||||
|
return {
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
std::min(client_size.first, x + width) - x,
|
||||||
|
std::min(client_size.second, y + height) - y,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CacheBusterToken() {
|
||||||
|
const auto now = std::chrono::system_clock::now().time_since_epoch();
|
||||||
|
const auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(now).count();
|
||||||
|
return std::to_string(millis);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DestroyTopLevelWindow(NativeWindow window) {
|
||||||
|
NSView* view = AsView(window);
|
||||||
|
NSWindow* native_window = [view window];
|
||||||
|
if (native_window) {
|
||||||
|
[native_window setDelegate:nil];
|
||||||
|
[native_window close];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#include "platform/default_browser.h"
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
|
||||||
|
bool IsDefaultBrowser() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EnsureDefaultBrowserRegistration() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RequestDefaultBrowser() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
#include "window/nebula_window.h"
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace nebula::window {
|
||||||
|
struct NebulaWindowImpl;
|
||||||
|
} // namespace nebula::window
|
||||||
|
|
||||||
|
@interface NebulaContentView : NSView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NebulaContentView
|
||||||
|
- (BOOL)isFlipped {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NebulaWindowDelegate : NSObject <NSWindowDelegate> {
|
||||||
|
@private
|
||||||
|
nebula::window::NebulaWindowImpl* owner_;
|
||||||
|
}
|
||||||
|
- (instancetype)initWithOwner:(nebula::window::NebulaWindowImpl*)owner;
|
||||||
|
@end
|
||||||
|
|
||||||
|
namespace nebula::window {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr CGFloat kChromeHeight = 104.0;
|
||||||
|
|
||||||
|
NSRect ToNativeRect(const platform::Rect& rect) {
|
||||||
|
return NSMakeRect(rect.x, rect.y, std::max(0, rect.width), std::max(0, rect.height));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
struct NebulaWindowImpl {
|
||||||
|
WindowDelegate* delegate = nullptr;
|
||||||
|
NSWindow* window = nil;
|
||||||
|
NebulaContentView* content_view = nil;
|
||||||
|
NebulaWindowDelegate* window_delegate = nil;
|
||||||
|
bool fullscreen = false;
|
||||||
|
|
||||||
|
BrowserLayout CurrentLayout(bool show_chrome) const {
|
||||||
|
const NSRect bounds = content_view ? [content_view bounds] : NSZeroRect;
|
||||||
|
const int width = std::max(0, static_cast<int>(std::round(NSWidth(bounds))));
|
||||||
|
const int height = std::max(0, static_cast<int>(std::round(NSHeight(bounds))));
|
||||||
|
const int chrome_height = show_chrome ? std::min(height, static_cast<int>(kChromeHeight)) : 0;
|
||||||
|
|
||||||
|
BrowserLayout layout;
|
||||||
|
layout.chrome = show_chrome ? platform::Rect{0, 0, width, chrome_height} : platform::Rect{};
|
||||||
|
layout.content = {0, chrome_height, width, std::max(0, height - chrome_height)};
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyCreated() const {
|
||||||
|
if (delegate) {
|
||||||
|
delegate->OnWindowCreated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyResized() const {
|
||||||
|
if (delegate) {
|
||||||
|
delegate->OnWindowResized(CurrentLayout(true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyCloseRequested() const {
|
||||||
|
if (delegate) {
|
||||||
|
delegate->OnWindowCloseRequested();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace nebula::window
|
||||||
|
|
||||||
|
@implementation NebulaWindowDelegate
|
||||||
|
- (instancetype)initWithOwner:(nebula::window::NebulaWindowImpl*)owner {
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
owner_ = owner;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)windowDidResize:(NSNotification*)notification {
|
||||||
|
(void)notification;
|
||||||
|
if (owner_) {
|
||||||
|
owner_->NotifyResized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)windowShouldClose:(id)sender {
|
||||||
|
(void)sender;
|
||||||
|
if (owner_) {
|
||||||
|
owner_->NotifyCloseRequested();
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
namespace nebula::window {
|
||||||
|
|
||||||
|
NebulaWindow::NebulaWindow(WindowDelegate* delegate)
|
||||||
|
: impl_(std::make_unique<NebulaWindowImpl>()) {
|
||||||
|
impl_->delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
NebulaWindow::~NebulaWindow() = default;
|
||||||
|
|
||||||
|
bool NebulaWindow::Create(const platform::AppStartup& startup) {
|
||||||
|
(void)startup;
|
||||||
|
|
||||||
|
@autoreleasepool {
|
||||||
|
[NSApplication sharedApplication];
|
||||||
|
|
||||||
|
const NSRect visible_frame = [[NSScreen mainScreen] visibleFrame];
|
||||||
|
const CGFloat width = std::min<CGFloat>(1400.0, NSWidth(visible_frame));
|
||||||
|
const CGFloat height = std::min<CGFloat>(900.0, NSHeight(visible_frame));
|
||||||
|
const CGFloat x = NSMinX(visible_frame) + (NSWidth(visible_frame) - width) / 2.0;
|
||||||
|
const CGFloat y = NSMinY(visible_frame) + (NSHeight(visible_frame) - height) / 2.0;
|
||||||
|
|
||||||
|
impl_->content_view = [[NebulaContentView alloc] initWithFrame:NSMakeRect(0, 0, width, height)];
|
||||||
|
impl_->window_delegate = [[NebulaWindowDelegate alloc] initWithOwner:impl_.get()];
|
||||||
|
impl_->window = [[NSWindow alloc] initWithContentRect:NSMakeRect(x, y, width, height)
|
||||||
|
styleMask:NSWindowStyleMaskTitled |
|
||||||
|
NSWindowStyleMaskClosable |
|
||||||
|
NSWindowStyleMaskMiniaturizable |
|
||||||
|
NSWindowStyleMaskResizable |
|
||||||
|
NSWindowStyleMaskFullSizeContentView
|
||||||
|
backing:NSBackingStoreBuffered
|
||||||
|
defer:NO];
|
||||||
|
if (!impl_->window) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
[impl_->window setTitle:@"Nebula Browser"];
|
||||||
|
[impl_->window setTitleVisibility:NSWindowTitleHidden];
|
||||||
|
[impl_->window setTitlebarAppearsTransparent:YES];
|
||||||
|
[impl_->window setContentView:impl_->content_view];
|
||||||
|
[impl_->window setDelegate:impl_->window_delegate];
|
||||||
|
[impl_->window center];
|
||||||
|
[impl_->window makeKeyAndOrderFront:nil];
|
||||||
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
|
|
||||||
|
impl_->NotifyCreated();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
platform::NativeWindow NebulaWindow::native_handle() const {
|
||||||
|
return (__bridge void*)impl_->content_view;
|
||||||
|
}
|
||||||
|
|
||||||
|
BrowserLayout NebulaWindow::CurrentLayout(bool show_chrome) const {
|
||||||
|
return impl_->CurrentLayout(show_chrome);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::ResizeChild(platform::NativeWindow child, const platform::Rect& rect) const {
|
||||||
|
NSView* view = (__bridge NSView*)child;
|
||||||
|
if (!view) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[view setFrame:ToNativeRect(rect)];
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::Minimize() {
|
||||||
|
[impl_->window miniaturize:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::ToggleMaximize() {
|
||||||
|
if (impl_->window && !impl_->fullscreen) {
|
||||||
|
[impl_->window zoom:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::SetFullscreen(bool fullscreen) {
|
||||||
|
if (!impl_->window || impl_->fullscreen == fullscreen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_->fullscreen = fullscreen;
|
||||||
|
[impl_->window toggleFullScreen:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::Close() {
|
||||||
|
if (impl_->delegate) {
|
||||||
|
impl_->delegate->OnWindowCloseRequested();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::BeginDrag() {
|
||||||
|
if (!impl_->window) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSEvent* event = [NSApp currentEvent];
|
||||||
|
if (event) {
|
||||||
|
[impl_->window performWindowDragWithEvent:event];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::SetTitle(const std::string& title) {
|
||||||
|
if (!impl_->window) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString* native_title = title.empty()
|
||||||
|
? @"Nebula Browser"
|
||||||
|
: [[NSString alloc] initWithUTF8String:title.c_str()];
|
||||||
|
[impl_->window setTitle:native_title ?: @"Nebula Browser"];
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::EnableFrameHitTest(platform::NativeWindow child) const {
|
||||||
|
(void)child;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::window
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#include "platform/paths_platform.h"
|
||||||
|
|
||||||
|
#include <mach-o/dyld.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
|
||||||
|
std::filesystem::path ExecutableDirectory() {
|
||||||
|
char buffer[4096] = {};
|
||||||
|
uint32_t size = sizeof(buffer);
|
||||||
|
if (_NSGetExecutablePath(buffer, &size) != 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::filesystem::path(buffer).parent_path();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::path DefaultUserDataRoot() {
|
||||||
|
if (const char* home = std::getenv("HOME")) {
|
||||||
|
return std::filesystem::path(home) / "Library" / "Application Support";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (passwd* pw = getpwuid(getuid())) {
|
||||||
|
return std::filesystem::path(pw->pw_dir) / "Library" / "Application Support";
|
||||||
|
}
|
||||||
|
|
||||||
|
return ExecutableDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string PathToUtf8(const std::filesystem::path& path) {
|
||||||
|
return path.string();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
#include "platform/startup.h"
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <system_error>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "include/cef_command_line.h"
|
||||||
|
#include "ui/paths.h"
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
int g_single_instance_lock = -1;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void PrepareApp() {
|
||||||
|
@autoreleasepool {
|
||||||
|
[NSApplication sharedApplication];
|
||||||
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
|
[NSApp finishLaunching];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TryAcquireSingleInstance(const std::string& launch_target) {
|
||||||
|
NEBULA_UNUSED(launch_target);
|
||||||
|
|
||||||
|
const auto lock_path = nebula::ui::GetUserDataDirectory() / ".nebula_instance.lock";
|
||||||
|
std::error_code ec;
|
||||||
|
std::filesystem::create_directories(lock_path.parent_path(), ec);
|
||||||
|
|
||||||
|
g_single_instance_lock = open(lock_path.c_str(), O_CREAT | O_RDWR, 0644);
|
||||||
|
if (g_single_instance_lock < 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return flock(g_single_instance_lock, LOCK_EX | LOCK_NB) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefMainArgs MakeMainArgs(const AppStartup& startup) {
|
||||||
|
return CefMainArgs(startup.argc, startup.argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitCommandLine(CefRefPtr<CefCommandLine> command_line, const AppStartup& startup) {
|
||||||
|
command_line->InitFromArgv(startup.argc, startup.argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigureCefSettings(CefSettings& settings) {
|
||||||
|
const std::string user_data_dir = nebula::ui::GetUserDataDirectory().string();
|
||||||
|
const std::string cache_dir = nebula::ui::GetCacheDirectory().string();
|
||||||
|
if (!user_data_dir.empty()) {
|
||||||
|
CefString(&settings.root_cache_path).FromString(user_data_dir);
|
||||||
|
}
|
||||||
|
if (!cache_dir.empty()) {
|
||||||
|
CefString(&settings.cache_path).FromString(cache_dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
|
||||||
|
std::filesystem::path ExecutableDirectory();
|
||||||
|
std::filesystem::path DefaultUserDataRoot();
|
||||||
|
std::string PathToUtf8(const std::filesystem::path& path);
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "include/cef_app.h"
|
||||||
|
#include "platform/types.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
|
||||||
|
void PrepareApp();
|
||||||
|
bool TryAcquireSingleInstance(const std::string& launch_target = {});
|
||||||
|
CefMainArgs MakeMainArgs(const AppStartup& startup);
|
||||||
|
void InitCommandLine(CefRefPtr<CefCommandLine> command_line, const AppStartup& startup);
|
||||||
|
void ConfigureCefSettings(CefSettings& settings);
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NEBULA_UNUSED
|
||||||
|
#define NEBULA_UNUSED(P) (void)(P)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
|
||||||
|
struct Rect {
|
||||||
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
int width = 0;
|
||||||
|
int height = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BrowserLayout {
|
||||||
|
Rect chrome;
|
||||||
|
Rect content;
|
||||||
|
};
|
||||||
|
|
||||||
|
using NativeWindow = void*;
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
struct AppStartup {
|
||||||
|
void* instance = nullptr;
|
||||||
|
int show_command = 0;
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
struct AppStartup {
|
||||||
|
int argc = 0;
|
||||||
|
char** argv = nullptr;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
#include "platform/browser_host.h"
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
HWND AsHwnd(NativeWindow window) {
|
||||||
|
return static_cast<HWND>(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
RECT ToRect(const Rect& rect) {
|
||||||
|
return {
|
||||||
|
rect.x,
|
||||||
|
rect.y,
|
||||||
|
rect.x + rect.width,
|
||||||
|
rect.y + rect.height,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
CefWindowInfo MakeChildWindowInfo(NativeWindow parent, const Rect& rect) {
|
||||||
|
CefWindowInfo info;
|
||||||
|
info.SetAsChild(
|
||||||
|
AsHwnd(parent),
|
||||||
|
CefRect(rect.x, rect.y, rect.width, rect.height));
|
||||||
|
info.runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefWindowInfo MakeDevToolsPopup(NativeWindow parent, const char* title) {
|
||||||
|
CefWindowInfo info;
|
||||||
|
info.SetAsPopup(AsHwnd(parent), title);
|
||||||
|
info.runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResizeBrowserWindow(NativeWindow browser_window, const Rect& rect) {
|
||||||
|
const HWND hwnd = AsHwnd(browser_window);
|
||||||
|
if (!hwnd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetWindowPos(
|
||||||
|
hwnd,
|
||||||
|
nullptr,
|
||||||
|
rect.x,
|
||||||
|
rect.y,
|
||||||
|
std::max(0, rect.width),
|
||||||
|
std::max(0, rect.height),
|
||||||
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetBrowserVisible(NativeWindow browser_window, bool visible) {
|
||||||
|
const HWND hwnd = AsHwnd(browser_window);
|
||||||
|
if (!hwnd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowWindow(hwnd, visible ? SW_SHOW : SW_HIDE);
|
||||||
|
if (visible) {
|
||||||
|
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RaiseBrowserWindow(NativeWindow browser_window) {
|
||||||
|
const HWND hwnd = AsHwnd(browser_window);
|
||||||
|
if (!hwnd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MoveCursorToBrowserPoint(NativeWindow browser_window, int x, int y) {
|
||||||
|
const HWND hwnd = AsHwnd(browser_window);
|
||||||
|
if (!hwnd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
POINT point = {x, y};
|
||||||
|
if (!ClientToScreen(hwnd, &point)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetCursorPos(point.x, point.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ScaleForParentWindow(NativeWindow parent, int value) {
|
||||||
|
const HWND hwnd = AsHwnd(parent);
|
||||||
|
if (!hwnd) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MulDiv(value, static_cast<int>(GetDpiForWindow(hwnd)), 96);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<int, int> ParentClientSize(NativeWindow parent) {
|
||||||
|
RECT client = {};
|
||||||
|
const HWND hwnd = AsHwnd(parent);
|
||||||
|
if (hwnd) {
|
||||||
|
GetClientRect(hwnd, &client);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {static_cast<int>(client.right), static_cast<int>(client.bottom)};
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect MenuPopupRect(NativeWindow parent, const BrowserLayout& layout) {
|
||||||
|
const auto client_size = ParentClientSize(parent);
|
||||||
|
const int width = ScaleForParentWindow(parent, 260);
|
||||||
|
const int height = ScaleForParentWindow(parent, 258);
|
||||||
|
const int margin = ScaleForParentWindow(parent, 12);
|
||||||
|
const int overlap = ScaleForParentWindow(parent, 2);
|
||||||
|
|
||||||
|
const int x = std::max(0, client_size.first - width - margin);
|
||||||
|
const int y = std::max(0, layout.chrome.y + layout.chrome.height - overlap);
|
||||||
|
return {
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
std::min(client_size.first, x + width) - x,
|
||||||
|
std::min(client_size.second, y + height) - y,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CacheBusterToken() {
|
||||||
|
return std::to_string(GetTickCount64());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DestroyTopLevelWindow(NativeWindow window) {
|
||||||
|
const HWND hwnd = AsHwnd(window);
|
||||||
|
if (hwnd) {
|
||||||
|
DestroyWindow(hwnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
#include "platform/default_browser.h"
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <shellapi.h>
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr wchar_t kAppName[] = L"Nebula Browser";
|
||||||
|
constexpr wchar_t kClientKeyName[] = L"NebulaBrowser";
|
||||||
|
constexpr wchar_t kRegisteredApplicationsKey[] = L"Software\\RegisteredApplications";
|
||||||
|
constexpr wchar_t kClientRootKey[] = L"Software\\Clients\\StartMenuInternet\\NebulaBrowser";
|
||||||
|
constexpr wchar_t kFileAssociationsKey[] =
|
||||||
|
L"Software\\Clients\\StartMenuInternet\\NebulaBrowser\\Capabilities\\FileAssociations";
|
||||||
|
constexpr wchar_t kUrlAssociationsKey[] =
|
||||||
|
L"Software\\Clients\\StartMenuInternet\\NebulaBrowser\\Capabilities\\URLAssociations";
|
||||||
|
constexpr wchar_t kHttpUserChoiceKey[] =
|
||||||
|
L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice";
|
||||||
|
constexpr wchar_t kHttpsUserChoiceKey[] =
|
||||||
|
L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\https\\UserChoice";
|
||||||
|
constexpr std::wstring_view kWebFileExtensions[] = {
|
||||||
|
L".htm",
|
||||||
|
L".html",
|
||||||
|
L".shtml",
|
||||||
|
L".xht",
|
||||||
|
L".xhtml",
|
||||||
|
L".svg",
|
||||||
|
L".webp",
|
||||||
|
};
|
||||||
|
|
||||||
|
std::wstring CurrentExecutablePath() {
|
||||||
|
std::wstring path(MAX_PATH, L'\0');
|
||||||
|
DWORD length = 0;
|
||||||
|
while (true) {
|
||||||
|
length = GetModuleFileNameW(nullptr, path.data(), static_cast<DWORD>(path.size()));
|
||||||
|
if (length == 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
if (length < path.size() - 1) {
|
||||||
|
path.resize(length);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
path.resize(path.size() * 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring Quote(std::wstring_view value) {
|
||||||
|
std::wstring quoted = L"\"";
|
||||||
|
quoted += value;
|
||||||
|
quoted += L"\"";
|
||||||
|
return quoted;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SetStringValue(HKEY root,
|
||||||
|
const std::wstring& subkey,
|
||||||
|
const wchar_t* value_name,
|
||||||
|
const std::wstring& value) {
|
||||||
|
HKEY key = nullptr;
|
||||||
|
const LSTATUS status = RegCreateKeyExW(
|
||||||
|
root, subkey.c_str(), 0, nullptr, 0, KEY_SET_VALUE, nullptr, &key, nullptr);
|
||||||
|
if (status != ERROR_SUCCESS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DWORD byte_size = static_cast<DWORD>((value.size() + 1) * sizeof(wchar_t));
|
||||||
|
const LSTATUS set_status = RegSetValueExW(
|
||||||
|
key,
|
||||||
|
value_name,
|
||||||
|
0,
|
||||||
|
REG_SZ,
|
||||||
|
reinterpret_cast<const BYTE*>(value.c_str()),
|
||||||
|
byte_size);
|
||||||
|
RegCloseKey(key);
|
||||||
|
return set_status == ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring ReadStringValue(HKEY root, const wchar_t* subkey, const wchar_t* value_name) {
|
||||||
|
HKEY key = nullptr;
|
||||||
|
if (RegOpenKeyExW(root, subkey, 0, KEY_QUERY_VALUE, &key) != ERROR_SUCCESS) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD type = 0;
|
||||||
|
DWORD byte_size = 0;
|
||||||
|
if (RegQueryValueExW(key, value_name, nullptr, &type, nullptr, &byte_size) != ERROR_SUCCESS ||
|
||||||
|
type != REG_SZ || byte_size == 0) {
|
||||||
|
RegCloseKey(key);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring value(byte_size / sizeof(wchar_t), L'\0');
|
||||||
|
const LSTATUS status = RegQueryValueExW(
|
||||||
|
key, value_name, nullptr, nullptr, reinterpret_cast<BYTE*>(value.data()), &byte_size);
|
||||||
|
RegCloseKey(key);
|
||||||
|
if (status != ERROR_SUCCESS) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!value.empty() && value.back() == L'\0') {
|
||||||
|
value.pop_back();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RegisterDefaultBrowserCapabilities() {
|
||||||
|
const std::wstring exe_path = CurrentExecutablePath();
|
||||||
|
if (exe_path.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::wstring exe_name = std::filesystem::path(exe_path).filename().wstring();
|
||||||
|
const std::wstring command = Quote(exe_path) + L" --url=" + Quote(L"%1");
|
||||||
|
bool ok = true;
|
||||||
|
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, kRegisteredApplicationsKey, kAppName,
|
||||||
|
std::wstring(kClientRootKey) + L"\\Capabilities");
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, kClientRootKey, nullptr, kAppName);
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, std::wstring(kClientRootKey) + L"\\DefaultIcon",
|
||||||
|
nullptr, exe_path + L",0");
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, std::wstring(kClientRootKey) + L"\\shell\\open\\command",
|
||||||
|
nullptr, Quote(exe_path));
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, std::wstring(kClientRootKey) + L"\\Capabilities",
|
||||||
|
L"ApplicationName", kAppName);
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, std::wstring(kClientRootKey) + L"\\Capabilities",
|
||||||
|
L"ApplicationDescription", L"Nebula Browser");
|
||||||
|
for (std::wstring_view extension : kWebFileExtensions) {
|
||||||
|
const std::wstring extension_name(extension);
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, kFileAssociationsKey, extension_name.c_str(),
|
||||||
|
kClientKeyName);
|
||||||
|
}
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, kUrlAssociationsKey, L"http", kClientKeyName);
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, kUrlAssociationsKey, L"https", kClientKeyName);
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, L"Software\\Classes\\NebulaBrowser", nullptr,
|
||||||
|
L"Nebula Browser HTML Document");
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, L"Software\\Classes\\NebulaBrowser", L"URL Protocol",
|
||||||
|
L"");
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, L"Software\\Classes\\NebulaBrowser\\DefaultIcon",
|
||||||
|
nullptr, exe_path + L",0");
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, L"Software\\Classes\\NebulaBrowser\\shell\\open\\command",
|
||||||
|
nullptr, command);
|
||||||
|
const std::wstring application_key = std::wstring(L"Software\\Classes\\Applications\\") + exe_name;
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER, application_key,
|
||||||
|
L"ApplicationName", kAppName);
|
||||||
|
ok &= SetStringValue(HKEY_CURRENT_USER,
|
||||||
|
application_key + L"\\shell\\open\\command",
|
||||||
|
nullptr, command);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenDefaultAppsSettings() {
|
||||||
|
ShellExecuteW(nullptr, L"open", L"ms-settings:defaultapps", nullptr, nullptr, SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
bool IsDefaultBrowser() {
|
||||||
|
return ReadStringValue(HKEY_CURRENT_USER, kHttpUserChoiceKey, L"ProgId") == kClientKeyName &&
|
||||||
|
ReadStringValue(HKEY_CURRENT_USER, kHttpsUserChoiceKey, L"ProgId") == kClientKeyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EnsureDefaultBrowserRegistration() {
|
||||||
|
return RegisterDefaultBrowserCapabilities();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RequestDefaultBrowser() {
|
||||||
|
const bool registered = RegisterDefaultBrowserCapabilities();
|
||||||
|
OpenDefaultAppsSettings();
|
||||||
|
return registered;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
#include "window/nebula_window.h"
|
#include "window/nebula_window.h"
|
||||||
|
|
||||||
#include <dwmapi.h>
|
#include <dwmapi.h>
|
||||||
|
#include <windows.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
namespace nebula::window {
|
namespace nebula::window {
|
||||||
namespace {
|
namespace {
|
||||||
@@ -12,6 +14,7 @@ constexpr wchar_t kWindowClassName[] = L"NebulaBrowserWindow";
|
|||||||
constexpr wchar_t kWindowTitle[] = L"Nebula Browser";
|
constexpr wchar_t kWindowTitle[] = L"Nebula Browser";
|
||||||
constexpr wchar_t kChildFrameHitTestOldProcProp[] = L"NebulaChildFrameHitTestOldProc";
|
constexpr wchar_t kChildFrameHitTestOldProcProp[] = L"NebulaChildFrameHitTestOldProc";
|
||||||
constexpr wchar_t kChildFrameHitTestParentProp[] = L"NebulaChildFrameHitTestParent";
|
constexpr wchar_t kChildFrameHitTestParentProp[] = L"NebulaChildFrameHitTestParent";
|
||||||
|
constexpr ULONG_PTR kOpenTargetCopyDataId = 0x4E42554CUL;
|
||||||
constexpr int kTitleRowHeightDip = 42;
|
constexpr int kTitleRowHeightDip = 42;
|
||||||
constexpr int kWindowControlWidthDip = 46;
|
constexpr int kWindowControlWidthDip = 46;
|
||||||
constexpr int kWindowControlCount = 3;
|
constexpr int kWindowControlCount = 3;
|
||||||
@@ -103,190 +106,137 @@ void ApplyWindowFrameStyle(HWND hwnd) {
|
|||||||
sizeof(kNoWindowBorderColor));
|
sizeof(kNoWindowBorderColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
platform::Rect ToPlatformRect(const RECT& rect) {
|
||||||
|
return {
|
||||||
NebulaWindow::NebulaWindow(WindowDelegate* delegate) : delegate_(delegate) {}
|
|
||||||
|
|
||||||
NebulaWindow::~NebulaWindow() = default;
|
|
||||||
|
|
||||||
bool NebulaWindow::Create(HINSTANCE instance, int show_command) {
|
|
||||||
instance_ = instance;
|
|
||||||
RegisterClass(instance);
|
|
||||||
|
|
||||||
const RECT work_area = GetWorkArea();
|
|
||||||
dpi_ = GetDpiForSystem();
|
|
||||||
const int width = std::min<LONG>(ScaleForDpi(1400), work_area.right - work_area.left);
|
|
||||||
const int height = std::min<LONG>(ScaleForDpi(900), work_area.bottom - work_area.top);
|
|
||||||
const int x = work_area.left + ((work_area.right - work_area.left) - width) / 2;
|
|
||||||
const int y = work_area.top + ((work_area.bottom - work_area.top) - height) / 2;
|
|
||||||
|
|
||||||
hwnd_ = CreateWindowExW(
|
|
||||||
0,
|
|
||||||
kWindowClassName,
|
|
||||||
kWindowTitle,
|
|
||||||
WS_POPUP | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CLIPCHILDREN,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
instance_,
|
|
||||||
this);
|
|
||||||
|
|
||||||
if (!hwnd_) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateDpi();
|
|
||||||
ApplyWindowFrameStyle(hwnd_);
|
|
||||||
|
|
||||||
const MARGINS margins = {0, 0, 0, 0};
|
|
||||||
DwmExtendFrameIntoClientArea(hwnd_, &margins);
|
|
||||||
|
|
||||||
ShowWindow(hwnd_, show_command);
|
|
||||||
UpdateWindow(hwnd_);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
BrowserLayout NebulaWindow::CurrentLayout(bool show_chrome) const {
|
|
||||||
RECT client = {};
|
|
||||||
if (hwnd_) {
|
|
||||||
GetClientRect(hwnd_, &client);
|
|
||||||
}
|
|
||||||
|
|
||||||
BrowserLayout layout;
|
|
||||||
layout.chrome = show_chrome
|
|
||||||
? RECT{0, 0, client.right, std::min<LONG>(ScaleForDpi(chrome_height_dip_), client.bottom)}
|
|
||||||
: RECT{0, 0, 0, 0};
|
|
||||||
layout.content = {0, layout.chrome.bottom, client.right, client.bottom};
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NebulaWindow::ResizeChild(HWND child, const RECT& rect) const {
|
|
||||||
if (!child) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
EnableFrameHitTest(child);
|
|
||||||
SetWindowPos(
|
|
||||||
child,
|
|
||||||
nullptr,
|
|
||||||
rect.left,
|
rect.left,
|
||||||
rect.top,
|
rect.top,
|
||||||
std::max(0L, rect.right - rect.left),
|
std::max(0L, rect.right - rect.left),
|
||||||
std::max(0L, rect.bottom - rect.top),
|
std::max(0L, rect.bottom - rect.top),
|
||||||
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void NebulaWindow::Minimize() {
|
RECT ToNativeRect(const platform::Rect& rect) {
|
||||||
if (hwnd_) {
|
return {
|
||||||
ShowWindow(hwnd_, SW_MINIMIZE);
|
rect.x,
|
||||||
}
|
rect.y,
|
||||||
|
rect.x + rect.width,
|
||||||
|
rect.y + rect.height,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void NebulaWindow::ToggleMaximize() {
|
std::string WideToUtf8(std::wstring_view value) {
|
||||||
if (!hwnd_ || fullscreen_) {
|
if (value.empty()) {
|
||||||
return;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowWindow(hwnd_, IsZoomed(hwnd_) ? SW_RESTORE : SW_MAXIMIZE);
|
const int size = WideCharToMultiByte(
|
||||||
|
CP_UTF8,
|
||||||
|
0,
|
||||||
|
value.data(),
|
||||||
|
static_cast<int>(value.size()),
|
||||||
|
nullptr,
|
||||||
|
0,
|
||||||
|
nullptr,
|
||||||
|
nullptr);
|
||||||
|
if (size <= 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string result(size, '\0');
|
||||||
|
WideCharToMultiByte(
|
||||||
|
CP_UTF8,
|
||||||
|
0,
|
||||||
|
value.data(),
|
||||||
|
static_cast<int>(value.size()),
|
||||||
|
result.data(),
|
||||||
|
size,
|
||||||
|
nullptr,
|
||||||
|
nullptr);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NebulaWindow::SetFullscreen(bool fullscreen) {
|
} // namespace
|
||||||
if (!hwnd_ || fullscreen_ == fullscreen) {
|
|
||||||
return;
|
struct nebula::window::NebulaWindowImpl {
|
||||||
|
WindowDelegate* delegate = nullptr;
|
||||||
|
HINSTANCE instance = nullptr;
|
||||||
|
HWND hwnd = nullptr;
|
||||||
|
bool fullscreen = false;
|
||||||
|
LONG_PTR restore_style = 0;
|
||||||
|
LONG_PTR restore_ex_style = 0;
|
||||||
|
WINDOWPLACEMENT restore_placement = {sizeof(WINDOWPLACEMENT)};
|
||||||
|
UINT dpi = 96;
|
||||||
|
int resize_border_dip = 8;
|
||||||
|
int chrome_height_dip = 104;
|
||||||
|
|
||||||
|
int ScaleForDpi(int value) const {
|
||||||
|
return MulDiv(value, static_cast<int>(dpi), 96);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullscreen) {
|
void UpdateDpi() {
|
||||||
restore_style_ = GetWindowLongPtrW(hwnd_, GWL_STYLE);
|
if (hwnd) {
|
||||||
restore_ex_style_ = GetWindowLongPtrW(hwnd_, GWL_EXSTYLE);
|
dpi = GetDpiForWindow(hwnd);
|
||||||
restore_placement_.length = sizeof(restore_placement_);
|
}
|
||||||
GetWindowPlacement(hwnd_, &restore_placement_);
|
|
||||||
|
|
||||||
fullscreen_ = true;
|
|
||||||
const RECT monitor = GetMonitorArea(hwnd_);
|
|
||||||
SetWindowLongPtrW(hwnd_, GWL_STYLE, restore_style_ & ~(WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
|
|
||||||
SetWindowLongPtrW(hwnd_, GWL_EXSTYLE, restore_ex_style_);
|
|
||||||
SetWindowPos(
|
|
||||||
hwnd_,
|
|
||||||
HWND_TOPMOST,
|
|
||||||
monitor.left,
|
|
||||||
monitor.top,
|
|
||||||
monitor.right - monitor.left,
|
|
||||||
monitor.bottom - monitor.top,
|
|
||||||
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
|
||||||
} else {
|
|
||||||
fullscreen_ = false;
|
|
||||||
SetWindowLongPtrW(hwnd_, GWL_STYLE, restore_style_);
|
|
||||||
SetWindowLongPtrW(hwnd_, GWL_EXSTYLE, restore_ex_style_);
|
|
||||||
SetWindowPlacement(hwnd_, &restore_placement_);
|
|
||||||
SetWindowPos(
|
|
||||||
hwnd_,
|
|
||||||
HWND_NOTOPMOST,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
|
||||||
ApplyWindowFrameStyle(hwnd_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NotifyResize();
|
void NotifyResize() {
|
||||||
}
|
if (delegate) {
|
||||||
|
delegate->OnWindowResized(CurrentLayout(true));
|
||||||
void NebulaWindow::Close() {
|
}
|
||||||
if (hwnd_) {
|
|
||||||
SendMessageW(hwnd_, WM_CLOSE, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NebulaWindow::BeginDrag() {
|
|
||||||
if (!hwnd_) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseCapture();
|
BrowserLayout CurrentLayout(bool show_chrome) const {
|
||||||
SendMessageW(hwnd_, WM_NCLBUTTONDOWN, HTCAPTION, 0);
|
RECT client = {};
|
||||||
}
|
if (hwnd) {
|
||||||
|
GetClientRect(hwnd, &client);
|
||||||
|
}
|
||||||
|
|
||||||
void NebulaWindow::SetTitle(const std::wstring& title) {
|
BrowserLayout layout;
|
||||||
if (hwnd_) {
|
layout.chrome = show_chrome
|
||||||
SetWindowTextW(hwnd_, title.empty() ? kWindowTitle : title.c_str());
|
? ToPlatformRect(RECT{
|
||||||
}
|
0,
|
||||||
}
|
0,
|
||||||
|
client.right,
|
||||||
void NebulaWindow::EnableFrameHitTest(HWND child) const {
|
std::min<LONG>(ScaleForDpi(chrome_height_dip), client.bottom)})
|
||||||
if (!hwnd_ || !child) {
|
: platform::Rect{};
|
||||||
return;
|
layout.content = ToPlatformRect(
|
||||||
|
RECT{0, layout.chrome.y + layout.chrome.height, client.right, client.bottom});
|
||||||
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnableFrameHitTestForWindow(child);
|
void EnableFrameHitTestForWindow(HWND child) const;
|
||||||
EnumChildWindows(child, &NebulaWindow::EnableFrameHitTestForDescendant, reinterpret_cast<LPARAM>(this));
|
LRESULT HitTest(LPARAM lparam) const;
|
||||||
}
|
LRESULT HitTestPoint(POINT point) const;
|
||||||
|
LRESULT WndProc(UINT message, WPARAM wparam, LPARAM lparam);
|
||||||
|
void RegisterClass(HINSTANCE instance_handle);
|
||||||
|
|
||||||
LRESULT CALLBACK NebulaWindow::StaticWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
|
static LRESULT CALLBACK StaticWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
|
||||||
NebulaWindow* self = nullptr;
|
static LRESULT CALLBACK ChildFrameWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
|
||||||
|
static BOOL CALLBACK EnableFrameHitTestForDescendant(HWND hwnd, LPARAM lparam);
|
||||||
|
};
|
||||||
|
|
||||||
|
LRESULT CALLBACK nebula::window::NebulaWindowImpl::StaticWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
|
||||||
|
NebulaWindowImpl* self = nullptr;
|
||||||
|
|
||||||
if (message == WM_NCCREATE) {
|
if (message == WM_NCCREATE) {
|
||||||
auto* create = reinterpret_cast<CREATESTRUCTW*>(lparam);
|
auto* create = reinterpret_cast<CREATESTRUCTW*>(lparam);
|
||||||
self = static_cast<NebulaWindow*>(create->lpCreateParams);
|
self = static_cast<NebulaWindowImpl*>(create->lpCreateParams);
|
||||||
SetWindowLongPtrW(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(self));
|
SetWindowLongPtrW(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(self));
|
||||||
self->hwnd_ = hwnd;
|
self->hwnd = hwnd;
|
||||||
} else {
|
} else {
|
||||||
self = reinterpret_cast<NebulaWindow*>(GetWindowLongPtrW(hwnd, GWLP_USERDATA));
|
self = reinterpret_cast<NebulaWindowImpl*>(GetWindowLongPtrW(hwnd, GWLP_USERDATA));
|
||||||
}
|
}
|
||||||
|
|
||||||
return self ? self->WndProc(message, wparam, lparam)
|
return self ? self->WndProc(message, wparam, lparam)
|
||||||
: DefWindowProcW(hwnd, message, wparam, lparam);
|
: DefWindowProcW(hwnd, message, wparam, lparam);
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK NebulaWindow::ChildFrameWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
|
LRESULT CALLBACK nebula::window::NebulaWindowImpl::ChildFrameWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
|
||||||
auto old_proc = reinterpret_cast<WNDPROC>(GetPropW(hwnd, kChildFrameHitTestOldProcProp));
|
auto old_proc = reinterpret_cast<WNDPROC>(GetPropW(hwnd, kChildFrameHitTestOldProcProp));
|
||||||
|
|
||||||
if (message == WM_NCHITTEST) {
|
if (message == WM_NCHITTEST) {
|
||||||
const auto parent = reinterpret_cast<HWND>(GetPropW(hwnd, kChildFrameHitTestParentProp));
|
const auto parent = reinterpret_cast<HWND>(GetPropW(hwnd, kChildFrameHitTestParentProp));
|
||||||
auto* self = parent ? reinterpret_cast<NebulaWindow*>(GetWindowLongPtrW(parent, GWLP_USERDATA)) : nullptr;
|
auto* self = parent ? reinterpret_cast<NebulaWindowImpl*>(GetWindowLongPtrW(parent, GWLP_USERDATA)) : nullptr;
|
||||||
if (self) {
|
if (self) {
|
||||||
const LRESULT hit = self->HitTest(lparam);
|
const LRESULT hit = self->HitTest(lparam);
|
||||||
if (IsResizeHit(hit)) {
|
if (IsResizeHit(hit)) {
|
||||||
@@ -297,7 +247,7 @@ LRESULT CALLBACK NebulaWindow::ChildFrameWndProc(HWND hwnd, UINT message, WPARAM
|
|||||||
|
|
||||||
if (message == WM_SETCURSOR) {
|
if (message == WM_SETCURSOR) {
|
||||||
const auto parent = reinterpret_cast<HWND>(GetPropW(hwnd, kChildFrameHitTestParentProp));
|
const auto parent = reinterpret_cast<HWND>(GetPropW(hwnd, kChildFrameHitTestParentProp));
|
||||||
auto* self = parent ? reinterpret_cast<NebulaWindow*>(GetWindowLongPtrW(parent, GWLP_USERDATA)) : nullptr;
|
auto* self = parent ? reinterpret_cast<NebulaWindowImpl*>(GetWindowLongPtrW(parent, GWLP_USERDATA)) : nullptr;
|
||||||
POINT point = {};
|
POINT point = {};
|
||||||
if (self && GetCursorPos(&point) && SetResizeCursor(self->HitTestPoint(point))) {
|
if (self && GetCursorPos(&point) && SetResizeCursor(self->HitTestPoint(point))) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -306,7 +256,7 @@ LRESULT CALLBACK NebulaWindow::ChildFrameWndProc(HWND hwnd, UINT message, WPARAM
|
|||||||
|
|
||||||
if (message == WM_MOUSEMOVE || message == WM_NCMOUSEMOVE) {
|
if (message == WM_MOUSEMOVE || message == WM_NCMOUSEMOVE) {
|
||||||
const auto parent = reinterpret_cast<HWND>(GetPropW(hwnd, kChildFrameHitTestParentProp));
|
const auto parent = reinterpret_cast<HWND>(GetPropW(hwnd, kChildFrameHitTestParentProp));
|
||||||
auto* self = parent ? reinterpret_cast<NebulaWindow*>(GetWindowLongPtrW(parent, GWLP_USERDATA)) : nullptr;
|
auto* self = parent ? reinterpret_cast<NebulaWindowImpl*>(GetWindowLongPtrW(parent, GWLP_USERDATA)) : nullptr;
|
||||||
POINT point = {};
|
POINT point = {};
|
||||||
if (self && GetCursorPos(&point) && SetResizeCursor(self->HitTestPoint(point))) {
|
if (self && GetCursorPos(&point) && SetResizeCursor(self->HitTestPoint(point))) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -334,20 +284,35 @@ LRESULT CALLBACK NebulaWindow::ChildFrameWndProc(HWND hwnd, UINT message, WPARAM
|
|||||||
: DefWindowProcW(hwnd, message, wparam, lparam);
|
: DefWindowProcW(hwnd, message, wparam, lparam);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CALLBACK NebulaWindow::EnableFrameHitTestForDescendant(HWND hwnd, LPARAM lparam) {
|
BOOL CALLBACK nebula::window::NebulaWindowImpl::EnableFrameHitTestForDescendant(HWND hwnd, LPARAM lparam) {
|
||||||
const auto* self = reinterpret_cast<const NebulaWindow*>(lparam);
|
const auto* self = reinterpret_cast<const NebulaWindowImpl*>(lparam);
|
||||||
if (self) {
|
if (self) {
|
||||||
self->EnableFrameHitTestForWindow(hwnd);
|
self->EnableFrameHitTestForWindow(hwnd);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT NebulaWindow::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
|
void nebula::window::NebulaWindowImpl::EnableFrameHitTestForWindow(HWND child) const {
|
||||||
|
if (!child || GetPropW(child, kChildFrameHitTestOldProcProp)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetPropW(child, kChildFrameHitTestParentProp, hwnd);
|
||||||
|
const auto old_proc = reinterpret_cast<WNDPROC>(
|
||||||
|
SetWindowLongPtrW(child, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&NebulaWindowImpl::ChildFrameWndProc)));
|
||||||
|
if (old_proc) {
|
||||||
|
SetPropW(child, kChildFrameHitTestOldProcProp, reinterpret_cast<HANDLE>(old_proc));
|
||||||
|
} else {
|
||||||
|
RemovePropW(child, kChildFrameHitTestParentProp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT nebula::window::NebulaWindowImpl::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
UpdateDpi();
|
UpdateDpi();
|
||||||
if (delegate_) {
|
if (delegate) {
|
||||||
delegate_->OnWindowCreated();
|
delegate->OnWindowCreated();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -358,7 +323,7 @@ LRESULT NebulaWindow::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_NCACTIVATE:
|
case WM_NCACTIVATE:
|
||||||
ApplyWindowFrameStyle(hwnd_);
|
ApplyWindowFrameStyle(hwnd);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
||||||
@@ -389,10 +354,10 @@ LRESULT NebulaWindow::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_DPICHANGED: {
|
case WM_DPICHANGED: {
|
||||||
dpi_ = HIWORD(wparam);
|
dpi = HIWORD(wparam);
|
||||||
const auto* suggested_rect = reinterpret_cast<RECT*>(lparam);
|
const auto* suggested_rect = reinterpret_cast<RECT*>(lparam);
|
||||||
SetWindowPos(
|
SetWindowPos(
|
||||||
hwnd_,
|
hwnd,
|
||||||
nullptr,
|
nullptr,
|
||||||
suggested_rect->left,
|
suggested_rect->left,
|
||||||
suggested_rect->top,
|
suggested_rect->top,
|
||||||
@@ -404,8 +369,8 @@ LRESULT NebulaWindow::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WM_GETMINMAXINFO: {
|
case WM_GETMINMAXINFO: {
|
||||||
const RECT work_area = GetMonitorWorkArea(hwnd_);
|
const RECT work_area = GetMonitorWorkArea(hwnd);
|
||||||
const RECT monitor_area = GetMonitorArea(hwnd_);
|
const RECT monitor_area = GetMonitorArea(hwnd);
|
||||||
|
|
||||||
auto* minmax = reinterpret_cast<MINMAXINFO*>(lparam);
|
auto* minmax = reinterpret_cast<MINMAXINFO*>(lparam);
|
||||||
minmax->ptMaxPosition.x = work_area.left - monitor_area.left;
|
minmax->ptMaxPosition.x = work_area.left - monitor_area.left;
|
||||||
@@ -416,64 +381,47 @@ LRESULT NebulaWindow::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
if (delegate_) {
|
if (delegate) {
|
||||||
delegate_->OnWindowCloseRequested();
|
delegate->OnWindowCloseRequested();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_COPYDATA: {
|
||||||
|
const auto* copy_data = reinterpret_cast<const COPYDATASTRUCT*>(lparam);
|
||||||
|
if (copy_data && copy_data->dwData == kOpenTargetCopyDataId &&
|
||||||
|
copy_data->lpData && copy_data->cbData >= sizeof(wchar_t)) {
|
||||||
|
const auto* text = static_cast<const wchar_t*>(copy_data->lpData);
|
||||||
|
const size_t char_count = (copy_data->cbData / sizeof(wchar_t)) - 1;
|
||||||
|
if (delegate) {
|
||||||
|
delegate->OnExternalOpenRequested(WideToUtf8(std::wstring_view(text, char_count)));
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
hwnd_ = nullptr;
|
hwnd = nullptr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProcW(hwnd_, message, wparam, lparam);
|
return DefWindowProcW(hwnd, message, wparam, lparam);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NebulaWindow::RegisterClass(HINSTANCE instance) {
|
void nebula::window::NebulaWindowImpl::RegisterClass(HINSTANCE instance_handle) {
|
||||||
WNDCLASSEXW window_class = {};
|
WNDCLASSEXW window_class = {};
|
||||||
window_class.cbSize = sizeof(window_class);
|
window_class.cbSize = sizeof(window_class);
|
||||||
window_class.lpfnWndProc = StaticWndProc;
|
window_class.lpfnWndProc = StaticWndProc;
|
||||||
window_class.hInstance = instance;
|
window_class.hInstance = instance_handle;
|
||||||
window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||||
window_class.lpszClassName = kWindowClassName;
|
window_class.lpszClassName = kWindowClassName;
|
||||||
|
|
||||||
RegisterClassExW(&window_class);
|
RegisterClassExW(&window_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NebulaWindow::NotifyResize() {
|
LRESULT nebula::window::NebulaWindowImpl::HitTest(LPARAM lparam) const {
|
||||||
if (delegate_) {
|
if (!hwnd) {
|
||||||
delegate_->OnWindowResized(CurrentLayout());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NebulaWindow::EnableFrameHitTestForWindow(HWND child) const {
|
|
||||||
if (!child || GetPropW(child, kChildFrameHitTestOldProcProp)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetPropW(child, kChildFrameHitTestParentProp, hwnd_);
|
|
||||||
const auto old_proc = reinterpret_cast<WNDPROC>(
|
|
||||||
SetWindowLongPtrW(child, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&NebulaWindow::ChildFrameWndProc)));
|
|
||||||
if (old_proc) {
|
|
||||||
SetPropW(child, kChildFrameHitTestOldProcProp, reinterpret_cast<HANDLE>(old_proc));
|
|
||||||
} else {
|
|
||||||
RemovePropW(child, kChildFrameHitTestParentProp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int NebulaWindow::ScaleForDpi(int value) const {
|
|
||||||
return MulDiv(value, static_cast<int>(dpi_), 96);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NebulaWindow::UpdateDpi() {
|
|
||||||
if (hwnd_) {
|
|
||||||
dpi_ = GetDpiForWindow(hwnd_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT NebulaWindow::HitTest(LPARAM lparam) const {
|
|
||||||
if (!hwnd_) {
|
|
||||||
return HTNOWHERE;
|
return HTNOWHERE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,19 +429,19 @@ LRESULT NebulaWindow::HitTest(LPARAM lparam) const {
|
|||||||
return HitTestPoint(point);
|
return HitTestPoint(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT NebulaWindow::HitTestPoint(POINT point) const {
|
LRESULT nebula::window::NebulaWindowImpl::HitTestPoint(POINT point) const {
|
||||||
if (!hwnd_) {
|
if (!hwnd) {
|
||||||
return HTNOWHERE;
|
return HTNOWHERE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RECT window = {};
|
RECT window = {};
|
||||||
GetWindowRect(hwnd_, &window);
|
GetWindowRect(hwnd, &window);
|
||||||
|
|
||||||
if (fullscreen_ || IsZoomed(hwnd_)) {
|
if (fullscreen || IsZoomed(hwnd)) {
|
||||||
return HTCLIENT;
|
return HTCLIENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int resize_border = ScaleForDpi(resize_border_dip_);
|
const int resize_border = ScaleForDpi(resize_border_dip);
|
||||||
const bool left = point.x >= window.left && point.x < window.left + resize_border;
|
const bool left = point.x >= window.left && point.x < window.left + resize_border;
|
||||||
const bool right = point.x < window.right && point.x >= window.right - resize_border;
|
const bool right = point.x < window.right && point.x >= window.right - resize_border;
|
||||||
const bool top = point.y >= window.top && point.y < window.top + resize_border;
|
const bool top = point.y >= window.top && point.y < window.top + resize_border;
|
||||||
@@ -535,4 +483,191 @@ LRESULT NebulaWindow::HitTestPoint(POINT point) const {
|
|||||||
return HTCLIENT;
|
return HTCLIENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::wstring Utf8ToWide(const std::string& value) {
|
||||||
|
if (value.empty()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const int size = MultiByteToWideChar(
|
||||||
|
CP_UTF8, 0, value.data(), static_cast<int>(value.size()), nullptr, 0);
|
||||||
|
std::wstring result(size, L'\0');
|
||||||
|
MultiByteToWideChar(
|
||||||
|
CP_UTF8, 0, value.data(), static_cast<int>(value.size()), result.data(), size);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace nebula::window {
|
||||||
|
|
||||||
|
NebulaWindow::NebulaWindow(WindowDelegate* delegate)
|
||||||
|
: impl_(std::make_unique<NebulaWindowImpl>()) {
|
||||||
|
impl_->delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
NebulaWindow::~NebulaWindow() = default;
|
||||||
|
|
||||||
|
bool NebulaWindow::Create(const platform::AppStartup& startup) {
|
||||||
|
impl_->instance = static_cast<HINSTANCE>(startup.instance);
|
||||||
|
impl_->RegisterClass(impl_->instance);
|
||||||
|
|
||||||
|
const RECT work_area = GetWorkArea();
|
||||||
|
impl_->dpi = GetDpiForSystem();
|
||||||
|
const int width =
|
||||||
|
std::min<LONG>(impl_->ScaleForDpi(1400), work_area.right - work_area.left);
|
||||||
|
const int height =
|
||||||
|
std::min<LONG>(impl_->ScaleForDpi(900), work_area.bottom - work_area.top);
|
||||||
|
const int x = work_area.left + ((work_area.right - work_area.left) - width) / 2;
|
||||||
|
const int y = work_area.top + ((work_area.bottom - work_area.top) - height) / 2;
|
||||||
|
|
||||||
|
impl_->hwnd = CreateWindowExW(
|
||||||
|
0,
|
||||||
|
kWindowClassName,
|
||||||
|
kWindowTitle,
|
||||||
|
WS_POPUP | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CLIPCHILDREN,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
impl_->instance,
|
||||||
|
impl_.get());
|
||||||
|
|
||||||
|
if (!impl_->hwnd) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_->UpdateDpi();
|
||||||
|
ApplyWindowFrameStyle(impl_->hwnd);
|
||||||
|
|
||||||
|
const MARGINS margins = {0, 0, 0, 0};
|
||||||
|
DwmExtendFrameIntoClientArea(impl_->hwnd, &margins);
|
||||||
|
|
||||||
|
ShowWindow(impl_->hwnd, startup.show_command);
|
||||||
|
UpdateWindow(impl_->hwnd);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
platform::NativeWindow NebulaWindow::native_handle() const {
|
||||||
|
return impl_->hwnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
BrowserLayout NebulaWindow::CurrentLayout(bool show_chrome) const {
|
||||||
|
return impl_->CurrentLayout(show_chrome);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::ResizeChild(platform::NativeWindow child, const platform::Rect& rect) const {
|
||||||
|
const HWND hwnd = static_cast<HWND>(child);
|
||||||
|
if (!hwnd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnableFrameHitTest(child);
|
||||||
|
const RECT native_rect = ToNativeRect(rect);
|
||||||
|
SetWindowPos(
|
||||||
|
hwnd,
|
||||||
|
nullptr,
|
||||||
|
native_rect.left,
|
||||||
|
native_rect.top,
|
||||||
|
std::max(0L, native_rect.right - native_rect.left),
|
||||||
|
std::max(0L, native_rect.bottom - native_rect.top),
|
||||||
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::Minimize() {
|
||||||
|
if (impl_->hwnd) {
|
||||||
|
ShowWindow(impl_->hwnd, SW_MINIMIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::ToggleMaximize() {
|
||||||
|
if (!impl_->hwnd || impl_->fullscreen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowWindow(impl_->hwnd, IsZoomed(impl_->hwnd) ? SW_RESTORE : SW_MAXIMIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::SetFullscreen(bool fullscreen) {
|
||||||
|
if (!impl_->hwnd || impl_->fullscreen == fullscreen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fullscreen) {
|
||||||
|
impl_->restore_style = GetWindowLongPtrW(impl_->hwnd, GWL_STYLE);
|
||||||
|
impl_->restore_ex_style = GetWindowLongPtrW(impl_->hwnd, GWL_EXSTYLE);
|
||||||
|
impl_->restore_placement.length = sizeof(impl_->restore_placement);
|
||||||
|
GetWindowPlacement(impl_->hwnd, &impl_->restore_placement);
|
||||||
|
|
||||||
|
impl_->fullscreen = true;
|
||||||
|
const RECT monitor = GetMonitorArea(impl_->hwnd);
|
||||||
|
SetWindowLongPtrW(
|
||||||
|
impl_->hwnd,
|
||||||
|
GWL_STYLE,
|
||||||
|
impl_->restore_style & ~(WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
|
||||||
|
SetWindowLongPtrW(impl_->hwnd, GWL_EXSTYLE, impl_->restore_ex_style);
|
||||||
|
SetWindowPos(
|
||||||
|
impl_->hwnd,
|
||||||
|
HWND_TOPMOST,
|
||||||
|
monitor.left,
|
||||||
|
monitor.top,
|
||||||
|
monitor.right - monitor.left,
|
||||||
|
monitor.bottom - monitor.top,
|
||||||
|
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||||
|
} else {
|
||||||
|
impl_->fullscreen = false;
|
||||||
|
SetWindowLongPtrW(impl_->hwnd, GWL_STYLE, impl_->restore_style);
|
||||||
|
SetWindowLongPtrW(impl_->hwnd, GWL_EXSTYLE, impl_->restore_ex_style);
|
||||||
|
SetWindowPlacement(impl_->hwnd, &impl_->restore_placement);
|
||||||
|
SetWindowPos(
|
||||||
|
impl_->hwnd,
|
||||||
|
HWND_NOTOPMOST,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||||
|
ApplyWindowFrameStyle(impl_->hwnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_->NotifyResize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::Close() {
|
||||||
|
if (impl_->hwnd) {
|
||||||
|
SendMessageW(impl_->hwnd, WM_CLOSE, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::BeginDrag() {
|
||||||
|
if (!impl_->hwnd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReleaseCapture();
|
||||||
|
SendMessageW(impl_->hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::SetTitle(const std::string& title) {
|
||||||
|
if (!impl_->hwnd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::wstring wide = title.empty() ? kWindowTitle : Utf8ToWide(title);
|
||||||
|
SetWindowTextW(impl_->hwnd, wide.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void NebulaWindow::EnableFrameHitTest(platform::NativeWindow child) const {
|
||||||
|
if (!impl_->hwnd || !child) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_->EnableFrameHitTestForWindow(static_cast<HWND>(child));
|
||||||
|
EnumChildWindows(
|
||||||
|
static_cast<HWND>(child),
|
||||||
|
&NebulaWindowImpl::EnableFrameHitTestForDescendant,
|
||||||
|
reinterpret_cast<LPARAM>(impl_.get()));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace nebula::window
|
} // namespace nebula::window
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#include "platform/paths_platform.h"
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
|
||||||
|
std::filesystem::path ExecutableDirectory() {
|
||||||
|
wchar_t exe_path[MAX_PATH] = {};
|
||||||
|
const DWORD length = GetModuleFileNameW(nullptr, exe_path, MAX_PATH);
|
||||||
|
if (length == 0 || length == MAX_PATH) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::filesystem::path(exe_path).parent_path();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::path DefaultUserDataRoot() {
|
||||||
|
wchar_t buffer[MAX_PATH] = {};
|
||||||
|
const DWORD length = GetEnvironmentVariableW(L"LOCALAPPDATA", buffer, MAX_PATH);
|
||||||
|
if (length > 0 && length < MAX_PATH) {
|
||||||
|
return std::filesystem::path(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ExecutableDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string PathToUtf8(const std::filesystem::path& path) {
|
||||||
|
const std::wstring wide = path.wstring();
|
||||||
|
if (wide.empty()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const int size = WideCharToMultiByte(
|
||||||
|
CP_UTF8, 0, wide.data(), static_cast<int>(wide.size()), nullptr, 0, nullptr, nullptr);
|
||||||
|
std::string result(size, '\0');
|
||||||
|
WideCharToMultiByte(
|
||||||
|
CP_UTF8, 0, wide.data(), static_cast<int>(wide.size()), result.data(), size, nullptr, nullptr);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
#include "platform/startup.h"
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "include/cef_command_line.h"
|
||||||
|
#include "ui/paths.h"
|
||||||
|
|
||||||
|
namespace nebula::platform {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr wchar_t kMainInstanceMutexName[] = L"Local\\NebulaBrowserMainInstance";
|
||||||
|
constexpr wchar_t kWindowClassName[] = L"NebulaBrowserWindow";
|
||||||
|
constexpr ULONG_PTR kOpenTargetCopyDataId = 0x4E42554CUL;
|
||||||
|
|
||||||
|
class ScopedHandle {
|
||||||
|
public:
|
||||||
|
explicit ScopedHandle(HANDLE handle) : handle_(handle) {}
|
||||||
|
~ScopedHandle() {
|
||||||
|
if (handle_) {
|
||||||
|
CloseHandle(handle_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedHandle(const ScopedHandle&) = delete;
|
||||||
|
ScopedHandle& operator=(const ScopedHandle&) = delete;
|
||||||
|
|
||||||
|
bool valid() const { return handle_ != nullptr; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
HANDLE handle_ = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::wstring Utf8ToWide(const std::string& value) {
|
||||||
|
if (value.empty()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const int size = MultiByteToWideChar(
|
||||||
|
CP_UTF8, 0, value.data(), static_cast<int>(value.size()), nullptr, 0);
|
||||||
|
if (size <= 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring result(size, L'\0');
|
||||||
|
MultiByteToWideChar(
|
||||||
|
CP_UTF8, 0, value.data(), static_cast<int>(value.size()), result.data(), size);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForwardLaunchTargetToExistingWindow(const std::string& launch_target) {
|
||||||
|
if (launch_target.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HWND existing_window = FindWindowW(kWindowClassName, nullptr);
|
||||||
|
if (!existing_window) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::wstring target = Utf8ToWide(launch_target);
|
||||||
|
if (target.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
COPYDATASTRUCT data = {};
|
||||||
|
data.dwData = kOpenTargetCopyDataId;
|
||||||
|
data.cbData = static_cast<DWORD>((target.size() + 1) * sizeof(wchar_t));
|
||||||
|
data.lpData = const_cast<wchar_t*>(target.c_str());
|
||||||
|
SendMessageW(existing_window, WM_COPYDATA, 0, reinterpret_cast<LPARAM>(&data));
|
||||||
|
|
||||||
|
ShowWindow(existing_window, SW_SHOWNORMAL);
|
||||||
|
SetForegroundWindow(existing_window);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void PrepareApp() {
|
||||||
|
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TryAcquireSingleInstance(const std::string& launch_target) {
|
||||||
|
static ScopedHandle mutex(CreateMutexW(nullptr, TRUE, kMainInstanceMutexName));
|
||||||
|
const bool already_running = mutex.valid() && GetLastError() == ERROR_ALREADY_EXISTS;
|
||||||
|
if (already_running) {
|
||||||
|
ForwardLaunchTargetToExistingWindow(launch_target);
|
||||||
|
}
|
||||||
|
return !already_running;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefMainArgs MakeMainArgs(const AppStartup& startup) {
|
||||||
|
return CefMainArgs(static_cast<HINSTANCE>(startup.instance));
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitCommandLine(CefRefPtr<CefCommandLine> command_line, const AppStartup& startup) {
|
||||||
|
NEBULA_UNUSED(startup);
|
||||||
|
command_line->InitFromString(::GetCommandLineW());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigureCefSettings(CefSettings& settings) {
|
||||||
|
const std::wstring user_data_dir = nebula::ui::GetUserDataDirectory().wstring();
|
||||||
|
const std::wstring cache_dir = nebula::ui::GetCacheDirectory().wstring();
|
||||||
|
if (!user_data_dir.empty()) {
|
||||||
|
CefString(&settings.root_cache_path).FromWString(user_data_dir);
|
||||||
|
}
|
||||||
|
if (!cache_dir.empty()) {
|
||||||
|
CefString(&settings.cache_path).FromWString(cache_dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nebula::platform
|
||||||
+37
-60
@@ -1,6 +1,6 @@
|
|||||||
#include "ui/paths.h"
|
#include "ui/paths.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include "platform/paths_platform.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
@@ -10,40 +10,25 @@ namespace nebula::ui {
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr std::string_view kNebulaScheme = "nebula://";
|
constexpr std::string_view kNebulaScheme = "nebula://";
|
||||||
constexpr std::wstring_view kInternalFallbackPage = L"404.html";
|
constexpr std::string_view kInternalFallbackPage = "404.html";
|
||||||
|
|
||||||
struct InternalPage {
|
struct InternalPage {
|
||||||
std::string_view slug;
|
std::string_view slug;
|
||||||
std::wstring_view file_name;
|
std::string_view file_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr InternalPage kInternalPages[] = {
|
constexpr InternalPage kInternalPages[] = {
|
||||||
{"home", L"home.html"},
|
{"home", "home.html"},
|
||||||
{"settings", L"settings.html"},
|
{"settings", "settings.html"},
|
||||||
{"downloads", L"downloads.html"},
|
{"downloads", "downloads.html"},
|
||||||
{"bigpicture", L"bigpicture.html"},
|
{"bigpicture", "bigpicture.html"},
|
||||||
{"big-picture", L"bigpicture.html"},
|
{"big-picture", "bigpicture.html"},
|
||||||
{"gpu-diagnostics", L"gpu-diagnostics.html"},
|
{"gpu-diagnostics", "gpu-diagnostics.html"},
|
||||||
{"setup", L"setup.html"},
|
{"setup", "setup.html"},
|
||||||
{"404", L"404.html"},
|
{"404", "404.html"},
|
||||||
{"insecure", L"insecure.html"},
|
{"insecure", "insecure.html"},
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string WideToUtf8(const std::wstring& value) {
|
|
||||||
if (value.empty()) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
const int size = WideCharToMultiByte(
|
|
||||||
CP_UTF8, 0, value.data(), static_cast<int>(value.size()),
|
|
||||||
nullptr, 0, nullptr, nullptr);
|
|
||||||
std::string result(size, '\0');
|
|
||||||
WideCharToMultiByte(
|
|
||||||
CP_UTF8, 0, value.data(), static_cast<int>(value.size()),
|
|
||||||
result.data(), size, nullptr, nullptr);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GetUrlWithoutDecoration(std::string url) {
|
std::string GetUrlWithoutDecoration(std::string url) {
|
||||||
const size_t split = url.find_first_of("?#");
|
const size_t split = url.find_first_of("?#");
|
||||||
if (split != std::string::npos) {
|
if (split != std::string::npos) {
|
||||||
@@ -64,8 +49,8 @@ std::string ToLowerAscii(std::string value) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PageFileUrl(std::wstring_view page_name) {
|
std::string PageFileUrl(std::string_view page_name) {
|
||||||
const auto path = GetUiPagePath(std::wstring(page_name));
|
const auto path = GetUiPagePath(std::string(page_name));
|
||||||
return path.empty() ? std::string{} : FilePathToUrl(path);
|
return path.empty() ? std::string{} : FilePathToUrl(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,36 +112,19 @@ const InternalPage* FindInternalPageByFileUrl(const std::string& url) {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::filesystem::path GetExecutableDirectory() {
|
std::filesystem::path GetExecutableDirectory() {
|
||||||
wchar_t exe_path[MAX_PATH] = {};
|
return nebula::platform::ExecutableDirectory();
|
||||||
const DWORD length = GetModuleFileNameW(nullptr, exe_path, MAX_PATH);
|
|
||||||
if (length == 0 || length == MAX_PATH) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::filesystem::path(exe_path).parent_path();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path GetUserDataDirectory() {
|
std::filesystem::path GetUserDataDirectory() {
|
||||||
std::filesystem::path root;
|
auto root = nebula::platform::DefaultUserDataRoot();
|
||||||
|
if (root.empty()) {
|
||||||
wchar_t buffer[MAX_PATH] = {};
|
|
||||||
// Prefer %LOCALAPPDATA% so the profile follows Chromium conventions and
|
|
||||||
// survives executable relocation.
|
|
||||||
const DWORD length =
|
|
||||||
GetEnvironmentVariableW(L"LOCALAPPDATA", buffer, MAX_PATH);
|
|
||||||
if (length > 0 && length < MAX_PATH) {
|
|
||||||
root = std::filesystem::path(buffer);
|
|
||||||
} else {
|
|
||||||
// Fall back to a directory next to the executable so a portable
|
|
||||||
// install still gets a writable profile.
|
|
||||||
root = GetExecutableDirectory();
|
root = GetExecutableDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root.empty()) {
|
if (root.empty()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path user_data = root / L"Nebula" / L"User Data";
|
std::filesystem::path user_data = root / "Nebula" / "User Data";
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
std::filesystem::create_directories(user_data, ec);
|
std::filesystem::create_directories(user_data, ec);
|
||||||
return user_data;
|
return user_data;
|
||||||
@@ -168,7 +136,7 @@ std::filesystem::path GetCacheDirectory() {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path cache = user_data / L"Cache";
|
std::filesystem::path cache = user_data / "Cache";
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
std::filesystem::create_directories(cache, ec);
|
std::filesystem::create_directories(cache, ec);
|
||||||
return cache;
|
return cache;
|
||||||
@@ -176,20 +144,25 @@ std::filesystem::path GetCacheDirectory() {
|
|||||||
|
|
||||||
std::filesystem::path GetSessionStatePath() {
|
std::filesystem::path GetSessionStatePath() {
|
||||||
auto user_data = GetUserDataDirectory();
|
auto user_data = GetUserDataDirectory();
|
||||||
return user_data.empty() ? std::filesystem::path{} : user_data / L"session_state.json";
|
return user_data.empty() ? std::filesystem::path{} : user_data / "session_state.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path GetUiPagePath(const std::wstring& page_name) {
|
std::filesystem::path GetFirstRunStatePath() {
|
||||||
|
auto user_data = GetUserDataDirectory();
|
||||||
|
return user_data.empty() ? std::filesystem::path{} : user_data / "first_run_state.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::path GetUiPagePath(const std::string& page_name) {
|
||||||
const auto exe_dir = GetExecutableDirectory();
|
const auto exe_dir = GetExecutableDirectory();
|
||||||
if (exe_dir.empty()) {
|
if (exe_dir.empty()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return exe_dir / L"ui" / L"pages" / page_name;
|
return exe_dir / "ui" / "pages" / page_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FilePathToUrl(std::filesystem::path path) {
|
std::string FilePathToUrl(std::filesystem::path path) {
|
||||||
std::string value = WideToUtf8(path.wstring());
|
std::string value = nebula::platform::PathToUtf8(path);
|
||||||
for (char& ch : value) {
|
for (char& ch : value) {
|
||||||
if (ch == '\\') {
|
if (ch == '\\') {
|
||||||
ch = '/';
|
ch = '/';
|
||||||
@@ -201,12 +174,12 @@ std::string FilePathToUrl(std::filesystem::path path) {
|
|||||||
for (char ch : value) {
|
for (char ch : value) {
|
||||||
encoded += ch == ' ' ? "%20" : std::string(1, ch);
|
encoded += ch == ' ' ? "%20" : std::string(1, ch);
|
||||||
}
|
}
|
||||||
return "file:///" + encoded;
|
return encoded.starts_with('/') ? "file://" + encoded : "file:///" + encoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetChromeUrl() {
|
std::string GetChromeUrl() {
|
||||||
const auto path = GetUiPagePath(L"chrome.html");
|
const auto path = GetUiPagePath("chrome.html");
|
||||||
const std::string fallback = PageFileUrl(L"home.html");
|
const std::string fallback = PageFileUrl("home.html");
|
||||||
return path.empty() ? (fallback.empty() ? "https://www.google.com" : fallback) : FilePathToUrl(path);
|
return path.empty() ? (fallback.empty() ? "https://www.google.com" : fallback) : FilePathToUrl(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,6 +187,10 @@ std::string GetHomeUrl() {
|
|||||||
return InternalUrlForSlug("home");
|
return InternalUrlForSlug("home");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GetSetupUrl() {
|
||||||
|
return InternalUrlForSlug("setup");
|
||||||
|
}
|
||||||
|
|
||||||
std::string GetSettingsUrl() {
|
std::string GetSettingsUrl() {
|
||||||
return InternalUrlForSlug("settings");
|
return InternalUrlForSlug("settings");
|
||||||
}
|
}
|
||||||
@@ -231,8 +208,8 @@ std::string GetGpuDiagnosticsUrl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string GetMenuPopupUrl() {
|
std::string GetMenuPopupUrl() {
|
||||||
const auto path = GetUiPagePath(L"menu-popup.html");
|
const auto path = GetUiPagePath("menu-popup.html");
|
||||||
const std::string fallback = PageFileUrl(L"home.html");
|
const std::string fallback = PageFileUrl("home.html");
|
||||||
return path.empty() ? (fallback.empty() ? "https://www.google.com" : fallback) : FilePathToUrl(path);
|
return path.empty() ? (fallback.empty() ? "https://www.google.com" : fallback) : FilePathToUrl(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -9,10 +9,12 @@ std::filesystem::path GetExecutableDirectory();
|
|||||||
std::filesystem::path GetUserDataDirectory();
|
std::filesystem::path GetUserDataDirectory();
|
||||||
std::filesystem::path GetCacheDirectory();
|
std::filesystem::path GetCacheDirectory();
|
||||||
std::filesystem::path GetSessionStatePath();
|
std::filesystem::path GetSessionStatePath();
|
||||||
std::filesystem::path GetUiPagePath(const std::wstring& page_name);
|
std::filesystem::path GetFirstRunStatePath();
|
||||||
|
std::filesystem::path GetUiPagePath(const std::string& page_name);
|
||||||
std::string FilePathToUrl(std::filesystem::path path);
|
std::string FilePathToUrl(std::filesystem::path path);
|
||||||
std::string GetChromeUrl();
|
std::string GetChromeUrl();
|
||||||
std::string GetHomeUrl();
|
std::string GetHomeUrl();
|
||||||
|
std::string GetSetupUrl();
|
||||||
std::string GetSettingsUrl();
|
std::string GetSettingsUrl();
|
||||||
std::string GetDownloadsUrl();
|
std::string GetDownloadsUrl();
|
||||||
std::string GetBigPictureUrl();
|
std::string GetBigPictureUrl();
|
||||||
|
|||||||
+13
-34
@@ -1,15 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <windows.h>
|
#include <memory>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "platform/types.h"
|
||||||
|
|
||||||
namespace nebula::window {
|
namespace nebula::window {
|
||||||
|
|
||||||
struct BrowserLayout {
|
struct NebulaWindowImpl;
|
||||||
RECT chrome = {};
|
|
||||||
RECT content = {};
|
using BrowserLayout = nebula::platform::BrowserLayout;
|
||||||
};
|
|
||||||
|
|
||||||
class WindowDelegate {
|
class WindowDelegate {
|
||||||
public:
|
public:
|
||||||
@@ -17,6 +17,7 @@ public:
|
|||||||
virtual void OnWindowCreated() = 0;
|
virtual void OnWindowCreated() = 0;
|
||||||
virtual void OnWindowResized(const BrowserLayout& layout) = 0;
|
virtual void OnWindowResized(const BrowserLayout& layout) = 0;
|
||||||
virtual void OnWindowCloseRequested() = 0;
|
virtual void OnWindowCloseRequested() = 0;
|
||||||
|
virtual void OnExternalOpenRequested(const std::string& target) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NebulaWindow {
|
class NebulaWindow {
|
||||||
@@ -24,43 +25,21 @@ public:
|
|||||||
explicit NebulaWindow(WindowDelegate* delegate);
|
explicit NebulaWindow(WindowDelegate* delegate);
|
||||||
~NebulaWindow();
|
~NebulaWindow();
|
||||||
|
|
||||||
bool Create(HINSTANCE instance, int show_command);
|
bool Create(const nebula::platform::AppStartup& startup);
|
||||||
HWND hwnd() const { return hwnd_; }
|
nebula::platform::NativeWindow native_handle() const;
|
||||||
BrowserLayout CurrentLayout(bool show_chrome = true) const;
|
BrowserLayout CurrentLayout(bool show_chrome = true) const;
|
||||||
|
|
||||||
void ResizeChild(HWND child, const RECT& rect) const;
|
void ResizeChild(nebula::platform::NativeWindow child, const nebula::platform::Rect& rect) const;
|
||||||
void Minimize();
|
void Minimize();
|
||||||
void ToggleMaximize();
|
void ToggleMaximize();
|
||||||
void SetFullscreen(bool fullscreen);
|
void SetFullscreen(bool fullscreen);
|
||||||
void Close();
|
void Close();
|
||||||
void BeginDrag();
|
void BeginDrag();
|
||||||
void SetTitle(const std::wstring& title);
|
void SetTitle(const std::string& title);
|
||||||
void EnableFrameHitTest(HWND child) const;
|
void EnableFrameHitTest(nebula::platform::NativeWindow child) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static LRESULT CALLBACK StaticWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
|
std::unique_ptr<NebulaWindowImpl> impl_;
|
||||||
static LRESULT CALLBACK ChildFrameWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
|
|
||||||
static BOOL CALLBACK EnableFrameHitTestForDescendant(HWND hwnd, LPARAM lparam);
|
|
||||||
LRESULT WndProc(UINT message, WPARAM wparam, LPARAM lparam);
|
|
||||||
|
|
||||||
void RegisterClass(HINSTANCE instance);
|
|
||||||
void NotifyResize();
|
|
||||||
void EnableFrameHitTestForWindow(HWND child) const;
|
|
||||||
LRESULT HitTest(LPARAM lparam) const;
|
|
||||||
LRESULT HitTestPoint(POINT point) const;
|
|
||||||
int ScaleForDpi(int value) const;
|
|
||||||
void UpdateDpi();
|
|
||||||
|
|
||||||
WindowDelegate* delegate_ = nullptr;
|
|
||||||
HINSTANCE instance_ = nullptr;
|
|
||||||
HWND hwnd_ = nullptr;
|
|
||||||
bool fullscreen_ = false;
|
|
||||||
LONG_PTR restore_style_ = 0;
|
|
||||||
LONG_PTR restore_ex_style_ = 0;
|
|
||||||
WINDOWPLACEMENT restore_placement_ = {sizeof(WINDOWPLACEMENT)};
|
|
||||||
UINT dpi_ = 96;
|
|
||||||
int resize_border_dip_ = 8;
|
|
||||||
int chrome_height_dip_ = 104;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace nebula::window
|
} // namespace nebula::window
|
||||||
|
|||||||
+237
-1
@@ -132,6 +132,83 @@ body.mouse-active {
|
|||||||
left: -100px;
|
left: -100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.browser-stage-frame {
|
||||||
|
position: fixed;
|
||||||
|
left: var(--browser-stage-x, 20%);
|
||||||
|
top: var(--browser-stage-y, 10%);
|
||||||
|
width: var(--browser-stage-width, 60%);
|
||||||
|
height: var(--browser-stage-height, 80%);
|
||||||
|
z-index: 3;
|
||||||
|
pointer-events: none;
|
||||||
|
border-radius: var(--bp-radius-xl);
|
||||||
|
box-shadow:
|
||||||
|
0 0 0 2px rgba(255, 255, 255, 0.08),
|
||||||
|
0 0 0 6px rgba(123, 46, 255, 0.18),
|
||||||
|
0 24px 80px rgba(0, 0, 0, 0.55),
|
||||||
|
0 0 80px var(--bp-primary-glow);
|
||||||
|
opacity: 1;
|
||||||
|
transition: opacity var(--bp-transition-normal), box-shadow var(--bp-transition-normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
.browser-stage-frame.hidden {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.virtual-cursor {
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
z-index: 250;
|
||||||
|
width: 34px;
|
||||||
|
height: 34px;
|
||||||
|
pointer-events: none;
|
||||||
|
transform: translate3d(var(--virtual-cursor-x, 50vw), var(--virtual-cursor-y, 50vh), 0);
|
||||||
|
transition: opacity var(--bp-transition-fast);
|
||||||
|
filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.55));
|
||||||
|
}
|
||||||
|
|
||||||
|
.virtual-cursor.hidden {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.virtual-cursor::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: 4px;
|
||||||
|
top: 3px;
|
||||||
|
width: 18px;
|
||||||
|
height: 24px;
|
||||||
|
background: linear-gradient(135deg, var(--bp-text), var(--bp-accent));
|
||||||
|
clip-path: polygon(0 0, 0 100%, 38% 76%, 60% 100%, 84% 86%, 62% 62%, 100% 62%);
|
||||||
|
box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45), 0 0 20px var(--bp-accent-glow);
|
||||||
|
}
|
||||||
|
|
||||||
|
.virtual-cursor-dot {
|
||||||
|
position: absolute;
|
||||||
|
left: 10px;
|
||||||
|
top: 10px;
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--bp-primary);
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.virtual-cursor.clicking .virtual-cursor-dot {
|
||||||
|
animation: virtual-cursor-click 180ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.virtual-cursor.right-clicking .virtual-cursor-dot {
|
||||||
|
background: var(--bp-warning);
|
||||||
|
animation: virtual-cursor-click 180ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes virtual-cursor-click {
|
||||||
|
0% { opacity: 0.95; transform: scale(0.8); }
|
||||||
|
100% { opacity: 0; transform: scale(4.4); }
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes glow-pulse {
|
@keyframes glow-pulse {
|
||||||
0% { transform: scale(1); opacity: 0.3; }
|
0% { transform: scale(1); opacity: 0.3; }
|
||||||
100% { transform: scale(1.2); opacity: 0.5; }
|
100% { transform: scale(1.2); opacity: 0.5; }
|
||||||
@@ -220,6 +297,15 @@ body.mouse-active {
|
|||||||
color: var(--bp-text-muted);
|
color: var(--bp-text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.status-icon.controller-status.connected {
|
||||||
|
color: var(--bp-success);
|
||||||
|
box-shadow: 0 0 20px rgba(74, 222, 128, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-icon.controller-status.disconnected {
|
||||||
|
color: var(--bp-text-dim);
|
||||||
|
}
|
||||||
|
|
||||||
.status-icon .material-symbols-outlined {
|
.status-icon .material-symbols-outlined {
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
}
|
}
|
||||||
@@ -338,8 +424,9 @@ body.mouse-active {
|
|||||||
inset: 0;
|
inset: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: var(--bp-bg);
|
background: transparent;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.webview-container.hidden {
|
.webview-container.hidden {
|
||||||
@@ -353,6 +440,155 @@ body.mouse-active {
|
|||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.native-browser-panel {
|
||||||
|
position: absolute;
|
||||||
|
top: var(--bp-spacing-md);
|
||||||
|
right: var(--bp-spacing-md);
|
||||||
|
bottom: var(--bp-spacing-md);
|
||||||
|
width: clamp(168px, 18vw, 260px);
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: var(--bp-spacing-sm);
|
||||||
|
background: linear-gradient(180deg, rgba(10,10,15,0.88) 0%, rgba(20,20,31,0.82) 100%);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
|
border-radius: var(--bp-radius-lg);
|
||||||
|
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.native-page-card {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto minmax(0, 1fr);
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--bp-spacing-sm);
|
||||||
|
padding: var(--bp-spacing-sm);
|
||||||
|
margin-bottom: var(--bp-spacing-md);
|
||||||
|
background: rgba(20, 20, 31, 0.78);
|
||||||
|
border: 2px solid var(--bp-border);
|
||||||
|
border-radius: var(--bp-radius-lg);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.native-page-card:focus,
|
||||||
|
.native-page-card.focused {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--bp-accent);
|
||||||
|
box-shadow: var(--bp-focus-ring-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.native-page-card .material-symbols-outlined {
|
||||||
|
font-size: 28px;
|
||||||
|
color: var(--bp-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.native-page-card h2 {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: var(--bp-text);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.native-page-card p {
|
||||||
|
font-size: 0.72rem;
|
||||||
|
color: var(--bp-text-muted);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.native-page-card .controller-note {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
margin-top: 4px;
|
||||||
|
color: var(--bp-accent);
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.browser-actions {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
gap: var(--bp-spacing-xs);
|
||||||
|
margin-bottom: var(--bp-spacing-lg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-button:disabled {
|
||||||
|
opacity: 0.45;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--bp-spacing-xs);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bp-tab {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||||
|
grid-template-areas:
|
||||||
|
"dot title close"
|
||||||
|
"dot url close";
|
||||||
|
align-items: center;
|
||||||
|
column-gap: var(--bp-spacing-sm);
|
||||||
|
padding: var(--bp-spacing-sm);
|
||||||
|
background: var(--bp-surface);
|
||||||
|
border: 2px solid var(--bp-border);
|
||||||
|
border-radius: var(--bp-radius-md);
|
||||||
|
color: var(--bp-text);
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bp-tab.active {
|
||||||
|
border-color: var(--bp-primary);
|
||||||
|
background: var(--bp-surface-active);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bp-tab:focus,
|
||||||
|
.bp-tab.focused {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--bp-accent);
|
||||||
|
box-shadow: var(--bp-focus-ring-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-dot {
|
||||||
|
grid-area: dot;
|
||||||
|
color: var(--bp-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-text {
|
||||||
|
grid-area: title;
|
||||||
|
font-weight: 600;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-url {
|
||||||
|
grid-area: url;
|
||||||
|
color: var(--bp-text-muted);
|
||||||
|
font-size: 0.8rem;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-close-inline {
|
||||||
|
grid-area: close;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
border-radius: var(--bp-radius-sm);
|
||||||
|
color: var(--bp-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-close-inline:hover {
|
||||||
|
background: var(--bp-danger);
|
||||||
|
color: var(--bp-text);
|
||||||
|
}
|
||||||
|
|
||||||
/* Content area */
|
/* Content area */
|
||||||
.bp-content {
|
.bp-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|||||||
+53
-32
@@ -6,10 +6,20 @@
|
|||||||
--text: #e8e8f0;
|
--text: #e8e8f0;
|
||||||
--muted: #7a7e90;
|
--muted: #7a7e90;
|
||||||
--accent: #7b2eff;
|
--accent: #7b2eff;
|
||||||
|
--primary: #7b2eff;
|
||||||
--accent-2: #00c6ff;
|
--accent-2: #00c6ff;
|
||||||
--outline: #1f2533;
|
--outline: #1f2533;
|
||||||
--outline-soft: rgba(255, 255, 255, 0.06);
|
--outline-soft: rgba(255, 255, 255, 0.06);
|
||||||
--danger: #e0445c;
|
--danger: #e0445c;
|
||||||
|
--url-bar-bg: #1c2030;
|
||||||
|
--url-bar-text: #e0e0e0;
|
||||||
|
--url-bar-border: #3e4652;
|
||||||
|
--tab-bg: #161925;
|
||||||
|
--tab-text: #a4a7b3;
|
||||||
|
--tab-active: #1c2030;
|
||||||
|
--tab-active-text: #e0e0e0;
|
||||||
|
--tab-border: #2b3040;
|
||||||
|
--chrome-hover: color-mix(in srgb, var(--text) 10%, transparent);
|
||||||
color-scheme: dark;
|
color-scheme: dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,9 +69,10 @@ button:disabled {
|
|||||||
|
|
||||||
.nebula-chrome {
|
.nebula-chrome {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-rows: 42px 52px;
|
grid-template-rows: 42px 52px 1fr;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border-bottom: 1px solid var(--outline);
|
border-bottom: 1px solid var(--outline);
|
||||||
|
overflow: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Title row ──────────────────────────────────────────────── */
|
/* ── Title row ──────────────────────────────────────────────── */
|
||||||
@@ -78,6 +89,10 @@ button:disabled {
|
|||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.platform-macos .title-row {
|
||||||
|
padding: 0 12px 0 78px;
|
||||||
|
}
|
||||||
|
|
||||||
/* ── Tabs ───────────────────────────────────────────────────── */
|
/* ── Tabs ───────────────────────────────────────────────────── */
|
||||||
|
|
||||||
.tabs {
|
.tabs {
|
||||||
@@ -101,21 +116,21 @@ button:disabled {
|
|||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: var(--muted);
|
color: var(--tab-text);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 0.82rem;
|
font-size: 0.82rem;
|
||||||
transition: background 120ms, color 120ms;
|
transition: background 120ms, color 120ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab:hover:not(.active) {
|
.tab:hover:not(.active) {
|
||||||
background: var(--surface);
|
background: var(--tab-bg);
|
||||||
color: var(--text);
|
color: var(--tab-active-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab.active {
|
.tab.active {
|
||||||
background: var(--surface-raised);
|
background: var(--tab-active);
|
||||||
border-color: var(--outline);
|
border-color: var(--tab-border);
|
||||||
color: var(--text);
|
color: var(--tab-active-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-title {
|
.tab-title {
|
||||||
@@ -138,7 +153,7 @@ button:disabled {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
background: var(--accent);
|
background: var(--primary);
|
||||||
opacity: 0.85;
|
opacity: 0.85;
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -165,8 +180,8 @@ button:disabled {
|
|||||||
.tab-loading {
|
.tab-loading {
|
||||||
width: 13px;
|
width: 13px;
|
||||||
height: 13px;
|
height: 13px;
|
||||||
border: 2px solid rgba(0, 198, 255, 0.2);
|
border: 2px solid color-mix(in srgb, var(--accent) 20%, transparent);
|
||||||
border-top-color: var(--accent-2);
|
border-top-color: var(--accent);
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
animation: spin 0.8s linear infinite;
|
animation: spin 0.8s linear infinite;
|
||||||
}
|
}
|
||||||
@@ -180,7 +195,7 @@ button:disabled {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: var(--muted);
|
color: var(--tab-text);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: background 120ms, color 120ms, opacity 120ms;
|
transition: background 120ms, color 120ms, opacity 120ms;
|
||||||
}
|
}
|
||||||
@@ -192,8 +207,8 @@ button:disabled {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tab-close:hover {
|
.tab-close:hover {
|
||||||
background: var(--surface-hover);
|
background: var(--chrome-hover);
|
||||||
color: var(--text);
|
color: var(--tab-active-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-add {
|
.tab-add {
|
||||||
@@ -206,14 +221,14 @@ button:disabled {
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: var(--muted);
|
color: var(--tab-text);
|
||||||
transition: background 120ms, color 120ms, border-color 120ms;
|
transition: background 120ms, color 120ms, border-color 120ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-add:hover {
|
.tab-add:hover {
|
||||||
background: var(--surface-hover);
|
background: var(--chrome-hover);
|
||||||
border-color: var(--outline);
|
border-color: var(--tab-border);
|
||||||
color: var(--text);
|
color: var(--tab-active-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Window controls ────────────────────────────────────────── */
|
/* ── Window controls ────────────────────────────────────────── */
|
||||||
@@ -232,13 +247,13 @@ button:disabled {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 46px;
|
width: 46px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: var(--muted);
|
color: var(--tab-text);
|
||||||
transition: background 100ms, color 100ms;
|
transition: background 100ms, color 100ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
.window-controls button:hover {
|
.window-controls button:hover {
|
||||||
background: var(--surface-hover);
|
background: var(--chrome-hover);
|
||||||
color: var(--text);
|
color: var(--tab-active-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
.window-controls .close:hover {
|
.window-controls .close:hover {
|
||||||
@@ -246,13 +261,18 @@ button:disabled {
|
|||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.platform-macos .window-controls {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
/* ── Toolbar ────────────────────────────────────────────────── */
|
/* ── Toolbar ────────────────────────────────────────────────── */
|
||||||
|
|
||||||
.toolbar {
|
.toolbar {
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
padding: 0 12px;
|
padding: 0 12px;
|
||||||
background: var(--surface-raised);
|
background: var(--tab-active);
|
||||||
border-top: 1px solid var(--outline);
|
border-top: 1px solid var(--tab-border);
|
||||||
|
overflow: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Lucide icon sizing ─────────────────────────────────────── */
|
/* ── Lucide icon sizing ─────────────────────────────────────── */
|
||||||
@@ -281,15 +301,15 @@ button:disabled {
|
|||||||
border-radius: 9px;
|
border-radius: 9px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
color: var(--muted);
|
color: var(--tab-text);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
transition: background 120ms, color 120ms, border-color 120ms;
|
transition: background 120ms, color 120ms, border-color 120ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-button:hover:not(:disabled) {
|
.icon-button:hover:not(:disabled) {
|
||||||
background: var(--surface-hover);
|
background: var(--chrome-hover);
|
||||||
border-color: var(--outline);
|
border-color: var(--tab-border);
|
||||||
color: var(--text);
|
color: var(--tab-active-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Address bar ────────────────────────────────────────────── */
|
/* ── Address bar ────────────────────────────────────────────── */
|
||||||
@@ -303,15 +323,15 @@ button:disabled {
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
margin: 0 4px;
|
margin: 0 4px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border: 1px solid var(--outline);
|
border: 1px solid var(--url-bar-border);
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
background: var(--surface);
|
background: var(--url-bar-bg);
|
||||||
transition: border-color 140ms, box-shadow 140ms;
|
transition: border-color 140ms, box-shadow 140ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
.address-shell:focus-within {
|
.address-shell:focus-within {
|
||||||
border-color: rgba(123, 46, 255, 0.55);
|
border-color: color-mix(in srgb, var(--primary) 70%, var(--url-bar-border));
|
||||||
box-shadow: 0 0 0 3px rgba(123, 46, 255, 0.12);
|
box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
.address-shell input {
|
.address-shell input {
|
||||||
@@ -321,12 +341,12 @@ button:disabled {
|
|||||||
outline: 0;
|
outline: 0;
|
||||||
padding: 0 16px;
|
padding: 0 16px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: var(--text);
|
color: var(--url-bar-text);
|
||||||
font-size: 0.84rem;
|
font-size: 0.84rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.address-shell input::placeholder {
|
.address-shell input::placeholder {
|
||||||
color: var(--muted);
|
color: color-mix(in srgb, var(--url-bar-text) 55%, transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress-bar {
|
.progress-bar {
|
||||||
@@ -361,3 +381,4 @@ button:disabled {
|
|||||||
transform: rotate(360deg);
|
transform: rotate(360deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+31
-21
@@ -1,34 +1,40 @@
|
|||||||
:root {
|
:root {
|
||||||
--bg: #0b0d10;
|
--surface-raised: #141824;
|
||||||
--primary: #7b2eff;
|
--surface-hover: rgba(255, 255, 255, 0.06);
|
||||||
--accent: #00c6ff;
|
--text: #e8e8f0;
|
||||||
--text: #e0e0e0;
|
--muted: #7a7e90;
|
||||||
--url-bar-bg: #1c2030;
|
--outline: #1f2533;
|
||||||
--url-bar-border: #3e4652;
|
color-scheme: dark;
|
||||||
--shadow-1: 0 12px 30px rgba(0, 0, 0, 0.35);
|
}
|
||||||
--blur: 12px;
|
|
||||||
|
@font-face {
|
||||||
|
font-family: "InterVariable";
|
||||||
|
src: url("../assets/fonts/InterVariable.ttf") format("truetype");
|
||||||
|
font-weight: 100 900;
|
||||||
|
font-display: swap;
|
||||||
}
|
}
|
||||||
|
|
||||||
* { box-sizing: border-box; }
|
* { box-sizing: border-box; }
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
background: transparent;
|
background: var(--surface-raised);
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
|
font-family: "InterVariable", "Segoe UI", system-ui, sans-serif;
|
||||||
|
overflow: hidden;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#menu-popup {
|
#menu-popup {
|
||||||
background: color-mix(in srgb, var(--url-bar-bg) 92%, var(--text) 8%);
|
width: 100%;
|
||||||
border: 1px solid color-mix(in srgb, var(--primary) 25%, color-mix(in srgb, var(--accent) 18%, transparent));
|
height: 100%;
|
||||||
border-radius: 14px;
|
background: var(--surface-raised);
|
||||||
padding: 8px;
|
border: 1px solid var(--outline);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 6px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
min-width: 220px;
|
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
|
||||||
box-shadow: var(--shadow-1);
|
|
||||||
-webkit-backdrop-filter: blur(var(--blur));
|
|
||||||
backdrop-filter: blur(var(--blur));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#menu-popup button {
|
#menu-popup button {
|
||||||
@@ -37,13 +43,15 @@ body {
|
|||||||
color: var(--text);
|
color: var(--text);
|
||||||
text-align: left;
|
text-align: left;
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
border-radius: 10px;
|
border-radius: 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background 120ms ease, filter 120ms ease;
|
font: inherit;
|
||||||
|
font-size: 0.84rem;
|
||||||
|
transition: background 120ms ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
#menu-popup button:hover {
|
#menu-popup button:hover {
|
||||||
background: color-mix(in srgb, var(--text) 8%, transparent);
|
background: var(--surface-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
.zoom-controls {
|
.zoom-controls {
|
||||||
@@ -63,4 +71,6 @@ body {
|
|||||||
#zoom-percent {
|
#zoom-percent {
|
||||||
min-width: 54px;
|
min-width: 54px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 0.82rem;
|
||||||
}
|
}
|
||||||
|
|||||||
+800
-2780
File diff suppressed because it is too large
Load Diff
+120
-1
@@ -1,5 +1,24 @@
|
|||||||
const SEARCH_URL = 'https://www.google.com/search?q=';
|
const SEARCH_URL = 'https://www.google.com/search?q=';
|
||||||
|
|
||||||
|
const DEFAULT_THEME = {
|
||||||
|
colors: {
|
||||||
|
bg: '#080a0f',
|
||||||
|
darkBlue: '#0e1119',
|
||||||
|
darkPurple: '#141824',
|
||||||
|
primary: '#7b2eff',
|
||||||
|
accent: '#00c6ff',
|
||||||
|
text: '#e8e8f0',
|
||||||
|
urlBarBg: '#1c2030',
|
||||||
|
urlBarText: '#e0e0e0',
|
||||||
|
urlBarBorder: '#3e4652',
|
||||||
|
tabBg: '#161925',
|
||||||
|
tabText: '#a4a7b3',
|
||||||
|
tabActive: '#1c2030',
|
||||||
|
tabActiveText: '#e0e0e0',
|
||||||
|
tabBorder: '#2b3040'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
id: 1,
|
id: 1,
|
||||||
url: '',
|
url: '',
|
||||||
@@ -9,9 +28,97 @@ const state = {
|
|||||||
canGoBack: false,
|
canGoBack: false,
|
||||||
canGoForward: false,
|
canGoForward: false,
|
||||||
favicon: '',
|
favicon: '',
|
||||||
|
platform: detectHostPlatform(),
|
||||||
tabs: []
|
tabs: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function detectHostPlatform() {
|
||||||
|
const platform = `${navigator.userAgentData?.platform || ''} ${navigator.platform || ''} ${navigator.userAgent || ''}`.toLowerCase();
|
||||||
|
if (platform.includes('mac')) return 'macos';
|
||||||
|
if (platform.includes('win')) return 'windows';
|
||||||
|
if (platform.includes('linux')) return 'linux';
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyPlatform(platform) {
|
||||||
|
const normalized = ['macos', 'windows', 'linux'].includes(platform) ? platform : 'unknown';
|
||||||
|
document.body.classList.remove('platform-macos', 'platform-windows', 'platform-linux', 'platform-unknown');
|
||||||
|
document.body.classList.add(`platform-${normalized}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hexToRgb(hex) {
|
||||||
|
if (!hex || typeof hex !== 'string') return null;
|
||||||
|
let normalized = hex.trim().replace(/^#/, '');
|
||||||
|
if (normalized.length === 3) {
|
||||||
|
normalized = normalized.split('').map(char => char + char).join('');
|
||||||
|
}
|
||||||
|
if (!/^[a-fA-F\d]{6}$/.test(normalized)) return null;
|
||||||
|
|
||||||
|
const value = parseInt(normalized, 16);
|
||||||
|
return {
|
||||||
|
r: (value >> 16) & 255,
|
||||||
|
g: (value >> 8) & 255,
|
||||||
|
b: value & 255
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function isDarkColor(hex) {
|
||||||
|
const rgb = hexToRgb(hex);
|
||||||
|
if (!rgb) return true;
|
||||||
|
const luminance = (0.2126 * rgb.r + 0.7152 * rgb.g + 0.0722 * rgb.b) / 255;
|
||||||
|
return luminance < 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCssVar(name, value, fallback) {
|
||||||
|
document.documentElement.style.setProperty(name, value || fallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeTheme(theme) {
|
||||||
|
const colors = theme?.colors || {};
|
||||||
|
return {
|
||||||
|
...DEFAULT_THEME,
|
||||||
|
...(theme || {}),
|
||||||
|
colors: {
|
||||||
|
...DEFAULT_THEME.colors,
|
||||||
|
...colors
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyTheme(theme) {
|
||||||
|
const normalized = normalizeTheme(theme);
|
||||||
|
const colors = normalized.colors;
|
||||||
|
|
||||||
|
setCssVar('--bg', colors.bg, DEFAULT_THEME.colors.bg);
|
||||||
|
setCssVar('--surface', colors.darkBlue, DEFAULT_THEME.colors.darkBlue);
|
||||||
|
setCssVar('--surface-raised', colors.darkPurple, DEFAULT_THEME.colors.darkPurple);
|
||||||
|
setCssVar('--text', colors.text, DEFAULT_THEME.colors.text);
|
||||||
|
setCssVar('--muted', colors.tabText, DEFAULT_THEME.colors.tabText);
|
||||||
|
setCssVar('--primary', colors.primary, DEFAULT_THEME.colors.primary);
|
||||||
|
setCssVar('--accent', colors.accent, DEFAULT_THEME.colors.accent);
|
||||||
|
setCssVar('--accent-2', colors.accent, DEFAULT_THEME.colors.accent);
|
||||||
|
setCssVar('--outline', colors.tabBorder, DEFAULT_THEME.colors.tabBorder);
|
||||||
|
setCssVar('--url-bar-bg', colors.urlBarBg, colors.darkBlue);
|
||||||
|
setCssVar('--url-bar-text', colors.urlBarText, colors.text);
|
||||||
|
setCssVar('--url-bar-border', colors.urlBarBorder, colors.primary);
|
||||||
|
setCssVar('--tab-bg', colors.tabBg, colors.darkBlue);
|
||||||
|
setCssVar('--tab-text', colors.tabText, colors.text);
|
||||||
|
setCssVar('--tab-active', colors.tabActive, colors.darkPurple);
|
||||||
|
setCssVar('--tab-active-text', colors.tabActiveText, colors.text);
|
||||||
|
setCssVar('--tab-border', colors.tabBorder, colors.darkBlue);
|
||||||
|
|
||||||
|
document.documentElement.style.colorScheme = isDarkColor(colors.bg) ? 'dark' : 'light';
|
||||||
|
}
|
||||||
|
|
||||||
|
function applySavedTheme() {
|
||||||
|
try {
|
||||||
|
const savedTheme = localStorage.getItem('currentTheme');
|
||||||
|
if (savedTheme) applyTheme(JSON.parse(savedTheme));
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('[Chrome] Failed to apply saved theme:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toNavigationUrl(input) {
|
function toNavigationUrl(input) {
|
||||||
const value = (input || '').trim();
|
const value = (input || '').trim();
|
||||||
if (!value) return null;
|
if (!value) return null;
|
||||||
@@ -99,6 +206,7 @@ function renderTabs() {
|
|||||||
|
|
||||||
function applyState(nextState) {
|
function applyState(nextState) {
|
||||||
Object.assign(state, nextState || {});
|
Object.assign(state, nextState || {});
|
||||||
|
applyPlatform(state.platform);
|
||||||
|
|
||||||
const title = state.title || 'New Tab';
|
const title = state.title || 'New Tab';
|
||||||
const url = state.url || '';
|
const url = state.url || '';
|
||||||
@@ -123,6 +231,7 @@ function applyState(nextState) {
|
|||||||
|
|
||||||
progressBar.style.width = `${Math.max(0, Math.min(1, state.progress || 0)) * 100}%`;
|
progressBar.style.width = `${Math.max(0, Math.min(1, state.progress || 0)) * 100}%`;
|
||||||
progressBar.style.opacity = state.isLoading ? '1' : '0';
|
progressBar.style.opacity = state.isLoading ? '1' : '0';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function wireCommands() {
|
function wireCommands() {
|
||||||
@@ -174,9 +283,19 @@ function wireCommands() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.NebulaChrome = { applyState, postCommand, toNavigationUrl };
|
window.NebulaChrome = { applyState, applyTheme, postCommand, toNavigationUrl };
|
||||||
|
|
||||||
|
window.addEventListener('storage', event => {
|
||||||
|
if (event.key !== 'currentTheme' || !event.newValue) return;
|
||||||
|
try {
|
||||||
|
applyTheme(JSON.parse(event.newValue));
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('[Chrome] Failed to apply updated theme:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
applySavedTheme();
|
||||||
wireCommands();
|
wireCommands();
|
||||||
applyState(state);
|
applyState(state);
|
||||||
});
|
});
|
||||||
|
|||||||
+12
-4
@@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class BrowserCustomizer {
|
class BrowserCustomizer {
|
||||||
constructor() {
|
constructor(options = {}) {
|
||||||
this.defaultTheme = {
|
this.defaultTheme = {
|
||||||
name: 'Default',
|
name: 'Default',
|
||||||
colors: {
|
colors: {
|
||||||
@@ -286,6 +286,10 @@ class BrowserCustomizer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (options.skipInit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.currentTheme = this.loadTheme();
|
this.currentTheme = this.loadTheme();
|
||||||
this.activeThemeName = this.loadActiveThemeName();
|
this.activeThemeName = this.loadActiveThemeName();
|
||||||
this.init();
|
this.init();
|
||||||
@@ -584,9 +588,13 @@ class BrowserCustomizer {
|
|||||||
// This will be called to apply theme to home.html and other pages
|
// This will be called to apply theme to home.html and other pages
|
||||||
this.saveTheme();
|
this.saveTheme();
|
||||||
|
|
||||||
// Send theme update to host (for settings webview)
|
const themePayload = JSON.stringify(this.currentTheme);
|
||||||
if (window.electronAPI && typeof window.electronAPI.sendToHost === 'function') {
|
|
||||||
window.electronAPI.sendToHost('theme-update', this.currentTheme);
|
// Send theme update to host so the separate chrome browser can update live.
|
||||||
|
if (window.nebulaNative && typeof window.nebulaNative.postMessage === 'function') {
|
||||||
|
window.nebulaNative.postMessage('theme-update', themePayload);
|
||||||
|
} else if (window.electronAPI && typeof window.electronAPI.sendToHost === 'function') {
|
||||||
|
window.electronAPI.sendToHost('theme-update', themePayload);
|
||||||
}
|
}
|
||||||
// Fallback: send via postMessage (for iframe embedding)
|
// Fallback: send via postMessage (for iframe embedding)
|
||||||
try {
|
try {
|
||||||
|
|||||||
+11
-19
@@ -18,37 +18,29 @@ function applyTheme(theme) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendMenuCommand(cmd) {
|
function sendMenuCommand(cmd) {
|
||||||
if (window.electronAPI?.send) {
|
|
||||||
window.electronAPI.send('menu-popup-command', { cmd });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window.nebulaNative?.postMessage) {
|
if (window.nebulaNative?.postMessage) {
|
||||||
window.nebulaNative.postMessage(cmd);
|
window.nebulaNative.postMessage(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refreshZoom() {
|
function formatZoomPercent(zoomLevel) {
|
||||||
if (!window.electronAPI?.invoke || !zoomPercentEl) return;
|
const level = Number.isFinite(zoomLevel) ? zoomLevel : 0;
|
||||||
try {
|
return `${Math.round(Math.pow(1.2, level) * 100)}%`;
|
||||||
const z = await window.electronAPI.invoke('get-zoom-factor');
|
|
||||||
zoomPercentEl.textContent = `${Math.round(z * 100)}%`;
|
|
||||||
} catch {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.electronAPI?.on?.('menu-popup-init', (payload) => {
|
function setZoomLevel(zoomLevel) {
|
||||||
applyTheme(payload?.theme);
|
if (zoomPercentEl) {
|
||||||
refreshZoom();
|
zoomPercentEl.textContent = formatZoomPercent(zoomLevel);
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.NebulaMenuPopup = { applyTheme, setZoomLevel };
|
||||||
|
|
||||||
window.addEventListener('click', (e) => {
|
window.addEventListener('click', (e) => {
|
||||||
const btn = e.target.closest('button[data-cmd]');
|
const btn = e.target.closest('button[data-cmd]');
|
||||||
if (!btn) return;
|
if (!btn) return;
|
||||||
const cmd = btn.getAttribute('data-cmd');
|
const cmd = btn.getAttribute('data-cmd');
|
||||||
sendMenuCommand(cmd);
|
sendMenuCommand(cmd);
|
||||||
if (cmd === 'zoom-in' || cmd === 'zoom-out') {
|
|
||||||
setTimeout(refreshZoom, 50);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('keydown', (e) => {
|
window.addEventListener('keydown', (e) => {
|
||||||
@@ -57,4 +49,4 @@ window.addEventListener('keydown', (e) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
refreshZoom();
|
setZoomLevel(0);
|
||||||
|
|||||||
+112
-3
@@ -12,6 +12,109 @@ const HOME_SEARCH_Y_KEY = 'nebula-home-search-y'; // number (vh)
|
|||||||
const HOME_BOOKMARKS_Y_KEY = 'nebula-home-bookmarks-y'; // number (vh)
|
const HOME_BOOKMARKS_Y_KEY = 'nebula-home-bookmarks-y'; // number (vh)
|
||||||
const HOME_GLANCE_CORNER_KEY = 'nebula-home-glance-corner'; // 'br'|'bl'|'tr'|'tl'
|
const HOME_GLANCE_CORNER_KEY = 'nebula-home-glance-corner'; // 'br'|'bl'|'tr'|'tl'
|
||||||
const DISPLAY_SCALE_KEY = 'nebula-display-scale'; // number (50-300)
|
const DISPLAY_SCALE_KEY = 'nebula-display-scale'; // number (50-300)
|
||||||
|
const defaultBrowserRequests = new Map();
|
||||||
|
let defaultBrowserRequestId = 0;
|
||||||
|
|
||||||
|
function hasNebulaNativeBridge() {
|
||||||
|
return !!(window.nebulaNative && typeof window.nebulaNative.postMessage === 'function');
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('nebula-default-browser-result', (event) => {
|
||||||
|
const detail = event.detail || {};
|
||||||
|
const pending = defaultBrowserRequests.get(detail.requestId);
|
||||||
|
if (!pending) return;
|
||||||
|
|
||||||
|
defaultBrowserRequests.delete(detail.requestId);
|
||||||
|
pending.resolve(detail);
|
||||||
|
});
|
||||||
|
|
||||||
|
function sendDefaultBrowserRequest(command) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!hasNebulaNativeBridge()) {
|
||||||
|
reject(new Error('Native browser integration is unavailable.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestId = `settings-default-browser-${Date.now()}-${++defaultBrowserRequestId}`;
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
defaultBrowserRequests.delete(requestId);
|
||||||
|
reject(new Error('Timed out waiting for default browser status.'));
|
||||||
|
}, 10000);
|
||||||
|
|
||||||
|
defaultBrowserRequests.set(requestId, {
|
||||||
|
resolve: (value) => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
resolve(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
window.nebulaNative.postMessage(command, requestId);
|
||||||
|
} catch (error) {
|
||||||
|
defaultBrowserRequests.delete(requestId);
|
||||||
|
clearTimeout(timeout);
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refreshDefaultBrowserStatus() {
|
||||||
|
const btn = document.getElementById('set-default-browser-btn');
|
||||||
|
const status = document.getElementById('default-browser-status');
|
||||||
|
if (!btn || !status) return;
|
||||||
|
|
||||||
|
if (!hasNebulaNativeBridge()) {
|
||||||
|
btn.disabled = true;
|
||||||
|
status.textContent = 'Default browser setup is only available in the native app.';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await sendDefaultBrowserRequest('check-default-browser');
|
||||||
|
btn.disabled = !!result.isDefault;
|
||||||
|
btn.textContent = result.isDefault ? 'Already Default' : 'Make Default Browser';
|
||||||
|
status.textContent = result.isDefault
|
||||||
|
? 'Nebula is your default browser.'
|
||||||
|
: 'Nebula is not your default browser.';
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Default browser status error:', error);
|
||||||
|
status.textContent = 'Unable to check default browser status.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function attachDefaultBrowserHandler() {
|
||||||
|
const btn = document.getElementById('set-default-browser-btn');
|
||||||
|
const status = document.getElementById('default-browser-status');
|
||||||
|
if (!btn || !status) return;
|
||||||
|
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.textContent = 'Opening Settings...';
|
||||||
|
status.textContent = 'Opening Windows default apps settings...';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await sendDefaultBrowserRequest('set-default-browser');
|
||||||
|
if (result.isDefault) {
|
||||||
|
btn.textContent = 'Already Default';
|
||||||
|
status.textContent = 'Nebula is your default browser.';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
btn.disabled = false;
|
||||||
|
btn.textContent = 'Check Again';
|
||||||
|
status.textContent = result.success
|
||||||
|
? 'Choose Nebula in Windows default apps settings, then check again.'
|
||||||
|
: (result.error || 'Unable to open default browser settings.');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Default browser setup error:', error);
|
||||||
|
btn.disabled = false;
|
||||||
|
btn.textContent = 'Try Again';
|
||||||
|
status.textContent = 'Unable to open default browser settings.';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
refreshDefaultBrowserStatus();
|
||||||
|
}
|
||||||
|
|
||||||
function showStatus(message) {
|
function showStatus(message) {
|
||||||
if (statusText && statusDiv) {
|
if (statusText && statusDiv) {
|
||||||
@@ -65,7 +168,7 @@ function attachClearHandler(btn) {
|
|||||||
} finally {
|
} finally {
|
||||||
const currentTheme = window.browserCustomizer ? window.browserCustomizer.currentTheme : null;
|
const currentTheme = window.browserCustomizer ? window.browserCustomizer.currentTheme : null;
|
||||||
if (currentTheme && window.electronAPI && typeof window.electronAPI.sendToHost === 'function') {
|
if (currentTheme && window.electronAPI && typeof window.electronAPI.sendToHost === 'function') {
|
||||||
window.electronAPI.sendToHost('theme-update', currentTheme);
|
window.electronAPI.sendToHost('theme-update', JSON.stringify(currentTheme));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -74,6 +177,8 @@ function attachClearHandler(btn) {
|
|||||||
// Try attaching immediately, and again on DOMContentLoaded
|
// Try attaching immediately, and again on DOMContentLoaded
|
||||||
attachClearHandler(clearBtn);
|
attachClearHandler(clearBtn);
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
|
attachDefaultBrowserHandler();
|
||||||
|
|
||||||
if (!clearBtn) {
|
if (!clearBtn) {
|
||||||
clearBtn = document.getElementById('clear-data-btn');
|
clearBtn = document.getElementById('clear-data-btn');
|
||||||
attachClearHandler(clearBtn);
|
attachClearHandler(clearBtn);
|
||||||
@@ -773,7 +878,9 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
try {
|
try {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const url = gh.getAttribute('href');
|
const url = gh.getAttribute('href');
|
||||||
if (window.electronAPI && typeof window.electronAPI.sendToHost === 'function') {
|
if (window.nebulaNative && typeof window.nebulaNative.postMessage === 'function') {
|
||||||
|
window.nebulaNative.postMessage('new-tab', url);
|
||||||
|
} else if (window.electronAPI && typeof window.electronAPI.sendToHost === 'function') {
|
||||||
window.electronAPI.sendToHost('navigate', url, { newTab: true });
|
window.electronAPI.sendToHost('navigate', url, { newTab: true });
|
||||||
} else if (window.parent && window.parent !== window) {
|
} else if (window.parent && window.parent !== window) {
|
||||||
window.parent.postMessage({ type: 'navigate', url, newTab: true }, '*');
|
window.parent.postMessage({ type: 'navigate', url, newTab: true }, '*');
|
||||||
@@ -792,7 +899,9 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
try {
|
try {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const url = help.getAttribute('href');
|
const url = help.getAttribute('href');
|
||||||
if (window.electronAPI && typeof window.electronAPI.sendToHost === 'function') {
|
if (window.nebulaNative && typeof window.nebulaNative.postMessage === 'function') {
|
||||||
|
window.nebulaNative.postMessage('new-tab', url);
|
||||||
|
} else if (window.electronAPI && typeof window.electronAPI.sendToHost === 'function') {
|
||||||
window.electronAPI.sendToHost('navigate', url, { newTab: true });
|
window.electronAPI.sendToHost('navigate', url, { newTab: true });
|
||||||
} else if (window.parent && window.parent !== window) {
|
} else if (window.parent && window.parent !== window) {
|
||||||
window.parent.postMessage({ type: 'navigate', url, newTab: true }, '*');
|
window.parent.postMessage({ type: 'navigate', url, newTab: true }, '*');
|
||||||
|
|||||||
+146
-21
@@ -12,17 +12,130 @@ const setupState = {
|
|||||||
themes: []
|
themes: []
|
||||||
};
|
};
|
||||||
|
|
||||||
const nativeApi = window.api || {
|
function hasNebulaNativeBridge() {
|
||||||
async getAllThemes() {
|
return !!(window.nebulaNative && typeof window.nebulaNative.postMessage === 'function');
|
||||||
return {
|
}
|
||||||
default: {
|
|
||||||
default: {
|
const defaultBrowserRequests = new Map();
|
||||||
name: 'Default',
|
let defaultBrowserRequestId = 0;
|
||||||
description: 'Classic Nebula theme',
|
|
||||||
colors: { bg: '#121418', primary: '#7B2EFF', accent: '#00C6FF', text: '#E0E0E0' }
|
window.addEventListener('nebula-default-browser-result', (event) => {
|
||||||
}
|
const detail = event.detail || {};
|
||||||
|
const pending = defaultBrowserRequests.get(detail.requestId);
|
||||||
|
if (!pending) return;
|
||||||
|
|
||||||
|
defaultBrowserRequests.delete(detail.requestId);
|
||||||
|
pending.resolve(detail);
|
||||||
|
});
|
||||||
|
|
||||||
|
function sendDefaultBrowserRequest(command) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!hasNebulaNativeBridge()) {
|
||||||
|
reject(new Error('Native browser integration is unavailable.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestId = `default-browser-${Date.now()}-${++defaultBrowserRequestId}`;
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
defaultBrowserRequests.delete(requestId);
|
||||||
|
reject(new Error('Timed out waiting for default browser status.'));
|
||||||
|
}, 10000);
|
||||||
|
|
||||||
|
defaultBrowserRequests.set(requestId, {
|
||||||
|
resolve: (value) => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
resolve(value);
|
||||||
|
},
|
||||||
|
reject: (error) => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
reject(error);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
window.nebulaNative.postMessage(command, requestId);
|
||||||
|
} catch (error) {
|
||||||
|
defaultBrowserRequests.delete(requestId);
|
||||||
|
clearTimeout(timeout);
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function createNebulaNativeApi() {
|
||||||
|
return {
|
||||||
|
async getAllThemes() {
|
||||||
|
return { default: getPresetThemes() };
|
||||||
|
},
|
||||||
|
async isDefaultBrowser() {
|
||||||
|
const result = await sendDefaultBrowserRequest('check-default-browser');
|
||||||
|
return !!result.isDefault;
|
||||||
|
},
|
||||||
|
async setAsDefaultBrowser() {
|
||||||
|
return sendDefaultBrowserRequest('set-default-browser');
|
||||||
|
},
|
||||||
|
async applyTheme(themeId) {
|
||||||
|
const theme = getThemeById(themeId);
|
||||||
|
if (theme) {
|
||||||
|
localStorage.setItem('currentTheme', JSON.stringify(normalizeTheme(theme)));
|
||||||
|
}
|
||||||
|
localStorage.setItem('activeThemeName', themeId);
|
||||||
|
},
|
||||||
|
async completeFirstRun(data) {
|
||||||
|
localStorage.setItem('nebula-first-run-complete', JSON.stringify(data));
|
||||||
|
window.nebulaNative.postMessage('complete-first-run', JSON.stringify(data));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPresetThemes() {
|
||||||
|
if (typeof BrowserCustomizer === 'function') {
|
||||||
|
const customizer = new BrowserCustomizer({ skipInit: true });
|
||||||
|
return customizer.predefinedThemes || { default: customizer.defaultTheme };
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
default: {
|
||||||
|
name: 'Default',
|
||||||
|
colors: {
|
||||||
|
bg: '#121418',
|
||||||
|
darkBlue: '#0B1C2B',
|
||||||
|
darkPurple: '#1B1035',
|
||||||
|
primary: '#7B2EFF',
|
||||||
|
accent: '#00C6FF',
|
||||||
|
text: '#E0E0E0',
|
||||||
|
urlBarBg: '#1C2030',
|
||||||
|
urlBarText: '#E0E0E0',
|
||||||
|
urlBarBorder: '#3E4652',
|
||||||
|
tabBg: '#161925',
|
||||||
|
tabText: '#A4A7B3',
|
||||||
|
tabActive: '#1C2030',
|
||||||
|
tabActiveText: '#E0E0E0',
|
||||||
|
tabBorder: '#2B3040'
|
||||||
|
},
|
||||||
|
layout: 'centered',
|
||||||
|
showLogo: true,
|
||||||
|
customTitle: 'Nebula Browser',
|
||||||
|
gradient: 'linear-gradient(145deg, #121418 0%, #1B1035 100%)'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeTheme(theme) {
|
||||||
|
const fallback = getPresetThemes().default;
|
||||||
|
return {
|
||||||
|
...fallback,
|
||||||
|
...(theme || {}),
|
||||||
|
colors: {
|
||||||
|
...fallback.colors,
|
||||||
|
...((theme && theme.colors) || {})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const fallbackApi = {
|
||||||
|
async getAllThemes() {
|
||||||
|
return { default: getPresetThemes() };
|
||||||
},
|
},
|
||||||
async isDefaultBrowser() {
|
async isDefaultBrowser() {
|
||||||
return false;
|
return false;
|
||||||
@@ -31,13 +144,22 @@ const nativeApi = window.api || {
|
|||||||
return { success: false, error: 'Default browser setup is handled by the native CEF app.' };
|
return { success: false, error: 'Default browser setup is handled by the native CEF app.' };
|
||||||
},
|
},
|
||||||
async applyTheme(themeId) {
|
async applyTheme(themeId) {
|
||||||
|
const theme = getThemeById(themeId);
|
||||||
|
if (theme) {
|
||||||
|
localStorage.setItem('currentTheme', JSON.stringify(normalizeTheme(theme)));
|
||||||
|
}
|
||||||
localStorage.setItem('activeThemeName', themeId);
|
localStorage.setItem('activeThemeName', themeId);
|
||||||
},
|
},
|
||||||
async completeFirstRun(data) {
|
async completeFirstRun(data) {
|
||||||
localStorage.setItem('nebula-first-run-complete', JSON.stringify(data));
|
localStorage.setItem('nebula-first-run-complete', JSON.stringify(data));
|
||||||
|
if (hasNebulaNativeBridge()) {
|
||||||
|
window.nebulaNative.postMessage('complete-first-run', JSON.stringify(data));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const nativeApi = window.api || (hasNebulaNativeBridge() ? createNebulaNativeApi() : fallbackApi);
|
||||||
|
|
||||||
// Initialize setup when DOM is ready
|
// Initialize setup when DOM is ready
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
console.log('[Setup] Initializing first-time setup...');
|
console.log('[Setup] Initializing first-time setup...');
|
||||||
@@ -67,9 +189,7 @@ async function loadThemes() {
|
|||||||
console.error('[Setup] Error loading themes:', error);
|
console.error('[Setup] Error loading themes:', error);
|
||||||
// Fallback to a default theme
|
// Fallback to a default theme
|
||||||
setupState.themes = {
|
setupState.themes = {
|
||||||
default: {
|
default: getPresetThemes()
|
||||||
default: { name: 'Default', description: 'Classic Nebula theme', colors: { bg: '#121418', primary: '#7B2EFF', accent: '#00C6FF' } }
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
renderThemeGrid(setupState.themes);
|
renderThemeGrid(setupState.themes);
|
||||||
}
|
}
|
||||||
@@ -167,8 +287,9 @@ function hexToRgb(hex) {
|
|||||||
* Apply theme to the setup page UI and persist selection
|
* Apply theme to the setup page UI and persist selection
|
||||||
*/
|
*/
|
||||||
function applyThemeToSetupPage(theme, themeId = null) {
|
function applyThemeToSetupPage(theme, themeId = null) {
|
||||||
if (!theme || !theme.colors) return;
|
const completeTheme = normalizeTheme(theme);
|
||||||
const colors = theme.colors;
|
if (!completeTheme || !completeTheme.colors) return;
|
||||||
|
const colors = completeTheme.colors;
|
||||||
const root = document.documentElement;
|
const root = document.documentElement;
|
||||||
|
|
||||||
const setVar = (cssVar, value, fallback) => {
|
const setVar = (cssVar, value, fallback) => {
|
||||||
@@ -202,15 +323,15 @@ function applyThemeToSetupPage(theme, themeId = null) {
|
|||||||
setVar('--warning-rgb', `${warningRgb.r}, ${warningRgb.g}, ${warningRgb.b}`);
|
setVar('--warning-rgb', `${warningRgb.r}, ${warningRgb.g}, ${warningRgb.b}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theme.gradient) {
|
if (completeTheme.gradient) {
|
||||||
document.body.style.background = theme.gradient;
|
document.body.style.background = completeTheme.gradient;
|
||||||
} else if (colors.bg) {
|
} else if (colors.bg) {
|
||||||
document.body.style.background = colors.bg;
|
document.body.style.background = colors.bg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Persist for main UI to pick up on first load
|
// Persist for main UI to pick up on first load
|
||||||
try {
|
try {
|
||||||
localStorage.setItem('currentTheme', JSON.stringify(theme));
|
localStorage.setItem('currentTheme', JSON.stringify(completeTheme));
|
||||||
if (themeId) localStorage.setItem('activeThemeName', themeId);
|
if (themeId) localStorage.setItem('activeThemeName', themeId);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn('[Setup] Failed to persist theme:', err);
|
console.warn('[Setup] Failed to persist theme:', err);
|
||||||
@@ -355,7 +476,7 @@ async function setDefaultBrowser() {
|
|||||||
const result = await nativeApi.setAsDefaultBrowser();
|
const result = await nativeApi.setAsDefaultBrowser();
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const isDefault = await window.api.isDefaultBrowser();
|
const isDefault = !!result.isDefault || await nativeApi.isDefaultBrowser();
|
||||||
if (isDefault) {
|
if (isDefault) {
|
||||||
setupState.defaultBrowserSet = true;
|
setupState.defaultBrowserSet = true;
|
||||||
|
|
||||||
@@ -499,7 +620,9 @@ async function completeSetup() {
|
|||||||
|
|
||||||
console.log('[Setup] First-time setup completed successfully');
|
console.log('[Setup] First-time setup completed successfully');
|
||||||
|
|
||||||
window.location.href = 'home.html';
|
if (!hasNebulaNativeBridge()) {
|
||||||
|
window.location.href = 'home.html';
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[Setup] Error completing setup:', error);
|
console.error('[Setup] Error completing setup:', error);
|
||||||
alert('There was an error saving your preferences. Please try again.');
|
alert('There was an error saving your preferences. Please try again.');
|
||||||
@@ -522,7 +645,9 @@ async function skipSetup() {
|
|||||||
|
|
||||||
console.log('[Setup] Setup skipped, using defaults');
|
console.log('[Setup] Setup skipped, using defaults');
|
||||||
|
|
||||||
window.location.href = 'home.html';
|
if (!hasNebulaNativeBridge()) {
|
||||||
|
window.location.href = 'home.html';
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[Setup] Error skipping setup:', error);
|
console.error('[Setup] Error skipping setup:', error);
|
||||||
window.location.href = 'home.html';
|
window.location.href = 'home.html';
|
||||||
|
|||||||
@@ -26,6 +26,10 @@
|
|||||||
<div class="bg-particles"></div>
|
<div class="bg-particles"></div>
|
||||||
<div class="bg-glow"></div>
|
<div class="bg-glow"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="browser-stage-frame" class="browser-stage-frame hidden" aria-hidden="true"></div>
|
||||||
|
<div id="virtual-cursor" class="virtual-cursor hidden" aria-hidden="true">
|
||||||
|
<div class="virtual-cursor-dot"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Top header bar -->
|
<!-- Top header bar -->
|
||||||
<header class="bp-header">
|
<header class="bp-header">
|
||||||
@@ -41,6 +45,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="header-right">
|
<div class="header-right">
|
||||||
<div class="status-icons">
|
<div class="status-icons">
|
||||||
|
<span id="bp-controller-status" class="status-icon controller-status disconnected" title="Controller disconnected">
|
||||||
|
<span class="material-symbols-outlined">sports_esports</span>
|
||||||
|
</span>
|
||||||
<span id="bp-wifi" class="status-icon" title="Connected">
|
<span id="bp-wifi" class="status-icon" title="Connected">
|
||||||
<span class="material-symbols-outlined">wifi</span>
|
<span class="material-symbols-outlined">wifi</span>
|
||||||
</span>
|
</span>
|
||||||
@@ -72,6 +79,10 @@
|
|||||||
<span class="material-symbols-outlined">bookmarks</span>
|
<span class="material-symbols-outlined">bookmarks</span>
|
||||||
<span class="nav-label">Bookmarks</span>
|
<span class="nav-label">Bookmarks</span>
|
||||||
</button>
|
</button>
|
||||||
|
<button class="nav-item" data-section="history" data-focusable tabindex="0">
|
||||||
|
<span class="material-symbols-outlined">history</span>
|
||||||
|
<span class="nav-label">History</span>
|
||||||
|
</button>
|
||||||
<button class="nav-item" data-section="downloads" data-focusable tabindex="0">
|
<button class="nav-item" data-section="downloads" data-focusable tabindex="0">
|
||||||
<span class="material-symbols-outlined">download</span>
|
<span class="material-symbols-outlined">download</span>
|
||||||
<span class="nav-label">Downloads</span>
|
<span class="nav-label">Downloads</span>
|
||||||
@@ -147,6 +158,26 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- History section -->
|
||||||
|
<section id="section-history" class="bp-section">
|
||||||
|
<div class="section-header">
|
||||||
|
<h1 class="section-title">History</h1>
|
||||||
|
<p class="section-subtitle">Recently visited sites from this profile</p>
|
||||||
|
</div>
|
||||||
|
<div class="section-actions">
|
||||||
|
<button class="action-btn danger" id="bp-clear-history" data-focusable tabindex="0">
|
||||||
|
<span class="material-symbols-outlined">delete</span>
|
||||||
|
<span>Clear History</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="list-container" id="historyList">
|
||||||
|
<div class="empty-state">
|
||||||
|
<span class="material-symbols-outlined">history</span>
|
||||||
|
<p>No browsing history</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<!-- Downloads section -->
|
<!-- Downloads section -->
|
||||||
<section id="section-downloads" class="bp-section">
|
<section id="section-downloads" class="bp-section">
|
||||||
<div class="section-header">
|
<div class="section-header">
|
||||||
@@ -332,7 +363,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="option-control">
|
<div class="option-control">
|
||||||
<button class="action-button" id="bp-clear-history" data-focusable tabindex="0">
|
<button class="action-button" id="bp-clear-history-settings" data-focusable tabindex="0">
|
||||||
<span class="material-symbols-outlined">delete</span>
|
<span class="material-symbols-outlined">delete</span>
|
||||||
<span>Clear</span>
|
<span>Clear</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -403,28 +434,28 @@
|
|||||||
|
|
||||||
<!-- Bottom controller hints -->
|
<!-- Bottom controller hints -->
|
||||||
<footer class="bp-footer">
|
<footer class="bp-footer">
|
||||||
<div class="controller-hints">
|
<div class="controller-hints" id="controller-hints">
|
||||||
<div class="hint">
|
<div class="hint">
|
||||||
<span class="controller-btn dpad">
|
<span class="controller-btn dpad">
|
||||||
<span class="material-symbols-outlined">gamepad</span>
|
<span class="material-symbols-outlined">gamepad</span>
|
||||||
</span>
|
</span>
|
||||||
<span>Navigate</span>
|
<span id="hint-navigate">Navigate</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="hint">
|
<div class="hint">
|
||||||
<span class="controller-btn a-btn">A</span>
|
<span class="controller-btn a-btn">A</span>
|
||||||
<span>Select</span>
|
<span id="hint-a">Select</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="hint">
|
<div class="hint">
|
||||||
<span class="controller-btn b-btn">B</span>
|
<span class="controller-btn b-btn">B</span>
|
||||||
<span>Back</span>
|
<span id="hint-b">Back</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="hint">
|
<div class="hint">
|
||||||
<span class="controller-btn y-btn">Y</span>
|
<span class="controller-btn y-btn">Y</span>
|
||||||
<span>Search</span>
|
<span id="hint-y">Search</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="hint">
|
<div class="hint">
|
||||||
<span class="controller-btn menu-btn">☰</span>
|
<span class="controller-btn menu-btn">☰</span>
|
||||||
<span>Menu</span>
|
<span id="hint-menu">Menu</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
+19
-15
@@ -1,24 +1,28 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8">
|
||||||
<title>Menu</title>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="../css/menu-popup.css" />
|
<title>Nebula Menu</title>
|
||||||
|
<link rel="stylesheet" href="../css/menu-popup.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="menu-popup" role="menu">
|
<main id="menu-popup" role="menu" aria-label="Nebula browser menu">
|
||||||
<button data-cmd="open-settings" role="menuitem">Settings</button>
|
<button type="button" role="menuitem" data-cmd="open-settings">Settings</button>
|
||||||
<button data-cmd="big-picture" role="menuitem">🎮 Big Picture Mode</button>
|
<button type="button" role="menuitem" data-cmd="gpu-diagnostics">GPU diagnostics</button>
|
||||||
<button data-cmd="gpu-diagnostics" role="menuitem">GPU Diagnostics</button>
|
<button type="button" role="menuitem" data-cmd="big-picture">Big Picture mode</button>
|
||||||
<button data-cmd="toggle-devtools" role="menuitem">Toggle Developer Tools</button>
|
<button type="button" role="menuitem" data-cmd="toggle-devtools">Developer tools</button>
|
||||||
<div class="zoom-controls" role="group" aria-label="Zoom controls">
|
|
||||||
<button data-cmd="zoom-out" aria-label="Zoom out">-</button>
|
<div class="zoom-controls" aria-label="Page zoom">
|
||||||
|
<button type="button" data-cmd="zoom-out" aria-label="Zoom out">-</button>
|
||||||
<span id="zoom-percent">100%</span>
|
<span id="zoom-percent">100%</span>
|
||||||
<button data-cmd="zoom-in" aria-label="Zoom in">+</button>
|
<button type="button" data-cmd="zoom-in" aria-label="Zoom in">+</button>
|
||||||
</div>
|
</div>
|
||||||
<button data-cmd="hard-reload" role="menuitem">Hard Reload (Ignore Cache)</button>
|
|
||||||
<button data-cmd="fresh-reload" role="menuitem">Reload Fresh (Add Cache-Buster)</button>
|
<button type="button" role="menuitem" data-cmd="hard-reload">Hard reload</button>
|
||||||
</div>
|
<button type="button" role="menuitem" data-cmd="fresh-reload">Fresh reload</button>
|
||||||
|
</main>
|
||||||
|
|
||||||
<script src="../js/menu-popup.js"></script>
|
<script src="../js/menu-popup.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+13
-2
@@ -45,6 +45,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-group">
|
||||||
|
<h3>Default Browser</h3>
|
||||||
|
<p class="note">Use Nebula Browser for web links opened from other apps.</p>
|
||||||
|
<div class="setting-row">
|
||||||
|
<button id="set-default-browser-btn" class="primary-btn">Make Default Browser</button>
|
||||||
|
<span id="default-browser-status" class="note">Checking status...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="setting-group">
|
<div class="setting-group">
|
||||||
<h3>Weather Display</h3>
|
<h3>Weather Display</h3>
|
||||||
<p class="note">Choose how temperature is displayed on the Home page weather card.</p>
|
<p class="note">Choose how temperature is displayed on the Home page weather card.</p>
|
||||||
@@ -489,8 +498,10 @@
|
|||||||
a.addEventListener('click', (e) => {
|
a.addEventListener('click', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
try {
|
try {
|
||||||
if (window.electronAPI && typeof window.electronAPI.sendToHost === 'function') {
|
if (window.nebulaNative && typeof window.nebulaNative.postMessage === 'function') {
|
||||||
// Ask the host to open this URL in a new tab to keep Settings open
|
// Ask the CEF host to open this URL in a new tab to keep Settings open.
|
||||||
|
window.nebulaNative.postMessage('new-tab', item);
|
||||||
|
} else if (window.electronAPI && typeof window.electronAPI.sendToHost === 'function') {
|
||||||
window.electronAPI.sendToHost('navigate', item, { newTab: true });
|
window.electronAPI.sendToHost('navigate', item, { newTab: true });
|
||||||
} else if (window.parent && window.parent !== window) {
|
} else if (window.parent && window.parent !== window) {
|
||||||
// Fallback: postMessage to parent if available
|
// Fallback: postMessage to parent if available
|
||||||
|
|||||||
@@ -129,6 +129,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script src="../js/customization.js"></script>
|
||||||
<script src="../js/setup.js"></script>
|
<script src="../js/setup.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user