<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><ul class=""><p class="code-line">Possible ways to implement this:</p><ul class=""><li class="code-line">taking screenshot:<ul class=""><li class="code-line">open issue against Wayland, may be resolved someday:<span class=""> </span><a href="https://gitlab.freedesktop.org/wayland/wayland/-/issues/32" title="https://gitlab.freedesktop.org/wayland/wayland/-/issues/32" class="external-link" rel="nofollow" style="text-decoration: none;">https://gitlab.freedesktop.org/wayland/wayland/-/issues/32</a></li><li class="code-line"><a href="https://flatpak.github.io/xdg-desktop-portal/portal-docs.html#gdbus-org.freedesktop.portal.Screenshot" class="external-link" rel="nofollow" style="text-decoration: none;">https://flatpak.github.io/xdg-desktop-portal/portal-docs.html#gdbus-org.freedesktop.portal.Screenshot</a></li><li class="code-line">via DBUS interface(display server dependent), e.g.<span class=""> </span><a href="https://github.com/flameshot-org/flameshot/blob/master/src/utils/screengrabber.cpp#L43" class="external-link" rel="nofollow" style="text-decoration: none;">https://github.com/flameshot-org/flameshot/blob/master/src/utils/screengrabber.cpp#L43</a></li><li class=""></li></ul></li></ul></ul></div></blockquote><div class=""><br class=""></div>I’ve already did an implementation of AWT Robot via DBUS interface. It works well for single snapshot but if you need to implement something like color picker (you need to obtain Color many times per second) this approach severely slows things down.</div><div class=""><br class=""></div><div class="">Best Regards,</div><div class="">Alexey </div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 8 Jul 2021, at 00:52, Alexander Zvegintsev <<a href="mailto:alexander.zvegintsev@oracle.com" class="">alexander.zvegintsev@oracle.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
  
  <div class=""><p class="">(adding awt-dev)<br class="">
    </p><p class="">Let me add a few comments.<br class="">
      </p><blockquote type="cite" class="">already Wayland is the default on RHEL 8,
        OL 8, Ubuntu 21.04 and I am sure others too. </blockquote>
      It is the default, <span class="VIiyi" lang="en"><span class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="ru" data-phrase-index="0"><span class="">but
            not in every case</span></span></span>. Wayland may be
      turned off deliberately if you are using a Nvidia graphics card,
      so you need to take <a href="https://askubuntu.com/questions/1334825/what-are-the-steps-to-run-wayland-on-21-04-with-optimus-nvidia" class="external-link" rel="nofollow">extra steps to get it
        working</a>.<div class=""><br class="webkit-block-placeholder"></div><p class="">I faced this issue on Ubuntu 21.04. <br class="">
    </p><p class="code-line">However things <a href="https://www.phoronix.com/scan.php?page=news_item&px=NVIDIA-470-Wayland-Friendly" class="external-link" rel="nofollow">getting better </a>with
      Nvidia 470 drivers, its beta <a href="https://www.nvidia.com/download/driverResults.aspx/176525/en-us" class="external-link" rel="nofollow" moz-do-not-send="true">released</a>
      on 2021.6.22. So probably it won't be a problem in the near
      future.<br class="">
      </p><blockquote type="cite" class="">Consequently we expect quite shortly to
        propose an OpenJDK project that will consider the goals of
        <br class="">
        - a short to medium term solution for JDK running on Wayland in
        X11 compatibility mode
        <br class="">
        - a medium to long term solution for JDK running as a native
        Wayland client.
      </blockquote><div class=""><br class="webkit-block-placeholder"></div><p class="code-line">Both goals having a common task: we will need
      to implement java.awt.Robot functionality for Wayland(at least).</p><p class="code-line">So it makes sense to make XToolkit's
      java.awt.Robot work under Wayland first, and then reuse this code
      for native Wayland client.</p><p class="code-line">I see two major tasks here: taking screenshots
      and mouse/keyboard control. As far as I know there is no standard
      way to implement they across all display servers yet.</p><p class="code-line">Possible ways to implement this:</p>
    <ul class="">
      <li class="code-line">taking screenshot:
        <ul class="">
          <li class="code-line">open issue against Wayland, may be
            resolved someday:<span class=""> </span><a href="https://gitlab.freedesktop.org/wayland/wayland/-/issues/32" style="text-decoration: none;" title="https://gitlab.freedesktop.org/wayland/wayland/-/issues/32" class="external-link" rel="nofollow">https://gitlab.freedesktop.org/wayland/wayland/-/issues/32</a></li>
          <li class="code-line"><a href="https://flatpak.github.io/xdg-desktop-portal/portal-docs.html#gdbus-org.freedesktop.portal.Screenshot" style="text-decoration: none;" class="external-link" rel="nofollow">https://flatpak.github.io/xdg-desktop-portal/portal-docs.html#gdbus-org.freedesktop.portal.Screenshot</a></li>
          <li class="code-line">via DBUS interface(display server
            dependent), e.g.<span class=""> </span><a href="https://github.com/flameshot-org/flameshot/blob/master/src/utils/screengrabber.cpp#L43" style="text-decoration: none;" class="external-link" rel="nofollow">https://github.com/flameshot-org/flameshot/blob/master/src/utils/screengrabber.cpp#L43</a></li>
        </ul>
      </li>
      <li class="code-line">generating key/mouse events:
        <ul class="">
          <li class="code-line"><a style="text-decoration: none;" href="https://flatpak.github.io/xdg-desktop-portal/portal-docs.html#gdbus-org.freedesktop.impl.portal.RemoteDesktop" class="external-link" rel="nofollow">https://flatpak.github.io/xdg-desktop-portal/portal-docs.html#gdbus-org.freedesktop.impl.portal.RemoteDesktop</a></li>
          <li class="code-line">generating new virtual input device,
            uinput, superuser privileges required<span class="">, looks too flaky
            </span><a style="text-decoration: none;" href="https://unix.stackexchange.com/questions/422698/how-to-set-absolute-mouse-cursor-position-in-wayland-without-using-mouse" title="https://unix.stackexchange.com/questions/422698/how-to-set-absolute-mouse-cursor-position-in-wayland-without-using-mouse" class="external-link" rel="nofollow">https://unix.stackexchange.com/questions/422698/how-to-set-absolute-mouse-cursor-position-in-wayland-without-using-mouse</a></li>
        </ul>
      </li>
    </ul><p class="code-line">This still need more investigation, but<span class=""> </span><a style="text-decoration: none;" title="https://github.com/flatpak/xdg-desktop-portal" href="https://github.com/flatpak/xdg-desktop-portal" class="external-link" rel="nofollow">xdg-desktop-portal</a><span class=""> </span>looks
      more preferable way for now.</p><p class=""><br class="">
    </p><p class="">Please see below some caveats for OpenJDK native Wayland client:</p><p class="">You <a moz-do-not-send="true" href="https://gitlab.freedesktop.org/wayland/wayland/-/issues/183" class="">can't
        control a position for a top-level window.</a> <br class="">
    </p><p class="">This will also affect a splashscreen windows. It is still
      possible to control position under XWayland though.</p><p class="">Looks like we will just accept it.<br class="">
    </p><p class=""><br class="">
    </p><p class="">Top-level window decorations. <br class="">
    </p><p class="">Initially Wayland had only client-side decorations(you have to
      draw it by yourself).</p><p class="">As of now server-side decorations are available by <a moz-do-not-send="true" href="https://gitlab.gnome.org/GNOME/mutter/-/issues/217" class="">XDG-Decoration
        protocol</a>.</p><p class=""> However server-side window decorations are not mandatory and not
      all compositors are supporting it, e.g. Mutter(Gnome Shell's
      compositor).</p><p class="">Gnome Shell is the default on Ubuntu, so we will need to provide
      window decorations somehow. One of possible solutions is to use
      Gtk to create a window for us.<br class="">
    </p><p class=""><br class="">
    </p>
    <pre class="moz-signature" cols="72">--
