RDCT-1149 '+' are disapearing on hover

Make sure focus events are dispatched, and painting is done with controller's client id in RD setup.
Focus events are explicitly dispatched with controller's client id, as it doesn't seem possible to propagate client id via 'requestFocus' requests and such without introducing a dedicated JBR API.
As for the painting events, we just make them covered with the existing logic of client id propagation for InvocationEvent-s.

GitOrigin-RevId: 52d59e0ffef69dfa4dff7618a8e50551b2a26549
This commit is contained in:
Dmitry Batrak
2024-05-14 13:53:28 +03:00
committed by intellij-monorepo-bot
parent c0b6cfbfc5
commit 9d8567a5b1
4 changed files with 62 additions and 41 deletions

View File

@@ -33,7 +33,7 @@ open class ClientSessionsManager<T : ClientSession> {
*/
@JvmStatic
fun getAppSessions(kind: ClientKind): List<ClientAppSession> {
return ApplicationManager.getApplication().service<ClientSessionsManager<ClientAppSession>>().getSessions(kind)
return ApplicationManager.getApplication()?.service<ClientSessionsManager<ClientAppSession>>()?.getSessions(kind) ?: emptyList()
}
/**

View File

@@ -1,6 +1,7 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.util.ui
import com.intellij.codeWithMe.ClientId
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.EDT
@@ -24,7 +25,7 @@ abstract class Animator @JvmOverloads constructor(private val name: @NonNls Stri
private var startTime: Long = 0
private var startDeltaTime: Long = 0
private var initialStep = false
private val coroutineScope = coroutineScope ?: CoroutineScope(SupervisorJob() + Dispatchers.Default)
private val coroutineScope = coroutineScope ?: CoroutineScope(SupervisorJob() + Dispatchers.Default + ClientId.coroutineContext())
@Obsolete
fun isForward(): Boolean = isForward

View File

@@ -346,6 +346,7 @@ class IdeEventQueue private constructor() : EventQueue() {
val runnable = InvocationUtil.extractRunnable(event)
val runnableClass = runnable?.javaClass ?: Runnable::class.java
val processEventRunnable = Runnable {
withAttachedClientId(event).use {
val progressManager = ProgressManager.getInstanceOrNull()
try {
runCustomProcessors(finalEvent, preProcessors)
@@ -384,13 +385,13 @@ class IdeEventQueue private constructor() : EventQueue() {
onFocusEvent(finalEvent)
}
}
}
if (runnableClass == InvocationUtil.REPAINT_PROCESSING_CLASS) {
processEventRunnable.run()
return
}
withAttachedClientId(event).use {
if (defaultEventWithWrite) {
ApplicationManagerEx.getApplicationEx().runIntendedWriteActionOnCurrentThread(processEventRunnable)
}
@@ -398,7 +399,6 @@ class IdeEventQueue private constructor() : EventQueue() {
processEventRunnable.run()
}
}
}
finally {
Thread.interrupted()
processIdleActivityListeners(e)

View File

@@ -1,12 +1,18 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide
import com.intellij.codeWithMe.ClientId.Companion.withClientId
import com.intellij.ide.ui.ShowingContainer
import com.intellij.openapi.application.AccessToken
import com.intellij.openapi.client.ClientKind
import com.intellij.openapi.client.ClientSessionsManager
import com.intellij.openapi.diagnostic.logger
import java.awt.*
import java.awt.event.FocusEvent
import java.awt.event.HierarchyEvent
import java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED
import java.awt.event.HierarchyEvent.SHOWING_CHANGED
import java.awt.event.WindowEvent
import java.lang.invoke.MethodHandles
import java.lang.invoke.MethodType
import javax.swing.DefaultFocusManager
@@ -34,16 +40,30 @@ internal class IdeKeyboardFocusManager : DefaultFocusManager() /* see javadoc ab
e.component.dispatchEvent(patchedEvent)
return true
}
val dispatch = { getAssociatedClientId(e).use { super.dispatchEvent(e) } }
if (EventQueue.isDispatchThread()) {
var result = false
performActivity(e) { result = super.dispatchEvent(e) }
performActivity(e) { result = dispatch() }
return result
}
else {
return super.dispatchEvent(e)
return dispatch()
}
}
private fun getAssociatedClientId(e: AWTEvent) : AccessToken {
val id = e.id
if (id == WindowEvent.WINDOW_GAINED_FOCUS ||
id == WindowEvent.WINDOW_LOST_FOCUS ||
id == FocusEvent.FOCUS_GAINED ||
id == FocusEvent.FOCUS_LOST) {
ClientSessionsManager.getAppSessions(ClientKind.CONTROLLER).firstOrNull()?.let {
return withClientId(it.clientId)
}
}
return AccessToken.EMPTY_ACCESS_TOKEN
}
override fun setDefaultFocusTraversalPolicy(defaultPolicy: FocusTraversalPolicy) {
if (parentConstructorExecuted) {
val log = logger<IdeKeyboardFocusManager>()