On Thu, 27 Apr 2023 09:16:26 GMT, Maxim Kartashev <[email protected]> 
wrote:

>> src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java line 894:
>> 
>>> 892:             Insets insets = device.getInsets();
>>> 893:             if (insets == null) {
>>> 894:                 insets = getScreenInsetsImpl(gc);
>> 
>> Is it possible to set insets in the device constructor and update it on a 
>> callback? In this case, this method will be just an accessor.
>
>> Is it possible to set insets in the device constructor 
> 
> I would very much like to delay getting the insets until they are actually 
> needed. The device construction is already happening at the time when lots of 
> info is being fetched from the X server; however, insets are needed 
> relatively rarely, the major use case being pull-down menus.
> 
> In Ubuntu, for instance, you can change your Dock size gradually with a 
> slider and each time insets get updated. But unless you open a menu while 
> dragging that slider (which is virtually impossible), the Java program 
> doesn't need to know about new insets, all it needs is to know that the 
> current insets are outdated. Once Dock has been resized *and* the focus has 
> shifted to the Java application *and* menu is about to be opened, then we 
> *must* call `getScreenInsetsImpl()` to fetch the new insets. In this scenario 
> we do this only once instead of each time the slider in the Dock 
> configuration dialog changes its state.
> 
>> Is it possible [...] update it on a callback? In this case, this method will 
>> be just an accessor.
> 
> I'm afraid I don't fully understand what you meant. Can you give an example 
> in pseudo-code?

If we would like to initialize it lazy then can we change that synchronization 
to use the "double-checked locking" instead of "synchronized (device)"?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13346#discussion_r1184569050

Reply via email to