Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8280982

[Wayland] [XWayland] java.awt.Robot taking screenshots

    XMLWordPrintable

    Details

      Description

      The java.awt.Robot class provides createScreenCapture() method which currently uses X11-specific APIs.

      Use xdg-desktop-portal, a cross-platform stable D-Bus API which works on GNOME, KDE and wlroots-based compositors.

      Specifically, it provides [org.freedesktop.portal.Screenshot]( https://flatpak.github.io/xdg-desktop-portal/portal-docs.html#gdbus-org.freedesktop.portal.Screenshot ) which can be used to create a screenshot.

      However, it has significant drawbacks(at least on Gnome):
       It asks a confirmation on each screenshot request, so it is unusable for automated testing.
       It does not allow to take a specified screen area, only whole screen.
       A user can deny the request. In this case as a possible solution we can throw a SecurityException for Robot#createScreenCapture (javadoc update required). Currently it is thrown only if readDisplayPixels permission is not granted(which is not suitable here).


      There is also [org.freedesktop.portal.Screenshot#PickColor]( https://flatpak.github.io/xdg-desktop-portal/#gdbus-method-org-freedesktop-portal-Screenshot.PickColor ) API which can't be used for Robot#getPixelColor needs. It does not allow to take a pixel color at specified location, but interactively asks a user to pick a color with mouse cursor.

        Attachments

          Activity

            People

            Assignee:
            azvegint Alexander Zvegintsev
            Reporter:
            azvegint Alexander Zvegintsev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: