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

Reply via email to