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

Taking screenshots on x11 composite desktop produce wrong result

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7, 8, 9
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b130
    • OS:
      linux

      Description

      The Robot code that grabs the content of the screen uses the default root window. On composite desktop the root window does not contain the final composited desktop, so screenshots taken using this window will generally have black areas instead of transparent or translucent ones, as is demonstrated on the attached screenshots.

      The proposed solution is to determine if the desktop is composited or not, and then get a reference to the correct window id, which is either the root window or the compositor owned one.

      This bug is quite likely related to:

      https://bugs.openjdk.java.net/browse/JDK-7043455

      I believe that the original fix that was backed out by 7043455 because it was trying to acquire the composite window, which is wrong since the XCompositeGetOverlayWindow would always return a valid window id.

      The proposed fix uses an Atom to detect if the window manager is a composite wm:

      https://specifications.freedesktop.org/wm-spec/1.4/ar01s08.html
      1. ScreenshotTaker.java
        0.8 kB
        Mario Torre
      1. screenshot-non-xcomp.png
        694 kB
      2. screenshot-patched-non-xcomp.png
        696 kB
      3. screenshot-unpatched-xcomp.png
        2.53 MB
      4. screenshot-xcomp.png
        2.74 MB

        Activity

        Hide
        serb Sergey Bylokhov added a comment -
        Is the problem can be reproduced on jdk9? Implementation was changed to use gtk.
        Show
        serb Sergey Bylokhov added a comment - Is the problem can be reproduced on jdk9? Implementation was changed to use gtk.
        Hide
        neugens Mario Torre added a comment -
        Hi Sergey,

        Sorry, I was sidetracked in the middle of filing this bug report, this bug report is for OpenJDK 8 and 7, I didn't try on 6 yet.
        Show
        neugens Mario Torre added a comment - Hi Sergey, Sorry, I was sidetracked in the middle of filing this bug report, this bug report is for OpenJDK 8 and 7, I didn't try on 6 yet.
        Hide
        neugens Mario Torre added a comment -
        Show
        neugens Mario Torre added a comment - Proposed patch: http://cr.openjdk.java.net/~neugens/8150954/
        Hide
        neugens Mario Torre added a comment -
        Minimal test case
        Show
        neugens Mario Torre added a comment - Minimal test case
        Hide
        neugens Mario Torre added a comment -
        Show
        neugens Mario Torre added a comment - Proposed fix for JDK9: http://cr.openjdk.java.net/~neugens/8150954/webrev.02/
        Hide
        vdyakov Victor Dyakov added a comment -
        Mario, could you submit this fix on review at openjdk mailing list? Thx.
        Show
        vdyakov Victor Dyakov added a comment - Mario, could you submit this fix on review at openjdk mailing list? Thx.
        Hide
        neugens Mario Torre added a comment -
        Hi Viktor,

        I apologise for the delay, it's been quite busy lately. The patch was discussed on awt-dev mailing list already:

        http://mail.openjdk.java.net/pipermail/awt-dev/2016-March/010742.html

        I was asked to add support for a system property to choose between GTK and X11 implementation, is this still the case? I should be able to have a patch ready very quickly, it's right on top in my priority queue now.
        Show
        neugens Mario Torre added a comment - Hi Viktor, I apologise for the delay, it's been quite busy lately. The patch was discussed on awt-dev mailing list already: http://mail.openjdk.java.net/pipermail/awt-dev/2016-March/010742.html I was asked to add support for a system property to choose between GTK and X11 implementation, is this still the case? I should be able to have a patch ready very quickly, it's right on top in my priority queue now.
        Hide
        hgupdate HG Updates added a comment -
        URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/947ed8e207b5
        User: neugens
        Date: 2016-07-11 17:45:40 +0000
        Show
        hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/947ed8e207b5 User: neugens Date: 2016-07-11 17:45:40 +0000
        Hide
        hgupdate HG Updates added a comment -
        URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/947ed8e207b5
        User: amurillo
        Date: 2016-08-03 16:28:12 +0000
        Show
        hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/947ed8e207b5 User: amurillo Date: 2016-08-03 16:28:12 +0000

          People

          • Assignee:
            neugens Mario Torre
            Reporter:
            neugens Mario Torre
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: