sparkbun 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-linux-arm64/libNativeWrapper.so +0 -0
- package/dist-linux-arm64/{libElectrobunCore.so → libSparkBunCore.so} +0 -0
- package/dist-linux-x64/libNativeWrapper.so +0 -0
- package/dist-linux-x64/{libElectrobunCore.so → libSparkBunCore.so} +0 -0
- package/dist-macos-arm64/libNativeWrapper.dylib +0 -0
- package/dist-macos-arm64/libSparkBunCore.dylib +0 -0
- package/dist-macos-x64/libNativeWrapper.dylib +0 -0
- package/dist-macos-x64/libSparkBunCore.dylib +0 -0
- package/dist-macos-x64/libasar.dylib +0 -0
- package/dist-macos-x64/libwebgpu_dawn.dylib +0 -0
- package/dist-macos-x64/process_helper +0 -0
- package/dist-win-arm64/SparkBunCore.dll +0 -0
- package/dist-win-arm64/WebView2Loader.dll +0 -0
- package/dist-win-arm64/libNativeWrapper.dll +0 -0
- package/dist-win-arm64/zig-asar/arm64/libasar.dll +0 -0
- package/dist-win-arm64/zig-asar/x64/libasar.dll +0 -0
- package/dist-win-x64/SparkBunCore.dll +0 -0
- package/package.json +1 -1
- package/scripts/setup-win-arm64.ps1 +19 -0
- package/src/browser/global.d.ts +11 -11
- package/src/browser/index.ts +10 -10
- package/src/bun/core/BrowserView.ts +2 -2
- package/src/bun/core/Updater.ts +6 -56
- package/src/bun/preload/.generated/compiled.ts +2 -2
- package/src/bun/preload/dragRegions.ts +2 -2
- package/src/bun/preload/encryption.ts +4 -4
- package/src/bun/preload/events.ts +4 -4
- package/src/bun/preload/globals.d.ts +14 -14
- package/src/bun/preload/index-sandboxed.ts +3 -3
- package/src/bun/preload/index.ts +19 -19
- package/src/bun/preload/internalRpc.ts +3 -3
- package/src/bun/preload/webviewTag.ts +2 -2
- package/src/bun/preload/wgpuTag.ts +1 -1
- package/src/bun/proc/native.ts +6 -6
- package/src/cli/index.ts +47 -83
- package/src/core/build.zig +1 -1
- package/src/core/main.zig +25 -24
- package/src/installer/installer-template.ts +1 -1
- package/src/launcher/main.ts +10 -10
- package/src/native/linux/cef_process_helper_linux.cpp +4 -4
- package/src/native/linux/nativeWrapper.cpp +230 -230
- package/src/native/macos/cef_process_helper_mac.cc +4 -4
- package/src/native/macos/nativeWrapper.mm +100 -100
- package/src/native/shared/accelerator_parser.h +5 -5
- package/src/native/shared/app_paths.h +7 -7
- package/src/native/shared/asar.h +5 -5
- package/src/native/shared/cache_migration.h +14 -14
- package/src/native/shared/callbacks.h +5 -5
- package/src/native/shared/cef_response_filter.h +18 -18
- package/src/native/shared/chromium_flags.h +6 -6
- package/src/native/shared/config.h +5 -5
- package/src/native/shared/download_event.h +5 -5
- package/src/native/shared/ffi_helpers.h +6 -6
- package/src/native/shared/glob_match.h +5 -5
- package/src/native/shared/json_menu_parser.h +5 -5
- package/src/native/shared/mime_types.h +5 -5
- package/src/native/shared/navigation_rules.h +5 -5
- package/src/native/shared/partition_context.h +5 -5
- package/src/native/shared/permissions.h +5 -5
- package/src/native/shared/permissions_cef.h +5 -5
- package/src/native/shared/preload_script.h +5 -5
- package/src/native/shared/shutdown_guard.h +5 -5
- package/src/native/shared/thread_safe_map.h +5 -5
- package/src/native/shared/webview_storage.h +5 -5
- package/src/native/win/cef_process_helper_win.cpp +4 -4
- package/src/native/win/dcomp_compositor.h +1 -1
- package/src/native/win/nativeWrapper.cpp +288 -288
- package/src/shared/bsdiff.ts +236 -0
- package/src/shared/bspatch.ts +98 -0
- package/dist-linux-arm64/bsdiff +0 -0
- package/dist-linux-arm64/bspatch +0 -0
- package/dist-linux-x64/bsdiff +0 -0
- package/dist-linux-x64/bspatch +0 -0
- package/dist-macos-arm64/bsdiff +0 -0
- package/dist-macos-arm64/bspatch +0 -0
- package/dist-macos-arm64/libElectrobunCore.dylib +0 -0
- package/dist-macos-arm64/preload-full.js +0 -885
- package/dist-macos-arm64/preload-sandboxed.js +0 -111
- package/dist-win-x64/ElectrobunCore.dll +0 -0
- package/dist-win-x64/bsdiff.exe +0 -0
- package/dist-win-x64/bspatch.exe +0 -0
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
#include "../shared/chromium_flags.h"
|
|
63
63
|
#include "../shared/cache_migration.h"
|
|
64
64
|
|
|
65
|
-
using namespace
|
|
65
|
+
using namespace sparkbun;
|
|
66
66
|
|
|
67
67
|
// Global ASAR archive handle (lazy-loaded) with thread-safe initialization
|
|
68
68
|
// ASAR C FFI declarations are in shared/asar.h
|
|
@@ -89,15 +89,15 @@ static int g_sigint_count = 0;
|
|
|
89
89
|
static std::atomic<int> g_activeOperations{0};
|
|
90
90
|
static std::mutex g_cefBrowserMutex;
|
|
91
91
|
|
|
92
|
-
// Map from CEF browser identifier to
|
|
92
|
+
// Map from CEF browser identifier to sparkbun webviewId, used by scheme handlers
|
|
93
93
|
static std::map<int, uint32_t> g_browserIdToWebviewId;
|
|
94
94
|
static std::mutex g_browserIdToWebviewIdMutex;
|
|
95
95
|
|
|
96
96
|
// Use OperationGuard from shared/shutdown_guard.h
|
|
97
|
-
using
|
|
97
|
+
using sparkbun::OperationGuard;
|
|
98
98
|
|
|
99
99
|
// CEF includes - always include them even if it marginally increases binary size
|
|
100
|
-
// we want a few binaries that will work whenever an
|
|
100
|
+
// we want a few binaries that will work whenever an sparkbun developer
|
|
101
101
|
// adds CEF into their bundles
|
|
102
102
|
#include "include/cef_app.h"
|
|
103
103
|
#include "include/cef_browser.h"
|
|
@@ -119,7 +119,7 @@ using electrobun::OperationGuard;
|
|
|
119
119
|
#include "cef_loader.h"
|
|
120
120
|
|
|
121
121
|
// Ensure the exported functions have appropriate visibility
|
|
122
|
-
#define
|
|
122
|
+
#define SPARKBUN_EXPORT __attribute__((visibility("default")))
|
|
123
123
|
|
|
124
124
|
// X11 Error Handler (non-fatal errors are common in WebKit/GTK)
|
|
125
125
|
static int x11_error_handler(Display* display, XErrorEvent* error) {
|
|
@@ -180,12 +180,12 @@ static std::map<uint32_t, std::string> webviewHTMLContent;
|
|
|
180
180
|
static std::mutex webviewHTMLMutex;
|
|
181
181
|
|
|
182
182
|
// Global variables for CEF cache path isolation
|
|
183
|
-
static std::string
|
|
184
|
-
static std::string
|
|
183
|
+
static std::string g_sparkbunChannel = "";
|
|
184
|
+
static std::string g_sparkbunIdentifier = "";
|
|
185
185
|
|
|
186
186
|
// Forward declarations for HTML content management
|
|
187
|
-
extern "C"
|
|
188
|
-
extern "C"
|
|
187
|
+
extern "C" SPARKBUN_EXPORT const char* getWebviewHTMLContent(uint32_t webviewId);
|
|
188
|
+
extern "C" SPARKBUN_EXPORT void setWebviewHTMLContent(uint32_t webviewId, const char* htmlContent);
|
|
189
189
|
|
|
190
190
|
// MIME type detection function is in shared/mime_types.h
|
|
191
191
|
// Permission cache types and functions are in shared/permissions.h
|
|
@@ -241,7 +241,7 @@ extern "C" void stopWgpuTestForWindow(Window window);
|
|
|
241
241
|
void applyApplicationMenuToX11Window(X11Window* x11win);
|
|
242
242
|
|
|
243
243
|
// Use parseMenuJson from shared/json_menu_parser.h
|
|
244
|
-
using
|
|
244
|
+
using sparkbun::parseMenuJson;
|
|
245
245
|
|
|
246
246
|
// Mask rectangle structure for X11 regions
|
|
247
247
|
struct MaskRect {
|
|
@@ -355,8 +355,8 @@ static std::mutex g_webviewViewsRootMutex;
|
|
|
355
355
|
// Global map to store preload scripts by browser ID (for multi-process CEF)
|
|
356
356
|
static std::map<int, std::string> g_preloadScripts;
|
|
357
357
|
|
|
358
|
-
CefRefPtr<class
|
|
359
|
-
|
|
358
|
+
CefRefPtr<class SparkBunApp> g_app;
|
|
359
|
+
sparkbun::ChromiumFlagConfig g_userChromiumFlags;
|
|
360
360
|
|
|
361
361
|
|
|
362
362
|
// Get the directory of the current executable
|
|
@@ -457,17 +457,17 @@ bool isCEFAvailable() {
|
|
|
457
457
|
|
|
458
458
|
|
|
459
459
|
// CEF Response Filter for preload script injection (Mac-style clean approach)
|
|
460
|
-
class
|
|
460
|
+
class SparkBunResponseFilter : public CefResponseFilter {
|
|
461
461
|
private:
|
|
462
|
-
std::string
|
|
462
|
+
std::string sparkbun_script_;
|
|
463
463
|
std::string custom_script_;
|
|
464
464
|
std::string buffer_;
|
|
465
465
|
bool has_head_;
|
|
466
466
|
bool injected_;
|
|
467
467
|
|
|
468
468
|
public:
|
|
469
|
-
|
|
470
|
-
:
|
|
469
|
+
SparkBunResponseFilter(const std::string& sparkbunScript, const std::string& customScript)
|
|
470
|
+
: sparkbun_script_(sparkbunScript),
|
|
471
471
|
custom_script_(customScript),
|
|
472
472
|
has_head_(false),
|
|
473
473
|
injected_(false) {}
|
|
@@ -487,8 +487,8 @@ public:
|
|
|
487
487
|
data_in_read = data_in_size;
|
|
488
488
|
|
|
489
489
|
// Only inject once and if we have scripts to inject
|
|
490
|
-
if (!injected_ && (!
|
|
491
|
-
std::string combined_script =
|
|
490
|
+
if (!injected_ && (!sparkbun_script_.empty() || !custom_script_.empty())) {
|
|
491
|
+
std::string combined_script = sparkbun_script_;
|
|
492
492
|
if (!custom_script_.empty()) {
|
|
493
493
|
combined_script += "\n" + custom_script_;
|
|
494
494
|
}
|
|
@@ -542,7 +542,7 @@ public:
|
|
|
542
542
|
return buffer_.empty() ? RESPONSE_FILTER_DONE : RESPONSE_FILTER_NEED_MORE_DATA;
|
|
543
543
|
}
|
|
544
544
|
|
|
545
|
-
IMPLEMENT_REFCOUNTING(
|
|
545
|
+
IMPLEMENT_REFCOUNTING(SparkBunResponseFilter);
|
|
546
546
|
};
|
|
547
547
|
|
|
548
548
|
// CEF views:// scheme handler implementation
|
|
@@ -822,12 +822,12 @@ private:
|
|
|
822
822
|
IMPLEMENT_REFCOUNTING(V8MessageHandler);
|
|
823
823
|
};
|
|
824
824
|
|
|
825
|
-
//
|
|
826
|
-
class
|
|
825
|
+
// SparkBunApp implementation for Linux
|
|
826
|
+
class SparkBunApp : public CefApp,
|
|
827
827
|
public CefBrowserProcessHandler,
|
|
828
828
|
public CefRenderProcessHandler {
|
|
829
829
|
public:
|
|
830
|
-
|
|
830
|
+
SparkBunApp() {}
|
|
831
831
|
|
|
832
832
|
void OnBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr<CefCommandLine> command_line) override {
|
|
833
833
|
command_line->AppendSwitchWithValue("custom-scheme", "views");
|
|
@@ -835,7 +835,7 @@ public:
|
|
|
835
835
|
// Linux default flags — can be overridden via chromiumFlags in config
|
|
836
836
|
// GPU acceleration disabled by default for VM compatibility;
|
|
837
837
|
// skip with e.g. chromiumFlags: { "disable-gpu": false }
|
|
838
|
-
static const std::vector<
|
|
838
|
+
static const std::vector<sparkbun::DefaultFlag> defaults = {
|
|
839
839
|
{"use-mock-keychain", ""},
|
|
840
840
|
{"disable-gpu", ""},
|
|
841
841
|
{"disable-gpu-compositing", ""},
|
|
@@ -850,10 +850,10 @@ public:
|
|
|
850
850
|
{"ozone-platform", "x11"},
|
|
851
851
|
{"use-x11", ""},
|
|
852
852
|
};
|
|
853
|
-
|
|
853
|
+
sparkbun::applyDefaultFlags(defaults, g_userChromiumFlags.skip, command_line);
|
|
854
854
|
|
|
855
855
|
// Apply user-defined chromium flags from build.json
|
|
856
|
-
|
|
856
|
+
sparkbun::applyChromiumFlags(g_userChromiumFlags, command_line);
|
|
857
857
|
}
|
|
858
858
|
|
|
859
859
|
void OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) override {
|
|
@@ -911,13 +911,13 @@ public:
|
|
|
911
911
|
}
|
|
912
912
|
|
|
913
913
|
private:
|
|
914
|
-
IMPLEMENT_REFCOUNTING(
|
|
915
|
-
DISALLOW_COPY_AND_ASSIGN(
|
|
914
|
+
IMPLEMENT_REFCOUNTING(SparkBunApp);
|
|
915
|
+
DISALLOW_COPY_AND_ASSIGN(SparkBunApp);
|
|
916
916
|
};
|
|
917
917
|
|
|
918
918
|
|
|
919
|
-
//
|
|
920
|
-
class
|
|
919
|
+
// SparkBunClient implementation for Linux
|
|
920
|
+
class SparkBunClient : public CefClient,
|
|
921
921
|
public CefLoadHandler,
|
|
922
922
|
public CefRequestHandler,
|
|
923
923
|
public CefContextMenuHandler,
|
|
@@ -938,7 +938,7 @@ private:
|
|
|
938
938
|
DecideNavigationCallback navigation_callback_;
|
|
939
939
|
bool is_sandboxed_;
|
|
940
940
|
|
|
941
|
-
std::string
|
|
941
|
+
std::string sparkbun_script_;
|
|
942
942
|
std::string custom_script_;
|
|
943
943
|
CefRefPtr<CefBrowser> browser_;
|
|
944
944
|
|
|
@@ -959,7 +959,7 @@ private:
|
|
|
959
959
|
Window parent_window_handle_;
|
|
960
960
|
|
|
961
961
|
public:
|
|
962
|
-
|
|
962
|
+
SparkBunClient(uint32_t webviewId,
|
|
963
963
|
HandlePostMessage eventBridgeHandler,
|
|
964
964
|
HandlePostMessage bunBridgeHandler,
|
|
965
965
|
HandlePostMessage internalBridgeHandler,
|
|
@@ -984,7 +984,7 @@ public:
|
|
|
984
984
|
, parent_window_handle_(0) {}
|
|
985
985
|
|
|
986
986
|
void AddPreloadScript(const std::string& script, bool mainFrameOnly = false) {
|
|
987
|
-
|
|
987
|
+
sparkbun_script_ = script;
|
|
988
988
|
}
|
|
989
989
|
|
|
990
990
|
void UpdateCustomPreloadScript(const std::string& script) {
|
|
@@ -992,7 +992,7 @@ public:
|
|
|
992
992
|
}
|
|
993
993
|
|
|
994
994
|
std::string GetCombinedScript() {
|
|
995
|
-
std::string combined_script =
|
|
995
|
+
std::string combined_script = sparkbun_script_;
|
|
996
996
|
if (!custom_script_.empty()) {
|
|
997
997
|
combined_script += "\n" + custom_script_;
|
|
998
998
|
}
|
|
@@ -1293,7 +1293,7 @@ public:
|
|
|
1293
1293
|
|
|
1294
1294
|
std::string combined_script = GetCombinedScript();
|
|
1295
1295
|
if (!combined_script.empty()) {
|
|
1296
|
-
return new
|
|
1296
|
+
return new SparkBunResponseFilter(sparkbun_script_, custom_script_);
|
|
1297
1297
|
}
|
|
1298
1298
|
}
|
|
1299
1299
|
return nullptr;
|
|
@@ -1834,7 +1834,7 @@ public:
|
|
|
1834
1834
|
// Unrecognized permission type — name what's being requested instead of
|
|
1835
1835
|
// a generic "additional permissions" dialog so the user can decide.
|
|
1836
1836
|
message = "This page is requesting permission for: " +
|
|
1837
|
-
|
|
1837
|
+
sparkbun::describeCefPermissions(requested_permissions) +
|
|
1838
1838
|
".\n\nDo you want to allow this?";
|
|
1839
1839
|
}
|
|
1840
1840
|
|
|
@@ -2182,17 +2182,17 @@ public:
|
|
|
2182
2182
|
}
|
|
2183
2183
|
|
|
2184
2184
|
private:
|
|
2185
|
-
IMPLEMENT_REFCOUNTING(
|
|
2186
|
-
DISALLOW_COPY_AND_ASSIGN(
|
|
2185
|
+
IMPLEMENT_REFCOUNTING(SparkBunClient);
|
|
2186
|
+
DISALLOW_COPY_AND_ASSIGN(SparkBunClient);
|
|
2187
2187
|
};
|
|
2188
2188
|
|
|
2189
2189
|
// Initialize static debounce timestamp for ctrl+click handling
|
|
2190
|
-
double
|
|
2190
|
+
double SparkBunClient::lastCtrlClickTime = 0;
|
|
2191
2191
|
|
|
2192
2192
|
static std::mutex g_osrClientsMutex;
|
|
2193
|
-
static std::map<uint32_t, CefRefPtr<
|
|
2193
|
+
static std::map<uint32_t, CefRefPtr<SparkBunClient>> g_osrClientsByWindowId;
|
|
2194
2194
|
|
|
2195
|
-
static void registerOSRClientForWindow(uint32_t windowId, CefRefPtr<
|
|
2195
|
+
static void registerOSRClientForWindow(uint32_t windowId, CefRefPtr<SparkBunClient> client) {
|
|
2196
2196
|
if (!windowId) return;
|
|
2197
2197
|
std::lock_guard<std::mutex> lock(g_osrClientsMutex);
|
|
2198
2198
|
if (client) {
|
|
@@ -2202,7 +2202,7 @@ static void registerOSRClientForWindow(uint32_t windowId, CefRefPtr<ElectrobunCl
|
|
|
2202
2202
|
}
|
|
2203
2203
|
}
|
|
2204
2204
|
|
|
2205
|
-
static CefRefPtr<
|
|
2205
|
+
static CefRefPtr<SparkBunClient> getOSRClientForWindow(uint32_t windowId) {
|
|
2206
2206
|
std::lock_guard<std::mutex> lock(g_osrClientsMutex);
|
|
2207
2207
|
auto it = g_osrClientsByWindowId.find(windowId);
|
|
2208
2208
|
return it != g_osrClientsByWindowId.end() ? it->second : nullptr;
|
|
@@ -2258,7 +2258,7 @@ static int osrClickCountForEvent(Window window, const XButtonEvent& buttonEvent,
|
|
|
2258
2258
|
return clickCount;
|
|
2259
2259
|
}
|
|
2260
2260
|
|
|
2261
|
-
static void forwardX11EventToOSRClient(const XEvent& event, Display* display, Window window, CefRefPtr<
|
|
2261
|
+
static void forwardX11EventToOSRClient(const XEvent& event, Display* display, Window window, CefRefPtr<SparkBunClient> client) {
|
|
2262
2262
|
if (!client) return;
|
|
2263
2263
|
|
|
2264
2264
|
CefRefPtr<CefBrowser> browser;
|
|
@@ -2370,13 +2370,13 @@ bool initializeCEF() {
|
|
|
2370
2370
|
}
|
|
2371
2371
|
|
|
2372
2372
|
CefMainArgs main_args(argc, argv);
|
|
2373
|
-
g_app = new
|
|
2373
|
+
g_app = new SparkBunApp();
|
|
2374
2374
|
|
|
2375
2375
|
// Read user-defined chromium flags from build.json
|
|
2376
2376
|
std::string buildJsonPath = getExecutableDir() + "/../Resources/build.json";
|
|
2377
|
-
std::string buildJsonContent =
|
|
2377
|
+
std::string buildJsonContent = sparkbun::readFileToString(buildJsonPath);
|
|
2378
2378
|
if (!buildJsonContent.empty()) {
|
|
2379
|
-
g_userChromiumFlags =
|
|
2379
|
+
g_userChromiumFlags = sparkbun::parseChromiumFlags(buildJsonContent);
|
|
2380
2380
|
}
|
|
2381
2381
|
|
|
2382
2382
|
CefSettings settings;
|
|
@@ -2405,12 +2405,12 @@ bool initializeCEF() {
|
|
|
2405
2405
|
char* home = getenv("HOME");
|
|
2406
2406
|
if (home) {
|
|
2407
2407
|
std::string basePath = std::string(home) + "/.cache";
|
|
2408
|
-
std::string cachePath = buildAppDataPath(basePath,
|
|
2408
|
+
std::string cachePath = buildAppDataPath(basePath, g_sparkbunIdentifier, g_sparkbunChannel, "CEF");
|
|
2409
2409
|
std::cout << "[CEF] Using path: " << cachePath << std::endl;
|
|
2410
2410
|
|
|
2411
|
-
// One-shot wipe if
|
|
2411
|
+
// One-shot wipe if SparkBun's cache format version has been bumped
|
|
2412
2412
|
// since the user's last launch. See cache_migration.h.
|
|
2413
|
-
|
|
2413
|
+
sparkbun::migrateCacheFolderIfNeeded(cachePath);
|
|
2414
2414
|
|
|
2415
2415
|
CefString(&settings.root_cache_path) = cachePath;
|
|
2416
2416
|
}
|
|
@@ -2528,7 +2528,7 @@ public:
|
|
|
2528
2528
|
bool isBlockRule = !rule.empty() && rule[0] == '^';
|
|
2529
2529
|
std::string pattern = isBlockRule ? rule.substr(1) : rule;
|
|
2530
2530
|
|
|
2531
|
-
if (
|
|
2531
|
+
if (sparkbun::globMatch(pattern, url)) {
|
|
2532
2532
|
allowed = !isBlockRule; // Last match wins
|
|
2533
2533
|
}
|
|
2534
2534
|
}
|
|
@@ -2631,7 +2631,7 @@ public:
|
|
|
2631
2631
|
HandlePostMessage bunBridgeHandler;
|
|
2632
2632
|
HandlePostMessage internalBridgeHandler;
|
|
2633
2633
|
bool isSandboxed;
|
|
2634
|
-
std::string
|
|
2634
|
+
std::string sparkbunPreloadScript;
|
|
2635
2635
|
std::string customPreloadScript;
|
|
2636
2636
|
std::string partition;
|
|
2637
2637
|
bool partitionContextReleased = false;
|
|
@@ -2653,7 +2653,7 @@ public:
|
|
|
2653
2653
|
HandlePostMessage eventBridgeHandler,
|
|
2654
2654
|
HandlePostMessage bunBridgeHandler,
|
|
2655
2655
|
HandlePostMessage internalBridgeHandler,
|
|
2656
|
-
const char*
|
|
2656
|
+
const char* sparkbunPreloadScript,
|
|
2657
2657
|
const char* customPreloadScript,
|
|
2658
2658
|
bool sandbox,
|
|
2659
2659
|
bool startTransparent,
|
|
@@ -2662,7 +2662,7 @@ public:
|
|
|
2662
2662
|
eventHandler(webviewEventHandler), eventBridgeHandler(eventBridgeHandler),
|
|
2663
2663
|
bunBridgeHandler(bunBridgeHandler),
|
|
2664
2664
|
internalBridgeHandler(internalBridgeHandler), isSandboxed(sandbox),
|
|
2665
|
-
|
|
2665
|
+
sparkbunPreloadScript(sparkbunPreloadScript ? sparkbunPreloadScript : ""),
|
|
2666
2666
|
customPreloadScript(customPreloadScript ? customPreloadScript : ""),
|
|
2667
2667
|
partition(partitionIdentifier ? partitionIdentifier : "")
|
|
2668
2668
|
{
|
|
@@ -2730,8 +2730,8 @@ public:
|
|
|
2730
2730
|
}
|
|
2731
2731
|
|
|
2732
2732
|
// Add preload scripts
|
|
2733
|
-
if (!this->
|
|
2734
|
-
addPreloadScriptToWebView(this->
|
|
2733
|
+
if (!this->sparkbunPreloadScript.empty()) {
|
|
2734
|
+
addPreloadScriptToWebView(this->sparkbunPreloadScript.c_str());
|
|
2735
2735
|
}
|
|
2736
2736
|
if (!this->customPreloadScript.empty()) {
|
|
2737
2737
|
addPreloadScriptToWebView(this->customPreloadScript.c_str());
|
|
@@ -2980,9 +2980,9 @@ public:
|
|
|
2980
2980
|
// Remove all custom scripts (we'll track them with a prefix)
|
|
2981
2981
|
webkit_user_content_manager_remove_all_scripts(manager);
|
|
2982
2982
|
|
|
2983
|
-
// Re-add
|
|
2984
|
-
if (!
|
|
2985
|
-
WebKitUserScript* script = webkit_user_script_new(
|
|
2983
|
+
// Re-add sparkbun preload script
|
|
2984
|
+
if (!sparkbunPreloadScript.empty()) {
|
|
2985
|
+
WebKitUserScript* script = webkit_user_script_new(sparkbunPreloadScript.c_str(),
|
|
2986
2986
|
WEBKIT_USER_CONTENT_INJECT_TOP_FRAME,
|
|
2987
2987
|
WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_START,
|
|
2988
2988
|
nullptr, nullptr);
|
|
@@ -4083,31 +4083,31 @@ double WebKitWebViewImpl::lastCtrlClickTime = 0;
|
|
|
4083
4083
|
// Platform implementation for partition_context.h — builds the on-disk
|
|
4084
4084
|
// cache_path for a persistent partition under $HOME/.cache, creating any
|
|
4085
4085
|
// missing parent directories.
|
|
4086
|
-
namespace
|
|
4086
|
+
namespace sparkbun {
|
|
4087
4087
|
std::string buildAndEnsurePartitionCachePath(const std::string& partitionName) {
|
|
4088
4088
|
char* home = getenv("HOME");
|
|
4089
4089
|
std::string basePath = home ? std::string(home) + "/.cache" : "/tmp";
|
|
4090
4090
|
std::string cachePath = buildCEFPartitionPath(
|
|
4091
|
-
basePath,
|
|
4091
|
+
basePath, g_sparkbunIdentifier, g_sparkbunChannel, "CEF", partitionName);
|
|
4092
4092
|
g_mkdir_with_parents(cachePath.c_str(), 0755);
|
|
4093
4093
|
return cachePath;
|
|
4094
4094
|
}
|
|
4095
|
-
} // namespace
|
|
4095
|
+
} // namespace sparkbun
|
|
4096
4096
|
|
|
4097
4097
|
CefRefPtr<CefRequestContext> CreateRequestContextForPartition(const char* partitionIdentifier,
|
|
4098
4098
|
uint32_t webviewId) {
|
|
4099
4099
|
static CefRefPtr<ViewsSchemeHandlerFactory> schemeFactory = new ViewsSchemeHandlerFactory();
|
|
4100
|
-
return
|
|
4100
|
+
return sparkbun::getOrCreateRequestContextForPartition(
|
|
4101
4101
|
partitionIdentifier, webviewId, schemeFactory);
|
|
4102
4102
|
}
|
|
4103
4103
|
|
|
4104
4104
|
// Forward declaration for X11 event processing
|
|
4105
|
-
void processX11EventsForOSR(uint32_t windowId, CefRefPtr<
|
|
4105
|
+
void processX11EventsForOSR(uint32_t windowId, CefRefPtr<SparkBunClient> client);
|
|
4106
4106
|
|
|
4107
4107
|
// OSR event handling data structure
|
|
4108
4108
|
struct OSREventData {
|
|
4109
4109
|
uint32_t windowId;
|
|
4110
|
-
CefRefPtr<
|
|
4110
|
+
CefRefPtr<SparkBunClient> client;
|
|
4111
4111
|
bool active;
|
|
4112
4112
|
};
|
|
4113
4113
|
|
|
@@ -4115,14 +4115,14 @@ struct OSREventData {
|
|
|
4115
4115
|
class CEFWebViewImpl : public AbstractView {
|
|
4116
4116
|
public:
|
|
4117
4117
|
CefRefPtr<CefBrowser> browser;
|
|
4118
|
-
CefRefPtr<
|
|
4118
|
+
CefRefPtr<SparkBunClient> client;
|
|
4119
4119
|
DecideNavigationCallback navigationCallback;
|
|
4120
4120
|
WebviewEventHandler eventHandler;
|
|
4121
4121
|
HandlePostMessage eventBridgeHandler;
|
|
4122
4122
|
HandlePostMessage bunBridgeHandler;
|
|
4123
4123
|
HandlePostMessage internalBridgeHandler;
|
|
4124
4124
|
bool isSandboxed;
|
|
4125
|
-
std::string
|
|
4125
|
+
std::string sparkbunPreloadScript;
|
|
4126
4126
|
std::string customPreloadScript;
|
|
4127
4127
|
std::string partition;
|
|
4128
4128
|
|
|
@@ -4162,7 +4162,7 @@ public:
|
|
|
4162
4162
|
HandlePostMessage eventBridgeHandler,
|
|
4163
4163
|
HandlePostMessage bunBridgeHandler,
|
|
4164
4164
|
HandlePostMessage internalBridgeHandler,
|
|
4165
|
-
const char*
|
|
4165
|
+
const char* sparkbunPreloadScript,
|
|
4166
4166
|
const char* customPreloadScript,
|
|
4167
4167
|
bool sandbox,
|
|
4168
4168
|
bool startTransparent,
|
|
@@ -4171,7 +4171,7 @@ public:
|
|
|
4171
4171
|
eventHandler(webviewEventHandler), eventBridgeHandler(eventBridgeHandler),
|
|
4172
4172
|
bunBridgeHandler(bunBridgeHandler),
|
|
4173
4173
|
internalBridgeHandler(internalBridgeHandler), isSandboxed(sandbox),
|
|
4174
|
-
|
|
4174
|
+
sparkbunPreloadScript(sparkbunPreloadScript ? sparkbunPreloadScript : ""),
|
|
4175
4175
|
customPreloadScript(customPreloadScript ? customPreloadScript : ""),
|
|
4176
4176
|
partition(partitionIdentifier ? partitionIdentifier : "")
|
|
4177
4177
|
{
|
|
@@ -4263,7 +4263,7 @@ public:
|
|
|
4263
4263
|
}
|
|
4264
4264
|
|
|
4265
4265
|
// Create client
|
|
4266
|
-
client = new
|
|
4266
|
+
client = new SparkBunClient(
|
|
4267
4267
|
webviewId,
|
|
4268
4268
|
eventBridgeHandler,
|
|
4269
4269
|
bunBridgeHandler,
|
|
@@ -4368,8 +4368,8 @@ public:
|
|
|
4368
4368
|
});
|
|
4369
4369
|
|
|
4370
4370
|
// Add preload scripts to the client
|
|
4371
|
-
if (!
|
|
4372
|
-
client->AddPreloadScript(
|
|
4371
|
+
if (!sparkbunPreloadScript.empty()) {
|
|
4372
|
+
client->AddPreloadScript(sparkbunPreloadScript);
|
|
4373
4373
|
}
|
|
4374
4374
|
if (!customPreloadScript.empty()) {
|
|
4375
4375
|
client->UpdateCustomPreloadScript(customPreloadScript);
|
|
@@ -4700,9 +4700,9 @@ public:
|
|
|
4700
4700
|
}
|
|
4701
4701
|
|
|
4702
4702
|
void addPreloadScriptToWebView(const char* jsString) override {
|
|
4703
|
-
|
|
4703
|
+
sparkbunPreloadScript = jsString ? jsString : "";
|
|
4704
4704
|
if (client) {
|
|
4705
|
-
client->AddPreloadScript(
|
|
4705
|
+
client->AddPreloadScript(sparkbunPreloadScript);
|
|
4706
4706
|
}
|
|
4707
4707
|
}
|
|
4708
4708
|
|
|
@@ -5222,7 +5222,7 @@ public:
|
|
|
5222
5222
|
title(title ? title : ""), imagePath(pathToImage ? pathToImage : "") {
|
|
5223
5223
|
|
|
5224
5224
|
// Create unique indicator ID
|
|
5225
|
-
std::string indicatorId = "
|
|
5225
|
+
std::string indicatorId = "sparkbun-tray-" + std::to_string(id);
|
|
5226
5226
|
|
|
5227
5227
|
// Create app indicator
|
|
5228
5228
|
indicator = app_indicator_new(indicatorId.c_str(),
|
|
@@ -5261,7 +5261,7 @@ public:
|
|
|
5261
5261
|
void setImage(const char* newImage) {
|
|
5262
5262
|
imagePath = newImage ? newImage : "";
|
|
5263
5263
|
if (indicator && !imagePath.empty()) {
|
|
5264
|
-
app_indicator_set_icon_full(indicator, imagePath.c_str(), "
|
|
5264
|
+
app_indicator_set_icon_full(indicator, imagePath.c_str(), "SparkBun Tray Icon");
|
|
5265
5265
|
}
|
|
5266
5266
|
}
|
|
5267
5267
|
|
|
@@ -5297,7 +5297,7 @@ private:
|
|
|
5297
5297
|
void createDefaultMenu() {
|
|
5298
5298
|
menu = gtk_menu_new();
|
|
5299
5299
|
|
|
5300
|
-
GtkWidget* defaultItem = gtk_menu_item_new_with_label("
|
|
5300
|
+
GtkWidget* defaultItem = gtk_menu_item_new_with_label("SparkBun App");
|
|
5301
5301
|
gtk_widget_set_sensitive(defaultItem, FALSE);
|
|
5302
5302
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), defaultItem);
|
|
5303
5303
|
|
|
@@ -5373,7 +5373,7 @@ static void focusX11Window(Display* display, Window window) {
|
|
|
5373
5373
|
}
|
|
5374
5374
|
|
|
5375
5375
|
// X11 event processing for OSR windows
|
|
5376
|
-
void processX11EventsForOSR(uint32_t windowId, CefRefPtr<
|
|
5376
|
+
void processX11EventsForOSR(uint32_t windowId, CefRefPtr<SparkBunClient> client) {
|
|
5377
5377
|
// Check if shutting down
|
|
5378
5378
|
if (g_shuttingDown.load()) return;
|
|
5379
5379
|
|
|
@@ -6057,8 +6057,8 @@ static WebKitWebContext* getContextForPartition(const char* partitionIdentifier)
|
|
|
6057
6057
|
// Build paths with identifier/channel structure (consistent with CLI and updater)
|
|
6058
6058
|
char* home = getenv("HOME");
|
|
6059
6059
|
std::string homeStr = home ? std::string(home) : "/tmp";
|
|
6060
|
-
std::string dataPath = buildPartitionPath(homeStr + "/.local/share",
|
|
6061
|
-
std::string cachePath = buildPartitionPath(homeStr + "/.cache",
|
|
6060
|
+
std::string dataPath = buildPartitionPath(homeStr + "/.local/share", g_sparkbunIdentifier, g_sparkbunChannel, "WebKit", partitionName);
|
|
6061
|
+
std::string cachePath = buildPartitionPath(homeStr + "/.cache", g_sparkbunIdentifier, g_sparkbunChannel, "WebKit", partitionName);
|
|
6062
6062
|
|
|
6063
6063
|
g_mkdir_with_parents(dataPath.c_str(), 0755);
|
|
6064
6064
|
g_mkdir_with_parents(cachePath.c_str(), 0755);
|
|
@@ -6310,7 +6310,7 @@ gboolean process_x11_events(gpointer data) {
|
|
|
6310
6310
|
}
|
|
6311
6311
|
|
|
6312
6312
|
if (x11win->transparent) {
|
|
6313
|
-
CefRefPtr<
|
|
6313
|
+
CefRefPtr<SparkBunClient> osrClient = getOSRClientForWindow(windowId);
|
|
6314
6314
|
if (osrClient) {
|
|
6315
6315
|
forwardX11EventToOSRClient(event, x11win->display, x11win->window, osrClient);
|
|
6316
6316
|
}
|
|
@@ -6414,7 +6414,7 @@ gboolean process_x11_events(gpointer data) {
|
|
|
6414
6414
|
void runCEFEventLoop() {
|
|
6415
6415
|
// Initialize GTK on the main thread (this MUST be done here)
|
|
6416
6416
|
initializeGTK();
|
|
6417
|
-
printf("===
|
|
6417
|
+
printf("=== SPARKBUN NATIVE WRAPPER VERSION 1.0.2 === CEF EVENT LOOP STARTED ===\n");
|
|
6418
6418
|
fflush(stdout);
|
|
6419
6419
|
|
|
6420
6420
|
// Set up a timer to periodically call CefDoMessageLoopWork()
|
|
@@ -6439,7 +6439,7 @@ void runCEFEventLoop() {
|
|
|
6439
6439
|
void runGTKEventLoop() {
|
|
6440
6440
|
// Initialize GTK on the main thread (this MUST be done here)
|
|
6441
6441
|
initializeGTK();
|
|
6442
|
-
printf("===
|
|
6442
|
+
printf("=== SPARKBUN NATIVE WRAPPER VERSION 1.0.2 === GTK EVENT LOOP STARTED ===\n");
|
|
6443
6443
|
|
|
6444
6444
|
// Note: GDK_BACKEND=x11 forced for Wayland compatibility
|
|
6445
6445
|
|
|
@@ -6542,8 +6542,8 @@ void* createX11Window(uint32_t windowId, double x, double y, double width, doubl
|
|
|
6542
6542
|
|
|
6543
6543
|
// Set WM_CLASS for proper taskbar icon matching
|
|
6544
6544
|
XClassHint class_hint;
|
|
6545
|
-
class_hint.res_name = (char*)"
|
|
6546
|
-
class_hint.res_class = (char*)"
|
|
6545
|
+
class_hint.res_name = (char*)"SparkBunKitchenSink-dev";
|
|
6546
|
+
class_hint.res_class = (char*)"SparkBunKitchenSink-dev";
|
|
6547
6547
|
XSetClassHint(display, x11_window, &class_hint);
|
|
6548
6548
|
|
|
6549
6549
|
// Set window protocols for close button
|
|
@@ -6633,7 +6633,7 @@ void* createX11Window(uint32_t windowId, double x, double y, double width, doubl
|
|
|
6633
6633
|
return result;
|
|
6634
6634
|
}
|
|
6635
6635
|
|
|
6636
|
-
|
|
6636
|
+
SPARKBUN_EXPORT void* createGTKWindow(uint32_t windowId, double x, double y, double width, double height, const char* title,
|
|
6637
6637
|
WindowCloseCallback closeCallback, WindowMoveCallback moveCallback, WindowResizeCallback resizeCallback, WindowFocusCallback focusCallback, WindowBlurCallback blurCallback, WindowKeyHandler keyCallback,
|
|
6638
6638
|
const char* titleBarStyle = nullptr, bool transparent = false) {
|
|
6639
6639
|
|
|
@@ -6649,7 +6649,7 @@ ELECTROBUN_EXPORT void* createGTKWindow(uint32_t windowId, double x, double y, d
|
|
|
6649
6649
|
gtk_window_set_title(GTK_WINDOW(window), title);
|
|
6650
6650
|
|
|
6651
6651
|
// Set WM_CLASS for proper taskbar icon matching
|
|
6652
|
-
gtk_window_set_wmclass(GTK_WINDOW(window), "
|
|
6652
|
+
gtk_window_set_wmclass(GTK_WINDOW(window), "SparkBunKitchenSink-dev", "SparkBunKitchenSink-dev");
|
|
6653
6653
|
|
|
6654
6654
|
gtk_window_set_default_size(GTK_WINDOW(window), (int)width, (int)height);
|
|
6655
6655
|
|
|
@@ -6791,7 +6791,7 @@ ELECTROBUN_EXPORT void* createGTKWindow(uint32_t windowId, double x, double y, d
|
|
|
6791
6791
|
}
|
|
6792
6792
|
|
|
6793
6793
|
// Mac-compatible function for Linux
|
|
6794
|
-
|
|
6794
|
+
SPARKBUN_EXPORT void* createWindowWithFrameAndStyleFromWorker(uint32_t windowId, double x, double y, double width, double height,
|
|
6795
6795
|
uint32_t styleMask, const char* titleBarStyle, bool transparent,
|
|
6796
6796
|
double trafficLightOffsetX, double trafficLightOffsetY,
|
|
6797
6797
|
WindowCloseCallback closeCallback, WindowMoveCallback moveCallback, WindowResizeCallback resizeCallback, WindowFocusCallback focusCallback, WindowBlurCallback blurCallback, WindowKeyHandler keyCallback) {
|
|
@@ -6826,7 +6826,7 @@ void setGTKWindowTitle(void* window, const char* title) {
|
|
|
6826
6826
|
}
|
|
6827
6827
|
|
|
6828
6828
|
// Cross-platform compatible function for Linux
|
|
6829
|
-
|
|
6829
|
+
SPARKBUN_EXPORT void setWindowTitle(void* window, const char* title) {
|
|
6830
6830
|
if (isCEFAvailable()) {
|
|
6831
6831
|
setX11WindowTitle(window, title);
|
|
6832
6832
|
} else {
|
|
@@ -6913,7 +6913,7 @@ void activateGTKWindow(void* window) {
|
|
|
6913
6913
|
});
|
|
6914
6914
|
}
|
|
6915
6915
|
|
|
6916
|
-
|
|
6916
|
+
SPARKBUN_EXPORT void showWindow(void* window, bool activate) {
|
|
6917
6917
|
if (isCEFAvailable()) {
|
|
6918
6918
|
if (activate) {
|
|
6919
6919
|
showX11Window(window);
|
|
@@ -6929,7 +6929,7 @@ ELECTROBUN_EXPORT void showWindow(void* window, bool activate) {
|
|
|
6929
6929
|
}
|
|
6930
6930
|
}
|
|
6931
6931
|
|
|
6932
|
-
|
|
6932
|
+
SPARKBUN_EXPORT void activateWindow(void* window) {
|
|
6933
6933
|
if (isCEFAvailable()) {
|
|
6934
6934
|
activateX11Window(window);
|
|
6935
6935
|
} else {
|
|
@@ -6953,7 +6953,7 @@ void hideGTKWindow(void* window) {
|
|
|
6953
6953
|
});
|
|
6954
6954
|
}
|
|
6955
6955
|
|
|
6956
|
-
|
|
6956
|
+
SPARKBUN_EXPORT void hideWindow(void* window) {
|
|
6957
6957
|
if (isCEFAvailable()) {
|
|
6958
6958
|
hideX11Window(window);
|
|
6959
6959
|
} else {
|
|
@@ -6962,7 +6962,7 @@ ELECTROBUN_EXPORT void hideWindow(void* window) {
|
|
|
6962
6962
|
}
|
|
6963
6963
|
|
|
6964
6964
|
// Cross-platform compatible function for Linux - return dummy style mask
|
|
6965
|
-
|
|
6965
|
+
SPARKBUN_EXPORT uint32_t getWindowStyle(bool borderless, bool titled, bool closable, bool miniaturizable,
|
|
6966
6966
|
bool resizable, bool unifiedTitleAndToolbar, bool fullScreen,
|
|
6967
6967
|
bool fullSizeContentView, bool utilityWindow, bool docModalWindow,
|
|
6968
6968
|
bool nonactivatingPanel, bool hudWindow) {
|
|
@@ -6989,7 +6989,7 @@ AbstractView* initCEFWebview(uint32_t webviewId,
|
|
|
6989
6989
|
HandlePostMessage eventBridgeHandler,
|
|
6990
6990
|
HandlePostMessage bunBridgeHandler,
|
|
6991
6991
|
HandlePostMessage internalBridgeHandler,
|
|
6992
|
-
const char*
|
|
6992
|
+
const char* sparkbunPreloadScript,
|
|
6993
6993
|
const char* customPreloadScript,
|
|
6994
6994
|
const char* viewsRoot,
|
|
6995
6995
|
bool sandbox,
|
|
@@ -7005,7 +7005,7 @@ AbstractView* initCEFWebview(uint32_t webviewId,
|
|
|
7005
7005
|
url, x, y, width, height, autoResize,
|
|
7006
7006
|
partitionIdentifier, navigationCallback, webviewEventHandler,
|
|
7007
7007
|
eventBridgeHandler, bunBridgeHandler, internalBridgeHandler,
|
|
7008
|
-
|
|
7008
|
+
sparkbunPreloadScript, customPreloadScript, sandbox,
|
|
7009
7009
|
startTransparent, startPassthrough
|
|
7010
7010
|
);
|
|
7011
7011
|
|
|
@@ -7091,7 +7091,7 @@ AbstractView* initGTKWebkitWebview(uint32_t webviewId,
|
|
|
7091
7091
|
HandlePostMessage eventBridgeHandler,
|
|
7092
7092
|
HandlePostMessage bunBridgeHandler,
|
|
7093
7093
|
HandlePostMessage internalBridgeHandler,
|
|
7094
|
-
const char*
|
|
7094
|
+
const char* sparkbunPreloadScript,
|
|
7095
7095
|
const char* customPreloadScript,
|
|
7096
7096
|
const char* viewsRoot,
|
|
7097
7097
|
bool sandbox,
|
|
@@ -7108,7 +7108,7 @@ AbstractView* initGTKWebkitWebview(uint32_t webviewId,
|
|
|
7108
7108
|
url, x, y, width, height, autoResize,
|
|
7109
7109
|
partitionIdentifier, navigationCallback, webviewEventHandler,
|
|
7110
7110
|
eventBridgeHandler, bunBridgeHandler, internalBridgeHandler,
|
|
7111
|
-
|
|
7111
|
+
sparkbunPreloadScript, customPreloadScript, sandbox,
|
|
7112
7112
|
startTransparent, startPassthrough
|
|
7113
7113
|
);
|
|
7114
7114
|
|
|
@@ -7154,12 +7154,12 @@ AbstractView* initGTKWebkitWebview(uint32_t webviewId,
|
|
|
7154
7154
|
return result;
|
|
7155
7155
|
}
|
|
7156
7156
|
|
|
7157
|
-
|
|
7157
|
+
SPARKBUN_EXPORT void setNextWebviewFlags(bool startTransparent, bool startPassthrough) {
|
|
7158
7158
|
g_nextWebviewFlags.startTransparent = startTransparent;
|
|
7159
7159
|
g_nextWebviewFlags.startPassthrough = startPassthrough;
|
|
7160
7160
|
}
|
|
7161
7161
|
|
|
7162
|
-
|
|
7162
|
+
SPARKBUN_EXPORT AbstractView* initWebview(uint32_t webviewId,
|
|
7163
7163
|
void* window,
|
|
7164
7164
|
const char* renderer,
|
|
7165
7165
|
const char* url,
|
|
@@ -7172,7 +7172,7 @@ ELECTROBUN_EXPORT AbstractView* initWebview(uint32_t webviewId,
|
|
|
7172
7172
|
HandlePostMessage eventBridgeHandler,
|
|
7173
7173
|
HandlePostMessage bunBridgeHandler,
|
|
7174
7174
|
HandlePostMessage internalBridgeHandler,
|
|
7175
|
-
const char*
|
|
7175
|
+
const char* sparkbunPreloadScript,
|
|
7176
7176
|
const char* customPreloadScript,
|
|
7177
7177
|
const char* viewsRoot,
|
|
7178
7178
|
bool transparent,
|
|
@@ -7198,13 +7198,13 @@ ELECTROBUN_EXPORT AbstractView* initWebview(uint32_t webviewId,
|
|
|
7198
7198
|
view = initCEFWebview(webviewId, window, renderer, url, x, y, width, height, autoResize,
|
|
7199
7199
|
partitionIdentifier, navigationCallback, webviewEventHandler,
|
|
7200
7200
|
eventBridgeHandler, bunBridgeHandler, internalBridgeHandler,
|
|
7201
|
-
|
|
7201
|
+
sparkbunPreloadScript, customPreloadScript, viewsRoot, sandbox,
|
|
7202
7202
|
startTransparent, startPassthrough);
|
|
7203
7203
|
} else {
|
|
7204
7204
|
view = initGTKWebkitWebview(webviewId, window, renderer, url, x, y, width, height, autoResize,
|
|
7205
7205
|
partitionIdentifier, navigationCallback, webviewEventHandler,
|
|
7206
7206
|
eventBridgeHandler, bunBridgeHandler, internalBridgeHandler,
|
|
7207
|
-
|
|
7207
|
+
sparkbunPreloadScript, customPreloadScript, viewsRoot, sandbox,
|
|
7208
7208
|
startTransparent, startPassthrough);
|
|
7209
7209
|
}
|
|
7210
7210
|
|
|
@@ -7214,7 +7214,7 @@ ELECTROBUN_EXPORT AbstractView* initWebview(uint32_t webviewId,
|
|
|
7214
7214
|
|
|
7215
7215
|
}
|
|
7216
7216
|
|
|
7217
|
-
|
|
7217
|
+
SPARKBUN_EXPORT AbstractView* initWGPUView(uint32_t webviewId,
|
|
7218
7218
|
void* window,
|
|
7219
7219
|
double x, double y,
|
|
7220
7220
|
double width, double height,
|
|
@@ -7372,7 +7372,7 @@ ELECTROBUN_EXPORT AbstractView* initWGPUView(uint32_t webviewId,
|
|
|
7372
7372
|
return view.get();
|
|
7373
7373
|
}
|
|
7374
7374
|
|
|
7375
|
-
|
|
7375
|
+
SPARKBUN_EXPORT void loadURLInWebView(AbstractView* abstractView, const char* urlString) {
|
|
7376
7376
|
if (abstractView && urlString) {
|
|
7377
7377
|
std::string urlStr(urlString); // Copy the string to ensure it survives
|
|
7378
7378
|
dispatch_sync_main_void([abstractView, urlStr]() { // Capture by value
|
|
@@ -7381,7 +7381,7 @@ ELECTROBUN_EXPORT void loadURLInWebView(AbstractView* abstractView, const char*
|
|
|
7381
7381
|
}
|
|
7382
7382
|
}
|
|
7383
7383
|
|
|
7384
|
-
|
|
7384
|
+
SPARKBUN_EXPORT void wgpuViewSetFrame(AbstractView* abstractView, double x, double y, double width, double height) {
|
|
7385
7385
|
if (!abstractView) return;
|
|
7386
7386
|
GdkRectangle frame = {(int)x, (int)y, (int)width, (int)height};
|
|
7387
7387
|
abstractView->storePendingResize(frame, "");
|
|
@@ -7389,28 +7389,28 @@ ELECTROBUN_EXPORT void wgpuViewSetFrame(AbstractView* abstractView, double x, do
|
|
|
7389
7389
|
schedulePendingResizeDrain();
|
|
7390
7390
|
}
|
|
7391
7391
|
|
|
7392
|
-
|
|
7392
|
+
SPARKBUN_EXPORT void wgpuViewSetTransparent(AbstractView* abstractView, bool transparent) {
|
|
7393
7393
|
if (!abstractView) return;
|
|
7394
7394
|
dispatch_sync_main_void([&]() {
|
|
7395
7395
|
abstractView->setTransparent(transparent);
|
|
7396
7396
|
});
|
|
7397
7397
|
}
|
|
7398
7398
|
|
|
7399
|
-
|
|
7399
|
+
SPARKBUN_EXPORT void wgpuViewSetPassthrough(AbstractView* abstractView, bool enablePassthrough) {
|
|
7400
7400
|
if (!abstractView) return;
|
|
7401
7401
|
dispatch_sync_main_void([&]() {
|
|
7402
7402
|
abstractView->setPassthrough(enablePassthrough);
|
|
7403
7403
|
});
|
|
7404
7404
|
}
|
|
7405
7405
|
|
|
7406
|
-
|
|
7406
|
+
SPARKBUN_EXPORT void wgpuViewSetHidden(AbstractView* abstractView, bool hidden) {
|
|
7407
7407
|
if (!abstractView) return;
|
|
7408
7408
|
dispatch_sync_main_void([&]() {
|
|
7409
7409
|
abstractView->setHidden(hidden);
|
|
7410
7410
|
});
|
|
7411
7411
|
}
|
|
7412
7412
|
|
|
7413
|
-
|
|
7413
|
+
SPARKBUN_EXPORT void wgpuViewRemove(AbstractView* abstractView) {
|
|
7414
7414
|
if (!abstractView) return;
|
|
7415
7415
|
uint32_t viewId = abstractView->webviewId;
|
|
7416
7416
|
WGPUViewImpl* view = dynamic_cast<WGPUViewImpl*>(abstractView);
|
|
@@ -7430,7 +7430,7 @@ ELECTROBUN_EXPORT void wgpuViewRemove(AbstractView* abstractView) {
|
|
|
7430
7430
|
}
|
|
7431
7431
|
}
|
|
7432
7432
|
|
|
7433
|
-
|
|
7433
|
+
SPARKBUN_EXPORT void* wgpuViewGetNativeHandle(AbstractView* abstractView) {
|
|
7434
7434
|
if (!abstractView) return nullptr;
|
|
7435
7435
|
WGPUViewImpl* view = dynamic_cast<WGPUViewImpl*>(abstractView);
|
|
7436
7436
|
if (!view) return nullptr;
|
|
@@ -8081,7 +8081,7 @@ static void gpuTestRequestDeviceCallback(WGPURequestDeviceStatus status, WGPUDev
|
|
|
8081
8081
|
dispatch_sync_main_void([state, device]() {
|
|
8082
8082
|
state->device = device;
|
|
8083
8083
|
if (p_wgpuDeviceSetLabel) {
|
|
8084
|
-
WGPUStringView label = {"
|
|
8084
|
+
WGPUStringView label = {"SparkBun WGPU Device", WGPU_STRLEN};
|
|
8085
8085
|
p_wgpuDeviceSetLabel(device, label);
|
|
8086
8086
|
}
|
|
8087
8087
|
state->queue = p_wgpuDeviceGetQueue(device);
|
|
@@ -8110,14 +8110,14 @@ static void runOnMainThreadAsyncVoid(std::function<void()> fn) {
|
|
|
8110
8110
|
dispatch_async_main_void([fn = std::move(fn)]() { fn(); });
|
|
8111
8111
|
}
|
|
8112
8112
|
|
|
8113
|
-
|
|
8113
|
+
SPARKBUN_EXPORT void* wgpuInstanceCreateSurfaceMainThread(void* instance, void* descriptor) {
|
|
8114
8114
|
if (!ensureWgpuSymbols()) return nullptr;
|
|
8115
8115
|
return runOnMainThreadSyncPtr([&]() -> void* {
|
|
8116
8116
|
return p_wgpuInstanceCreateSurface(instance, descriptor);
|
|
8117
8117
|
});
|
|
8118
8118
|
}
|
|
8119
8119
|
|
|
8120
|
-
|
|
8120
|
+
SPARKBUN_EXPORT void* wgpuCreateSurfaceForView(void* wgpuInstance, AbstractView* abstractView) {
|
|
8121
8121
|
if (!wgpuInstance || !abstractView) return nullptr;
|
|
8122
8122
|
if (!ensureWgpuSymbols()) return nullptr;
|
|
8123
8123
|
|
|
@@ -8151,24 +8151,24 @@ ELECTROBUN_EXPORT void* wgpuCreateSurfaceForView(void* wgpuInstance, AbstractVie
|
|
|
8151
8151
|
});
|
|
8152
8152
|
}
|
|
8153
8153
|
|
|
8154
|
-
|
|
8154
|
+
SPARKBUN_EXPORT void wgpuSurfaceConfigureMainThread(void* surface, void* config) {
|
|
8155
8155
|
if (!ensureWgpuSymbols()) return;
|
|
8156
8156
|
runOnMainThreadSyncVoid([&]() { p_wgpuSurfaceConfigure(surface, config); });
|
|
8157
8157
|
}
|
|
8158
8158
|
|
|
8159
|
-
|
|
8159
|
+
SPARKBUN_EXPORT void wgpuSurfaceGetCurrentTextureMainThread(void* surface, void* surfaceTexture) {
|
|
8160
8160
|
if (!ensureWgpuSymbols()) return;
|
|
8161
8161
|
runOnMainThreadSyncVoid([&]() { p_wgpuSurfaceGetCurrentTexture(surface, surfaceTexture); });
|
|
8162
8162
|
}
|
|
8163
8163
|
|
|
8164
|
-
|
|
8164
|
+
SPARKBUN_EXPORT int32_t wgpuSurfacePresentMainThread(void* surface) {
|
|
8165
8165
|
if (!ensureWgpuSymbols()) return 0;
|
|
8166
8166
|
return (int32_t)(intptr_t)runOnMainThreadSyncPtr([&]() -> void* {
|
|
8167
8167
|
return (void*)(intptr_t)p_wgpuSurfacePresent(surface);
|
|
8168
8168
|
});
|
|
8169
8169
|
}
|
|
8170
8170
|
|
|
8171
|
-
|
|
8171
|
+
SPARKBUN_EXPORT uint64_t wgpuQueueOnSubmittedWorkDoneShim(void* queue, void* callbackInfo) {
|
|
8172
8172
|
if (!ensureWgpuSymbols()) return 0;
|
|
8173
8173
|
if (!callbackInfo) return 0;
|
|
8174
8174
|
WGPUQueueWorkDoneCallbackInfo info = *(WGPUQueueWorkDoneCallbackInfo*)callbackInfo;
|
|
@@ -8176,7 +8176,7 @@ ELECTROBUN_EXPORT uint64_t wgpuQueueOnSubmittedWorkDoneShim(void* queue, void* c
|
|
|
8176
8176
|
return future.id;
|
|
8177
8177
|
}
|
|
8178
8178
|
|
|
8179
|
-
|
|
8179
|
+
SPARKBUN_EXPORT uint64_t wgpuBufferMapAsyncShim(void* buffer, uint64_t mode, uint64_t offset, uint64_t size, void* callbackInfo) {
|
|
8180
8180
|
if (!ensureWgpuSymbols()) return 0;
|
|
8181
8181
|
if (!callbackInfo) return 0;
|
|
8182
8182
|
WGPUBufferMapCallbackInfo info = *(WGPUBufferMapCallbackInfo*)callbackInfo;
|
|
@@ -8184,7 +8184,7 @@ ELECTROBUN_EXPORT uint64_t wgpuBufferMapAsyncShim(void* buffer, uint64_t mode, u
|
|
|
8184
8184
|
return future.id;
|
|
8185
8185
|
}
|
|
8186
8186
|
|
|
8187
|
-
|
|
8187
|
+
SPARKBUN_EXPORT int32_t wgpuInstanceWaitAnyShim(void* instance, uint64_t futureId, uint64_t timeoutNS) {
|
|
8188
8188
|
if (!ensureWgpuSymbols()) return 0;
|
|
8189
8189
|
if (!instance || !futureId) return 0;
|
|
8190
8190
|
WGPUFutureWaitInfo info;
|
|
@@ -8195,7 +8195,7 @@ ELECTROBUN_EXPORT int32_t wgpuInstanceWaitAnyShim(void* instance, uint64_t futur
|
|
|
8195
8195
|
return 0;
|
|
8196
8196
|
}
|
|
8197
8197
|
|
|
8198
|
-
|
|
8198
|
+
SPARKBUN_EXPORT uint8_t* wgpuBufferReadSyncShim(
|
|
8199
8199
|
void* instance,
|
|
8200
8200
|
void* buffer,
|
|
8201
8201
|
uint64_t offset,
|
|
@@ -8252,7 +8252,7 @@ ELECTROBUN_EXPORT uint8_t* wgpuBufferReadSyncShim(
|
|
|
8252
8252
|
return out;
|
|
8253
8253
|
}
|
|
8254
8254
|
|
|
8255
|
-
|
|
8255
|
+
SPARKBUN_EXPORT int32_t wgpuBufferReadSyncIntoShim(
|
|
8256
8256
|
void* instance,
|
|
8257
8257
|
void* buffer,
|
|
8258
8258
|
uint64_t offset,
|
|
@@ -8347,7 +8347,7 @@ static void wgpuReadbackCallback(
|
|
|
8347
8347
|
job->done.store(1);
|
|
8348
8348
|
}
|
|
8349
8349
|
|
|
8350
|
-
|
|
8350
|
+
SPARKBUN_EXPORT void* wgpuBufferReadbackBeginShim(
|
|
8351
8351
|
void* buffer,
|
|
8352
8352
|
uint64_t offset,
|
|
8353
8353
|
uint64_t size,
|
|
@@ -8383,20 +8383,20 @@ ELECTROBUN_EXPORT void* wgpuBufferReadbackBeginShim(
|
|
|
8383
8383
|
return job;
|
|
8384
8384
|
}
|
|
8385
8385
|
|
|
8386
|
-
|
|
8386
|
+
SPARKBUN_EXPORT int32_t wgpuBufferReadbackStatusShim(void* jobPtr) {
|
|
8387
8387
|
if (!jobPtr) return 2;
|
|
8388
8388
|
WGPUReadbackJob* job = (WGPUReadbackJob*)jobPtr;
|
|
8389
8389
|
if (job->done.load() == 0) return 0;
|
|
8390
8390
|
return job->status.load();
|
|
8391
8391
|
}
|
|
8392
8392
|
|
|
8393
|
-
|
|
8393
|
+
SPARKBUN_EXPORT void wgpuBufferReadbackFreeShim(void* jobPtr) {
|
|
8394
8394
|
if (!jobPtr) return;
|
|
8395
8395
|
WGPUReadbackJob* job = (WGPUReadbackJob*)jobPtr;
|
|
8396
8396
|
free(job);
|
|
8397
8397
|
}
|
|
8398
8398
|
|
|
8399
|
-
|
|
8399
|
+
SPARKBUN_EXPORT void wgpuRunGPUTest(void* abstractView) {
|
|
8400
8400
|
if (!abstractView) return;
|
|
8401
8401
|
if (!ensureWgpuTestSymbols()) return;
|
|
8402
8402
|
|
|
@@ -8463,7 +8463,7 @@ ELECTROBUN_EXPORT void wgpuRunGPUTest(void* abstractView) {
|
|
|
8463
8463
|
});
|
|
8464
8464
|
}
|
|
8465
8465
|
|
|
8466
|
-
|
|
8466
|
+
SPARKBUN_EXPORT void wgpuToggleGPUTestShader(void* abstractView) {
|
|
8467
8467
|
if (!abstractView) return;
|
|
8468
8468
|
if (!ensureWgpuTestSymbols()) return;
|
|
8469
8469
|
|
|
@@ -8476,7 +8476,7 @@ ELECTROBUN_EXPORT void wgpuToggleGPUTestShader(void* abstractView) {
|
|
|
8476
8476
|
});
|
|
8477
8477
|
}
|
|
8478
8478
|
|
|
8479
|
-
|
|
8479
|
+
SPARKBUN_EXPORT void wgpuCreateAdapterDeviceMainThread(void* instancePtr, void* surfacePtr, void* outAdapterDevice) {
|
|
8480
8480
|
if (!ensureWgpuTestSymbols()) return;
|
|
8481
8481
|
runOnMainThreadSyncVoid([&]() {
|
|
8482
8482
|
WGPUInstance instance = (WGPUInstance)instancePtr;
|
|
@@ -8572,7 +8572,7 @@ ELECTROBUN_EXPORT void wgpuCreateAdapterDeviceMainThread(void* instancePtr, void
|
|
|
8572
8572
|
});
|
|
8573
8573
|
}
|
|
8574
8574
|
|
|
8575
|
-
|
|
8575
|
+
SPARKBUN_EXPORT void loadHTMLInWebView(AbstractView* abstractView, const char* htmlString) {
|
|
8576
8576
|
if (abstractView && htmlString) {
|
|
8577
8577
|
std::string htmlStr(htmlString); // Copy the string to ensure it survives
|
|
8578
8578
|
dispatch_sync_main_void([abstractView, htmlStr]() { // Capture by value
|
|
@@ -8581,7 +8581,7 @@ ELECTROBUN_EXPORT void loadHTMLInWebView(AbstractView* abstractView, const char*
|
|
|
8581
8581
|
}
|
|
8582
8582
|
}
|
|
8583
8583
|
|
|
8584
|
-
|
|
8584
|
+
SPARKBUN_EXPORT void webviewGoBack(AbstractView* abstractView) {
|
|
8585
8585
|
if (abstractView) {
|
|
8586
8586
|
dispatch_sync_main_void([&]() {
|
|
8587
8587
|
abstractView->goBack();
|
|
@@ -8589,7 +8589,7 @@ ELECTROBUN_EXPORT void webviewGoBack(AbstractView* abstractView) {
|
|
|
8589
8589
|
}
|
|
8590
8590
|
}
|
|
8591
8591
|
|
|
8592
|
-
|
|
8592
|
+
SPARKBUN_EXPORT void webviewGoForward(AbstractView* abstractView) {
|
|
8593
8593
|
if (abstractView) {
|
|
8594
8594
|
dispatch_sync_main_void([&]() {
|
|
8595
8595
|
abstractView->goForward();
|
|
@@ -8597,7 +8597,7 @@ ELECTROBUN_EXPORT void webviewGoForward(AbstractView* abstractView) {
|
|
|
8597
8597
|
}
|
|
8598
8598
|
}
|
|
8599
8599
|
|
|
8600
|
-
|
|
8600
|
+
SPARKBUN_EXPORT void webviewReload(AbstractView* abstractView) {
|
|
8601
8601
|
if (abstractView) {
|
|
8602
8602
|
dispatch_sync_main_void([&]() {
|
|
8603
8603
|
abstractView->reload();
|
|
@@ -8605,7 +8605,7 @@ ELECTROBUN_EXPORT void webviewReload(AbstractView* abstractView) {
|
|
|
8605
8605
|
}
|
|
8606
8606
|
}
|
|
8607
8607
|
|
|
8608
|
-
|
|
8608
|
+
SPARKBUN_EXPORT void webviewRemove(AbstractView* abstractView) {
|
|
8609
8609
|
if (abstractView) {
|
|
8610
8610
|
// Get the webview ID before scheduling async removal
|
|
8611
8611
|
uint32_t webviewId = abstractView->webviewId;
|
|
@@ -8643,14 +8643,14 @@ ELECTROBUN_EXPORT void webviewRemove(AbstractView* abstractView) {
|
|
|
8643
8643
|
}
|
|
8644
8644
|
}
|
|
8645
8645
|
|
|
8646
|
-
|
|
8646
|
+
SPARKBUN_EXPORT bool webviewCanGoBack(AbstractView* abstractView) {
|
|
8647
8647
|
if (abstractView) {
|
|
8648
8648
|
return abstractView->canGoBack();
|
|
8649
8649
|
}
|
|
8650
8650
|
return false;
|
|
8651
8651
|
}
|
|
8652
8652
|
|
|
8653
|
-
|
|
8653
|
+
SPARKBUN_EXPORT bool webviewCanGoForward(AbstractView* abstractView) {
|
|
8654
8654
|
if (abstractView) {
|
|
8655
8655
|
return abstractView->canGoForward();
|
|
8656
8656
|
}
|
|
@@ -8717,7 +8717,7 @@ void updateActiveWebviewForMousePosition(uint32_t windowId, int mouseX, int mous
|
|
|
8717
8717
|
container->activeWebView = nullptr;
|
|
8718
8718
|
}
|
|
8719
8719
|
|
|
8720
|
-
|
|
8720
|
+
SPARKBUN_EXPORT void resizeWebview(AbstractView* abstractView, double x, double y, double width, double height, const char* masksJson) {
|
|
8721
8721
|
if (!abstractView) {
|
|
8722
8722
|
return;
|
|
8723
8723
|
}
|
|
@@ -8732,7 +8732,7 @@ ELECTROBUN_EXPORT void resizeWebview(AbstractView* abstractView, double x, doubl
|
|
|
8732
8732
|
schedulePendingResizeDrain();
|
|
8733
8733
|
}
|
|
8734
8734
|
|
|
8735
|
-
|
|
8735
|
+
SPARKBUN_EXPORT void evaluateJavaScriptWithNoCompletion(AbstractView* abstractView, const char* js) {
|
|
8736
8736
|
if (abstractView && js) {
|
|
8737
8737
|
std::string jsString(js); // Copy the string to ensure it survives
|
|
8738
8738
|
dispatch_sync_main_void([abstractView, jsString]() { // Capture by value
|
|
@@ -8773,7 +8773,7 @@ void webviewSetHidden(AbstractView* abstractView, bool hidden) {
|
|
|
8773
8773
|
}
|
|
8774
8774
|
}
|
|
8775
8775
|
|
|
8776
|
-
|
|
8776
|
+
SPARKBUN_EXPORT void setWebviewNavigationRules(AbstractView* abstractView, const char* rulesJson) {
|
|
8777
8777
|
if (abstractView) {
|
|
8778
8778
|
std::string rulesStr(rulesJson ? rulesJson : ""); // Copy the string to ensure it survives
|
|
8779
8779
|
dispatch_sync_main_void([abstractView, rulesStr]() {
|
|
@@ -8782,7 +8782,7 @@ ELECTROBUN_EXPORT void setWebviewNavigationRules(AbstractView* abstractView, con
|
|
|
8782
8782
|
}
|
|
8783
8783
|
}
|
|
8784
8784
|
|
|
8785
|
-
|
|
8785
|
+
SPARKBUN_EXPORT void webviewFindInPage(AbstractView* abstractView, const char* searchText, bool forward, bool matchCase) {
|
|
8786
8786
|
if (abstractView) {
|
|
8787
8787
|
std::string text(searchText ? searchText : "");
|
|
8788
8788
|
dispatch_sync_main_void([abstractView, text, forward, matchCase]() {
|
|
@@ -8791,7 +8791,7 @@ ELECTROBUN_EXPORT void webviewFindInPage(AbstractView* abstractView, const char*
|
|
|
8791
8791
|
}
|
|
8792
8792
|
}
|
|
8793
8793
|
|
|
8794
|
-
|
|
8794
|
+
SPARKBUN_EXPORT void webviewStopFind(AbstractView* abstractView) {
|
|
8795
8795
|
if (abstractView) {
|
|
8796
8796
|
dispatch_sync_main_void([abstractView]() {
|
|
8797
8797
|
abstractView->stopFindInPage();
|
|
@@ -8799,7 +8799,7 @@ ELECTROBUN_EXPORT void webviewStopFind(AbstractView* abstractView) {
|
|
|
8799
8799
|
}
|
|
8800
8800
|
}
|
|
8801
8801
|
|
|
8802
|
-
|
|
8802
|
+
SPARKBUN_EXPORT void webviewOpenDevTools(AbstractView* abstractView) {
|
|
8803
8803
|
if (abstractView) {
|
|
8804
8804
|
dispatch_sync_main_void([abstractView]() {
|
|
8805
8805
|
abstractView->openDevTools();
|
|
@@ -8807,7 +8807,7 @@ ELECTROBUN_EXPORT void webviewOpenDevTools(AbstractView* abstractView) {
|
|
|
8807
8807
|
}
|
|
8808
8808
|
}
|
|
8809
8809
|
|
|
8810
|
-
|
|
8810
|
+
SPARKBUN_EXPORT void webviewCloseDevTools(AbstractView* abstractView) {
|
|
8811
8811
|
if (abstractView) {
|
|
8812
8812
|
dispatch_sync_main_void([abstractView]() {
|
|
8813
8813
|
abstractView->closeDevTools();
|
|
@@ -8815,7 +8815,7 @@ ELECTROBUN_EXPORT void webviewCloseDevTools(AbstractView* abstractView) {
|
|
|
8815
8815
|
}
|
|
8816
8816
|
}
|
|
8817
8817
|
|
|
8818
|
-
|
|
8818
|
+
SPARKBUN_EXPORT void webviewToggleDevTools(AbstractView* abstractView) {
|
|
8819
8819
|
if (abstractView) {
|
|
8820
8820
|
dispatch_sync_main_void([abstractView]() {
|
|
8821
8821
|
abstractView->toggleDevTools();
|
|
@@ -8823,17 +8823,17 @@ ELECTROBUN_EXPORT void webviewToggleDevTools(AbstractView* abstractView) {
|
|
|
8823
8823
|
}
|
|
8824
8824
|
}
|
|
8825
8825
|
|
|
8826
|
-
|
|
8826
|
+
SPARKBUN_EXPORT void webviewSetPageZoom(AbstractView* abstractView, double zoomLevel) {
|
|
8827
8827
|
// pageZoom is WebKit-specific, not available on Linux CEF
|
|
8828
8828
|
// TODO: implement CEF zoom if needed
|
|
8829
8829
|
}
|
|
8830
8830
|
|
|
8831
|
-
|
|
8831
|
+
SPARKBUN_EXPORT double webviewGetPageZoom(AbstractView* abstractView) {
|
|
8832
8832
|
// pageZoom is WebKit-specific, not available on Linux CEF
|
|
8833
8833
|
return 1.0;
|
|
8834
8834
|
}
|
|
8835
8835
|
|
|
8836
|
-
|
|
8836
|
+
SPARKBUN_EXPORT void updatePreloadScriptToWebView(AbstractView* abstractView, const char* scriptIdentifier, const char* scriptContent, bool forMainFrameOnly) {
|
|
8837
8837
|
if (abstractView) {
|
|
8838
8838
|
dispatch_sync_main_void([&]() {
|
|
8839
8839
|
abstractView->updateCustomPreloadScript(scriptContent);
|
|
@@ -8884,7 +8884,7 @@ static gboolean onWindowDragButtonRelease(GtkWidget* widget, GdkEventButton* eve
|
|
|
8884
8884
|
return FALSE; // Let other handlers process the event
|
|
8885
8885
|
}
|
|
8886
8886
|
|
|
8887
|
-
|
|
8887
|
+
SPARKBUN_EXPORT void startWindowMove(void *window) {
|
|
8888
8888
|
dispatch_sync_main_void([&]() {
|
|
8889
8889
|
if (isCEFAvailable()) {
|
|
8890
8890
|
// CEF is always forced to X11 mode (--ozone-platform=x11 / --use-x11),
|
|
@@ -8951,14 +8951,14 @@ ELECTROBUN_EXPORT void startWindowMove(void *window) {
|
|
|
8951
8951
|
});
|
|
8952
8952
|
}
|
|
8953
8953
|
|
|
8954
|
-
|
|
8954
|
+
SPARKBUN_EXPORT void stopWindowMove() {
|
|
8955
8955
|
// gtk_window_begin_move_drag is handled entirely by the WM/compositor —
|
|
8956
8956
|
// there's nothing to clean up on our side.
|
|
8957
8957
|
printf("stopWindowMove called\n");
|
|
8958
8958
|
fflush(stdout);
|
|
8959
8959
|
}
|
|
8960
8960
|
|
|
8961
|
-
|
|
8961
|
+
SPARKBUN_EXPORT void addPreloadScriptToWebView(AbstractView* abstractView, const char* scriptContent, bool forMainFrameOnly) {
|
|
8962
8962
|
if (abstractView) {
|
|
8963
8963
|
dispatch_sync_main_void([&]() {
|
|
8964
8964
|
abstractView->addPreloadScriptToWebView(scriptContent);
|
|
@@ -8966,7 +8966,7 @@ ELECTROBUN_EXPORT void addPreloadScriptToWebView(AbstractView* abstractView, con
|
|
|
8966
8966
|
}
|
|
8967
8967
|
}
|
|
8968
8968
|
|
|
8969
|
-
|
|
8969
|
+
SPARKBUN_EXPORT void callAsyncJavaScript(const char* messageId, const char* jsString, uint32_t webviewId, uint32_t hostWebviewId, void* completionHandler) {
|
|
8970
8970
|
// Find the webview in containers
|
|
8971
8971
|
for (auto& [id, container] : g_containers) {
|
|
8972
8972
|
for (auto& view : container->abstractViews) {
|
|
@@ -9004,18 +9004,18 @@ void testFFI2(void (*completionHandler)()) {
|
|
|
9004
9004
|
}
|
|
9005
9005
|
}
|
|
9006
9006
|
|
|
9007
|
-
|
|
9007
|
+
SPARKBUN_EXPORT int simpleTest() {
|
|
9008
9008
|
printf("simpleTest called successfully\n");
|
|
9009
9009
|
fflush(stdout);
|
|
9010
9010
|
return 42;
|
|
9011
9011
|
}
|
|
9012
9012
|
|
|
9013
|
-
|
|
9013
|
+
SPARKBUN_EXPORT const char* getUrlFromNavigationAction(void* navigationAction) {
|
|
9014
9014
|
// TODO: Implement URL extraction from navigation action
|
|
9015
9015
|
return nullptr;
|
|
9016
9016
|
}
|
|
9017
9017
|
|
|
9018
|
-
|
|
9018
|
+
SPARKBUN_EXPORT const char* getBodyFromScriptMessage(void* message) {
|
|
9019
9019
|
// TODO: Implement body extraction from script message
|
|
9020
9020
|
return nullptr;
|
|
9021
9021
|
}
|
|
@@ -9024,7 +9024,7 @@ void invokeDecisionHandler(void* decisionHandler, uint32_t policy) {
|
|
|
9024
9024
|
// TODO: Implement decision handler invocation
|
|
9025
9025
|
}
|
|
9026
9026
|
|
|
9027
|
-
|
|
9027
|
+
SPARKBUN_EXPORT bool moveToTrash(char* pathString) {
|
|
9028
9028
|
if (!pathString) return false;
|
|
9029
9029
|
|
|
9030
9030
|
// Use GIO to move file to trash
|
|
@@ -9087,7 +9087,7 @@ void showItemInFolder(char* path) {
|
|
|
9087
9087
|
}
|
|
9088
9088
|
|
|
9089
9089
|
// Open a URL in the default browser or appropriate application
|
|
9090
|
-
|
|
9090
|
+
SPARKBUN_EXPORT bool openExternal(const char* urlString) {
|
|
9091
9091
|
if (!urlString) {
|
|
9092
9092
|
fprintf(stderr, "ERROR: NULL URL passed to openExternal\n");
|
|
9093
9093
|
return false;
|
|
@@ -9124,7 +9124,7 @@ ELECTROBUN_EXPORT bool openExternal(const char* urlString) {
|
|
|
9124
9124
|
}
|
|
9125
9125
|
|
|
9126
9126
|
// Open a file or folder with the default application
|
|
9127
|
-
|
|
9127
|
+
SPARKBUN_EXPORT bool openPath(const char* pathString) {
|
|
9128
9128
|
if (!pathString) {
|
|
9129
9129
|
fprintf(stderr, "ERROR: NULL path passed to openPath\n");
|
|
9130
9130
|
return false;
|
|
@@ -9227,7 +9227,7 @@ void showNotification(const char* title, const char* body, const char* subtitle,
|
|
|
9227
9227
|
}).detach();
|
|
9228
9228
|
}
|
|
9229
9229
|
|
|
9230
|
-
|
|
9230
|
+
SPARKBUN_EXPORT const char* openFileDialog(const char* startingFolder, const char* allowedFileTypes, int canChooseFiles, int canChooseDirectories, int allowsMultipleSelection) {
|
|
9231
9231
|
// This function needs to run on the main thread
|
|
9232
9232
|
return dispatch_sync_main([&]() -> const char* {
|
|
9233
9233
|
// Determine the file chooser action based on parameters
|
|
@@ -9332,7 +9332,7 @@ ELECTROBUN_EXPORT const char* openFileDialog(const char* startingFolder, const c
|
|
|
9332
9332
|
});
|
|
9333
9333
|
}
|
|
9334
9334
|
|
|
9335
|
-
|
|
9335
|
+
SPARKBUN_EXPORT int showMessageBox(const char *type,
|
|
9336
9336
|
const char *title,
|
|
9337
9337
|
const char *message,
|
|
9338
9338
|
const char *detail,
|
|
@@ -9425,7 +9425,7 @@ ELECTROBUN_EXPORT int showMessageBox(const char *type,
|
|
|
9425
9425
|
|
|
9426
9426
|
// clipboardReadText - Read text from the system clipboard
|
|
9427
9427
|
// Returns: UTF-8 string (caller must free) or NULL if no text available
|
|
9428
|
-
|
|
9428
|
+
SPARKBUN_EXPORT const char* clipboardReadText() {
|
|
9429
9429
|
return dispatch_sync_main([&]() -> const char* {
|
|
9430
9430
|
GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
|
|
9431
9431
|
gchar* text = gtk_clipboard_wait_for_text(clipboard);
|
|
@@ -9439,7 +9439,7 @@ ELECTROBUN_EXPORT const char* clipboardReadText() {
|
|
|
9439
9439
|
}
|
|
9440
9440
|
|
|
9441
9441
|
// clipboardWriteText - Write text to the system clipboard
|
|
9442
|
-
|
|
9442
|
+
SPARKBUN_EXPORT void clipboardWriteText(const char* text) {
|
|
9443
9443
|
if (!text) return;
|
|
9444
9444
|
|
|
9445
9445
|
// Make a copy of the text since we need it to persist
|
|
@@ -9493,7 +9493,7 @@ const uint8_t* clipboardReadImage(size_t* outSize) {
|
|
|
9493
9493
|
}
|
|
9494
9494
|
|
|
9495
9495
|
// clipboardWriteImage - Write PNG image data to clipboard
|
|
9496
|
-
|
|
9496
|
+
SPARKBUN_EXPORT void clipboardWriteImage(const uint8_t* pngData, size_t size) {
|
|
9497
9497
|
if (!pngData || size == 0) return;
|
|
9498
9498
|
|
|
9499
9499
|
// Copy the data since we need it to persist
|
|
@@ -9526,7 +9526,7 @@ ELECTROBUN_EXPORT void clipboardWriteImage(const uint8_t* pngData, size_t size)
|
|
|
9526
9526
|
}
|
|
9527
9527
|
|
|
9528
9528
|
// clipboardClear - Clear the clipboard
|
|
9529
|
-
|
|
9529
|
+
SPARKBUN_EXPORT void clipboardClear() {
|
|
9530
9530
|
dispatch_sync_main_void([&]() {
|
|
9531
9531
|
GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
|
|
9532
9532
|
gtk_clipboard_clear(clipboard);
|
|
@@ -9535,7 +9535,7 @@ ELECTROBUN_EXPORT void clipboardClear() {
|
|
|
9535
9535
|
|
|
9536
9536
|
// clipboardAvailableFormats - Get available formats in clipboard
|
|
9537
9537
|
// Returns: comma-separated list of formats (caller must free)
|
|
9538
|
-
|
|
9538
|
+
SPARKBUN_EXPORT const char* clipboardAvailableFormats() {
|
|
9539
9539
|
return dispatch_sync_main([&]() -> const char* {
|
|
9540
9540
|
GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
|
|
9541
9541
|
std::vector<std::string> formats;
|
|
@@ -9570,7 +9570,7 @@ ELECTROBUN_EXPORT const char* clipboardAvailableFormats() {
|
|
|
9570
9570
|
// The TrayItem constructor handles deferred AppIndicator creation internally
|
|
9571
9571
|
|
|
9572
9572
|
#ifndef NO_APPINDICATOR
|
|
9573
|
-
|
|
9573
|
+
SPARKBUN_EXPORT void* createTray(uint32_t trayId, const char* title, const char* pathToImage, bool isTemplate, uint32_t width, uint32_t height, void* clickHandler) {
|
|
9574
9574
|
// NOTE: width and height parameters are ignored on Linux since AppIndicator doesn't support custom sizing
|
|
9575
9575
|
// These parameters are included for FFI consistency across platforms (macOS and Windows use them)
|
|
9576
9576
|
|
|
@@ -9600,7 +9600,7 @@ ELECTROBUN_EXPORT void* createTray(uint32_t trayId, const char* title, const cha
|
|
|
9600
9600
|
});
|
|
9601
9601
|
}
|
|
9602
9602
|
|
|
9603
|
-
|
|
9603
|
+
SPARKBUN_EXPORT void setTrayTitle(void* statusItem, const char* title) {
|
|
9604
9604
|
dispatch_sync_main_void([&]() {
|
|
9605
9605
|
// Find the tray by statusItem pointer
|
|
9606
9606
|
for (auto& [id, tray] : g_trays) {
|
|
@@ -9612,7 +9612,7 @@ ELECTROBUN_EXPORT void setTrayTitle(void* statusItem, const char* title) {
|
|
|
9612
9612
|
});
|
|
9613
9613
|
}
|
|
9614
9614
|
|
|
9615
|
-
|
|
9615
|
+
SPARKBUN_EXPORT void setTrayImage(void* statusItem, const char* image) {
|
|
9616
9616
|
dispatch_sync_main_void([&]() {
|
|
9617
9617
|
// Find the tray by statusItem pointer
|
|
9618
9618
|
for (auto& [id, tray] : g_trays) {
|
|
@@ -9624,7 +9624,7 @@ ELECTROBUN_EXPORT void setTrayImage(void* statusItem, const char* image) {
|
|
|
9624
9624
|
});
|
|
9625
9625
|
}
|
|
9626
9626
|
|
|
9627
|
-
|
|
9627
|
+
SPARKBUN_EXPORT void setTrayMenuFromJSON(void* statusItem, const char* jsonString) {
|
|
9628
9628
|
dispatch_sync_main_void([&]() {
|
|
9629
9629
|
// Find the tray by statusItem pointer
|
|
9630
9630
|
for (auto& [id, tray] : g_trays) {
|
|
@@ -9636,11 +9636,11 @@ ELECTROBUN_EXPORT void setTrayMenuFromJSON(void* statusItem, const char* jsonStr
|
|
|
9636
9636
|
});
|
|
9637
9637
|
}
|
|
9638
9638
|
|
|
9639
|
-
|
|
9639
|
+
SPARKBUN_EXPORT void setTrayMenu(void* statusItem, const char* menuConfig) {
|
|
9640
9640
|
setTrayMenuFromJSON(statusItem, menuConfig);
|
|
9641
9641
|
}
|
|
9642
9642
|
|
|
9643
|
-
|
|
9643
|
+
SPARKBUN_EXPORT void removeTray(void* statusItem) {
|
|
9644
9644
|
dispatch_sync_main_void([&]() {
|
|
9645
9645
|
// Find the tray by statusItem pointer and remove it
|
|
9646
9646
|
for (auto it = g_trays.begin(); it != g_trays.end(); ++it) {
|
|
@@ -9652,25 +9652,25 @@ ELECTROBUN_EXPORT void removeTray(void* statusItem) {
|
|
|
9652
9652
|
});
|
|
9653
9653
|
}
|
|
9654
9654
|
|
|
9655
|
-
|
|
9655
|
+
SPARKBUN_EXPORT const char* getTrayBounds(void* statusItem) {
|
|
9656
9656
|
(void)statusItem;
|
|
9657
9657
|
return strdup("{\"x\":0,\"y\":0,\"width\":0,\"height\":0}");
|
|
9658
9658
|
}
|
|
9659
9659
|
#else // NO_APPINDICATOR
|
|
9660
9660
|
// Stub implementations when AppIndicator is not available
|
|
9661
|
-
|
|
9661
|
+
SPARKBUN_EXPORT void* createTray(uint32_t trayId, const char* title, const char* pathToImage, bool isTemplate, uint32_t width, uint32_t height, void* clickHandler) {
|
|
9662
9662
|
return nullptr;
|
|
9663
9663
|
}
|
|
9664
9664
|
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9669
|
-
|
|
9670
|
-
|
|
9665
|
+
SPARKBUN_EXPORT void setTrayTitle(void* statusItem, const char* title) {}
|
|
9666
|
+
SPARKBUN_EXPORT void setTrayImage(void* statusItem, const char* image) {}
|
|
9667
|
+
SPARKBUN_EXPORT void setTrayMenuFromJSON(void* statusItem, const char* jsonString) {}
|
|
9668
|
+
SPARKBUN_EXPORT void setTrayMenu(void* statusItem, const char* menuConfig) {}
|
|
9669
|
+
SPARKBUN_EXPORT void removeTray(void* statusItem) {}
|
|
9670
|
+
SPARKBUN_EXPORT const char* getTrayBounds(void* statusItem) { return strdup("{\"x\":0,\"y\":0,\"width\":0,\"height\":0}"); }
|
|
9671
9671
|
#endif // NO_APPINDICATOR
|
|
9672
9672
|
|
|
9673
|
-
|
|
9673
|
+
SPARKBUN_EXPORT void setApplicationMenu(const char* jsonString, void* applicationMenuHandler) {
|
|
9674
9674
|
if (!jsonString || strlen(jsonString) == 0) {
|
|
9675
9675
|
return;
|
|
9676
9676
|
}
|
|
@@ -9711,12 +9711,12 @@ ELECTROBUN_EXPORT void setApplicationMenu(const char* jsonString, void* applicat
|
|
|
9711
9711
|
// On macOS, you can programmatically show a custom menu at the current mouse position.
|
|
9712
9712
|
// On Linux/GTK, context menus are typically triggered by right-click events rather than
|
|
9713
9713
|
// programmatic calls. This function is not supported on Linux.
|
|
9714
|
-
|
|
9714
|
+
SPARKBUN_EXPORT void showContextMenu(const char* jsonString, void* contextMenuHandler) {
|
|
9715
9715
|
printf("showContextMenu is not supported on Linux. Use application menus or system tray menus instead.\n");
|
|
9716
9716
|
fflush(stdout);
|
|
9717
9717
|
}
|
|
9718
9718
|
|
|
9719
|
-
|
|
9719
|
+
SPARKBUN_EXPORT void getWebviewSnapshot(uint32_t hostId, uint32_t webviewId, double x, double y, double width, double height, void* completionHandler) {
|
|
9720
9720
|
// TODO: Implement webview snapshot
|
|
9721
9721
|
}
|
|
9722
9722
|
|
|
@@ -9755,25 +9755,25 @@ const char* getWebviewHTMLContent(uint32_t webviewId) {
|
|
|
9755
9755
|
}
|
|
9756
9756
|
|
|
9757
9757
|
// Forward declaration - stopEventLoop is defined after startEventLoop
|
|
9758
|
-
|
|
9758
|
+
SPARKBUN_EXPORT void stopEventLoop();
|
|
9759
9759
|
|
|
9760
9760
|
// Note: `name` parameter is accepted for API consistency with Windows but not used on Linux
|
|
9761
|
-
|
|
9761
|
+
SPARKBUN_EXPORT void startEventLoop(const char* identifier, const char* name, const char* channel) {
|
|
9762
9762
|
(void)name; // Unused on Linux - kept for API consistency with Windows
|
|
9763
9763
|
|
|
9764
9764
|
// Store identifier and channel globally for use in CEF initialization
|
|
9765
9765
|
if (identifier && identifier[0]) {
|
|
9766
|
-
|
|
9766
|
+
g_sparkbunIdentifier = std::string(identifier);
|
|
9767
9767
|
}
|
|
9768
9768
|
if (channel && channel[0]) {
|
|
9769
|
-
|
|
9769
|
+
g_sparkbunChannel = std::string(channel);
|
|
9770
9770
|
}
|
|
9771
9771
|
|
|
9772
9772
|
// Linux uses runEventLoop instead
|
|
9773
9773
|
runEventLoop();
|
|
9774
9774
|
}
|
|
9775
9775
|
|
|
9776
|
-
|
|
9776
|
+
SPARKBUN_EXPORT void stopEventLoop() {
|
|
9777
9777
|
if (g_eventLoopStopping.exchange(true)) {
|
|
9778
9778
|
return;
|
|
9779
9779
|
}
|
|
@@ -9785,12 +9785,12 @@ ELECTROBUN_EXPORT void stopEventLoop() {
|
|
|
9785
9785
|
});
|
|
9786
9786
|
}
|
|
9787
9787
|
|
|
9788
|
-
|
|
9788
|
+
SPARKBUN_EXPORT void killApp() {
|
|
9789
9789
|
// Deprecated - delegates to stopEventLoop for backward compatibility
|
|
9790
9790
|
stopEventLoop();
|
|
9791
9791
|
}
|
|
9792
9792
|
|
|
9793
|
-
|
|
9793
|
+
SPARKBUN_EXPORT void waitForShutdownComplete(int timeoutMs) {
|
|
9794
9794
|
int waited = 0;
|
|
9795
9795
|
while (!g_shutdownComplete.load() && waited < timeoutMs) {
|
|
9796
9796
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
@@ -9798,7 +9798,7 @@ ELECTROBUN_EXPORT void waitForShutdownComplete(int timeoutMs) {
|
|
|
9798
9798
|
}
|
|
9799
9799
|
}
|
|
9800
9800
|
|
|
9801
|
-
|
|
9801
|
+
SPARKBUN_EXPORT void forceExit(int code) {
|
|
9802
9802
|
_exit(code);
|
|
9803
9803
|
}
|
|
9804
9804
|
|
|
@@ -9839,7 +9839,7 @@ static gboolean linux_signal_pipe_read(GIOChannel* source, GIOCondition conditio
|
|
|
9839
9839
|
return G_SOURCE_CONTINUE;
|
|
9840
9840
|
}
|
|
9841
9841
|
|
|
9842
|
-
|
|
9842
|
+
SPARKBUN_EXPORT void setQuitRequestedHandler(QuitRequestedHandler handler) {
|
|
9843
9843
|
g_quitRequestedHandler = handler;
|
|
9844
9844
|
|
|
9845
9845
|
// Set up signal handling via self-pipe + GLib IO watch.
|
|
@@ -9869,7 +9869,7 @@ ELECTROBUN_EXPORT void setQuitRequestedHandler(QuitRequestedHandler handler) {
|
|
|
9869
9869
|
sigaction(SIGTERM, &sa, nullptr);
|
|
9870
9870
|
}
|
|
9871
9871
|
|
|
9872
|
-
|
|
9872
|
+
SPARKBUN_EXPORT void shutdownApplication() {
|
|
9873
9873
|
// Deprecated - use stopEventLoop() instead
|
|
9874
9874
|
stopEventLoop();
|
|
9875
9875
|
}
|
|
@@ -9941,7 +9941,7 @@ void cleanupWebviewsForWindow(uint32_t windowId) {
|
|
|
9941
9941
|
}
|
|
9942
9942
|
}
|
|
9943
9943
|
|
|
9944
|
-
|
|
9944
|
+
SPARKBUN_EXPORT void closeWindow(void* window) {
|
|
9945
9945
|
if (!window) return;
|
|
9946
9946
|
|
|
9947
9947
|
// Check if we're shutting down
|
|
@@ -10051,7 +10051,7 @@ ELECTROBUN_EXPORT void closeWindow(void* window) {
|
|
|
10051
10051
|
}
|
|
10052
10052
|
}
|
|
10053
10053
|
|
|
10054
|
-
|
|
10054
|
+
SPARKBUN_EXPORT void minimizeWindow(void* window) {
|
|
10055
10055
|
if (!window) return;
|
|
10056
10056
|
|
|
10057
10057
|
dispatch_sync_main_void([&]() {
|
|
@@ -10070,7 +10070,7 @@ ELECTROBUN_EXPORT void minimizeWindow(void* window) {
|
|
|
10070
10070
|
});
|
|
10071
10071
|
}
|
|
10072
10072
|
|
|
10073
|
-
|
|
10073
|
+
SPARKBUN_EXPORT void restoreWindow(void* window) {
|
|
10074
10074
|
if (!window) return;
|
|
10075
10075
|
|
|
10076
10076
|
dispatch_sync_main_void([&]() {
|
|
@@ -10121,7 +10121,7 @@ ELECTROBUN_EXPORT void restoreWindow(void* window) {
|
|
|
10121
10121
|
});
|
|
10122
10122
|
}
|
|
10123
10123
|
|
|
10124
|
-
|
|
10124
|
+
SPARKBUN_EXPORT bool isWindowMinimized(void* window) {
|
|
10125
10125
|
if (!window) return false;
|
|
10126
10126
|
|
|
10127
10127
|
bool result = false;
|
|
@@ -10187,7 +10187,7 @@ ELECTROBUN_EXPORT bool isWindowMinimized(void* window) {
|
|
|
10187
10187
|
return result;
|
|
10188
10188
|
}
|
|
10189
10189
|
|
|
10190
|
-
|
|
10190
|
+
SPARKBUN_EXPORT void maximizeWindow(void* window) {
|
|
10191
10191
|
if (!window) return;
|
|
10192
10192
|
|
|
10193
10193
|
dispatch_sync_main_void([&]() {
|
|
@@ -10221,7 +10221,7 @@ ELECTROBUN_EXPORT void maximizeWindow(void* window) {
|
|
|
10221
10221
|
});
|
|
10222
10222
|
}
|
|
10223
10223
|
|
|
10224
|
-
|
|
10224
|
+
SPARKBUN_EXPORT void unmaximizeWindow(void* window) {
|
|
10225
10225
|
if (!window) return;
|
|
10226
10226
|
|
|
10227
10227
|
dispatch_sync_main_void([&]() {
|
|
@@ -10255,7 +10255,7 @@ ELECTROBUN_EXPORT void unmaximizeWindow(void* window) {
|
|
|
10255
10255
|
});
|
|
10256
10256
|
}
|
|
10257
10257
|
|
|
10258
|
-
|
|
10258
|
+
SPARKBUN_EXPORT bool isWindowMaximized(void* window) {
|
|
10259
10259
|
if (!window) return false;
|
|
10260
10260
|
|
|
10261
10261
|
bool result = false;
|
|
@@ -10295,7 +10295,7 @@ ELECTROBUN_EXPORT bool isWindowMaximized(void* window) {
|
|
|
10295
10295
|
return result;
|
|
10296
10296
|
}
|
|
10297
10297
|
|
|
10298
|
-
|
|
10298
|
+
SPARKBUN_EXPORT void setWindowFullScreen(void* window, bool fullScreen) {
|
|
10299
10299
|
if (!window) return;
|
|
10300
10300
|
|
|
10301
10301
|
dispatch_sync_main_void([&]() {
|
|
@@ -10332,7 +10332,7 @@ ELECTROBUN_EXPORT void setWindowFullScreen(void* window, bool fullScreen) {
|
|
|
10332
10332
|
});
|
|
10333
10333
|
}
|
|
10334
10334
|
|
|
10335
|
-
|
|
10335
|
+
SPARKBUN_EXPORT bool isWindowFullScreen(void* window) {
|
|
10336
10336
|
if (!window) return false;
|
|
10337
10337
|
|
|
10338
10338
|
bool result = false;
|
|
@@ -10375,7 +10375,7 @@ ELECTROBUN_EXPORT bool isWindowFullScreen(void* window) {
|
|
|
10375
10375
|
return result;
|
|
10376
10376
|
}
|
|
10377
10377
|
|
|
10378
|
-
|
|
10378
|
+
SPARKBUN_EXPORT void setWindowAlwaysOnTop(void* window, bool alwaysOnTop) {
|
|
10379
10379
|
if (!window) return;
|
|
10380
10380
|
|
|
10381
10381
|
dispatch_sync_main_void([&]() {
|
|
@@ -10412,7 +10412,7 @@ ELECTROBUN_EXPORT void setWindowAlwaysOnTop(void* window, bool alwaysOnTop) {
|
|
|
10412
10412
|
});
|
|
10413
10413
|
}
|
|
10414
10414
|
|
|
10415
|
-
|
|
10415
|
+
SPARKBUN_EXPORT bool isWindowAlwaysOnTop(void* window) {
|
|
10416
10416
|
if (!window) return false;
|
|
10417
10417
|
|
|
10418
10418
|
bool result = false;
|
|
@@ -10455,16 +10455,16 @@ ELECTROBUN_EXPORT bool isWindowAlwaysOnTop(void* window) {
|
|
|
10455
10455
|
return result;
|
|
10456
10456
|
}
|
|
10457
10457
|
|
|
10458
|
-
|
|
10458
|
+
SPARKBUN_EXPORT void setWindowVisibleOnAllWorkspaces(void* window, bool visible) {
|
|
10459
10459
|
// Not applicable on Linux - no-op
|
|
10460
10460
|
}
|
|
10461
10461
|
|
|
10462
|
-
|
|
10462
|
+
SPARKBUN_EXPORT bool isWindowVisibleOnAllWorkspaces(void* window) {
|
|
10463
10463
|
// Not applicable on Linux
|
|
10464
10464
|
return false;
|
|
10465
10465
|
}
|
|
10466
10466
|
|
|
10467
|
-
|
|
10467
|
+
SPARKBUN_EXPORT void setWindowPosition(void* window, double x, double y) {
|
|
10468
10468
|
if (!window) return;
|
|
10469
10469
|
|
|
10470
10470
|
dispatch_sync_main_void([=]() {
|
|
@@ -10494,14 +10494,14 @@ ELECTROBUN_EXPORT void setWindowPosition(void* window, double x, double y) {
|
|
|
10494
10494
|
});
|
|
10495
10495
|
}
|
|
10496
10496
|
|
|
10497
|
-
|
|
10497
|
+
SPARKBUN_EXPORT void setWindowButtonPosition(void* window, double x, double y) {
|
|
10498
10498
|
(void)window;
|
|
10499
10499
|
(void)x;
|
|
10500
10500
|
(void)y;
|
|
10501
10501
|
// Not applicable on Linux - no-op
|
|
10502
10502
|
}
|
|
10503
10503
|
|
|
10504
|
-
|
|
10504
|
+
SPARKBUN_EXPORT void setWindowSize(void* window, double width, double height) {
|
|
10505
10505
|
if (!window) return;
|
|
10506
10506
|
|
|
10507
10507
|
dispatch_sync_main_void([=]() {
|
|
@@ -10520,7 +10520,7 @@ ELECTROBUN_EXPORT void setWindowSize(void* window, double width, double height)
|
|
|
10520
10520
|
});
|
|
10521
10521
|
}
|
|
10522
10522
|
|
|
10523
|
-
|
|
10523
|
+
SPARKBUN_EXPORT void setWindowFrame(void* window, double x, double y, double width, double height) {
|
|
10524
10524
|
if (!window) return;
|
|
10525
10525
|
|
|
10526
10526
|
dispatch_sync_main_void([=]() {
|
|
@@ -10540,7 +10540,7 @@ ELECTROBUN_EXPORT void setWindowFrame(void* window, double x, double y, double w
|
|
|
10540
10540
|
});
|
|
10541
10541
|
}
|
|
10542
10542
|
|
|
10543
|
-
|
|
10543
|
+
SPARKBUN_EXPORT void getWindowFrame(void* window, double* outX, double* outY, double* outWidth, double* outHeight) {
|
|
10544
10544
|
if (!window) {
|
|
10545
10545
|
*outX = 0;
|
|
10546
10546
|
*outY = 0;
|
|
@@ -10612,17 +10612,17 @@ ELECTROBUN_EXPORT void getWindowFrame(void* window, double* outX, double* outY,
|
|
|
10612
10612
|
});
|
|
10613
10613
|
}
|
|
10614
10614
|
|
|
10615
|
-
|
|
10615
|
+
SPARKBUN_EXPORT void getWindowPosition(void* window, double* outX, double* outY) {
|
|
10616
10616
|
double width, height;
|
|
10617
10617
|
getWindowFrame(window, outX, outY, &width, &height);
|
|
10618
10618
|
}
|
|
10619
10619
|
|
|
10620
|
-
|
|
10620
|
+
SPARKBUN_EXPORT void getWindowSize(void* window, double* outWidth, double* outHeight) {
|
|
10621
10621
|
double x, y;
|
|
10622
10622
|
getWindowFrame(window, &x, &y, outWidth, outHeight);
|
|
10623
10623
|
}
|
|
10624
10624
|
|
|
10625
|
-
|
|
10625
|
+
SPARKBUN_EXPORT void setWindowIcon(void* window, const char* iconPath) {
|
|
10626
10626
|
if (!window || !iconPath) return;
|
|
10627
10627
|
|
|
10628
10628
|
dispatch_sync_main_void([=]() {
|
|
@@ -10816,7 +10816,7 @@ static KeySym getKeySym(const std::string& key) {
|
|
|
10816
10816
|
// Parse modifiers from accelerator string for X11 shortcuts using the
|
|
10817
10817
|
// shared cross-platform parser. Returns X11 modifier mask.
|
|
10818
10818
|
static unsigned int parseX11Modifiers(const std::string& accelerator, std::string& outKey) {
|
|
10819
|
-
auto parts =
|
|
10819
|
+
auto parts = sparkbun::parseAccelerator(accelerator);
|
|
10820
10820
|
outKey = parts.key;
|
|
10821
10821
|
|
|
10822
10822
|
unsigned int modifiers = 0;
|
|
@@ -10868,7 +10868,7 @@ static void shortcutEventLoop() {
|
|
|
10868
10868
|
}
|
|
10869
10869
|
|
|
10870
10870
|
// Set the callback for global shortcut events
|
|
10871
|
-
|
|
10871
|
+
SPARKBUN_EXPORT void setGlobalShortcutCallback(GlobalShortcutCallback callback) {
|
|
10872
10872
|
printf("GlobalShortcut: Setting callback (callback=%p)\n", callback);
|
|
10873
10873
|
g_globalShortcutCallback = callback;
|
|
10874
10874
|
|
|
@@ -10892,7 +10892,7 @@ ELECTROBUN_EXPORT void setGlobalShortcutCallback(GlobalShortcutCallback callback
|
|
|
10892
10892
|
}
|
|
10893
10893
|
|
|
10894
10894
|
// Register a global keyboard shortcut
|
|
10895
|
-
|
|
10895
|
+
SPARKBUN_EXPORT bool registerGlobalShortcut(const char* accelerator) {
|
|
10896
10896
|
printf("GlobalShortcut: registerGlobalShortcut called for '%s'\n", accelerator ? accelerator : "(null)");
|
|
10897
10897
|
|
|
10898
10898
|
if (!accelerator) {
|
|
@@ -10961,7 +10961,7 @@ ELECTROBUN_EXPORT bool registerGlobalShortcut(const char* accelerator) {
|
|
|
10961
10961
|
}
|
|
10962
10962
|
|
|
10963
10963
|
// Unregister a global keyboard shortcut
|
|
10964
|
-
|
|
10964
|
+
SPARKBUN_EXPORT bool unregisterGlobalShortcut(const char* accelerator) {
|
|
10965
10965
|
if (!accelerator || !g_shortcutDisplay) return false;
|
|
10966
10966
|
|
|
10967
10967
|
std::string accelStr(accelerator);
|
|
@@ -10993,7 +10993,7 @@ ELECTROBUN_EXPORT bool unregisterGlobalShortcut(const char* accelerator) {
|
|
|
10993
10993
|
}
|
|
10994
10994
|
|
|
10995
10995
|
// Unregister all global keyboard shortcuts
|
|
10996
|
-
|
|
10996
|
+
SPARKBUN_EXPORT void unregisterAllGlobalShortcuts() {
|
|
10997
10997
|
if (!g_shortcutDisplay) return;
|
|
10998
10998
|
|
|
10999
10999
|
Window root = DefaultRootWindow(g_shortcutDisplay);
|
|
@@ -11020,7 +11020,7 @@ ELECTROBUN_EXPORT void unregisterAllGlobalShortcuts() {
|
|
|
11020
11020
|
}
|
|
11021
11021
|
|
|
11022
11022
|
// Check if a shortcut is registered
|
|
11023
|
-
|
|
11023
|
+
SPARKBUN_EXPORT bool isGlobalShortcutRegistered(const char* accelerator) {
|
|
11024
11024
|
if (!accelerator) return false;
|
|
11025
11025
|
return g_globalShortcuts.find(std::string(accelerator)) != g_globalShortcuts.end();
|
|
11026
11026
|
}
|
|
@@ -11032,7 +11032,7 @@ ELECTROBUN_EXPORT bool isGlobalShortcutRegistered(const char* accelerator) {
|
|
|
11032
11032
|
*/
|
|
11033
11033
|
|
|
11034
11034
|
// Get all displays as JSON array
|
|
11035
|
-
|
|
11035
|
+
SPARKBUN_EXPORT const char* getAllDisplays() {
|
|
11036
11036
|
GdkDisplay* display = gdk_display_get_default();
|
|
11037
11037
|
if (!display) {
|
|
11038
11038
|
return strdup("[]");
|
|
@@ -11089,7 +11089,7 @@ ELECTROBUN_EXPORT const char* getAllDisplays() {
|
|
|
11089
11089
|
}
|
|
11090
11090
|
|
|
11091
11091
|
// Get primary display as JSON
|
|
11092
|
-
|
|
11092
|
+
SPARKBUN_EXPORT const char* getPrimaryDisplay() {
|
|
11093
11093
|
GdkDisplay* display = gdk_display_get_default();
|
|
11094
11094
|
if (!display) {
|
|
11095
11095
|
return strdup("{}");
|
|
@@ -11140,7 +11140,7 @@ ELECTROBUN_EXPORT const char* getPrimaryDisplay() {
|
|
|
11140
11140
|
}
|
|
11141
11141
|
|
|
11142
11142
|
// Get current cursor position as JSON: {"x": 123, "y": 456}
|
|
11143
|
-
|
|
11143
|
+
SPARKBUN_EXPORT const char* getCursorScreenPoint() {
|
|
11144
11144
|
return dispatch_sync_main([&]() -> const char* {
|
|
11145
11145
|
GdkDisplay* display = gdk_display_get_default();
|
|
11146
11146
|
if (!display) {
|
|
@@ -11167,7 +11167,7 @@ ELECTROBUN_EXPORT const char* getCursorScreenPoint() {
|
|
|
11167
11167
|
});
|
|
11168
11168
|
}
|
|
11169
11169
|
|
|
11170
|
-
|
|
11170
|
+
SPARKBUN_EXPORT uint64_t getMouseButtons() {
|
|
11171
11171
|
return dispatch_sync_main([&]() -> uint64_t {
|
|
11172
11172
|
GdkDisplay* display = gdk_display_get_default();
|
|
11173
11173
|
if (!display) {
|
|
@@ -11228,8 +11228,8 @@ static WebKitWebsiteDataManager* getDataManagerForPartition(const char* partitio
|
|
|
11228
11228
|
// Build paths with identifier/channel structure (consistent with CLI and updater)
|
|
11229
11229
|
char* home = getenv("HOME");
|
|
11230
11230
|
std::string homeStr = home ? std::string(home) : "/tmp";
|
|
11231
|
-
std::string dataPath = buildPartitionPath(homeStr + "/.local/share",
|
|
11232
|
-
std::string cachePath = buildPartitionPath(homeStr + "/.cache",
|
|
11231
|
+
std::string dataPath = buildPartitionPath(homeStr + "/.local/share", g_sparkbunIdentifier, g_sparkbunChannel, "WebKit", partitionName);
|
|
11232
|
+
std::string cachePath = buildPartitionPath(homeStr + "/.cache", g_sparkbunIdentifier, g_sparkbunChannel, "WebKit", partitionName);
|
|
11233
11233
|
|
|
11234
11234
|
g_mkdir_with_parents(dataPath.c_str(), 0755);
|
|
11235
11235
|
g_mkdir_with_parents(cachePath.c_str(), 0755);
|
|
@@ -11320,7 +11320,7 @@ static void onGetCookiesFinished(GObject* source, GAsyncResult* result, gpointer
|
|
|
11320
11320
|
}
|
|
11321
11321
|
|
|
11322
11322
|
// Get cookies for a partition (WebKit2GTK)
|
|
11323
|
-
|
|
11323
|
+
SPARKBUN_EXPORT const char* sessionGetCookies(const char* partitionIdentifier, const char* filterJson) {
|
|
11324
11324
|
// Copy arguments before dispatching to main thread
|
|
11325
11325
|
std::string partitionStr = partitionIdentifier ? partitionIdentifier : "";
|
|
11326
11326
|
std::string filterStr = filterJson ? filterJson : "{}";
|
|
@@ -11397,7 +11397,7 @@ static void onSetCookieFinished(GObject* source, GAsyncResult* result, gpointer
|
|
|
11397
11397
|
}
|
|
11398
11398
|
|
|
11399
11399
|
// Set a cookie (WebKit2GTK)
|
|
11400
|
-
|
|
11400
|
+
SPARKBUN_EXPORT bool sessionSetCookie(const char* partitionIdentifier, const char* cookieJson) {
|
|
11401
11401
|
// Copy arguments before dispatching to main thread
|
|
11402
11402
|
std::string partitionStr = partitionIdentifier ? partitionIdentifier : "";
|
|
11403
11403
|
std::string jsonStr = cookieJson ? cookieJson : "{}";
|
|
@@ -11543,7 +11543,7 @@ static void onDeleteCookieFinished(GObject* source, GAsyncResult* result, gpoint
|
|
|
11543
11543
|
}
|
|
11544
11544
|
|
|
11545
11545
|
// Remove a specific cookie (WebKit2GTK)
|
|
11546
|
-
|
|
11546
|
+
SPARKBUN_EXPORT bool sessionRemoveCookie(const char* partitionIdentifier, const char* urlStr, const char* cookieName) {
|
|
11547
11547
|
if (!urlStr || !cookieName) return false;
|
|
11548
11548
|
|
|
11549
11549
|
// Copy arguments before dispatching to main thread
|
|
@@ -11650,7 +11650,7 @@ ELECTROBUN_EXPORT bool sessionRemoveCookie(const char* partitionIdentifier, cons
|
|
|
11650
11650
|
|
|
11651
11651
|
// Clear all cookies (WebKit2GTK)
|
|
11652
11652
|
// Clear all cookies (WebKit2GTK) - STUB implementation to prevent crashes
|
|
11653
|
-
|
|
11653
|
+
SPARKBUN_EXPORT void sessionClearCookies(const char* partitionIdentifier) {
|
|
11654
11654
|
// Stub implementation: do nothing and return immediately
|
|
11655
11655
|
// This prevents crashes from complex WebKit async patterns during tests
|
|
11656
11656
|
// while maintaining API compatibility
|
|
@@ -11659,7 +11659,7 @@ ELECTROBUN_EXPORT void sessionClearCookies(const char* partitionIdentifier) {
|
|
|
11659
11659
|
}
|
|
11660
11660
|
|
|
11661
11661
|
// Clear storage data (WebKit2GTK)
|
|
11662
|
-
|
|
11662
|
+
SPARKBUN_EXPORT void sessionClearStorageData(const char* partitionIdentifier, const char* storageTypesJson) {
|
|
11663
11663
|
// Copy arguments before dispatching to main thread
|
|
11664
11664
|
std::string partitionStr = partitionIdentifier ? partitionIdentifier : "";
|
|
11665
11665
|
std::string typesStr = storageTypesJson ? storageTypesJson : "";
|
|
@@ -11727,29 +11727,29 @@ ELECTROBUN_EXPORT void sessionClearStorageData(const char* partitionIdentifier,
|
|
|
11727
11727
|
});
|
|
11728
11728
|
}
|
|
11729
11729
|
|
|
11730
|
-
|
|
11730
|
+
SPARKBUN_EXPORT void setURLOpenHandler(void (*callback)(const char*)) {
|
|
11731
11731
|
(void)callback;
|
|
11732
11732
|
// Not supported on Linux - stub to prevent dlopen failure
|
|
11733
11733
|
// Linux URL protocol handling is done via desktop file associations
|
|
11734
11734
|
}
|
|
11735
11735
|
|
|
11736
|
-
|
|
11736
|
+
SPARKBUN_EXPORT void setAppReopenHandler(void (*callback)()) {
|
|
11737
11737
|
(void)callback;
|
|
11738
11738
|
// Not supported on Linux - stub to prevent dlopen failure
|
|
11739
11739
|
}
|
|
11740
11740
|
|
|
11741
|
-
|
|
11741
|
+
SPARKBUN_EXPORT void setDockIconVisible(bool visible) {
|
|
11742
11742
|
(void)visible;
|
|
11743
11743
|
// Not supported on Linux - stub to prevent dlopen failure
|
|
11744
11744
|
}
|
|
11745
11745
|
|
|
11746
|
-
|
|
11746
|
+
SPARKBUN_EXPORT bool isDockIconVisible() {
|
|
11747
11747
|
// Not supported on Linux
|
|
11748
11748
|
return true;
|
|
11749
11749
|
}
|
|
11750
11750
|
|
|
11751
11751
|
// Graceful shutdown function to coordinate cleanup
|
|
11752
|
-
|
|
11752
|
+
SPARKBUN_EXPORT void shutdownNativeWrapper() {
|
|
11753
11753
|
printf("Starting graceful shutdown of native wrapper...\n");
|
|
11754
11754
|
|
|
11755
11755
|
// Set shutdown flag to prevent new operations
|