plusui-native-core 0.1.11 → 0.1.13
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/Core/CMakeLists.txt +14 -0
- package/Core/Features/Bindings/CustomBindings/custom_bindings.cpp +2 -0
- package/Core/Features/Browser/browser.cpp +1 -0
- package/Core/Features/Clipboard/clipboard.cpp +1 -0
- package/Core/Features/Display/display.cpp +3 -0
- package/Core/Features/Keyboard/keyboard.cpp +4 -1
- package/Core/Features/Menu/menu.cpp +2 -0
- package/Core/Features/Tray/tray.cpp +14 -0
- package/Core/Features/WebGPU/webgpu.cpp +9 -0
- package/Core/Features/WebView/webview.cpp +10 -0
- package/Core/Features/WindowManager/window_manager.cpp +87 -0
- package/Core/include/plusui/tray.hpp +1 -0
- package/Core/include/plusui/window_manager.hpp +2 -0
- package/package.json +1 -1
package/Core/CMakeLists.txt
CHANGED
|
@@ -54,6 +54,20 @@ target_compile_options(plusui PRIVATE
|
|
|
54
54
|
find_package(Threads REQUIRED)
|
|
55
55
|
target_link_libraries(plusui PRIVATE Threads::Threads)
|
|
56
56
|
|
|
57
|
+
# ============================================================
|
|
58
|
+
# nlohmann/json - Required for bindings
|
|
59
|
+
# ============================================================
|
|
60
|
+
include(FetchContent)
|
|
61
|
+
|
|
62
|
+
FetchContent_Declare(
|
|
63
|
+
nlohmann_json
|
|
64
|
+
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
|
|
65
|
+
URL_HASH SHA256=d6c65aca6b1ed68e7a182f4757257b107ae403032760ed6ef121c9d55e81757d
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
FetchContent_MakeAvailable(nlohmann_json)
|
|
69
|
+
target_link_libraries(plusui PUBLIC nlohmann_json::nlohmann_json)
|
|
70
|
+
|
|
57
71
|
# ============================================================
|
|
58
72
|
# WebGPU: Dawn Library (Optional)
|
|
59
73
|
# ============================================================
|
|
@@ -20,6 +20,8 @@ void registerEvent(const std::string& name, EventHandler handler) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
void emitToFrontend(const std::string& name, const json& data) {
|
|
23
|
+
(void)name;
|
|
24
|
+
(void)data;
|
|
23
25
|
// Emit event to frontend via webview
|
|
24
26
|
// Implementation depends on webview instance
|
|
25
27
|
// This will be wired up by the generated binding code
|
|
@@ -69,6 +69,7 @@ Browser Browser::create(WebView* webview) {
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
webview->onLoadError([impl = browser.pImpl](const std::string& error, int code) {
|
|
72
|
+
(void)code; // Suppress unused warning
|
|
72
73
|
impl->state.isLoading = false;
|
|
73
74
|
for (auto& cb : impl->loadErrorCallbacks) {
|
|
74
75
|
cb(error);
|
|
@@ -170,6 +170,7 @@ std::string Clipboard::getImage() {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
void Clipboard::setImage(const std::string &base64Data) {
|
|
173
|
+
(void)base64Data; // Suppress unused warning - placeholder implementation
|
|
173
174
|
// Image support would require base64 decoding
|
|
174
175
|
// Platform-specific image clipboard handling
|
|
175
176
|
// This is a placeholder for now
|
|
@@ -80,7 +80,10 @@ std::vector<Display> DisplayManager::getAllDisplays() {
|
|
|
80
80
|
d.id = i;
|
|
81
81
|
// Widestring to string conversion
|
|
82
82
|
std::wstring wname(dd.DeviceName);
|
|
83
|
+
#pragma warning(push)
|
|
84
|
+
#pragma warning(disable: 4244) // Suppress wchar_t to char conversion warning
|
|
83
85
|
d.name = std::string(wname.begin(), wname.end());
|
|
86
|
+
#pragma warning(pop)
|
|
84
87
|
|
|
85
88
|
DEVMODEW dm = {};
|
|
86
89
|
dm.dmSize = sizeof(dm);
|
|
@@ -86,7 +86,10 @@ bool Keyboard::isKeyPressed(KeyCode key) const {
|
|
|
86
86
|
pImpl->pressedKeys.at(static_cast<int>(key));
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
bool Keyboard::areModsActive(KeyMod mods) const {
|
|
89
|
+
bool Keyboard::areModsActive(KeyMod mods) const {
|
|
90
|
+
(void)mods; // Suppress unused warning - placeholder implementation
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
90
93
|
|
|
91
94
|
std::string Keyboard::getKeyName(KeyCode key) const {
|
|
92
95
|
auto it = Impl::keyNames().find(key);
|
|
@@ -225,6 +225,7 @@ void MenuBindings::registerBindings(WebView &webview) {
|
|
|
225
225
|
// Binding: Enable custom context menu
|
|
226
226
|
webview.bind("plusui_menu_enableContext",
|
|
227
227
|
[this, &webview](const std::string &args) -> std::string {
|
|
228
|
+
(void)args; // Suppress unused warning
|
|
228
229
|
contextMenuEnabled_ = true;
|
|
229
230
|
webview.eval("window.__plusui_contextMenu.enabled = true;");
|
|
230
231
|
return "null";
|
|
@@ -233,6 +234,7 @@ void MenuBindings::registerBindings(WebView &webview) {
|
|
|
233
234
|
// Binding: Disable custom context menu
|
|
234
235
|
webview.bind("plusui_menu_disableContext",
|
|
235
236
|
[this, &webview](const std::string &args) -> std::string {
|
|
237
|
+
(void)args; // Suppress unused warning
|
|
236
238
|
contextMenuEnabled_ = false;
|
|
237
239
|
webview.eval("window.__plusui_contextMenu.enabled = false;");
|
|
238
240
|
return "null";
|
|
@@ -307,4 +307,18 @@ void TrayManager::onTrayDestroyed(std::function<void(int)> callback) {
|
|
|
307
307
|
|
|
308
308
|
void TrayManager::refresh() {}
|
|
309
309
|
|
|
310
|
+
void TrayManager::setIconFromMemory(const unsigned char *data, size_t size) {
|
|
311
|
+
if (pImpl->mainIcon) {
|
|
312
|
+
pImpl->mainIcon->setIconFromMemory(data, size);
|
|
313
|
+
} else {
|
|
314
|
+
// Create the icon if it doesn't exist
|
|
315
|
+
pImpl->mainIcon = std::make_unique<TrayIcon>(TrayIcon::create("", ""));
|
|
316
|
+
#ifdef _WIN32
|
|
317
|
+
pImpl->mainIcon->pImpl->nid.cbSize = sizeof(NOTIFYICONDATAW);
|
|
318
|
+
pImpl->mainIcon->pImpl->hwnd = pImpl->hwnd;
|
|
319
|
+
#endif
|
|
320
|
+
pImpl->mainIcon->setIconFromMemory(data, size);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
310
324
|
} // namespace plusui
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
#include <plusui/webgpu.hpp>
|
|
2
2
|
|
|
3
|
+
#ifdef _WIN32
|
|
4
|
+
#pragma warning(push)
|
|
5
|
+
#pragma warning(disable: 4100) // Suppress unreferenced parameter warnings - placeholder implementations
|
|
6
|
+
#endif
|
|
7
|
+
|
|
3
8
|
#ifdef PLUSUI_WEBGPU_ENABLED
|
|
4
9
|
#include <dawn/webgpu_cpp.h>
|
|
5
10
|
#include <dawn_native/DawnNative.h>
|
|
@@ -937,3 +942,7 @@ std::string WebGPU::getMemoryStats() {
|
|
|
937
942
|
}
|
|
938
943
|
|
|
939
944
|
} // namespace plusui
|
|
945
|
+
|
|
946
|
+
#ifdef _WIN32
|
|
947
|
+
#pragma warning(pop)
|
|
948
|
+
#endif
|
|
@@ -10,10 +10,13 @@
|
|
|
10
10
|
#include <sstream>
|
|
11
11
|
|
|
12
12
|
#ifdef _WIN32
|
|
13
|
+
#pragma warning(push)
|
|
14
|
+
#pragma warning(disable: 4996) // Disable sscanf deprecation warning
|
|
13
15
|
#include <WebView2.h>
|
|
14
16
|
#include <windows.h>
|
|
15
17
|
#include <wrl.h>
|
|
16
18
|
using namespace Microsoft::WRL;
|
|
19
|
+
#pragma warning(pop)
|
|
17
20
|
#elif defined(__APPLE__)
|
|
18
21
|
#import <WebKit/WebKit.h>
|
|
19
22
|
#import <objc/objc-runtime.h>
|
|
@@ -90,6 +93,7 @@ WebView WebView::create(void *windowHandle, const WebViewConfig &config) {
|
|
|
90
93
|
ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(
|
|
91
94
|
[pImpl](HRESULT result,
|
|
92
95
|
ICoreWebView2Controller *controller) -> HRESULT {
|
|
96
|
+
(void)result; // Suppress unused warning
|
|
93
97
|
if (controller != nullptr) {
|
|
94
98
|
pImpl->controller = controller;
|
|
95
99
|
controller->get_CoreWebView2(&pImpl->webview);
|
|
@@ -143,12 +147,16 @@ WebView WebView::create(void *windowHandle, const WebViewConfig &config) {
|
|
|
143
147
|
[pImpl](ICoreWebView2 *sender,
|
|
144
148
|
ICoreWebView2WebMessageReceivedEventArgs
|
|
145
149
|
*args) -> HRESULT {
|
|
150
|
+
(void)sender; // Suppress unused warning
|
|
146
151
|
LPWSTR message = nullptr;
|
|
147
152
|
args->TryGetWebMessageAsString(&message);
|
|
148
153
|
if (!message)
|
|
149
154
|
return S_OK;
|
|
150
155
|
std::wstring wmsg(message);
|
|
156
|
+
#pragma warning(push)
|
|
157
|
+
#pragma warning(disable: 4244) // Suppress wchar_t to char conversion warning
|
|
151
158
|
std::string msg(wmsg.begin(), wmsg.end());
|
|
159
|
+
#pragma warning(pop)
|
|
152
160
|
CoTaskMemFree(message);
|
|
153
161
|
|
|
154
162
|
// Debug: log received message
|
|
@@ -713,6 +721,7 @@ void WebView::loadHTML(const std::string &html, const std::string &baseURL) {
|
|
|
713
721
|
pImpl->loading = true;
|
|
714
722
|
|
|
715
723
|
#ifdef _WIN32
|
|
724
|
+
(void)baseURL; // Not used on Windows
|
|
716
725
|
if (pImpl->ready && pImpl->webview) {
|
|
717
726
|
pImpl->webview->NavigateToString(
|
|
718
727
|
std::wstring(html.begin(), html.end()).c_str());
|
|
@@ -880,6 +889,7 @@ void WebView::executeScript(const std::string &script,
|
|
|
880
889
|
std::wstring(script.begin(), script.end()).c_str(),
|
|
881
890
|
Callback<ICoreWebView2ExecuteScriptCompletedHandler>(
|
|
882
891
|
[callback](HRESULT error, LPCWSTR result) -> HRESULT {
|
|
892
|
+
(void)error; // Suppress unused warning
|
|
883
893
|
if (result && callback) {
|
|
884
894
|
std::wstring wstr(result);
|
|
885
895
|
callback(std::string(wstr.begin(), wstr.end()));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include <plusui/window_manager.hpp>
|
|
2
|
+
#include <stb_image.h>
|
|
2
3
|
|
|
3
4
|
#ifdef _WIN32
|
|
4
5
|
#include <windows.h>
|
|
@@ -338,4 +339,90 @@ bool WindowManager::isMinimized() const { return pImpl->minimized; }
|
|
|
338
339
|
|
|
339
340
|
bool WindowManager::isVisible() const { return pImpl->visible; }
|
|
340
341
|
|
|
342
|
+
void WindowManager::setIcon(const std::string& iconPath) {
|
|
343
|
+
#ifdef _WIN32
|
|
344
|
+
if (pImpl->nativeWindow && !iconPath.empty()) {
|
|
345
|
+
std::wstring wpath(iconPath.begin(), iconPath.end());
|
|
346
|
+
HICON hIcon = (HICON)LoadImageW(nullptr, wpath.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);
|
|
347
|
+
if (hIcon) {
|
|
348
|
+
SendMessage(pImpl->hwnd(), WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
|
|
349
|
+
SendMessage(pImpl->hwnd(), WM_SETICON, ICON_BIG, (LPARAM)hIcon);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
#elif defined(__APPLE__)
|
|
353
|
+
// macOS implementation
|
|
354
|
+
#else
|
|
355
|
+
if (pImpl->nativeWindow && !iconPath.empty()) {
|
|
356
|
+
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(iconPath.c_str(), nullptr);
|
|
357
|
+
if (pixbuf) {
|
|
358
|
+
gtk_window_set_icon(GTK_WINDOW(pImpl->nativeWindow), pixbuf);
|
|
359
|
+
g_object_unref(pixbuf);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
#endif
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
void WindowManager::setIconFromMemory(const unsigned char *data, size_t size) {
|
|
366
|
+
#ifdef _WIN32
|
|
367
|
+
if (pImpl->nativeWindow && data && size > 0) {
|
|
368
|
+
int width, height, channels;
|
|
369
|
+
unsigned char *pixels = stbi_load_from_memory(data, (int)size, &width, &height, &channels, 4);
|
|
370
|
+
if (pixels) {
|
|
371
|
+
// Convert RGBA to BGRA for Windows
|
|
372
|
+
for (int i = 0; i < width * height; ++i) {
|
|
373
|
+
unsigned char r = pixels[i * 4 + 0];
|
|
374
|
+
unsigned char b = pixels[i * 4 + 2];
|
|
375
|
+
pixels[i * 4 + 0] = b;
|
|
376
|
+
pixels[i * 4 + 2] = r;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
BITMAPINFO bmi = {};
|
|
380
|
+
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
381
|
+
bmi.bmiHeader.biWidth = width;
|
|
382
|
+
bmi.bmiHeader.biHeight = -height;
|
|
383
|
+
bmi.bmiHeader.biPlanes = 1;
|
|
384
|
+
bmi.bmiHeader.biBitCount = 32;
|
|
385
|
+
bmi.bmiHeader.biCompression = BI_RGB;
|
|
386
|
+
|
|
387
|
+
void *bits = nullptr;
|
|
388
|
+
HBITMAP hbm = CreateDIBSection(nullptr, &bmi, DIB_RGB_COLORS, &bits, nullptr, 0);
|
|
389
|
+
if (hbm && bits) {
|
|
390
|
+
memcpy(bits, pixels, width * height * 4);
|
|
391
|
+
|
|
392
|
+
ICONINFO ii = {};
|
|
393
|
+
ii.fIcon = TRUE;
|
|
394
|
+
ii.hbmColor = hbm;
|
|
395
|
+
ii.hbmMask = CreateCompatibleBitmap(GetDC(nullptr), width, height);
|
|
396
|
+
|
|
397
|
+
HICON hIcon = CreateIconIndirect(&ii);
|
|
398
|
+
if (hIcon) {
|
|
399
|
+
SendMessage(pImpl->hwnd(), WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
|
|
400
|
+
SendMessage(pImpl->hwnd(), WM_SETICON, ICON_BIG, (LPARAM)hIcon);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
DeleteObject(ii.hbmMask);
|
|
404
|
+
DeleteObject(hbm);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
stbi_image_free(pixels);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
#elif defined(__APPLE__)
|
|
411
|
+
// macOS implementation
|
|
412
|
+
#else
|
|
413
|
+
if (pImpl->nativeWindow && data && size > 0) {
|
|
414
|
+
int width, height, channels;
|
|
415
|
+
unsigned char *pixels = stbi_load_from_memory(data, (int)size, &width, &height, &channels, 4);
|
|
416
|
+
if (pixels) {
|
|
417
|
+
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(pixels, GDK_COLORSPACE_RGB, TRUE, 8, width, height, width * 4, nullptr, nullptr);
|
|
418
|
+
if (pixbuf) {
|
|
419
|
+
gtk_window_set_icon(GTK_WINDOW(pImpl->nativeWindow), pixbuf);
|
|
420
|
+
g_object_unref(pixbuf);
|
|
421
|
+
}
|
|
422
|
+
stbi_image_free(pixels);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
#endif
|
|
426
|
+
}
|
|
427
|
+
|
|
341
428
|
} // namespace plusui
|
|
@@ -35,6 +35,8 @@ public:
|
|
|
35
35
|
void setDecorations(bool enabled);
|
|
36
36
|
void setSkipTaskbar(bool enabled);
|
|
37
37
|
void setTransparency(double alpha);
|
|
38
|
+
void setIcon(const std::string& iconPath);
|
|
39
|
+
void setIconFromMemory(const unsigned char *data, size_t size);
|
|
38
40
|
|
|
39
41
|
void minimize();
|
|
40
42
|
void maximize();
|