diff --git a/AGENTS.md b/AGENTS.md index 5bf725d..3f8f926 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -457,8 +457,8 @@ restart buttons. `ui/open_in_editor_buttons.dart` draws them, absent one. - **Most of it goes through `open`**, which hands the request to LaunchServices and so routes it to the copy that is *already running*. Three forms: - - **The folder as a document** — `open -a `, for VS Code, - which declares `public.folder` in `CFBundleDocumentTypes`. + - **The folder as a document** — `open -a `, for VS Code and + Antigravity, which declare `public.folder` in `CFBundleDocumentTypes`. - **A deep link** — `open ://…`, for Claude (`claude://code/new?folder=`), Codex (`codex://threads/new?path=`) and OpenCode (`opencode://open-project?directory=`). None of the three takes a @@ -474,13 +474,13 @@ restart buttons. `ui/open_in_editor_buttons.dart` draws them, is why the deep link is preferred over handing it the folder as a document. No `q`/`prompt` is sent: that would prefill *and* start a task, and the button only promises to open the project. -- **Antigravity is the one `IdeIntegration` with no button.** - `/Applications/Antigravity.app` is not the IDE — it is a thin Electron shell - around a Go language server, with no `open-file` handler and no - `CFBundleDocumentTypes`, so a folder handed to it is dropped. The editor is a - separate bundle, `Antigravity IDE.app`, and no route into it has been - confirmed. It is out only because no build of it has been seen to open the - folder it was given. +- **Antigravity opens through `Antigravity IDE.app`, never `Antigravity.app`.** + The latter is a thin Electron shell around a Go language server, with no + `open-file` handler and no `CFBundleDocumentTypes`, so a folder handed to it + is dropped and `open` still exits 0. The IDE is a separate bundle, a VS Code + fork, and `open -a` on it was confirmed against 2.5.5: the folder opened, and + a second call reused the running copy. **macOS only** — where the Windows + installer puts the IDE has not been seen, so there is no Windows button. - **Order is preference order**, and `ProjectStartedDialog` features the first. OpenCode is last deliberately: it only appears when the box was ticked, but App Studio already runs it in the Agent tab, so an editor it does *not* have @@ -1247,6 +1247,8 @@ install. Sparkle would also catch it, but later and less clearly. - **Custom widgets read the theme; they do not carry colors.** Use `scheme.*` for color, `theme.radii.{sm,md,lg,full}` for corners and `theme.style.*` for geometry — a literal `Color(0x…)` or `BorderRadius.circular(n)` in a widget is the thing to fix, not to match. Failure states are `scheme.destructive`, never a private red. - **Success and warning have no shadcn token**, so they ride in the scheme's `custom` map and are read through the `AppColorScheme` extension as `scheme.success` / `scheme.warning`. One value per status, picked to be legible on that brightness's background, covers both the dot and its label. - **The app icon is `AppIcon.appiconset` on macOS and `windows/runner/resources/app_icon.ico` on Windows** — separate artwork, each from the design's icon set, so neither is generated from the other. `ASSETCATALOG_COMPILER_APPICON_NAME` must name `AppIcon`: an Icon Composer `AppStudio.icon` used to be the one built, which left the asset catalog's PNGs unused, so replacing them changed nothing. macOS 27 draws the flat icon as is, with no grey frame (checked through `NSWorkspace.icon(forFile:)`). After changing the icon, a dev build keeps showing the old one even through `flutter clean` and a Dock restart: macOS caches it per bundle path and a rebuild does not invalidate that. `touch` the built `.app`, then `lsregister -f` it, and relaunch. + - **The Windows `.ico` runs nearly edge to edge, unlike the macOS one.** The design set's own `app_icon.ico` is drawn on Apple's grid: an 800 px plate in a 1024 px canvas with a drop shadow, so on the taskbar it looked a fifth smaller than every other app. It also had no 30, 36, 60, 72 or 80 px frames, so at 125% and 150% scale Windows shrank a larger frame to fit. Build it from the set's `source/windows.svg` instead: drop `filter="url(#wsx)"` (the outer shadow) and crop the viewBox to the plate (`112 112 800 800`). Then render each frame with `rsvg-convert` at the frame size minus a margin of 1/32 of the frame (1 px through 40, 8 px at 256), and centre it on a transparent canvas. Use 16, 20, 24, 30, 32, 36, 40, 48, 60, 64, 72, 80, 96, 128 and 256 px, stored as PNG entries. `rsvg-convert` reproduces the set's 256 px frame almost exactly. + - **The runner sets the window icons per DPI** (`Win32Window::UpdateIcons`). `LoadIcon` returns only the 32 px frame at the system DPI, so the title bar and Alt+Tab icons were rescaled from it. The runner now sends `WM_SETICON` with the frame for 16 and 32 px at the window's DPI, and again on `WM_DPICHANGED`. The Start menu shortcut and the pinned taskbar icon come from the exe's resource, which the shell reads at the size it needs. - **Layout constants** (`app_theme.dart`): `kPaneHeaderHeight` (36), `kDividerWidth` (1), `paneBorderSide()`, `kSplitHandleWidth` (6). - **Pane chrome:** headers use `scheme.muted`; content uses `scheme.background`. Use `paneBorderSide()` for all 1px dividers. - **Segmented controls:** `IconSegmentedControl` / `TextSegmentedControl` share `widgets/segmented_control_theme.dart`, which resolves color and geometry from the theme's **tab** tokens — the strip/segment treatment `ShadTabs` uses — so both follow the style preset like a built-in. Hover moves the *foreground*, not the fill, so no blend has to be invented. `onMutedSurface: true` on muted pane headers swaps track and selection. @@ -1937,6 +1939,14 @@ after the other. - Its second paragraph ("When the app has started, open this project in your AI editor…") is gone: that is the whole job of the notice that now follows it, and saying it during a two-minute compile is advice the user cannot act on. + What it says instead is something the user *can* do while waiting: write + down what they want to build, and a **Prompt Generator** button left of + Dismiss opens `kPromptGeneratorUrl` (`serverpod.dev/start-prompt`, + `util/prompt_generator.dart`) in the browser. It leaves the notice up — the + wait is not over. The two buttons share a `Row`: three children under + `spaceBetween` would strand the first mid-row. **Help → Open Prompt + Generator** opens the same page, on both platforms; on macOS it is added to + the stock Help menu by title, as View is. - **The started notice names one editor and offers one button** — `featuredEditor`, the first of `ExternalEditorsView.editors`. A row of equally weighted buttons is a decision; this is a next step. The toolbar carries the diff --git a/lib/platform/macos_app_menu.dart b/lib/platform/macos_app_menu.dart index 8720545..99c50c1 100644 --- a/lib/platform/macos_app_menu.dart +++ b/lib/platform/macos_app_menu.dart @@ -12,6 +12,8 @@ import '../session/project_session.dart'; import '../theme/theme_controller.dart'; import '../ui/server_log/log_view_controller.dart'; import '../ui/server_log/server_log_view.dart'; +import '../util/open_url.dart'; +import '../util/prompt_generator.dart'; /// Adds custom menus to the native macOS menu bar while preserving the /// standard items from MainMenu.xib. @@ -32,6 +34,7 @@ class MacAppMenu { required this.onCreateAndApplyMigrations, required this.onCreateRepairMigration, required this.logView, + this.openLink = openUrl, }) { session.addListener(_sync); themeController.addListener(_sync); @@ -82,6 +85,9 @@ class MacAppMenu { static const _logsLevelMenuId = 'logs_level'; static const _logsAppPrefix = 'logs_source_app_'; static const _logsLevelPrefix = 'logs_level_'; + static const _helpMenuId = 'Help'; + static const _promptGeneratorId = 'help_prompt_generator'; + static const _promptGeneratorIcon = 'sparkles'; final ProjectSession session; final ServerpodProcessController process; @@ -125,6 +131,10 @@ class MacAppMenu { /// sets, and what its checkmarks follow. final LogViewController logView; + /// Opens a web page in the user's browser. Injectable so a test can see what + /// Help → Open Prompt Generator asked for without a browser opening. + final Future Function(Uri url) openLink; + /// The Flutter apps the Logs menu lists, by item id, in the runner's order. /// Rebuilt only when the runner's app list changes: the log notifies on /// every line, and removing and re-adding items that often would be absurd. @@ -170,6 +180,7 @@ class MacAppMenu { await _installViewMenu(); await _installServerMenu(); await _installLogsMenu(); + await _installHelpMenu(); await _installAppMenuItems(); _installed = true; @@ -278,6 +289,22 @@ class MacAppMenu { ); } + /// Help → Open Prompt Generator, at the top of the stock Help menu. + /// + /// The menu comes from MainMenu.xib and is addressed by its title, as View + /// is. macOS puts its own search field above the items; that is not an item + /// and does not move the index. + Future _installHelpMenu() async { + final added = await MacMenuBar.addMenuItem( + menuId: _helpMenuId, + itemId: _promptGeneratorId, + title: 'Open Prompt Generator', + index: 0, + systemImage: _promptGeneratorIcon, + ); + if (!added) debugPrint('MacAppMenu: could not reach the Help menu'); + } + Future _installFileMenu() async { await MacMenuBar.addSubmenu( parentMenuId: 'main', @@ -619,6 +646,8 @@ class MacAppMenu { onCheckForUpdates(); case _uninstallId: onUninstall(); + case _promptGeneratorId: + unawaited(openLink(kPromptGeneratorUrl)); case _autoUpdatesId: // Sparkle owns the value; toggle it and let the sync reflect whatever // it actually became. diff --git a/lib/platform/windows_app_menu.dart b/lib/platform/windows_app_menu.dart index cb2025e..693818e 100644 --- a/lib/platform/windows_app_menu.dart +++ b/lib/platform/windows_app_menu.dart @@ -12,6 +12,8 @@ import '../session/project_session.dart'; import '../theme/theme_controller.dart'; import '../ui/server_log/log_view_controller.dart'; import '../ui/server_log/server_log_view.dart'; +import '../util/open_url.dart'; +import '../util/prompt_generator.dart'; /// The Windows counterpart of [MacAppMenu]: the same commands with the same /// rules for when each is live, as a menu strip across the top of the window @@ -459,6 +461,11 @@ class _WindowsAppMenuBarState extends State { final canCheck = widget.canCheckForUpdates(); final reason = widget.updatesUnavailableReason(); return [ + _item( + 'Open Prompt Generator', + onPressed: () => unawaited(openUrl(kPromptGeneratorUrl)), + ), + _divider, _item( reason == null ? 'Check for Updates...' : 'Check for Updates ($reason)', enabled: canCheck, diff --git a/lib/session/external_editors.dart b/lib/session/external_editors.dart index e7e3979..5f6e569 100644 --- a/lib/session/external_editors.dart +++ b/lib/session/external_editors.dart @@ -74,16 +74,17 @@ class _EditorCli { /// that takes a project directory. A CLI does not qualify — there is no window /// to open a folder in, and "open in …" has to mean something visible. /// -/// **Antigravity is the one absence.** `/Applications/Antigravity.app` is not -/// the IDE: it is a thin Electron shell around a Go language server, with no -/// `open-file` handler and no `CFBundleDocumentTypes`, so a folder handed to it -/// is dropped and `open` still exits 0. The editor is a separate bundle, -/// `Antigravity IDE.app`, and no route into it has been confirmed. It is left -/// out only because no build of it has been seen to open the folder it was -/// given. +/// **Antigravity is `Antigravity IDE.app`, not `Antigravity.app`.** The latter +/// is a thin Electron shell around a Go language server, with no `open-file` +/// handler and no `CFBundleDocumentTypes`, so a folder handed to it is dropped +/// and `open` still exits 0. The IDE is a VS Code fork that declares +/// `public.folder`, so it takes the folder as a document like VS Code does. +/// Verified against Antigravity IDE 2.5.5: `open -a` opened the folder, and a +/// second call reused the running copy and opened the next folder beside it. const _editorApps = { IdeIntegration.cursor: _EditorApp('Cursor', cli: _cursorCli), IdeIntegration.vscode: _EditorApp('Visual Studio Code'), + IdeIntegration.antigravity: _EditorApp('Antigravity IDE'), IdeIntegration.claude: _EditorApp('Claude', deepLink: _claudeDeepLink), IdeIntegration.codex: _EditorApp('Codex', deepLink: _codexDeepLink), IdeIntegration.opencode: _EditorApp('OpenCode', deepLink: _openCodeDeepLink), @@ -185,6 +186,9 @@ final class _WindowsLink extends _WindowsEditor { final Uri Function(String projectPath) link; } +/// Antigravity is macOS-only for now: where its Windows installer puts the IDE +/// has not been seen, and the `antigravity` scheme belongs to the agent shell, +/// not the editor. const _windowsEditors = { IdeIntegration.cursor: _WindowsCli(userDir: 'cursor', exe: 'Cursor.exe'), IdeIntegration.vscode: _WindowsCli( diff --git a/lib/ui/project_startup_dialog.dart b/lib/ui/project_startup_dialog.dart index d2acee3..e673cf0 100644 --- a/lib/ui/project_startup_dialog.dart +++ b/lib/ui/project_startup_dialog.dart @@ -1,9 +1,13 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:shad/shad.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../process/project_ready_view.dart'; import '../theme/app_theme.dart'; +import '../util/open_url.dart'; +import '../util/prompt_generator.dart'; import '../widgets/app_dialog.dart'; import '../widgets/dialog_body.dart'; @@ -45,10 +49,18 @@ Future maybeShowProjectStartupNotice( /// caller's job, which keeps this widget free of `dart:io` and easy to show in /// Widgetbook. class ProjectStartupDialog extends StatefulWidget { - const ProjectStartupDialog({super.key, required this.process}); + const ProjectStartupDialog({ + super.key, + required this.process, + this.openLink = openUrl, + }); final ProjectReadyView process; + /// Opens the Prompt Generator in the user's browser. Injectable so a test + /// can press the button without a browser opening. + final Future Function(Uri url) openLink; + @override State createState() => _ProjectStartupDialogState(); } @@ -85,28 +97,57 @@ class _ProjectStartupDialogState extends State { Widget build(BuildContext context) { // The alert variant, not the primary one: its theme carries no // `closeIconData`, so there is no X in the corner — which is right for a - // notice you acknowledge rather than dismiss. Nothing here is styled by - // hand; the copy goes in `description` so it picks up shad's body role - // (`style.body` over `textTheme.muted`) instead of a label style. + // notice you acknowledge rather than dismiss. The copy goes in + // `description` so it picks up shad's body role (`style.body` over + // `textTheme.muted`) instead of a label style. return ShadDialog.alert( title: const Text('Starting your project'), - description: const Text( - 'App Studio is compiling your server and app, then starting them ' - 'up. The first run takes a minute or two.', + description: const Column( + crossAxisAlignment: CrossAxisAlignment.start, + spacing: 8, + children: [ + Text( + 'App Studio is building your server and app and starting them ' + 'up. The first run takes a minute or two.', + ), + Text( + 'While you wait, write down what you want to build. The Prompt ' + 'Generator turns it into a prompt for your AI editor.', + ), + ], ), // The row defaults to `min`/`end`, which would park the checkbox next to // the button; `max` is what lets `spaceBetween` push them apart. actionsMainAxisSize: MainAxisSize.max, actionsMainAxisAlignment: MainAxisAlignment.spaceBetween, actions: [ - ShadCheckbox( - value: _dontShowAgain, - onChanged: (v) => setState(() => _dontShowAgain = v), - label: Text("Don't show this again", style: kWeightMedium), + // Flexible, as in the started notice: with two buttons beside it the + // row can run out of room, and the checkbox is the part that can wrap. + Flexible( + child: ShadCheckbox( + value: _dontShowAgain, + onChanged: (v) => setState(() => _dontShowAgain = v), + label: Text("Don't show this again", style: kWeightMedium), + ), ), - ShadButton( - onPressed: () => Navigator.of(context).pop(_dontShowAgain), - child: const Text("Let's Go"), + // The two buttons travel together: three children under + // `spaceBetween` would strand the first one mid-row. + Row( + mainAxisSize: MainAxisSize.min, + spacing: 8, + children: [ + // Opens the browser and leaves the notice up: the wait it describes + // is not over, and it still closes itself when the project starts. + ShadButton.outline( + onPressed: () => unawaited(widget.openLink(kPromptGeneratorUrl)), + trailing: const Icon(LucideIcons.arrowUpRight, size: 16), + child: const Text('Prompt Generator'), + ), + ShadButton( + onPressed: () => Navigator.of(context).pop(_dontShowAgain), + child: const Text('Dismiss'), + ), + ], ), ], child: const DialogBody(), diff --git a/lib/util/prompt_generator.dart b/lib/util/prompt_generator.dart new file mode 100644 index 0000000..03ec564 --- /dev/null +++ b/lib/util/prompt_generator.dart @@ -0,0 +1,3 @@ +/// Serverpod's prompt generator: it turns an idea for an app into a prompt for +/// an AI editor. Offered while a project starts, and from the Help menu. +final kPromptGeneratorUrl = Uri.parse('https://serverpod.dev/start-prompt'); diff --git a/test/platform/macos_app_menu_test.dart b/test/platform/macos_app_menu_test.dart index dd561a2..1fc01cf 100644 --- a/test/platform/macos_app_menu_test.dart +++ b/test/platform/macos_app_menu_test.dart @@ -32,12 +32,14 @@ void main() { late MacAppMenu menu; var migrations = 0; var newProjects = 0; + late List opened; setUp(() async { SharedPreferences.setMockInitialValues({}); calls = []; migrations = 0; newProjects = 0; + opened = []; // Tests run as Android, where the plugin picks its no-op implementation. MacMenuBarPlatform.instance = MethodChannelMacMenuBar(); messenger.setMockMethodCallHandler(channel, (call) async { @@ -72,6 +74,7 @@ void main() { onCreateAndApplyMigrations: () => migrations++, onCreateRepairMigration: () {}, logView: logView, + openLink: (url) async => opened.add(url), ); await menu.install(); }); @@ -101,6 +104,15 @@ void main() { orElse: () => fail('$itemId was never added'), ); + test('Help opens the prompt generator', () async { + final item = added('help_prompt_generator'); + expect(item['menuId'], 'Help'); + expect(item['title'], 'Open Prompt Generator'); + + await click('help_prompt_generator'); + expect(opened, [Uri.parse('https://serverpod.dev/start-prompt')]); + }); + test('Server and Logs sit between View and Window', () { expect(added('server')['title'], 'Server'); expect(added('server')['index'], 4); diff --git a/test/project_startup_dialog_test.dart b/test/project_startup_dialog_test.dart index 3eb41b5..d525027 100644 --- a/test/project_startup_dialog_test.dart +++ b/test/project_startup_dialog_test.dart @@ -54,11 +54,12 @@ void main() { expect(find.byType(ProjectStartupDialog), findsOneWidget); expect(find.textContaining('minute or two'), findsOneWidget); + expect(find.text('Prompt Generator'), findsOneWidget); }); testWidgets('dismissing alone does not silence it', (tester) async { await pumpAndOpen(tester); - await tester.tap(find.text("Let's Go")); + await tester.tap(find.text('Dismiss')); await tester.pumpAndSettle(); expect(find.byType(ProjectStartupDialog), findsNothing); @@ -70,7 +71,7 @@ void main() { await pumpAndOpen(tester); await tester.tap(find.byType(ShadCheckbox)); await tester.pumpAndSettle(); - await tester.tap(find.text("Let's Go")); + await tester.tap(find.text('Dismiss')); await tester.pumpAndSettle(); final prefs = await SharedPreferences.getInstance(); @@ -102,6 +103,26 @@ void main() { expect(prefs.getBool('project.startup_notice_dismissed'), isTrue); }); + testWidgets('the Prompt Generator opens in the browser and leaves the notice ' + 'up', (tester) async { + final opened = []; + await tester.pumpWidget( + ShadApp( + theme: buildLightTheme(), + home: ProjectStartupDialog( + process: _FakeProcess(), + openLink: (url) async => opened.add(url), + ), + ), + ); + await tester.tap(find.text('Prompt Generator')); + await tester.pumpAndSettle(); + + expect(opened, [Uri.parse('https://serverpod.dev/start-prompt')]); + // The wait is not over, so the notice stays until the project is up. + expect(find.byType(ProjectStartupDialog), findsOneWidget); + }); + testWidgets('stays silent once dismissed', (tester) async { SharedPreferences.setMockInitialValues({ 'project.startup_notice_dismissed': true, diff --git a/test/session/external_editors_test.dart b/test/session/external_editors_test.dart index f667cfb..a85449c 100644 --- a/test/session/external_editors_test.dart +++ b/test/session/external_editors_test.dart @@ -85,16 +85,38 @@ void main() { expect(editors.editors.single.label, 'Cursor'); }); - test('offers nothing for Antigravity, installed or not', () async { + test('opens Antigravity through the IDE, never the agent shell', () async { // `/Applications/Antigravity.app` is a shell around a language server, not - // the IDE — it drops a folder handed to it and `open` still exits 0. + // the IDE — it drops a folder handed to it and `open` still exits 0. The + // IDE is its own bundle and takes the folder as a document. final session = _FakeSession()..setPath('/p'); + final launches = >[]; final editors = controller( session: session, editorsByProject: { '/p': {IdeIntegration.antigravity}, }, installedApps: {'Antigravity', 'Antigravity IDE'}, + launches: launches, + ); + addTearDown(editors.dispose); + await pumpEventQueue(); + + expect(editors.editors.single.label, 'Antigravity'); + await editors.open(editors.editors.single); + expect(launches, [ + ['/usr/bin/open', '-a', '/Applications/Antigravity IDE.app', '/p'], + ]); + }); + + test('offers nothing for Antigravity with only the agent shell', () async { + final session = _FakeSession()..setPath('/p'); + final editors = controller( + session: session, + editorsByProject: { + '/p': {IdeIntegration.antigravity}, + }, + installedApps: {'Antigravity'}, ); addTearDown(editors.dispose); await pumpEventQueue(); diff --git a/windows/runner/resources/app_icon.ico b/windows/runner/resources/app_icon.ico index 19dd2ca..e839298 100644 Binary files a/windows/runner/resources/app_icon.ico and b/windows/runner/resources/app_icon.ico differ diff --git a/windows/runner/win32_window.cpp b/windows/runner/win32_window.cpp index 60608d0..462d3e6 100644 --- a/windows/runner/win32_window.cpp +++ b/windows/runner/win32_window.cpp @@ -53,6 +53,15 @@ void EnableFullDpiSupportIfAvailable(HWND hwnd) { FreeLibrary(user32_module); } +// Loads the app icon's frame for |size| px. LoadIcon only ever returns the +// SM_CXICON frame at the system DPI, which Windows then rescales for the title +// bar and Alt+Tab; LoadImage picks the frame drawn for that size. +HICON LoadAppIcon(int size) { + return static_cast(LoadImage(GetModuleHandle(nullptr), + MAKEINTRESOURCE(IDI_APP_ICON), IMAGE_ICON, + size, size, LR_DEFAULTCOLOR)); +} + } // namespace // Manages the Win32Window's window class registration. @@ -145,6 +154,7 @@ bool Win32Window::Create(const std::wstring& title, } UpdateTheme(window); + UpdateIcons(dpi); return OnCreate(); } @@ -194,6 +204,7 @@ Win32Window::MessageHandler(HWND hwnd, SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + UpdateIcons(HIWORD(wparam)); return 0; } @@ -228,6 +239,14 @@ void Win32Window::Destroy() { DestroyWindow(window_handle_); window_handle_ = nullptr; } + if (small_icon_) { + DestroyIcon(small_icon_); + small_icon_ = nullptr; + } + if (big_icon_) { + DestroyIcon(big_icon_); + big_icon_ = nullptr; + } if (g_active_window_count == 0) { WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); } @@ -272,6 +291,27 @@ void Win32Window::OnDestroy() { // No-op; provided for subclasses. } +void Win32Window::UpdateIcons(UINT dpi) { + if (!window_handle_) { + return; + } + // SM_CXSMICON and SM_CXICON at |dpi|: 16 and 32 px at 100%. + HICON small_icon = LoadAppIcon(MulDiv(16, static_cast(dpi), 96)); + HICON big_icon = LoadAppIcon(MulDiv(32, static_cast(dpi), 96)); + SendMessage(window_handle_, WM_SETICON, ICON_SMALL, + reinterpret_cast(small_icon)); + SendMessage(window_handle_, WM_SETICON, ICON_BIG, + reinterpret_cast(big_icon)); + if (small_icon_) { + DestroyIcon(small_icon_); + } + if (big_icon_) { + DestroyIcon(big_icon_); + } + small_icon_ = small_icon; + big_icon_ = big_icon; +} + void Win32Window::UpdateTheme(HWND const window) { DWORD light_mode; DWORD light_mode_size = sizeof(light_mode); diff --git a/windows/runner/win32_window.h b/windows/runner/win32_window.h index e901dde..caa8c49 100644 --- a/windows/runner/win32_window.h +++ b/windows/runner/win32_window.h @@ -90,8 +90,15 @@ class Win32Window { // Update the window frame's theme to match the system theme. static void UpdateTheme(HWND const window); + // Sets the title bar and Alt+Tab icons to the app icon's frames for |dpi|. + void UpdateIcons(UINT dpi); + bool quit_on_close_ = false; + // The icons last set by UpdateIcons, owned by this window. + HICON small_icon_ = nullptr; + HICON big_icon_ = nullptr; + // window handle for top level window. HWND window_handle_ = nullptr;