docs: explain weird workaround

This commit is contained in:
Johannes Frohnmeyer 2024-07-22 16:44:32 +02:00
parent 4ab1cc9a6b
commit c3dff152b1
Signed by: Johannes
GPG Key ID: E76429612C2929F4

View File

@ -52,7 +52,6 @@ class GlobalMenuService(private val app: Application) : ApplicationActivationLis
else connection?.unExportObject(DbusmenuImpl.getMenuPath(peer.nativePtr)) else connection?.unExportObject(DbusmenuImpl.getMenuPath(peer.nativePtr))
if (GlobalMenu.Native.isDecorationSupported && GMSettings.getInstance().state.decorations && peer is WLPeer) { if (GlobalMenu.Native.isDecorationSupported && GMSettings.getInstance().state.decorations && peer is WLPeer) {
if (peer.decorated) { if (peer.decorated) {
// Disable client-side decorations and enable server-side decorations
peer.decorated = false peer.decorated = false
frame.size = Dimension(frame.width, frame.height + 1) frame.size = Dimension(frame.width, frame.height + 1)
val decoration = GlobalMenu.Native.createDecoration(peer.nativePtr) val decoration = GlobalMenu.Native.createDecoration(peer.nativePtr)
@ -61,6 +60,10 @@ class GlobalMenuService(private val app: Application) : ApplicationActivationLis
} }
} }
ApplicationManager.getApplication().invokeLater { ApplicationManager.getApplication().invokeLater {
// applicationActivated is only called with the IDE frame.
// If we are a dialog (like Settings) we also need to update its properties
// This is where we encounter a problem: the focused window might not be set yet when applicationActivated is called
// Thus, we add this task to the EDT queue to be executed (hopefully) after the focused window is set
val frame1 = FocusManager.getCurrentManager().focusedWindow val frame1 = FocusManager.getCurrentManager().focusedWindow
if (frame != frame1) onActivate(frame1.peer, frame1, when (frame1) { if (frame != frame1) onActivate(frame1.peer, frame1, when (frame1) {
is JFrame -> frame1.jMenuBar is JFrame -> frame1.jMenuBar