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

feat(rust): update macos activation policy #5410

Merged
merged 4 commits into from
Jul 21, 2023

Conversation

qxtaiba
Copy link
Contributor

@qxtaiba qxtaiba commented Jul 21, 2023

Current behavior

The macOS desktop application shows up in both the top right menu and the macOS dock.

Proposed changes

The issue that this PR fixes is described in #5365

This PR implements some platform-specific code that sets the activation policy for macOS. The activation policy is now explicitly configured to display the application only in the macOS menu bar and not in the dock.

Checks

@qxtaiba qxtaiba requested a review from a team as a code owner July 21, 2023 10:05
@qxtaiba
Copy link
Contributor Author

qxtaiba commented Jul 21, 2023

If you anticipate introducing more specific platform behaviour in the future, then we could also consider refactoring this PR to help improve code organization and make it easier to manage platform-specific functionalities.

main.rs:

#[cfg(target_os = "macos")]
mod macos;
#[cfg(not(target_os = "macos"))]
mod others;

#[cfg(target_os = "macos")]
use macos as platform;
#[cfg(not(target_os = "macos"))]
use others as platform;

lib.rs:

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    let app_state = AppState::new();

    // For now the application only consists in a system tray with several menu items
    let mut app = tauri::Builder::default()
        .plugin(configure_tauri_plugin_log())
        .setup(move |app| setup_app(app))
        .system_tray(make_system_tray(&app_state.options()))
        .on_system_tray_event(process_system_tray_event)
        .manage(app_state)
        .build(tauri::generate_context!())
        .expect("Error while building the Ockam application");

    platform::set_platform_activation_policy(&mut app);

    app.run(process_application_event);
}

macos.rs:

use tauri::AppBuilder;

pub fn set_platform_activation_policy(app: &mut AppBuilder<()>) {
    app.set_activation_policy(tauri::ActivationPolicy::Accessory);
}

others.rs:

use tauri::AppBuilder;

pub fn set_platform_activation_policy(_: &mut AppBuilder<()>) {
    // On non-macOS platforms, do nothing
}

etorreborre
etorreborre previously approved these changes Jul 21, 2023
Copy link
Member

@etorreborre etorreborre left a comment

Choose a reason for hiding this comment

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

Thanks @qxtaiba! Let's apply your refactor suggestion if we end-up adding more platform specific behaviors.

@etorreborre
Copy link
Member

@qxtaiba you need to rename your commit and prefix it with feat(rust): to make the build pass.

@qxtaiba qxtaiba force-pushed the qalnuaimy/activation-policy branch from d9ca6cb to 7437206 Compare July 21, 2023 12:38
etorreborre
etorreborre previously approved these changes Jul 21, 2023
etorreborre
etorreborre previously approved these changes Jul 21, 2023
@etorreborre etorreborre added this pull request to the merge queue Jul 21, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 21, 2023
@mrinalwadhwa mrinalwadhwa added this pull request to the merge queue Jul 21, 2023
Merged via the queue into build-trust:develop with commit 4032895 Jul 21, 2023
45 checks passed
@qxtaiba qxtaiba deleted the qalnuaimy/activation-policy branch July 22, 2023 02:27
@adrianbenavides adrianbenavides linked an issue Jul 25, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop desktop app from appearing in the macOS dock
3 participants