<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    I like the idea of looking at this holistically, even if we do end
    up adding such features one at a time.<br>
    <br>
    As for how to expose such an API, I don't much like the idea of
    exposing the underlying platform explicitly unless there is no
    viable alternative. A better approach is one where a feature is
    optional based on whether the platform you are running on supports
    that feature. Especially given, as you pointed out, that features
    that are only available in one platform today might make their way
    into other platforms tomorrow. As for how to let an application know
    whether they can use a particular API, we already have
    ConditionalFeature, so adding to that would be a reasonable thing to
    consider.<br>
    <br>
    -- Kevin<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 9/19/2022 9:06 AM, Andy Goryachev
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:BL0PR10MB2948280A958C35CC26BF3110E54D9@BL0PR10MB2948.namprd10.prod.outlook.com">
      
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
        {font-family:"Times New Roman \(Body CS\)";
        panose-1:2 11 6 4 2 2 2 2 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Courier New";
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}div.WordSection1
        {page:WordSection1;}</style>
      <div class="WordSection1">
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">Greetings!<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">Thank
            you for proposing a solution, Florian.  I wonder if we
            should extrapolate the problem further.  Given the fact that
            app developers always need access to platform specific APIs,
            be it integration with Mac menu, perhaps we should consider
            a way to do so in such a way that does not require various
            tricks.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">For
            example, we might invent a way to query whether we are
            running on a certain platform and get the corresponding
            APIs.  Let's say the class is PlatformAPI:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">These
            methods allow for querying whether the specific platform
            APIs are available<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">PlatformAPI.isWindows();<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">PlatformAPI.isMacOS();<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">PlatformAPI.isLinux();
            // isUnix()? isPosix() ?<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">and
            these will actually return a service object that provides
            access to the APIs, or throws some kind of exception:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">IWindowsAPI
            PlatformAPI.getWindowsAPI();<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">IMacOSAPI
            PlatformAPI.getMacOSAPI();<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">the
            service object returned by one of these methods might
            provide further information about the platform version, as
            well as access to platform-specific APIs.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">Another
            thought is perhaps we ought to think about expanding
            functionality that became available on every platform in the
            XXI century (example: going to sleep/hibernate).  Possibly
            external shutdown via Mac menu or a signal discussed by the
            OP would be considered as platform-independent.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">What
            do you think?<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">-andy<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <div style="border:none;border-top:solid #B5C4DF
          1.0pt;padding:3.0pt 0in 0in 0in">
          <p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
              </span></b><span style="font-size:12.0pt;color:black">openjfx-dev
              <a class="moz-txt-link-rfc2396E" href="mailto:openjfx-dev-retn@openjdk.org"><openjfx-dev-retn@openjdk.org></a> on behalf of Florian
              Kirmaier <a class="moz-txt-link-rfc2396E" href="mailto:florian.kirmaier@gmail.com"><florian.kirmaier@gmail.com></a><br>
              <b>Date: </b>Tuesday, 2022/09/13 at 08:11<br>
              <b>To: </b><a class="moz-txt-link-abbreviated" href="mailto:openjfx-dev@openjdk.java.net">openjfx-dev@openjdk.java.net</a>
              <a class="moz-txt-link-rfc2396E" href="mailto:openjfx-dev@openjdk.java.net"><openjfx-dev@openjdk.java.net></a><br>
              <b>Subject: </b>Provide Quit handler for system menu bar<o:p></o:p></span></p>
        </div>
        <div>
          <div>
            <p class="MsoNormal"><span style="font-size:11.0pt">Hi
                Everyone,<o:p></o:p></span></p>
          </div>
          <div>
            <p class="MsoNormal"><span style="font-size:11.0pt"><br>
                In one project, we have to handle the quit-logic for
                MacOS ourselves,<br>
                when the <quit app> menu entry is used.<br>
                As background information - this menu entry is set in
                the class com.sun.glass.ui.mac.MacApplication.<br>
                It's basically hard coded. Currently, in this project,
                the menu entry doesn't work in some cases.<br>
                <br>
                My Solution would be:<br>
                <br>
                Provide a method
                "Platform.setQuiteHandler(Supplier<Boolean>)"<br>
                This handler is called when quit <appname> from
                the menu is called.<br>
                If the handler returns true, all windows are closed.
                Otherwise, nothing happens.<br>
                <br>
                It would look like the following:<br>
                ```<br>
                /**<br>
                 * Sets the handler to be called when the application is
                about to quit.<br>
                 * Currently, this can only happen on MacOS.<br>
                 *<br>
                 * This handler is called, when the user selects<br>
                 * the "Quit <appname>" from the application menu.<br>
                 * When the provided handler returns true,<br>
                 * the application will close all windows.<br>
                 * If the handler returns false, the application will
                not quit.<br>
                 *<br>
                 * @param The new quit handler.<br>
                 */<br>
                public static void setQuitHandler(Supplier x) {<br>
                    ...<br>
                }<br>
                ```<br>
                I've created a ticket for this topic. <a href="https://bugs.openjdk.org/browse/JDK-8293700" moz-do-not-send="true" class="moz-txt-link-freetext">https://bugs.openjdk.org/browse/JDK-8293700</a><o:p></o:p></span></p>
          </div>
          <div>
            <p class="MsoNormal"><span style="font-size:11.0pt"><br>
                I've got a working version for this change. <o:p></o:p></span></p>
          </div>
          <div>
            <p class="MsoNormal"><span style="font-size:11.0pt">According
                to Kevin Rushforth this need a prior dicussion on the
                mailing list.<o:p></o:p></span></p>
          </div>
          <div>
            <p class="MsoNormal"><span style="font-size:11.0pt">Any
                opinion regarding this?<br>
                <br>
                I could provide a pullrequest, if someone is interested.<br>
                <br>
                Florian Kirmaier<o:p></o:p></span></p>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>