Skip to content

MacOS setting an ActivationPolicy prevent LSUIElement and LSBackground from functioning via editing Info.plist #261

Closed

Description

@gliheng

Hi, I'm trying to hide dock icon for my mac application. According to this,
I should set LSUIElement in Info.plist to true, and it should work, but it is not.
Setting LSUIElement and LSBackground in Info.plist are both useless for winit apps.

Further investigation, revealed that winit set ActivationPolicy to regular on start. Hence dock icon is shown. Maybe it should leave it at its default?

I tried that approach. It works fine for packaged mac apps. (dock icon is hidden when LSUIElement is true, shown otherwise). Only dock icon is not shown when it's launched as unpackaged executable. Maybe we should give user an oppotunity to bypass this setActivationPolicy call?

Activity

  1. added
    DS - appkit
    on Aug 18, 2017
  2. added
    H - help wanted
    S - api
    D - easy
    P - normal
    on May 6, 2018
  3. francesca64 commented on May 15, 2018

    @francesca64
    Member

    Is this covered by os::macos::WindowBuilderExt::with_activation_policy?

  4. Osspial commented on Apr 24, 2019

    @Osspial
    Contributor

    Closing since there hasn't been any discussion on this and it seems that with_activation_policy would indeed solve this issue. If that isn't an accurate assessment of this, please feel free to re-open this for further discussion.

  5. added a commit that references this issue on Jan 5, 2022
    d9e994e
  6. purajit commented on Sep 12, 2024

    @purajit
    Contributor

    Closing since there hasn't been any discussion on this and it seems that with_activation_policy would indeed solve this issue. If that isn't an accurate assessment of this, please feel free to re-open this for further discussion.

    I think there is still some value to this issue. A user of an application that uses winit should still be able to set LSUIElement to get their desired behavior, versus having to ask each application developer to pipe the config through. I think it makes sense that winit should honor what's in the package manifest, unless the application is explicitly setting activation_policy on top of that. I'm willing to do some work to get a patch, if this approach is acceptable.

  7. madsmtm commented on Sep 12, 2024

    @madsmtm
    Member

    I agree that we should try to honour the package manifest, though probably only if the implementation is reasonably simple (i.e. I don't really want Winit to try to read the bundle information, but if just avoiding calling setActivationPolicy is enough, then it'd be fine).

  8. purajit commented on Sep 12, 2024

    @purajit
    Contributor

    I don't really want Winit to try to read the bundle information

    Gotcha. I'll try to do some quick checks this weekend to see. Hopefully "only call setActivationPolicy if explicitly asked" works.

    And thanks for responding to my comment on a 5-year-old discussion!

  9. Hacksore commented on Sep 13, 2024

    @Hacksore

    We are also looking into hiding the process from the dock. We are using notan which uses winit under the hood so once support is available in winit we'd have to add that functionally to notan.

    image

    FWIW We also tried setting it at runtime via FFI but it didn't work because I believe you can't do it when the window is already created?

  10. purajit commented on Sep 16, 2024

    @purajit
    Contributor

    Not setting it worked! Going to see how to best implement this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    D - easyDS - appkitH - help wantedP - normalS - api

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions