Re: RFR: 8257414: Drag n Drop target area is wrong on high DPI systems [v3]

2021-02-26 Thread Sergey Bylokhov
On Fri, 12 Feb 2021 21:43:56 GMT, Olga Mikhaltsova  
wrote:

>> Please, review this small fix for drag-n-drop on Linux with HiDPI turned on!
>> 
>> This bug is due to the following reason: while scaling Java recalculates 
>> resolution (W x H) according to sun.java2d.uiScale (W/SCALE x H/SCALE) and 
>> works inside these new coordinates but at the same time the events, that 
>> come from the system, continue reporting positions in the old coordinates (W 
>> x H).
>> 
>> The idea of the suggested fix is in division of coordinates on the scale 
>> when they come from the system to Java and multiplying them on the scale 
>> when they go back from Java to the system. It is similar to processing 
>> events from mouse and buttons. 
>> 
>> Testing is quite complicated because for reproducing this bug the following 
>> conditions should be met:
>> 1.   HiDPI is turned on
>> 2.   sun.java2d.uiScale.enabled = true and sun.java2d.uiScale != 100%
>> 3.   the source of drag-n-drop is non-java application
>> 
>> The step-by-step guide how to reproduce this bug is added to 
>> https://bugs.openjdk.java.net/browse/JDK-8257414.
>
> Olga Mikhaltsova has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   8257414: Drag n Drop target area is wrong on high DPI systems

Marked as reviewed by serb (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/1907


Re: RFR: 8262161 Refactor manual I/O stream copying to new convinient methods in java.desktop

2021-02-26 Thread Phil Race
On Mon, 21 Dec 2020 07:54:17 GMT, Andrey Turbanov 
 wrote:

> Cleanup code to use new handy methods in 
> `java.io.InputStream`/`java.nio.file.Files` instead of manual stream copy:
> 1. java.io.InputStream#readAllBytes
> 2. java.io.InputStream#transferTo
> 3. java.nio.file.Files#copy
> 
> Similar issue - https://bugs.openjdk.java.net/browse/JDK-8080272

Marked as reviewed by prr (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/1856


Re: RFR: 8262161 Refactor manual I/O stream copying to new convinient methods in java.desktop

2021-02-26 Thread Phil Race
On Fri, 26 Feb 2021 20:21:21 GMT, Sergey Bylokhov  wrote:

>> src/java.desktop/unix/classes/sun/print/UnixPrintJob.java line 601:
>> 
>>> 599: try (BufferedInputStream bin = new 
>>> BufferedInputStream(instream);
>>> 600:  BufferedOutputStream bout = new 
>>> BufferedOutputStream(output)) {
>>> 601: bin.transferTo(bout);
>> 
>> https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/io/InputStream.html#transferTo(java.io.OutputStream)
>> 
>> This method does not close either stream.
>> 
>> ---
>> 
>> So this doesn't look right.
>
> The method itself does not close it, but the "try-with-res" around it should.

ah yes

-

PR: https://git.openjdk.java.net/jdk/pull/1856


Re: RFR: 8262161 Refactor manual I/O stream copying to new convinient methods in java.desktop

2021-02-26 Thread Sergey Bylokhov
On Wed, 24 Feb 2021 20:48:29 GMT, Phil Race  wrote:

>> Cleanup code to use new handy methods in 
>> `java.io.InputStream`/`java.nio.file.Files` instead of manual stream copy:
>> 1. java.io.InputStream#readAllBytes
>> 2. java.io.InputStream#transferTo
>> 3. java.nio.file.Files#copy
>> 
>> Similar issue - https://bugs.openjdk.java.net/browse/JDK-8080272
>
> src/java.desktop/unix/classes/sun/print/UnixPrintJob.java line 601:
> 
>> 599: try (BufferedInputStream bin = new 
>> BufferedInputStream(instream);
>> 600:  BufferedOutputStream bout = new 
>> BufferedOutputStream(output)) {
>> 601: bin.transferTo(bout);
> 
> https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/io/InputStream.html#transferTo(java.io.OutputStream)
> 
> This method does not close either stream.
> 
> ---
> 
> So this doesn't look right.

The method itself does not close it, but the "try-with-res" around it should.

> src/java.desktop/share/classes/com/sun/media/sound/DLSSoundbank.java line 990:
> 
>> 988: AudioInputStream stream = AudioSystem.getAudioInputStream(
>> 989: audioformat, (AudioInputStream)sample.getData());
>> 990: stream.transferTo(data_chunk);
> 
> Are all these audio streams buffered ? transferTo docs don't say anything in 
> terms of guarantees of what API they call. If it is unbuffered and it just 
> calls read(byte) over and over it would be really slow.

It read the data in chunks of "8192" bytes.

-

PR: https://git.openjdk.java.net/jdk/pull/1856


RFR: 8262470: Printed GlyphVector outline with low DPI has bad quality on Windows

2021-02-26 Thread Alexander Scherbatiy
Printing text using GlyphVector outline has bad quality on printers with low 
DPI on Windows.
The GDI system used for text printing on Windows accepts only integer path 
coordinates.
Rounding GlyphVector outline coordinates leads to distorted printed text.

The issue had been reported as JDK-8256264 but was reverted because of the 
regression JDK-8259007 "This test printed a blank page".

The fix JDK-8256264 scaled coordinates in wPrinterJob.moveTo()/lineTo()  
methods up and scaled transforms in wPrinterJob.beginPath()/endPath() down.

The regression was in the WPathGraphics.deviceDrawLine() method which uses 
wPrinterJob.moveTo()/lineTo() methods without surrounding them with 
wPrinterJob.beginPath()/endPath() so the line coordinates were only scaled up.

I tried to put wPrinterJob.beginPath()/endPath()  methods around 
wPrinterJob.moveTo()/lineTo()   in the method WPathGraphics.deviceDrawLine()  
but the line was not drawn at all even without scaling coordinates up and 
transform down (without JDK-8256264 fix). It looks like GDI treats this case as 
an empty shape.

The proposed fix applies path coordinates and transform scaling only in 
WPathGraphics.convertToWPath() method.
The one more PathPrecisionScaleFactorShapeTest.java manual test is added which 
checks that all methods that draw paths in WPathGraphics are used: line in 
WPathGraphics.deviceDrawLine() and SEG_LINETO/SEG_QUADTO/SEG_CUBICTO in 
WPathGraphics.convertToWPath() .

The `java/awt/print` and `java/awt/PrintJob` automatic and manual tests were 
run on Windows 10 Pro with the fix.

There are two failed automated tests which fail without the fix as well:
java/awt/print/PrinterJob/GlyphPositions.java 
java/awt/print/PrinterJob/PSQuestionMark.java

The following manual tests have issues on my system:
- `java/awt/print/Dialog/PrintDlgPageable.java` 
java.lang.IllegalAccessException: class 
com.sun.javatest.regtest.agent.MainWrapper$MainThread cannot access a member of 
class PrintDlgPageable with modifiers "public static"

- `java/awt/print/PrinterJob/PrintAttributeUpdateTest.java` I select pages 
radio button, press the print button but the test does not finish and I do not 
see any other dialogs with pass/fail buttons.

- `java/awt/PrintJob/PrintCheckboxTest/PrintCheckboxManualTest.java` Tests that 
there is no ClassCastException thrown in printing checkbox and scrollbar with 
XAWT. Error. Can't find HTML file: 
test\jdk\java\awt\PrintJob\PrintCheckboxTest\PrintCheckboxManualTest.html


- `java/awt/print/PrinterJob/SecurityDialogTest.java` A windows with 
instructions is shown but it does not contain  print/pass/fail buttons and it 
is not possible to close the window.

- The tests below fail with "Error. Parse Exception: Arguments to `manual' 
option not supported: yesno" message:
java/awt/print/Dialog/DialogOrient.java
java/awt/print/Dialog/DialogType.java
java/awt/print/PrinterJob/ImagePrinting/ClippedImages.java
java/awt/print/PrinterJob/ImagePrinting/ImageTypes.java
java/awt/print/PrinterJob/ImagePrinting/PrintARGBImage.java
java/awt/print/PrinterJob/PageDialogTest.java
java/awt/print/PrinterJob/PageRanges.java
java/awt/print/PrinterJob/PageRangesDlgTest.java
java/awt/print/PrinterJob/PrintGlyphVectorTest.java
java/awt/print/PrinterJob/PrintLatinCJKTest.java
java/awt/print/PrinterJob/PrintTextTest.java
java/awt/print/PrinterJob/SwingUIText.java
java/awt/PrintJob/ConstrainedPrintingTest/ConstrainedPrintingTest.java
java/awt/PrintJob/PageSetupDlgBlockingTest/PageSetupDlgBlockingTest.java
java/awt/PrintJob/SaveDialogTitleTest.java

-

Commit messages:
 - 8262470: Printed GlyphVector outline with low DPI has bad quality on Windows

Changes: https://git.openjdk.java.net/jdk/pull/2756/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk=2756=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8262470
  Stats: 725 lines in 5 files changed: 722 ins; 0 del; 3 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2756.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2756/head:pull/2756

PR: https://git.openjdk.java.net/jdk/pull/2756


Re: RFR: JDK-8262461: handle wcstombsdmp return value correctly in unix awt_InputMethod.c

2021-02-26 Thread Alexey Ivanov
On Fri, 26 Feb 2021 14:19:03 GMT, Matthias Baesken  wrote:

> The function wcstombsdmp is called at a few places in awt_InputMethod.c.
> This function needs checking of a NULL return value and freeing of the memory 
> allocated by this function. However this is missing at one place in the file.

Marked as reviewed by aivanov (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/2747


Re: RFR: JDK-8262461: handle wcstombsdmp return value correctly in unix awt_InputMethod.c

2021-02-26 Thread Alexander Zvegintsev
On Fri, 26 Feb 2021 14:19:03 GMT, Matthias Baesken  wrote:

> The function wcstombsdmp is called at a few places in awt_InputMethod.c.
> This function needs checking of a NULL return value and freeing of the memory 
> allocated by this function. However this is missing at one place in the file.

Marked as reviewed by azvegint (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/2747


Re: RFR: JDK-8262461: handle wcstombsdmp return value correctly in unix awt_InputMethod.c

2021-02-26 Thread Prasanta Sadhukhan
On Fri, 26 Feb 2021 14:19:03 GMT, Matthias Baesken  wrote:

> The function wcstombsdmp is called at a few places in awt_InputMethod.c.
> This function needs checking of a NULL return value and freeing of the memory 
> allocated by this function. However this is missing at one place in the file.

Marked as reviewed by psadhukhan (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/2747


Integrated: JDK-8262420: typo: @implnote in java.desktop module

2021-02-26 Thread Jonathan Gibbons
On Thu, 25 Feb 2021 23:15:03 GMT, Jonathan Gibbons  wrote:

> Please review some doc changes in `java.awt.TrayIcon`.
> 
> Note, the fix is more than the 1-character fix for the typo detected by 
> doclint. The changes are:
> 
> 1. Fix the name of the `@implNote` tag
> 2. Remove the redundant `` before the `@implNote` tag
> 3. Move the `@implNote` tag and its immediate content to after the following 
> paragraph, (beginning _See the ..._) which was originally part of the main 
> description, and does not appear that it should be part of the implementation 
> note.

This pull request has now been integrated.

Changeset: 67b9e5a6
Author:Jonathan Gibbons 
URL:   https://git.openjdk.java.net/jdk/commit/67b9e5a6
Stats: 7 lines in 1 file changed: 2 ins; 3 del; 2 mod

8262420: typo: @implnote in java.desktop module

Reviewed-by: iris, prr, azvegint, aivanov

-

PR: https://git.openjdk.java.net/jdk/pull/2735


RFR: JDK-8262461: handle wcstombsdmp return value correctly in unix awt_InputMethod.c

2021-02-26 Thread Matthias Baesken
The function wcstombsdmp is called at a few places in awt_InputMethod.c.
This function needs checking of a NULL return value and freeing of the memory 
allocated by this function. However this is missing at one place in the file.

-

Commit messages:
 - JDK-8262461

Changes: https://git.openjdk.java.net/jdk/pull/2747/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk=2747=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8262461
  Stats: 5 lines in 1 file changed: 4 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2747.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2747/head:pull/2747

PR: https://git.openjdk.java.net/jdk/pull/2747