On Thu, 4 May 2023 05:54:09 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:
>>> 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)"? Makes sense to me. Please, check the update. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/13346#discussion_r1184674091