Thanks,
Alexander.</pre>
    On 7/7/21 6:24 AM, Philip Race wrote:
    <br class="">
    <blockquote type="cite" class="">
      <br class="">
      For a number of years the Linux community has been working on a
      complete replacement for the 1980's era X11 desktop display server
      protocol
      <br class="">
      with new protocols and libraries that support client-side
      rendering and a compositing desktop windowing system.
      <br class="">
      This work is being done under the auspices of the Wayland project
      [1] and there is a reference
      <br class="">
      implementation of a Wayland compositor called "Weston".
      <br class="">
      <br class="">
      A new client written for  the Wayland desktop has no dependency at
      all on X11, but Wayland also provides a compatibility
      <br class="">
      mode where the <a href="http://X.org" class="">X.org</a> X11 server runs along side Wayland, so that
      thousands of X11 applications can continue to run.
      <br class="">
      <br class="">
      Presently all distros that ship the Wayland server, also still
      ship the pure X11 server and the user can select
      <br class="">
      which one to use on the login screen. However there will come a
      time when Wayland is the only choice and
      <br class="">
      already Wayland is the default on RHEL 8, OL 8, Ubuntu 21.04 and I
      am sure others too.
      <br class="">
      <br class="">
      At that time Java for Linux will "mostly" run via the X11
      compatibility layer, but would not pass the JCK,
      <br class="">
      since some important APIs,  notably those of the java.awt.Robot
      class [2] will fail with Wayland.
      <br class="">
      We need to solve this so that pure Java and applications which mix
      Java and X11 APis can work.
      <br class="">
      <br class="">
      But even then this would mean Java on Linux is not a first class
      desktop citizen, which is not desirable for
      <br class="">
      the long term, given the importance of Linux to many Java
      developers as well as to active
      <br class="">
      individual and corporate contributors to the JDK project.
      <br class="">
      <br class="">
      Indeed there have already been informal discussions for some time
      with various parties that have expressed
      <br class="">
      interest in helping towards the outcome of supporting Wayland
      <br class="">
      <br class="">
      Consequently we expect quite shortly to propose an OpenJDK project
      that will consider the goals of
      <br class="">
      - a short to medium term solution for JDK running on Wayland in
      X11 compatibility mode
      <br class="">
      - a medium to long term solution for JDK running as a native
      Wayland client.
      <br class="">
      <br class="">
      There are some unknowns and questions, such as what are the
      options for supporting Robot ?
      <br class="">
      What other support is missing ? What platform APIs should the
      implementation  use ?
      <br class="">
      How does a native Wayland solution interoperate with OpenJFX ?
      <br class="">
      <br class="">
      <br class="">
      Comments, expressions of interest etc are welcome.
      <br class="">
      <br class="">
      <br class="">
      -Phil Race, for the Java client groups.
      <br class="">
      <br class="">
      <br class="">
      [1] : <a class="moz-txt-link-freetext" href="https://wayland.freedesktop.org/">https://wayland.freedesktop.org/</a>
      <br class="">
      [2] :
<a class="moz-txt-link-freetext" href="https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/java/awt/Robot.html">https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/java/awt/Robot.html</a>
    </blockquote>
  </div>

</div></blockquote></div><br class=""></div></body></html>