On Mon, 8 May 2023 20:45:42 GMT, Phil Race <[email protected]> wrote:

> Is black guaranteed today if we fail to grab it ?

Currently we  are passing a java `pixelArray`  it to native to fill it up with 
screen capture data.
If we do not change this array(or part related to denied screen) it remains 
black.
But I'll change it to "unspecified"

> how do you get black if an exception is thrown ?

Exception is thrown only if user has denied screen capture at all(does not 
grant permission to at least one screen). 
In the case where user is trying to retrieve pixels from a screen to which the 
user has not given access he'll get the black pixels.

Alternatively, we can also give up on the SecurityException and not throw it at 
all in this case.

> Is there some subtlety about "ALL" screens ?

It is more like "the user has not allowed any of his screens to be captured."

In fact, we may not throw out this exception and just provide black pixels(and 
call it  "unspecified" behavior).

> Do you really mean all screens which are in the area being captured ?

> I added the word REQUIRED here, since if we only need screen 1 contents, 
> surely it
doesn't matter if we don't have screen 2 permission ?

That's not exactly true.

There are screens that the user may or may not have given permission to 
capture. 
This permission(specifically `restore_token`) is one at a single moment in 
time, not several separate permissions for each screen. This restore_token is 
associated with the permissions for specific screens.

There is an area that the user wants to capture.

The intersection of the capture area and the screens allowed for capture will 
have actual data from the screen, otherwise - black pixels.

So if a user allows access only to screen A and then asks for pixels from 
screen B he will get black pixels.

This is about the same when we have a single monitor and we capture an area 
outside of it (e.g. -100, -100, 50, 50) - we get a black square.

> Does that also imply you can get a partial capture if it spans 2 screens and 
> you only have permission for one of them ?

Yes, the plan is to provide what we can and leave the other parts black.

> We do also need to think forward to a pure wayland scenario - any differences 
> there. ?

As a screen capture - should work as it is.

The only concern is the impossibility to specify and get the window coordinates.
This way we won't know where the window we are displaying is located.
It will affect the testing approach and we will have to add a method like 
`captureWindowContents` to check the window contents.

> I do not understand why we need this method.

We need it in order to be able to revoke the saved permission.

For example, it may be necessary if the user has two monitors, but the user 
only allowed access to one of them.
If he later decides to get a screen capture of two monitors, with the current 
implementation it will be impossible to do so without this method.

Alternatively, we can replace it with a system property that says should we 
keep the permission or not.
It is discussed here 
https://github.com/openjdk/jdk/pull/13803#issuecomment-1540255849

> it needs a new bug ID.

done

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/13809#discussion_r1188820585
PR Review Comment: https://git.openjdk.org/jdk/pull/13809#discussion_r1188920280
PR Review Comment: https://git.openjdk.org/jdk/pull/13809#discussion_r1188828224

Reply via email to