plusui-native-core 0.1.105 → 0.1.106

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.
Files changed (48) hide show
  1. package/Core/.claude/settings.local.json +7 -0
  2. package/Core/CMakeLists.txt +1 -1
  3. package/Core/Features/API/app-api.ts +28 -28
  4. package/Core/Features/API/browser-api.ts +38 -38
  5. package/Core/Features/API/clipboard-api.ts +21 -21
  6. package/Core/Features/API/display-api.ts +33 -33
  7. package/Core/Features/API/keyboard-api.ts +33 -33
  8. package/Core/Features/API/menu-api.ts +39 -39
  9. package/Core/Features/API/router-api.ts +23 -23
  10. package/Core/Features/API/tray-api.ts +22 -22
  11. package/Core/Features/API/webgpu-api.ts +55 -55
  12. package/Core/Features/App/app.cpp +128 -102
  13. package/Core/Features/Browser/browser.cpp +227 -227
  14. package/Core/Features/Browser/browser.ts +161 -161
  15. package/Core/Features/Clipboard/clipboard.cpp +235 -235
  16. package/Core/Features/Display/display.cpp +212 -212
  17. package/Core/Features/FileDrop/filedrop.cpp +448 -324
  18. package/Core/Features/FileDrop/filedrop.css +421 -421
  19. package/Core/Features/FileDrop/filedrop.ts +0 -7
  20. package/Core/Features/Keyboard/keyboard_linux.cpp +4 -0
  21. package/Core/Features/Router/router.cpp +62 -62
  22. package/Core/Features/Router/router.ts +113 -113
  23. package/Core/Features/Tray/tray.cpp +328 -324
  24. package/Core/Features/WebGPU/webgpu.cpp +948 -948
  25. package/Core/Features/Window/webview.cpp +1009 -1009
  26. package/Core/Features/Window/webview.ts +516 -516
  27. package/Core/Features/Window/window.cpp +2240 -1986
  28. package/Core/include/plusui/api.hpp +237 -237
  29. package/Core/include/plusui/app.hpp +33 -33
  30. package/Core/include/plusui/browser.hpp +67 -67
  31. package/Core/include/plusui/clipboard.hpp +41 -41
  32. package/Core/include/plusui/connect.hpp +340 -340
  33. package/Core/include/plusui/connection.hpp +3 -3
  34. package/Core/include/plusui/display.hpp +90 -90
  35. package/Core/include/plusui/filedrop.hpp +92 -77
  36. package/Core/include/plusui/keyboard.hpp +112 -112
  37. package/Core/include/plusui/menu.hpp +153 -153
  38. package/Core/include/plusui/plusui +18 -18
  39. package/Core/include/plusui/router.hpp +42 -42
  40. package/Core/include/plusui/tray.hpp +94 -94
  41. package/Core/include/plusui/webgpu.hpp +434 -434
  42. package/Core/include/plusui/window.hpp +180 -177
  43. package/Core/scripts/generate-umbrella-header.mjs +77 -77
  44. package/Core/vendor/WebView2EnvironmentOptions.h +406 -406
  45. package/Core/vendor/webview.h +487 -487
  46. package/Core/vendor/webview2.h +52079 -52079
  47. package/README.md +19 -19
  48. package/package.json +1 -1
