windowpp 0.1.1

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 (88) hide show
  1. package/bin/windowpp.js +86 -0
  2. package/cmake/embed_assets.py +144 -0
  3. package/framework/CMakeLists.txt +176 -0
  4. package/framework/include/windowpp/windowpp.h +704 -0
  5. package/framework/src/AppData/API/AppData.ts +137 -0
  6. package/framework/src/AppData/appdata_bridge.h +138 -0
  7. package/framework/src/AppData/appdata_manager.cpp +126 -0
  8. package/framework/src/AppData/appdata_manager.h +3 -0
  9. package/framework/src/FileSystem/API/FileSystem.ts +389 -0
  10. package/framework/src/FileSystem/Linux/filesearch.cpp +148 -0
  11. package/framework/src/FileSystem/Linux/readfile.cpp +79 -0
  12. package/framework/src/FileSystem/Linux/savefile.cpp +333 -0
  13. package/framework/src/FileSystem/MacOS/filesearch.cpp +149 -0
  14. package/framework/src/FileSystem/MacOS/readfile.cpp +80 -0
  15. package/framework/src/FileSystem/MacOS/savefile.cpp +264 -0
  16. package/framework/src/FileSystem/Windows/filesearch.cpp +195 -0
  17. package/framework/src/FileSystem/Windows/readfile.cpp +122 -0
  18. package/framework/src/FileSystem/Windows/savefile.cpp +290 -0
  19. package/framework/src/FileSystem/file_index_service.cpp +262 -0
  20. package/framework/src/FileSystem/file_index_service.h +55 -0
  21. package/framework/src/FileSystem/filesystem_bridge.h +243 -0
  22. package/framework/src/FileSystem/filesystem_handler.h +93 -0
  23. package/framework/src/FileSystem/filesystem_json.h +241 -0
  24. package/framework/src/FileSystem/filesystem_search_service.cpp +414 -0
  25. package/framework/src/FileSystem/filesystem_search_service.h +94 -0
  26. package/framework/src/Input/API/Input.ts +161 -0
  27. package/framework/src/Input/Linux/linux_key_utils.h +135 -0
  28. package/framework/src/Input/MacOS/macos_key_utils.h +137 -0
  29. package/framework/src/Input/Windows/win32_key_utils.h +199 -0
  30. package/framework/src/Input/input_bridge.h +192 -0
  31. package/framework/src/Input/input_service.cpp +584 -0
  32. package/framework/src/Input/input_service.h +21 -0
  33. package/framework/src/application.cpp +29 -0
  34. package/framework/src/common/hit_test.cpp +40 -0
  35. package/framework/src/common/image_loader.cpp +24 -0
  36. package/framework/src/common/paths.cpp +75 -0
  37. package/framework/src/filedrop/filedrop.cpp +316 -0
  38. package/framework/src/filedrop/filedrop.css +421 -0
  39. package/framework/src/filedrop/filedrop.hpp +92 -0
  40. package/framework/src/filedrop/filedrop.ts +183 -0
  41. package/framework/src/platform/API/App.ts +156 -0
  42. package/framework/src/platform/API/Window.ts +249 -0
  43. package/framework/src/platform/linux/app_linux.cpp +256 -0
  44. package/framework/src/platform/linux/app_linux.h +64 -0
  45. package/framework/src/platform/linux/linux_helpers.cpp +26 -0
  46. package/framework/src/platform/linux/linux_helpers.h +19 -0
  47. package/framework/src/platform/linux/tray_linux.cpp +21 -0
  48. package/framework/src/platform/linux/tray_linux.h +26 -0
  49. package/framework/src/platform/linux/window_linux.cpp +256 -0
  50. package/framework/src/platform/linux/window_linux.h +70 -0
  51. package/framework/src/platform/macos/app_macos.h +59 -0
  52. package/framework/src/platform/macos/app_macos.mm +223 -0
  53. package/framework/src/platform/macos/macos_helpers.h +21 -0
  54. package/framework/src/platform/macos/tray_macos.h +22 -0
  55. package/framework/src/platform/macos/tray_macos.mm +53 -0
  56. package/framework/src/platform/macos/window_macos.h +74 -0
  57. package/framework/src/platform/macos/window_macos.mm +318 -0
  58. package/framework/src/platform/platform_bridge.h +514 -0
  59. package/framework/src/platform/platform_factory.cpp +33 -0
  60. package/framework/src/platform/platform_factory.h +19 -0
  61. package/framework/src/platform/win32/app_win32.cpp +572 -0
  62. package/framework/src/platform/win32/app_win32.h +83 -0
  63. package/framework/src/platform/win32/tray_win32.cpp +57 -0
  64. package/framework/src/platform/win32/tray_win32.h +30 -0
  65. package/framework/src/platform/win32/win32_helpers.h +61 -0
  66. package/framework/src/platform/win32/window_win32.cpp +267 -0
  67. package/framework/src/platform/win32/window_win32.h +79 -0
  68. package/framework/src/renderer/webgpu.h +128 -0
  69. package/framework/src/renderer/webview/include/WebView2.h +48014 -0
  70. package/framework/src/renderer/webview/include/WebView2EnvironmentOptions.h +342 -0
  71. package/framework/src/renderer/webview/webview.h +13 -0
  72. package/framework/src/renderer/webview/webview_linux.cpp +392 -0
  73. package/framework/src/renderer/webview/webview_macos.mm +388 -0
  74. package/framework/src/renderer/webview/webview_win32.cpp +688 -0
  75. package/framework/src/renderer/webview/x64/WebView2Loader.dll +0 -0
  76. package/framework/src/renderer/webview/x64/WebView2Loader.lib +0 -0
  77. package/framework/src/renderer/webview/x64/WebView2LoaderStatic.lib +0 -0
  78. package/lib/build.js +112 -0
  79. package/lib/create.js +283 -0
  80. package/lib/dev.js +155 -0
  81. package/package.json +24 -0
  82. package/scripts/publish.js +67 -0
  83. package/scripts/sync-framework.js +73 -0
  84. package/templates/solid/CMakeLists.txt +56 -0
  85. package/templates/solid/frontend/package.json +22 -0
  86. package/templates/solid/frontend/vite.config.ts +25 -0
  87. package/templates/solid/main.cpp +72 -0
  88. package/templates/solid/package.json +12 -0
