From b77a97cb1d60ac3b0700294cf5426b552ff79454 Mon Sep 17 00:00:00 2001 From: Marcus Tomlinson Date: Sun, 16 Jun 2024 14:22:37 +0100 Subject: [PATCH] Allow opening of child windows --- .gitmodules | 2 +- .vscode/launch.json | 1 + snap/snapcraft.yaml | 3 ++- src/main.cpp | 15 +++++++++++++++ subprojects/choc | 2 +- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 6b8b2f2..0b29cb8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "subprojects/choc"] path = subprojects/choc url = /~https://github.com/cross-platform/choc.git - branch = fork + branch = chip diff --git a/.vscode/launch.json b/.vscode/launch.json index 21a2350..fe136dd 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,6 +6,7 @@ "preLaunchTask": "Build", "program": "${workspaceFolder}/build/icloud-for-linux", "args": ["notes", "Notes"], + "environment": [{"name":"TMPDIR","value":"${workspaceFolder}/build"}], "cwd": "${workspaceFolder}", "request": "launch", "type": "cppdbg", diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 0f50ee7..82eecbc 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: icloud-for-linux -version: '0.15' +version: '0.16' summary: iCloud for Linux description: iCloud for Linux @@ -28,6 +28,7 @@ apps: - network-status - opengl - screen-inhibit-control + - wayland - x11 environment: &environment TMPDIR: $XDG_RUNTIME_DIR diff --git a/src/main.cpp b/src/main.cpp index a95860c..22f72ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,6 +16,21 @@ int main(int, char **argv) appWin.setContent(webView.getViewHandle()); appWin.toFront(); + webView.onNewWindow( [&](const std::string& url) + { + choc::ui::DesktopWindow appWin(choc::ui::Bounds{0, 0, 0, 0}); + appWin.centreWithSize(1000, 600); + appWin.setWindowTitle( "iCloud " + std::string(argv[2]) + " ⧉" ); + + choc::ui::WebView webView; + webView.navigate(url); + + appWin.setContent(webView.getViewHandle()); + appWin.toFront(); + + return appWin.getWindowHandle(); + }); + choc::messageloop::run(); return 0; } diff --git a/subprojects/choc b/subprojects/choc index e330260..a553c82 160000 --- a/subprojects/choc +++ b/subprojects/choc @@ -1 +1 @@ -Subproject commit e330260670b884a51774384a21a9048ee845bcca +Subproject commit a553c822a7ef887808ff2ff5d582fbf75a3779e4