@@ -1,212 +1,212 @@
1
- #ifdef _WIN32
2
- #ifndef _WIN32_WINNT
3
- #define _WIN32_WINNT 0x0601
4
- #endif
5
- #include <windows.h>
6
-
7
- #ifndef EXTERN_C
8
- #ifdef __cplusplus
9
- #define EXTERN_C extern "C"
10
- #else
11
- #define EXTERN_C extern
12
- #endif
13
- #endif
14
-
15
- #include <shellapi.h>
16
- #include <shlobj.h>
17
- #include <winuser.h>
18
-
19
- #ifndef DISPLAY_DEVICE_ATTACHED_TO_SESSION
20
- #define DISPLAY_DEVICE_ATTACHED_TO_SESSION 0x00000001
21
- #endif
22
- #ifndef SM_CXMM
23
- #define SM_CXMM 43
24
- #endif
25
- #ifndef SM_CYMM
26
- #define SM_CYMM 44
27
- #endif
28
-
29
- #pragma comment(lib, "user32.lib")
30
- #pragma comment(lib, "shell32.lib")
31
- #endif
32
-
33
- #include <algorithm>
34
- #include <plusui/display.hpp>
35
- #include <vector>
36
-
37
- #ifdef __APPLE__
38
- #include <Cocoa/Cocoa.h>
39
- #include <CoreGraphics/CoreGraphics.h>
40
- #elif !defined(_WIN32)
41
- #include <gdk/gdk.h>
42
- #include <gtk/gtk.h>
43
- #endif
44
-
45
- namespace plusui {
46
-
47
- struct DisplayManager::Impl {
48
- std::vector<Display> displays;
49
- std::function<void(const Display &)> onConnectCallback;
50
- std::function<void(int)> onDisconnectCallback;
51
- std::function<void(const Display &)> onChangeCallback;
52
- };
53
-
54
- DisplayManager::DisplayManager() : pImpl(std::make_unique<Impl>()) {
55
- refresh();
56
- }
57
-
58
- DisplayManager::~DisplayManager() = default;
59
-
60
- DisplayManager &DisplayManager::instance() {
61
- static DisplayManager inst;
62
- return inst;
63
- }
64
-
65
- std::vector<Display> DisplayManager::getAllDisplays() {
66
- #ifdef _WIN32
67
- pImpl->displays.clear();
68
-
69
- int i = 0;
70
- DISPLAY_DEVICEW dd = {};
71
- dd.cb = sizeof(dd);
72
-
73
- while (EnumDisplayDevicesW(nullptr, i, &dd, 0)) {
74
- if (dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) {
75
- i++;
76
- continue;
77
- }
78
-
79
- Display d;
80
- d.id = i;
81
- // Widestring to string conversion
82
- std::wstring wname(dd.DeviceName);
83
- #pragma warning(push)
84
- #pragma warning(disable: 4244) // Suppress wchar_t to char conversion warning
85
- d.name = std::string(wname.begin(), wname.end());
86
- #pragma warning(pop)
87
-
88
- DEVMODEW dm = {};
89
- dm.dmSize = sizeof(dm);
90
- if (EnumDisplaySettingsW(dd.DeviceName, ENUM_CURRENT_SETTINGS, &dm)) {
91
- d.bounds.x = dm.dmPosition.x;
92
- d.bounds.y = dm.dmPosition.y;
93
- d.bounds.width = dm.dmPelsWidth;
94
- d.bounds.height = dm.dmPelsHeight;
95
- d.resolution.width = dm.dmPelsWidth;
96
- d.resolution.height = dm.dmPelsHeight;
97
- d.currentMode.width = dm.dmPelsWidth;
98
- d.currentMode.height = dm.dmPelsHeight;
99
- d.currentMode.refreshRate = dm.dmDisplayFrequency;
100
- }
101
-
102
- d.isPrimary = (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE);
103
-
104
- HMONITOR hMon = MonitorFromWindow(nullptr, MONITOR_DEFAULTTOPRIMARY);
105
- MONITORINFO mi = {};
106
- mi.cbSize = sizeof(mi);
107
- if (GetMonitorInfoW(hMon, &mi)) {
108
- d.workArea.x = mi.rcWork.left;
109
- d.workArea.y = mi.rcWork.top;
110
- d.workArea.width = mi.rcWork.right - mi.rcWork.left;
111
- d.workArea.height = mi.rcWork.bottom - mi.rcWork.top;
112
- }
113
-
114
- d.scaleFactor = 1.0;
115
- d.isConnected = (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_SESSION);
116
-
117
- pImpl->displays.push_back(d);
118
- i++;
119
- }
120
-
121
- #elif defined(__APPLE__)
122
- pImpl->displays.clear();
123
-
124
- CGDirectDisplayID mainDisplay = CGMainDisplayID();
125
- CGDisplayCount count;
126
- CGGetActiveDisplayList(0, nullptr, &count);
127
-
128
- std::vector<CGDirectDisplayID> displays(count);
129
- CGGetActiveDisplayList(count, displays.data(), &count);
130
-
131
- for (auto displayID : displays) {
132
- Display d;
133
- d.id = (int)displayID;
134
- d.isPrimary = (displayID == mainDisplay);
135
-
136
- CGRect rect = CGDisplayBounds(displayID);
137
- d.bounds.x = rect.origin.x;
138
- d.bounds.y = rect.origin.y;
139
- d.bounds.width = rect.size.width;
140
- d.bounds.height = rect.size.height;
141
- d.resolution.width = rect.size.width;
142
- d.resolution.height = rect.size.height;
143
-
144
- // Work area on macOS is tricky without AppKit, but we can use NSScreen in
145
- // window.cpp if needed. For now, we'll just use the full bounds.
146
- d.workArea = d.bounds;
147
-
148
- CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displayID);
149
- if (mode) {
150
- d.currentMode.width = CGDisplayModeGetWidth(mode);
151
- d.currentMode.height = CGDisplayModeGetHeight(mode);
152
- d.currentMode.refreshRate = CGDisplayModeGetRefreshRate(mode);
153
- CGDisplayModeRelease(mode);
154
- }
155
-
156
- d.scaleFactor = 1.0; // TODO: Get backing scale factor
157
- d.isConnected = true;
158
-
159
- pImpl->displays.push_back(d);
160
- }
161
- #else
162
- pImpl->displays.clear();
163
- GdkDisplay *display = gdk_display_get_default();
164
- if (display) {
165
- int n = gdk_display_get_n_monitors(display);
166
- for (int i = 0; i < n; i++) {
167
- GdkMonitor *monitor = gdk_display_get_monitor(display, i);
168
- GdkRectangle rect;
169
- gdk_monitor_get_geometry(monitor, &rect);
170
-
171
- Display d;
172
- d.id = i;
173
- d.isPrimary = gdk_monitor_is_primary(monitor);
174
- d.bounds.x = rect.x;
175
- d.bounds.y = rect.y;
176
- d.bounds.width = rect.width;
177
- d.bounds.height = rect.height;
178
- d.resolution.width = rect.width;
179
- d.resolution.height = rect.height;
180
-
181
- gdk_monitor_get_workarea(monitor, &rect);
182
- d.workArea.x = rect.x;
183
- d.workArea.y = rect.y;
184
- d.workArea.width = rect.width;
185
- d.workArea.height = rect.height;
186
-
187
- d.scaleFactor = gdk_monitor_get_scale_factor(monitor);
188
- d.isConnected = true;
189
- pImpl->displays.push_back(d);
190
- }
191
- }
192
- #endif
193
- return pImpl->displays;
194
- }
195
-
196
- void DisplayManager::refresh() { getAllDisplays(); }
197
-
198
- void DisplayManager::onDisplayConnected(
199
- std::function<void(const Display &)> callback) {
200
- pImpl->onConnectCallback = callback;
201
- }
202
-
203
- void DisplayManager::onDisplayDisconnected(std::function<void(int)> callback) {
204
- pImpl->onDisconnectCallback = callback;
205
- }
206
-
207
- void DisplayManager::onDisplayChanged(
208
- std::function<void(const Display &)> callback) {
209
- pImpl->onChangeCallback = callback;
210
- }
211
-
212
- } // namespace plusui
1
+ #ifdef _WIN32
2
+ #ifndef _WIN32_WINNT
3
+ #define _WIN32_WINNT 0x0601
4
+ #endif
5
+ #include <windows.h>
6
+
7
+ #ifndef EXTERN_C
8
+ #ifdef __cplusplus
9
+ #define EXTERN_C extern "C"
10
+ #else
11
+ #define EXTERN_C extern
12
+ #endif
13
+ #endif
14
+
15
+ #include <shellapi.h>
16
+ #include <shlobj.h>
17
+ #include <winuser.h>
18
+
19
+ #ifndef DISPLAY_DEVICE_ATTACHED_TO_SESSION
20
+ #define DISPLAY_DEVICE_ATTACHED_TO_SESSION 0x00000001
21
+ #endif
22
+ #ifndef SM_CXMM
23
+ #define SM_CXMM 43
24
+ #endif
25
+ #ifndef SM_CYMM
26
+ #define SM_CYMM 44
27
+ #endif
28
+
29
+ #pragma comment(lib, "user32.lib")
30
+ #pragma comment(lib, "shell32.lib")
31
+ #endif
32
+
33
+ #include <algorithm>
34
+ #include <plusui/display.hpp>
35
+ #include <vector>
36
+
37
+ #ifdef __APPLE__
38
+ #include <Cocoa/Cocoa.h>
39
+ #include <CoreGraphics/CoreGraphics.h>
40
+ #elif !defined(_WIN32)
41
+ #include <gdk/gdk.h>
42
+ #include <gtk/gtk.h>
43
+ #endif
44
+
45
+ namespace plusui {
46
+
47
+ struct DisplayManager::Impl {
48
+ std::vector<Display> displays;
49
+ std::function<void(const Display &)> onConnectCallback;
50
+ std::function<void(int)> onDisconnectCallback;
51
+ std::function<void(const Display &)> onChangeCallback;
52
+ };
53
+
54
+ DisplayManager::DisplayManager() : pImpl(std::make_unique<Impl>()) {
55
+ refresh();
56
+ }
57
+
58
+ DisplayManager::~DisplayManager() = default;
59
+
60
+ DisplayManager &DisplayManager::instance() {
61
+ static DisplayManager inst;
62
+ return inst;
63
+ }
64
+
65
+ std::vector<Display> DisplayManager::getAllDisplays() {
66
+ #ifdef _WIN32
67
+ pImpl->displays.clear();
68
+
69
+ int i = 0;
70
+ DISPLAY_DEVICEW dd = {};
71
+ dd.cb = sizeof(dd);
72
+
73
+ while (EnumDisplayDevicesW(nullptr, i, &dd, 0)) {
74
+ if (dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) {
75
+ i++;
76
+ continue;
77
+ }
78
+
79
+ Display d;
80
+ d.id = i;
81
+ // Widestring to string conversion
82
+ std::wstring wname(dd.DeviceName);
83
+ #pragma warning(push)
84
+ #pragma warning(disable: 4244) // Suppress wchar_t to char conversion warning
85
+ d.name = std::string(wname.begin(), wname.end());
86
+ #pragma warning(pop)
87
+
88
+ DEVMODEW dm = {};
89
+ dm.dmSize = sizeof(dm);
90
+ if (EnumDisplaySettingsW(dd.DeviceName, ENUM_CURRENT_SETTINGS, &dm)) {
91
+ d.bounds.x = dm.dmPosition.x;
92
+ d.bounds.y = dm.dmPosition.y;
93
+ d.bounds.width = dm.dmPelsWidth;
94
+ d.bounds.height = dm.dmPelsHeight;
95
+ d.resolution.width = dm.dmPelsWidth;
96
+ d.resolution.height = dm.dmPelsHeight;
97
+ d.currentMode.width = dm.dmPelsWidth;
98
+ d.currentMode.height = dm.dmPelsHeight;
99
+ d.currentMode.refreshRate = dm.dmDisplayFrequency;
100
+ }
101
+
102
+ d.isPrimary = (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE);
103
+
104
+ HMONITOR hMon = MonitorFromWindow(nullptr, MONITOR_DEFAULTTOPRIMARY);
105
+ MONITORINFO mi = {};
106
+ mi.cbSize = sizeof(mi);
107
+ if (GetMonitorInfoW(hMon, &mi)) {
108
+ d.workArea.x = mi.rcWork.left;
109
+ d.workArea.y = mi.rcWork.top;
110
+ d.workArea.width = mi.rcWork.right - mi.rcWork.left;
111
+ d.workArea.height = mi.rcWork.bottom - mi.rcWork.top;
112
+ }
113
+
114
+ d.scaleFactor = 1.0;
115
+ d.isConnected = (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_SESSION);
116
+
117
+ pImpl->displays.push_back(d);
118
+ i++;
119
+ }
120
+
121
+ #elif defined(__APPLE__)
122
+ pImpl->displays.clear();
123
+
124
+ CGDirectDisplayID mainDisplay = CGMainDisplayID();
125
+ CGDisplayCount count;
126
+ CGGetActiveDisplayList(0, nullptr, &count);
127
+
128
+ std::vector<CGDirectDisplayID> displays(count);
129
+ CGGetActiveDisplayList(count, displays.data(), &count);
130
+
131
+ for (auto displayID : displays) {
132
+ Display d;
133
+ d.id = (int)displayID;
134
+ d.isPrimary = (displayID == mainDisplay);
135
+
136
+ CGRect rect = CGDisplayBounds(displayID);
137
+ d.bounds.x = rect.origin.x;
138
+ d.bounds.y = rect.origin.y;
139
+ d.bounds.width = rect.size.width;
140
+ d.bounds.height = rect.size.height;
141
+ d.resolution.width = rect.size.width;
142
+ d.resolution.height = rect.size.height;
143
+
144
+ // Work area on macOS is tricky without AppKit, but we can use NSScreen in
145
+ // window.cpp if needed. For now, we'll just use the full bounds.
146
+ d.workArea = d.bounds;
147
+
148
+ CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displayID);
149
+ if (mode) {
150
+ d.currentMode.width = CGDisplayModeGetWidth(mode);
151
+ d.currentMode.height = CGDisplayModeGetHeight(mode);
152
+ d.currentMode.refreshRate = CGDisplayModeGetRefreshRate(mode);
153
+ CGDisplayModeRelease(mode);
154
+ }
155
+
156
+ d.scaleFactor = 1.0; // TODO: Get backing scale factor
157
+ d.isConnected = true;
158
+
159
+ pImpl->displays.push_back(d);
160
+ }
161
+ #else
162
+ pImpl->displays.clear();
163
+ GdkDisplay *display = gdk_display_get_default();
164
+ if (display) {
165
+ int n = gdk_display_get_n_monitors(display);
166
+ for (int i = 0; i < n; i++) {
167
+ GdkMonitor *monitor = gdk_display_get_monitor(display, i);
168
+ GdkRectangle rect;
169
+ gdk_monitor_get_geometry(monitor, &rect);
170
+
171
+ Display d;
172
+ d.id = i;
173
+ d.isPrimary = gdk_monitor_is_primary(monitor);
174
+ d.bounds.x = rect.x;
175
+ d.bounds.y = rect.y;
176
+ d.bounds.width = rect.width;
177
+ d.bounds.height = rect.height;
178
+ d.resolution.width = rect.width;
179
+ d.resolution.height = rect.height;
180
+
181
+ gdk_monitor_get_workarea(monitor, &rect);
182
+ d.workArea.x = rect.x;
183
+ d.workArea.y = rect.y;
184
+ d.workArea.width = rect.width;
185
+ d.workArea.height = rect.height;
186
+
187
+ d.scaleFactor = gdk_monitor_get_scale_factor(monitor);
188
+ d.isConnected = true;
189
+ pImpl->displays.push_back(d);
190
+ }
191
+ }
192
+ #endif
193
+ return pImpl->displays;
194
+ }
195
+
196
+ void DisplayManager::refresh() { getAllDisplays(); }
197
+
198
+ void DisplayManager::onDisplayConnected(
199
+ std::function<void(const Display &)> callback) {
200
+ pImpl->onConnectCallback = callback;
201
+ }
202
+
203
+ void DisplayManager::onDisplayDisconnected(std::function<void(int)> callback) {
204
+ pImpl->onDisconnectCallback = callback;
205
+ }
206
+
207
+ void DisplayManager::onDisplayChanged(
208
+ std::function<void(const Display &)> callback) {
209
+ pImpl->onChangeCallback = callback;
210
+ }
211
+
212
+ } // namespace plusui