@@ -0,0 +1,64 @@
1
+ // ============================================================================
2
+ // app_linux.h — Linux/X11 Application implementation
3
+ // ============================================================================
4
+
5
+ #pragma once
6
+
7
+ #include <xcb/xcb.h>
8
+ #include <map>
9
+ #include <memory>
10
+ #include <functional>
11
+ #include "window_linux.h"
12
+ #include "tray_linux.h"
13
+ #include "windowpp.h"
14
+
15
+ namespace wpp {
16
+
17
+ class LinuxApplication : public Application {
18
+ public:
19
+ LinuxApplication(const AppConfig& config);
20
+ ~LinuxApplication() override;
21
+
22
+ Window* create_window(const WindowConfig& config) override;
23
+ Window* get_window(const std::string& id) override;
24
+ std::vector<Window*> all_windows() override;
25
+
26
+ void run() override;
27
+ void quit() override;
28
+ void set_tray(const TrayConfig& config) override;
29
+ void remove_tray() override;
30
+
31
+ std::vector<MonitorInfo> monitors() override;
32
+ MonitorInfo primary_monitor() override;
33
+
34
+ std::string clipboard_text() override;
35
+ void set_clipboard_text(const std::string& text) override;
36
+
37
+ void send_message(const std::string& window_id,
38
+ const std::string& event,
39
+ const std::string& payload) override;
40
+ void on_message(const std::string& window_id, MessageHandler handler) override;
41
+
42
+ TimerId set_timeout(uint32_t ms, std::function<void()> callback) override;
43
+ TimerId set_interval(uint32_t ms, std::function<void()> callback) override;
44
+ void clear_timer(TimerId id) override;
45
+
46
+ void dispatch(std::function<void()> fn) override;
47
+
48
+ xcb_connection_t* connection() const { return connection_; }
49
+ xcb_window_t root() const { return root_; }
50
+
51
+ private:
52
+ AppConfig config_;
53
+ xcb_connection_t* connection_;
54
+ xcb_window_t root_;
55
+ std::map<std::string, std::unique_ptr<LinuxWindow>> windows_;
56
+ std::unique_ptr<LinuxTray> tray_;
57
+ std::map<std::string, std::vector<MessageHandler>> message_handlers_;
58
+ bool running_ = false;
59
+
60
+ void handle_events();
61
+ LinuxWindow* get_window_by_native(xcb_window_t window);
62
+ };
63
+
64
+ } // namespace wpp
@@ -0,0 +1,26 @@
1
+ // ============================================================================
2
+ // linux_helpers.cpp — Linux/X11 helper utilities
3
+ // ============================================================================
4
+
5
+ #include "linux_helpers.h"
6
+
7
+ namespace wpp {
8
+ namespace linux {
9
+
10
+ xcb_atom_t get_atom(xcb_connection_t* conn, const char* name) {
11
+ xcb_atom_t atom = XCB_NONE;
12
+ auto len = strlen(name);
13
+ xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(
14
+ conn,
15
+ xcb_intern_atom(conn, len > 3 ? 1 : 0, len, name),
16
+ nullptr
17
+ );
18
+ if (reply) {
19
+ atom = reply->atom;
20
+ free(reply);
21
+ }
22
+ return atom;
23
+ }
24
+
25
+ } // namespace linux
26
+ } // namespace wpp
@@ -0,0 +1,19 @@
1
+ // ============================================================================
2
+ // linux_helpers.h — Linux/X11 helper utilities
3
+ // ============================================================================
4
+
5
+ #pragma once
6
+
7
+ #include <xcb/xcb.h>
8
+ #include <string>
9
+
10
+ namespace wpp {
11
+ namespace linux {
12
+
13
+ inline std::string to_utf8(const std::string& str) { return str; }
14
+ inline std::string from_utf8(const char* str) { return str ? str : ""; }
15
+
16
+ xcb_atom_t get_atom(xcb_connection_t* conn, const char* name);
17
+
18
+ } // namespace linux
19
+ } // namespace wpp
@@ -0,0 +1,21 @@
1
+ // ============================================================================
2
+ // tray_linux.cpp — Linux System Tray implementation
3
+ // ============================================================================
4
+
5
+ #include "tray_linux.h"
6
+
7
+ namespace wpp {
8
+
9
+ LinuxTray::LinuxTray(const TrayConfig& config, xcb_connection_t* conn, xcb_window_t root)
10
+ : config_(config), connection_(conn), root_(root) {
11
+ #ifdef WPP_HAS_APPINDICATOR
12
+ // Uses appindicator3-0.1 when available
13
+ #endif
14
+ }
15
+
16
+ LinuxTray::~LinuxTray() {
17
+ #ifdef WPP_HAS_APPINDICATOR
18
+ #endif
19
+ }
20
+
21
+ } // namespace wpp
@@ -0,0 +1,26 @@
1
+ // ============================================================================
2
+ // tray_linux.h — Linux System Tray implementation (StatusNotifierItem/AppIndicator)
3
+ // ============================================================================
4
+
5
+ #pragma once
6
+
7
+ #include <xcb/xcb.h>
8
+ #include "windowpp.h"
9
+
10
+ namespace wpp {
11
+
12
+ class LinuxTray {
13
+ public:
14
+ LinuxTray(const TrayConfig& config, xcb_connection_t* conn, xcb_window_t root);
15
+ ~LinuxTray();
16
+
17
+ private:
18
+ TrayConfig config_;
19
+ xcb_connection_t* connection_;
20
+ xcb_window_t root_;
21
+ #ifdef WPP_HAS_APPINDICATOR
22
+ void* indicator_;
23
+ #endif
24
+ };
25
+
26
+ } // namespace wpp
@@ -0,0 +1,256 @@
1
+ // ============================================================================
2
+ // window_linux.cpp — Linux/X11 Window implementation
3
+ // ============================================================================
4
+
5
+ #include "window_linux.h"
6
+ #include <cstring>
7
+
8
+ namespace wpp {
9
+
10
+ LinuxWindow::LinuxWindow(const WindowConfig& config, xcb_window_t window)
11
+ : config_(config), window_(window) {
12
+ connection_ = xcb_connect(nullptr, nullptr);
13
+ }
14
+
15
+ LinuxWindow::~LinuxWindow() {
16
+ xcb_destroy_window(connection_, window_);
17
+ xcb_disconnect(connection_);
18
+ }
19
+
20
+ std::string LinuxWindow::title() const {
21
+ auto reply = xcb_get_property_reply(
22
+ connection_,
23
+ xcb_get_property(connection_, 0, window_,
24
+ XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 0, 1024),
25
+ nullptr);
26
+ if (reply && reply->value_len > 0) {
27
+ std::string result((const char*)xcb_get_property_value(reply), reply->value_len);
28
+ free(reply);
29
+ return result;
30
+ }
31
+ return {};
32
+ }
33
+
34
+ Size LinuxWindow::size() const {
35
+ auto reply = xcb_get_geometry_reply(connection_,
36
+ xcb_get_geometry(connection_, window_), nullptr);
37
+ if (reply) {
38
+ Size s = { (int)reply->width, (int)reply->height };
39
+ free(reply);
40
+ return s;
41
+ }
42
+ return {0, 0};
43
+ }
44
+
45
+ Point LinuxWindow::position() const {
46
+ auto reply = xcb_get_geometry_reply(connection_,
47
+ xcb_get_geometry(connection_, window_), nullptr);
48
+ if (reply) {
49
+ Point p = { (int)reply->x, (int)reply->y };
50
+ free(reply);
51
+ return p;
52
+ }
53
+ return {0, 0};
54
+ }
55
+
56
+ WindowState LinuxWindow::state() const {
57
+ return WindowState::Normal;
58
+ }
59
+
60
+ bool LinuxWindow::is_visible() const {
61
+ auto reply = xcb_get_window_attributes_reply(connection_,
62
+ xcb_get_window_attributes(connection_, window_), nullptr);
63
+ if (reply) {
64
+ bool visible = reply->map_state == XCB_MAP_STATE_VIEWABLE;
65
+ free(reply);
66
+ return visible;
67
+ }
68
+ return false;
69
+ }
70
+
71
+ bool LinuxWindow::is_focused() const {
72
+ auto reply = xcb_get_input_focus_reply(connection_,
73
+ xcb_get_input_focus(connection_), nullptr);
74
+ if (reply) {
75
+ bool focused = reply->focus == window_;
76
+ free(reply);
77
+ return focused;
78
+ }
79
+ return false;
80
+ }
81
+
82
+ float LinuxWindow::scale_factor() const {
83
+ return 1.0f;
84
+ }
85
+
86
+ void LinuxWindow::set_title(const std::string& title) {
87
+ xcb_change_property(connection_, XCB_PROP_MODE_REPLACE, window_,
88
+ XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, title.size(), title.c_str());
89
+ }
90
+
91
+ void LinuxWindow::set_size(int w, int h) {
92
+ uint32_t values[] = { (uint32_t)w, (uint32_t)h };
93
+ xcb_configure_window(connection_, window_,
94
+ XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
95
+ }
96
+
97
+ void LinuxWindow::set_position(int x, int y) {
98
+ uint32_t values[] = { (uint32_t)x, (uint32_t)y };
99
+ xcb_configure_window(connection_, window_,
100
+ XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values);
101
+ }
102
+
103
+ void LinuxWindow::set_min_size(int w, int h) {
104
+ config_.min_width = w;
105
+ config_.min_height = h;
106
+ }
107
+
108
+ void LinuxWindow::set_max_size(int w, int h) {
109
+ config_.max_width = w;
110
+ config_.max_height = h;
111
+ }
112
+
113
+ void LinuxWindow::set_resizable(bool v) {
114
+ config_.resizable = v;
115
+ }
116
+
117
+ void LinuxWindow::set_always_on_top(bool v) {
118
+ uint32_t stack_mode = v ? XCB_STACK_MODE_ABOVE : XCB_STACK_MODE_BELOW;
119
+ xcb_configure_window(connection_, window_, XCB_CONFIG_WINDOW_STACK_MODE, &stack_mode);
120
+ }
121
+
122
+ void LinuxWindow::set_opacity(float v) {
123
+ uint32_t opacity = static_cast<uint32_t>(v * 0xFFFFFFFF);
124
+ auto atom = linux::get_atom(connection_, "_NET_WM_WINDOW_OPACITY");
125
+ if (atom != XCB_NONE) {
126
+ xcb_change_property(connection_, XCB_PROP_MODE_REPLACE, window_,
127
+ atom, XCB_ATOM_CARDINAL, 32, 1, &opacity);
128
+ }
129
+ }
130
+
131
+ void LinuxWindow::set_background(Color c) {
132
+ config_.background = c;
133
+ uint32_t color = (c.r << 16) | (c.g << 8) | c.b;
134
+ xcb_change_window_attributes(connection_, window_,
135
+ XCB_CW_BACK_PIXEL, &color);
136
+ }
137
+
138
+ void LinuxWindow::set_cursor(CursorType c) {
139
+ uint32_t cursor_id = 0;
140
+ switch (c) {
141
+ case CursorType::Arrow: cursor_id = 0; break;
142
+ case CursorType::Hand: cursor_id = 2; break;
143
+ case CursorType::IBeam: cursor_id = 4; break;
144
+ case CursorType::Crosshair: cursor_id = 8; break;
145
+ case CursorType::ResizeNS: cursor_id = 14; break;
146
+ case CursorType::ResizeEW: cursor_id = 12; break;
147
+ case CursorType::ResizeNWSE: cursor_id = 18; break;
148
+ case CursorType::ResizeNESW: cursor_id = 16; break;
149
+ case CursorType::Move: cursor_id = 20; break;
150
+ case CursorType::NotAllowed: cursor_id = 22; break;
151
+ default: cursor_id = 0; break;
152
+ }
153
+ }
154
+
155
+ void LinuxWindow::show() {
156
+ xcb_map_window(connection_, window_);
157
+ if (config_.on_shown) config_.on_shown();
158
+ }
159
+
160
+ void LinuxWindow::hide() {
161
+ xcb_unmap_window(connection_, window_);
162
+ if (config_.on_hidden) config_.on_hidden();
163
+ }
164
+
165
+ void LinuxWindow::close() {
166
+ if (config_.on_close_requested && !config_.on_close_requested()) {
167
+ return;
168
+ }
169
+ xcb_destroy_window(connection_, window_);
170
+ if (config_.on_closed) config_.on_closed();
171
+ }
172
+
173
+ void LinuxWindow::focus() {
174
+ xcb_set_input_focus(connection_, XCB_INPUT_FOCUS_PARENT, window_, XCB_CURRENT_TIME);
175
+ }
176
+
177
+ void LinuxWindow::minimize() {
178
+ xcb_iconify_window(connection_, window_, 0);
179
+ }
180
+
181
+ void LinuxWindow::maximize() {
182
+ auto reply = xcb_get_property_reply(connection_,
183
+ xcb_get_property(connection_, 0, window_,
184
+ linux::get_atom(connection_, "_NET_WM_STATE"),
185
+ XCB_ATOM_ATOM, 0, 32), nullptr);
186
+ free(reply);
187
+ }
188
+
189
+ void LinuxWindow::restore() {
190
+ xcb_map_window(connection_, window_);
191
+ }
192
+
193
+ void LinuxWindow::fullscreen() {
194
+ }
195
+
196
+ void LinuxWindow::center() {
197
+ }
198
+
199
+ void LinuxWindow::request_repaint() {
200
+ uint32_t values[] = { XCB_BACKING_STORE_NOT_USEFUL };
201
+ xcb_change_window_attributes(connection_, window_, XCB_CW_BACKING_STORE, values);
202
+ }
203
+
204
+ void LinuxWindow::start_drag() {
205
+ auto atom = linux::get_atom(connection_, "_NET_WM_MOVERESIZE");
206
+ xcb_client_message_event_t event = {};
207
+ event.response_type = XCB_CLIENT_MESSAGE;
208
+ event.window = window_;
209
+ event.type = atom;
210
+ event.format = 32;
211
+ event.data.data32[0] = 0;
212
+ event.data.data32[1] = 0;
213
+ event.data.data32[2] = 8;
214
+ xcb_send_event(connection_, 0, window_,
215
+ XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_BUTTON_PRESS,
216
+ (const char*)&event);
217
+ }
218
+
219
+ void LinuxWindow::start_resize(HitTestRegion edge) {
220
+ int direction = 0;
221
+ switch (edge) {
222
+ case HitTestRegion::ResizeTop: direction = 1; break;
223
+ case HitTestRegion::ResizeBottom: direction = 5; break;
224
+ case HitTestRegion::ResizeLeft: direction = 7; break;
225
+ case HitTestRegion::ResizeRight: direction = 3; break;
226
+ case HitTestRegion::ResizeTopLeft: direction = 0; break;
227
+ case HitTestRegion::ResizeTopRight: direction = 2; break;
228
+ case HitTestRegion::ResizeBottomLeft: direction = 6; break;
229
+ case HitTestRegion::ResizeBottomRight: direction = 4; break;
230
+ default: return;
231
+ }
232
+ auto atom = linux::get_atom(connection_, "_NET_WM_MOVERESIZE");
233
+ xcb_client_message_event_t event = {};
234
+ event.response_type = XCB_CLIENT_MESSAGE;
235
+ event.window = window_;
236
+ event.type = atom;
237
+ event.format = 32;
238
+ event.data.data32[0] = 0;
239
+ event.data.data32[1] = direction;
240
+ event.data.data32[2] = 0;
241
+ xcb_send_event(connection_, 0, window_,
242
+ XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_BUTTON_PRESS,
243
+ (const char*)&event);
244
+ }
245
+
246
+ HitTestRegion LinuxWindow::hit_test(Point cursor) {
247
+ if (config_.on_hit_test) {
248
+ return config_.on_hit_test(cursor);
249
+ }
250
+ return default_hit_test(cursor, size(),
251
+ config_.resize_border_width,
252
+ config_.caption_height,
253
+ config_.resizable);
254
+ }
255
+
256
+ } // namespace wpp
@@ -0,0 +1,70 @@
1
+ // ============================================================================
2
+ // window_linux.h — Linux/X11 Window implementation
3
+ // ============================================================================
4
+
5
+ #pragma once
6
+
7
+ #include <xcb/xcb.h>
8
+ #include <map>
9
+ #include <functional>
10
+ #include <memory>
11
+ #include "linux_helpers.h"
12
+ #include "windowpp.h"
13
+
14
+ namespace wpp {
15
+
16
+ class LinuxWindow : public Window {
17
+ public:
18
+ LinuxWindow(const WindowConfig& config, xcb_window_t window);
19
+ ~LinuxWindow() override;
20
+
21
+ std::string id() const override { return config_.id; }
22
+ std::string title() const override;
23
+ Size size() const override;
24
+ Point position() const override;
25
+ WindowState state() const override;
26
+ bool is_visible() const override;
27
+ bool is_focused() const override;
28
+ float scale_factor() const override;
29
+ void* native_handle() const override { return reinterpret_cast<void*>(window_); }
30
+
31
+ void set_title(const std::string& title) override;
32
+ void set_size(int w, int h) override;
33
+ void set_position(int x, int y) override;
34
+ void set_min_size(int w, int h) override;
35
+ void set_max_size(int w, int h) override;
36
+ void set_resizable(bool v) override;
37
+ void set_always_on_top(bool v) override;
38
+ void set_opacity(float v) override;
39
+ void set_background(Color c) override;
40
+ void set_cursor(CursorType c) override;
41
+
42
+ void show() override;
43
+ void hide() override;
44
+ void close() override;
45
+ void focus() override;
46
+ void minimize() override;
47
+ void maximize() override;
48
+ void restore() override;
49
+ void fullscreen() override;
50
+ void center() override;
51
+ void request_repaint() override;
52
+ void start_drag() override;
53
+ void start_resize(HitTestRegion edge) override;
54
+
55
+ WebView* webview() override { return webview_.get(); }
56
+ void set_webview(std::unique_ptr<WebView> wv) { webview_ = std::move(wv); }
57
+
58
+ xcb_window_t window() const { return window_; }
59
+ const WindowConfig& config() const { return config_; }
60
+
61
+ HitTestRegion hit_test(Point cursor);
62
+
63
+ private:
64
+ WindowConfig config_;
65
+ xcb_window_t window_;
66
+ xcb_connection_t* connection_;
67
+ std::unique_ptr<WebView> webview_;
68
+ };
69
+
70
+ } // namespace wpp
@@ -0,0 +1,59 @@
1
+ // ============================================================================
2
+ // app_macos.h — macOS/Cocoa Application implementation
3
+ // ============================================================================
4
+
5
+ #pragma once
6
+
7
+ #import <Cocoa/Cocoa.h>
8
+ #include <map>
9
+ #include <memory>
10
+ #include <functional>
11
+ #include "window_macos.h"
12
+ #include "tray_macos.h"
13
+ #include "windowpp.h"
14
+
15
+ @class PWAppDelegate;
16
+
17
+ namespace wpp {
18
+
19
+ class MacOSApplication : public Application {
20
+ public:
21
+ MacOSApplication(const AppConfig& config);
22
+ ~MacOSApplication() override;
23
+
24
+ Window* create_window(const WindowConfig& config) override;
25
+ Window* get_window(const std::string& id) override;
26
+ std::vector<Window*> all_windows() override;
27
+
28
+ void run() override;
29
+ void quit() override;
30
+ void set_tray(const TrayConfig& config) override;
31
+ void remove_tray() override;
32
+
33
+ std::vector<MonitorInfo> monitors() override;
34
+ MonitorInfo primary_monitor() override;
35
+
36
+ std::string clipboard_text() override;
37
+ void set_clipboard_text(const std::string& text) override;
38
+
39
+ void send_message(const std::string& window_id,
40
+ const std::string& event,
41
+ const std::string& payload) override;
42
+ void on_message(const std::string& window_id, MessageHandler handler) override;
43
+
44
+ TimerId set_timeout(uint32_t ms, std::function<void()> callback) override;
45
+ TimerId set_interval(uint32_t ms, std::function<void()> callback) override;
46
+ void clear_timer(TimerId id) override;
47
+
48
+ void dispatch(std::function<void()> fn) override;
49
+
50
+ private:
51
+ AppConfig config_;
52
+ NSApplication* app_;
53
+ PWAppDelegate* delegate_;
54
+ std::map<std::string, std::unique_ptr<MacOSWindow>> windows_;
55
+ std::unique_ptr<MacOSTray> tray_;
56
+ std::map<std::string, std::vector<MessageHandler>> message_handlers_;
57
+ };
58
+
59
+ } // namespace wpp