<AWT Dev> [13] Review Request: 8225118 Robot.createScreenCapture() returns black image on HiDPI linux with gtk3

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Fri May 31 21:58:00 UTC 2019

Hi, Anton.

The fix looks fine, thank you for contribution.

I guess at some point we need to cleanup this logic, currently on macOS and now on linux-gtk3 we scale the coordinates from the users space to device space in the shared code and then scale them back in the peer...

On 31/05/2019 09:11, Anton Tarasov wrote:
> Hi All!
> Please review the fix for JDK 13:
> Bug: https://bugs.openjdk.java.net/browse/JDK-8225118
> Fix: http://cr.openjdk.java.net/~ant/JDK-8225118/webrev.0
> The problem with Robot.createScreenCapture() on gtk3 is in the following function call (quoting from gtk3_interface.h):
> fp_gdk_pixbuf_get_from_drawable = dl_symbol("gdk_pixbuf_get_from_window")
> which, as you can see, is resolved to another function in gtk3 (unlike gtk2) due to its deprecation.
> The spec [1] states that the passed size is scaled:
> "the width and height arguments scaled by the scale factor of window"
> however this fact is not taken into account and so the returned pixbuf has wrong size and is then ignored.
> To meet the spec, I retrieve the root window scale and downscale the size, ceiling the result. Also, I weaken the condition where the pixbuf size is compared to the passed size, from "==" to ">=". My reasoning is this:
> 1) The original passed size (of the screen) may appear to be lossy due to downscaling/upscaling ops.
> 2) The weakened condition is enough for the valid pixbuf copying.
> The test (which I've modified to allow its run on Linux) reproduces the issue.
> With regards,
> Anton.
> /||/
> /|
> |/[1] https://developer.gnome.org/gdk3/stable/gdk3-Pixbufs.html#gdk-pixbuf-get-from-window

Best regards, Sergey.

More information about the awt-dev mailing list