Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop backgrounding support #2029

Merged
merged 20 commits into from
Aug 16, 2024
Merged

Desktop backgrounding support #2029

merged 20 commits into from
Aug 16, 2024

Conversation

gnunicorn
Copy link
Contributor

@gnunicorn gnunicorn commented Aug 4, 2024

built on top of #2028 , this adds:

  1. support to keep the desktop app running upon "closing" the window
  2. a tray icon to resurrect the window from the backgrounded process

Due to the nature of he different platforms, this acts slightly different on each one of them:

On MacOS, we currently only support the toggle:

macos-toggle.mp4

On Windows, we have a colored icon and toggle as well as menu support:

windows-toggle.mp4

On Linux, toggle doesn't exist on the icon itself, but only via the menu:

linux-toggle.mp4

@gnunicorn gnunicorn added the t-desktop Desktop Target related issues and tasks label Aug 4, 2024
Comment on lines +11 to +16
HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", L"Acter");
if (hwnd != NULL) {
::ShowWindow(hwnd, SW_NORMAL);
::SetForegroundWindow(hwnd);
return EXIT_FAILURE;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you made app singleton?
Good job.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, for the tray support it only makes sense if there isn't multiple instances.

Copy link
Contributor

@bitfriend bitfriend Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is reasonable to rename process to Acter too.
image
In this PR...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bitfriend not the focus of this PR but if you tell me how I can add it...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this project is built, we can find acter.exe in ./app/build/windows/x64/runner/Debug.
image
This is some of debug console log.

"ar": 18 untranslated message(s).
"da": 757 untranslated message(s).
"de": 103 untranslated message(s).
"es": 63 untranslated message(s).
"fr": 63 untranslated message(s).
"pl": 206 untranslated message(s).
"pt": 1051 untranslated message(s).
To see a detailed report, use the untranslated-messages-file
option in the l10n.yaml file:
untranslated-messages-file: desiredFileName.txt
<other option>: <other selection>

This will generate a JSON format file containing all messages that
need to be translated.
Launching lib\main.dart on Windows in debug mode...
√ Built build\windows\x64\runner\Debug\acter.exe

But we see app entry in Task Manager.
image
I think flutter wraps acter.exe by keyword of app.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please edit something in rc file.
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by #2070

@gnunicorn gnunicorn added the merge post release only Merge this only after the new release has been cut label Aug 13, 2024
@bitfriend
Copy link
Contributor

In windows, I couldn't open context menu on system tray.
And system tray shows tooltip, but doesn't show acter icon.

Copy link
Contributor

@bitfriend bitfriend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great solution.
Just confirmed it works fine on windows.

app/lib/features/auth/pages/forgot_password.dart Outdated Show resolved Hide resolved
Comment on lines +11 to +16
HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", L"Acter");
if (hwnd != NULL) {
::ShowWindow(hwnd, SW_NORMAL);
::SetForegroundWindow(hwnd);
return EXIT_FAILURE;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this project is built, we can find acter.exe in ./app/build/windows/x64/runner/Debug.
image
This is some of debug console log.

"ar": 18 untranslated message(s).
"da": 757 untranslated message(s).
"de": 103 untranslated message(s).
"es": 63 untranslated message(s).
"fr": 63 untranslated message(s).
"pl": 206 untranslated message(s).
"pt": 1051 untranslated message(s).
To see a detailed report, use the untranslated-messages-file
option in the l10n.yaml file:
untranslated-messages-file: desiredFileName.txt
<other option>: <other selection>

This will generate a JSON format file containing all messages that
need to be translated.
Launching lib\main.dart on Windows in debug mode...
√ Built build\windows\x64\runner\Debug\acter.exe

But we see app entry in Task Manager.
image
I think flutter wraps acter.exe by keyword of app.

Comment on lines +11 to +16
HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", L"Acter");
if (hwnd != NULL) {
::ShowWindow(hwnd, SW_NORMAL);
::SetForegroundWindow(hwnd);
return EXIT_FAILURE;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please edit something in rc file.
image

@gnunicorn gnunicorn merged commit b4f9310 into main Aug 16, 2024
17 checks passed
@gnunicorn gnunicorn deleted the ben-desktop-tray branch August 16, 2024 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge post release only Merge this only after the new release has been cut t-desktop Desktop Target related issues and tasks
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants