<html><head><style id="css_styles" type="text/css"><!--blockquote.cite { margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc }
blockquote.cite2 {margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc; margin-top: 3px; padding-top: 0px; }
a img { border: 0px; }
li[style='text-align: center;'], li[style='text-align: center; '], li[style='text-align: right;'], li[style='text-align: right; '] {  list-style-position: inside;}
body { font-family: Helvetica; font-size: 9pt; }
.quote { margin-left: 1em; margin-right: 1em; border-left: 5px #ebebeb solid; padding-left: 0.3em; }
--></style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div>Kirill,</div><div><br /></div><div>> <span>Is there a public / supported way to get notified when an OS-decorated window (native title pane from macOS, Windows, etc) is moved around or resized by the user grabbing the title bar or the border?</span></div><div><span><br /></span></div><div><span>Not that I’m aware of.</span></div><div><span><br /></span></div><div><span>> </span><span>I want to get notified on that process starting so that I can hide all the popups.</span></div><div><span><br /></span></div><div>Are you OK with just knowing when <i>your</i> JVM’s windows are grabbed?</div><div><span><br /></span></div><div>Attached is a small test app I threw together that I think (?) demonstrates what you’re describing. Even if we hide windows when we first detect movement, we don’t know exactly when to re-show them… so this just uses a timer to wait until movement stops. (We could add another layer of pseudoscience to it and look at the mouse location and guess if it’s in the title bar? Which is one of those things that will probably be right 95+% of the time.)</div><div><br /></div><div>When testing on my Mac: I don’t observe any delay between moving the mouse a pixel and all other windows instantly hiding. What do you observe, and what’s your testing environment like?</div><div><br /></div><div>From your description my initial assessment would be:</div><div>A. What you’re trying to do is not well supported in Java.</div><div>B. It may be worth implementing your own window decorations (for Mac, Windows, etc.) instead. This would give you complete control over the “grabbing” process. It might mean you miss out on some default OS behavior, though. (Like nudges the OS might make to auto-align windows, or to wrap windows onto other monitors, or to help manage virtual monitors.) But if these are small helper popup windows that stay close to their parent frame (are they?) that might all be worth it. Plus: if they are officially “undecorated” as far as the AWT is considered: you can fade them in/out (instead of toggling them on/off).</div><div><br /></div><div>Regards,</div><div> - Jeremy</div>
<div><br /></div>
<div>------ Original Message ------</div>
<div>From "Kirill Grouchnikov" <<a href="mailto:kirill.grouchnikov@gmail.com">kirill.grouchnikov@gmail.com</a>></div>
<div>To <a href="mailto:client-libs-dev@openjdk.org">client-libs-dev@openjdk.org</a></div>
<div>Date 6/28/2022 11:19:02 AM</div>
<div>Subject Getting notified on a window being grabbed and moved / resized</div><div><br /></div>
<div id="xb879a7ecdd1943c"><blockquote cite="CAMRG33ZWw1vikdJPjUfkPrXVMsY1TWW9JWsvemux=8LQLZ0HqA@mail.gmail.com" type="cite" class="cite2">
<div dir="ltr"><div>Is there a public / supported way to get notified when an OS-decorated window (native title pane from macOS, Windows, etc) is moved around or resized by the user grabbing the title bar or the border?</div><div><br /></div><div>I want to get notified on that process starting so that I can hide all the popups. What I see is that at [1]
 this is how Swing's popup menu registers itself to get notified on 
window grabbing. Note that it's using internal, undocumented and 
inaccessible event mask. Then at [2] it gets notified that the window has been ungrabbed so that it can hide
 itself. Again, internal and inaccessible event class. And there's also APIs at [3] to grab / ungrab windows to have the whole process rolling.</div><div><br /></div><div>Are there alternatives to these internal APIs that have been exposed as part of hiding the implementation details?</div><div><br /></div><div>The only thing I could find so far is adding a component listener to the frame, but "componentMoved" is called with a noticeable lag, hundreds of milliseconds after the window has started moving.</div><div><br /></div><div>[1] <a href="https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java#L790">https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java#L790</a></div><div>[2] <a href="https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java#L861">https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java#L861</a></div><div>[3] <a href="https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/awt/SunToolkit.java#L1641">https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/awt/SunToolkit.java#L1641</a></div></div>
</blockquote></div>
</body></html>